@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
2 | - exit('No direct script access allowed'); |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | |
5 | 5 | |
@@ -14,243 +14,243 @@ discard block |
||
14 | 14 | class EEH_Activation |
15 | 15 | { |
16 | 16 | |
17 | - /** |
|
18 | - * constant used to indicate a cron task is no longer in use |
|
19 | - */ |
|
20 | - const cron_task_no_longer_in_use = 'no_longer_in_use'; |
|
21 | - |
|
22 | - /** |
|
23 | - * option name that will indicate whether or not we still |
|
24 | - * need to create EE's folders in the uploads directory |
|
25 | - * (because if EE was installed without file system access, |
|
26 | - * we need to request credentials before we can create them) |
|
27 | - */ |
|
28 | - const upload_directories_incomplete_option_name = 'ee_upload_directories_incomplete'; |
|
29 | - |
|
30 | - /** |
|
31 | - * WP_User->ID |
|
32 | - * |
|
33 | - * @var int |
|
34 | - */ |
|
35 | - private static $_default_creator_id; |
|
36 | - |
|
37 | - /** |
|
38 | - * indicates whether or not we've already verified core's default data during this request, |
|
39 | - * because after migrations are done, any addons activated while in maintenance mode |
|
40 | - * will want to setup their own default data, and they might hook into core's default data |
|
41 | - * and trigger core to setup its default data. In which case they might all ask for core to init its default data. |
|
42 | - * This prevents doing that for EVERY single addon. |
|
43 | - * |
|
44 | - * @var boolean |
|
45 | - */ |
|
46 | - protected static $_initialized_db_content_already_in_this_request = false; |
|
47 | - |
|
48 | - /** |
|
49 | - * @var \EventEspresso\core\services\database\TableAnalysis $table_analysis |
|
50 | - */ |
|
51 | - private static $table_analysis; |
|
52 | - |
|
53 | - /** |
|
54 | - * @var \EventEspresso\core\services\database\TableManager $table_manager |
|
55 | - */ |
|
56 | - private static $table_manager; |
|
57 | - |
|
58 | - |
|
59 | - /** |
|
60 | - * @return \EventEspresso\core\services\database\TableAnalysis |
|
61 | - */ |
|
62 | - public static function getTableAnalysis() |
|
63 | - { |
|
64 | - if (! self::$table_analysis instanceof \EventEspresso\core\services\database\TableAnalysis) { |
|
65 | - self::$table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true); |
|
66 | - } |
|
67 | - return self::$table_analysis; |
|
68 | - } |
|
69 | - |
|
70 | - |
|
71 | - /** |
|
72 | - * @return \EventEspresso\core\services\database\TableManager |
|
73 | - */ |
|
74 | - public static function getTableManager() |
|
75 | - { |
|
76 | - if (! self::$table_manager instanceof \EventEspresso\core\services\database\TableManager) { |
|
77 | - self::$table_manager = EE_Registry::instance()->create('TableManager', array(), true); |
|
78 | - } |
|
79 | - return self::$table_manager; |
|
80 | - } |
|
81 | - |
|
82 | - |
|
83 | - /** |
|
84 | - * _ensure_table_name_has_prefix |
|
85 | - * |
|
86 | - * @deprecated instead use TableAnalysis::ensureTableNameHasPrefix() |
|
87 | - * @access public |
|
88 | - * @static |
|
89 | - * @param $table_name |
|
90 | - * @return string |
|
91 | - */ |
|
92 | - public static function ensure_table_name_has_prefix($table_name) |
|
93 | - { |
|
94 | - return \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix($table_name); |
|
95 | - } |
|
96 | - |
|
97 | - |
|
98 | - /** |
|
99 | - * system_initialization |
|
100 | - * ensures the EE configuration settings are loaded with at least default options set |
|
101 | - * and that all critical EE pages have been generated with the appropriate shortcodes in place |
|
102 | - * |
|
103 | - * @access public |
|
104 | - * @static |
|
105 | - * @return void |
|
106 | - */ |
|
107 | - public static function system_initialization() |
|
108 | - { |
|
109 | - EEH_Activation::reset_and_update_config(); |
|
110 | - //which is fired BEFORE activation of plugin anyways |
|
111 | - EEH_Activation::verify_default_pages_exist(); |
|
112 | - } |
|
113 | - |
|
114 | - |
|
115 | - /** |
|
116 | - * Sets the database schema and creates folders. This should |
|
117 | - * be called on plugin activation and reactivation |
|
118 | - * |
|
119 | - * @return boolean success, whether the database and folders are setup properly |
|
120 | - * @throws \EE_Error |
|
121 | - */ |
|
122 | - public static function initialize_db_and_folders() |
|
123 | - { |
|
124 | - $good_filesystem = EEH_Activation::create_upload_directories(); |
|
125 | - $good_db = EEH_Activation::create_database_tables(); |
|
126 | - return $good_filesystem && $good_db; |
|
127 | - } |
|
128 | - |
|
129 | - |
|
130 | - /** |
|
131 | - * assuming we have an up-to-date database schema, this will populate it |
|
132 | - * with default and initial data. This should be called |
|
133 | - * upon activation of a new plugin, reactivation, and at the end |
|
134 | - * of running migration scripts |
|
135 | - * |
|
136 | - * @throws \EE_Error |
|
137 | - */ |
|
138 | - public static function initialize_db_content() |
|
139 | - { |
|
140 | - //let's avoid doing all this logic repeatedly, especially when addons are requesting it |
|
141 | - if (EEH_Activation::$_initialized_db_content_already_in_this_request) { |
|
142 | - return; |
|
143 | - } |
|
144 | - EEH_Activation::$_initialized_db_content_already_in_this_request = true; |
|
145 | - |
|
146 | - EEH_Activation::initialize_system_questions(); |
|
147 | - EEH_Activation::insert_default_status_codes(); |
|
148 | - EEH_Activation::generate_default_message_templates(); |
|
149 | - EEH_Activation::create_no_ticket_prices_array(); |
|
150 | - EEH_Activation::validate_messages_system(); |
|
151 | - EEH_Activation::insert_default_payment_methods(); |
|
152 | - //in case we've |
|
153 | - EEH_Activation::remove_cron_tasks(); |
|
154 | - EEH_Activation::create_cron_tasks(); |
|
155 | - // remove all TXN locks since that is being done via extra meta now |
|
156 | - delete_option('ee_locked_transactions'); |
|
157 | - //also, check for CAF default db content |
|
158 | - do_action('AHEE__EEH_Activation__initialize_db_content'); |
|
159 | - //also: EEM_Gateways::load_all_gateways() outputs a lot of success messages |
|
160 | - //which users really won't care about on initial activation |
|
161 | - EE_Error::overwrite_success(); |
|
162 | - } |
|
163 | - |
|
164 | - |
|
165 | - /** |
|
166 | - * Returns an array of cron tasks. Array values are the actions fired by the cron tasks (the "hooks"), |
|
167 | - * values are the frequency (the "recurrence"). See http://codex.wordpress.org/Function_Reference/wp_schedule_event |
|
168 | - * If the cron task should NO longer be used, it should have a value of EEH_Activation::cron_task_no_longer_in_use |
|
169 | - * (null) |
|
170 | - * |
|
171 | - * @param string $which_to_include can be 'current' (ones that are currently in use), |
|
172 | - * 'old' (only returns ones that should no longer be used),or 'all', |
|
173 | - * @return array |
|
174 | - * @throws \EE_Error |
|
175 | - */ |
|
176 | - public static function get_cron_tasks($which_to_include) |
|
177 | - { |
|
178 | - $cron_tasks = apply_filters( |
|
179 | - 'FHEE__EEH_Activation__get_cron_tasks', |
|
180 | - array( |
|
181 | - 'AHEE__EE_Cron_Tasks__clean_up_junk_transactions' => 'hourly', |
|
17 | + /** |
|
18 | + * constant used to indicate a cron task is no longer in use |
|
19 | + */ |
|
20 | + const cron_task_no_longer_in_use = 'no_longer_in_use'; |
|
21 | + |
|
22 | + /** |
|
23 | + * option name that will indicate whether or not we still |
|
24 | + * need to create EE's folders in the uploads directory |
|
25 | + * (because if EE was installed without file system access, |
|
26 | + * we need to request credentials before we can create them) |
|
27 | + */ |
|
28 | + const upload_directories_incomplete_option_name = 'ee_upload_directories_incomplete'; |
|
29 | + |
|
30 | + /** |
|
31 | + * WP_User->ID |
|
32 | + * |
|
33 | + * @var int |
|
34 | + */ |
|
35 | + private static $_default_creator_id; |
|
36 | + |
|
37 | + /** |
|
38 | + * indicates whether or not we've already verified core's default data during this request, |
|
39 | + * because after migrations are done, any addons activated while in maintenance mode |
|
40 | + * will want to setup their own default data, and they might hook into core's default data |
|
41 | + * and trigger core to setup its default data. In which case they might all ask for core to init its default data. |
|
42 | + * This prevents doing that for EVERY single addon. |
|
43 | + * |
|
44 | + * @var boolean |
|
45 | + */ |
|
46 | + protected static $_initialized_db_content_already_in_this_request = false; |
|
47 | + |
|
48 | + /** |
|
49 | + * @var \EventEspresso\core\services\database\TableAnalysis $table_analysis |
|
50 | + */ |
|
51 | + private static $table_analysis; |
|
52 | + |
|
53 | + /** |
|
54 | + * @var \EventEspresso\core\services\database\TableManager $table_manager |
|
55 | + */ |
|
56 | + private static $table_manager; |
|
57 | + |
|
58 | + |
|
59 | + /** |
|
60 | + * @return \EventEspresso\core\services\database\TableAnalysis |
|
61 | + */ |
|
62 | + public static function getTableAnalysis() |
|
63 | + { |
|
64 | + if (! self::$table_analysis instanceof \EventEspresso\core\services\database\TableAnalysis) { |
|
65 | + self::$table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true); |
|
66 | + } |
|
67 | + return self::$table_analysis; |
|
68 | + } |
|
69 | + |
|
70 | + |
|
71 | + /** |
|
72 | + * @return \EventEspresso\core\services\database\TableManager |
|
73 | + */ |
|
74 | + public static function getTableManager() |
|
75 | + { |
|
76 | + if (! self::$table_manager instanceof \EventEspresso\core\services\database\TableManager) { |
|
77 | + self::$table_manager = EE_Registry::instance()->create('TableManager', array(), true); |
|
78 | + } |
|
79 | + return self::$table_manager; |
|
80 | + } |
|
81 | + |
|
82 | + |
|
83 | + /** |
|
84 | + * _ensure_table_name_has_prefix |
|
85 | + * |
|
86 | + * @deprecated instead use TableAnalysis::ensureTableNameHasPrefix() |
|
87 | + * @access public |
|
88 | + * @static |
|
89 | + * @param $table_name |
|
90 | + * @return string |
|
91 | + */ |
|
92 | + public static function ensure_table_name_has_prefix($table_name) |
|
93 | + { |
|
94 | + return \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix($table_name); |
|
95 | + } |
|
96 | + |
|
97 | + |
|
98 | + /** |
|
99 | + * system_initialization |
|
100 | + * ensures the EE configuration settings are loaded with at least default options set |
|
101 | + * and that all critical EE pages have been generated with the appropriate shortcodes in place |
|
102 | + * |
|
103 | + * @access public |
|
104 | + * @static |
|
105 | + * @return void |
|
106 | + */ |
|
107 | + public static function system_initialization() |
|
108 | + { |
|
109 | + EEH_Activation::reset_and_update_config(); |
|
110 | + //which is fired BEFORE activation of plugin anyways |
|
111 | + EEH_Activation::verify_default_pages_exist(); |
|
112 | + } |
|
113 | + |
|
114 | + |
|
115 | + /** |
|
116 | + * Sets the database schema and creates folders. This should |
|
117 | + * be called on plugin activation and reactivation |
|
118 | + * |
|
119 | + * @return boolean success, whether the database and folders are setup properly |
|
120 | + * @throws \EE_Error |
|
121 | + */ |
|
122 | + public static function initialize_db_and_folders() |
|
123 | + { |
|
124 | + $good_filesystem = EEH_Activation::create_upload_directories(); |
|
125 | + $good_db = EEH_Activation::create_database_tables(); |
|
126 | + return $good_filesystem && $good_db; |
|
127 | + } |
|
128 | + |
|
129 | + |
|
130 | + /** |
|
131 | + * assuming we have an up-to-date database schema, this will populate it |
|
132 | + * with default and initial data. This should be called |
|
133 | + * upon activation of a new plugin, reactivation, and at the end |
|
134 | + * of running migration scripts |
|
135 | + * |
|
136 | + * @throws \EE_Error |
|
137 | + */ |
|
138 | + public static function initialize_db_content() |
|
139 | + { |
|
140 | + //let's avoid doing all this logic repeatedly, especially when addons are requesting it |
|
141 | + if (EEH_Activation::$_initialized_db_content_already_in_this_request) { |
|
142 | + return; |
|
143 | + } |
|
144 | + EEH_Activation::$_initialized_db_content_already_in_this_request = true; |
|
145 | + |
|
146 | + EEH_Activation::initialize_system_questions(); |
|
147 | + EEH_Activation::insert_default_status_codes(); |
|
148 | + EEH_Activation::generate_default_message_templates(); |
|
149 | + EEH_Activation::create_no_ticket_prices_array(); |
|
150 | + EEH_Activation::validate_messages_system(); |
|
151 | + EEH_Activation::insert_default_payment_methods(); |
|
152 | + //in case we've |
|
153 | + EEH_Activation::remove_cron_tasks(); |
|
154 | + EEH_Activation::create_cron_tasks(); |
|
155 | + // remove all TXN locks since that is being done via extra meta now |
|
156 | + delete_option('ee_locked_transactions'); |
|
157 | + //also, check for CAF default db content |
|
158 | + do_action('AHEE__EEH_Activation__initialize_db_content'); |
|
159 | + //also: EEM_Gateways::load_all_gateways() outputs a lot of success messages |
|
160 | + //which users really won't care about on initial activation |
|
161 | + EE_Error::overwrite_success(); |
|
162 | + } |
|
163 | + |
|
164 | + |
|
165 | + /** |
|
166 | + * Returns an array of cron tasks. Array values are the actions fired by the cron tasks (the "hooks"), |
|
167 | + * values are the frequency (the "recurrence"). See http://codex.wordpress.org/Function_Reference/wp_schedule_event |
|
168 | + * If the cron task should NO longer be used, it should have a value of EEH_Activation::cron_task_no_longer_in_use |
|
169 | + * (null) |
|
170 | + * |
|
171 | + * @param string $which_to_include can be 'current' (ones that are currently in use), |
|
172 | + * 'old' (only returns ones that should no longer be used),or 'all', |
|
173 | + * @return array |
|
174 | + * @throws \EE_Error |
|
175 | + */ |
|
176 | + public static function get_cron_tasks($which_to_include) |
|
177 | + { |
|
178 | + $cron_tasks = apply_filters( |
|
179 | + 'FHEE__EEH_Activation__get_cron_tasks', |
|
180 | + array( |
|
181 | + 'AHEE__EE_Cron_Tasks__clean_up_junk_transactions' => 'hourly', |
|
182 | 182 | // 'AHEE__EE_Cron_Tasks__finalize_abandoned_transactions' => EEH_Activation::cron_task_no_longer_in_use, actually this is still in use |
183 | - 'AHEE__EE_Cron_Tasks__update_transaction_with_payment' => EEH_Activation::cron_task_no_longer_in_use, |
|
184 | - //there may have been a bug which prevented from these cron tasks from getting unscheduled, so we might want to remove these for a few updates |
|
185 | - 'AHEE_EE_Cron_Tasks__clean_out_old_gateway_logs' => 'daily', |
|
186 | - ) |
|
187 | - ); |
|
188 | - if ($which_to_include === 'old') { |
|
189 | - $cron_tasks = array_filter( |
|
190 | - $cron_tasks, |
|
191 | - function ($value) { |
|
192 | - return $value === EEH_Activation::cron_task_no_longer_in_use; |
|
193 | - } |
|
194 | - ); |
|
195 | - } elseif ($which_to_include === 'current') { |
|
196 | - $cron_tasks = array_filter($cron_tasks); |
|
197 | - } elseif (WP_DEBUG && $which_to_include !== 'all') { |
|
198 | - throw new EE_Error( |
|
199 | - sprintf( |
|
200 | - __( |
|
201 | - 'Invalid argument of "%1$s" passed to EEH_Activation::get_cron_tasks. Valid values are "all", "old" and "current".', |
|
202 | - 'event_espresso' |
|
203 | - ), |
|
204 | - $which_to_include |
|
205 | - ) |
|
206 | - ); |
|
207 | - } |
|
208 | - return $cron_tasks; |
|
209 | - } |
|
210 | - |
|
211 | - |
|
212 | - /** |
|
213 | - * Ensure cron tasks are setup (the removal of crons should be done by remove_crons()) |
|
214 | - * |
|
215 | - * @throws \EE_Error |
|
216 | - */ |
|
217 | - public static function create_cron_tasks() |
|
218 | - { |
|
219 | - |
|
220 | - foreach (EEH_Activation::get_cron_tasks('current') as $hook_name => $frequency) { |
|
221 | - if (! wp_next_scheduled($hook_name)) { |
|
222 | - /** |
|
223 | - * This allows client code to define the initial start timestamp for this schedule. |
|
224 | - */ |
|
225 | - if (is_array($frequency) |
|
226 | - && count($frequency) === 2 |
|
227 | - && isset($frequency[0], $frequency[1]) |
|
228 | - ) { |
|
229 | - $start_timestamp = $frequency[0]; |
|
230 | - $frequency = $frequency[1]; |
|
231 | - } else { |
|
232 | - $start_timestamp = time(); |
|
233 | - } |
|
234 | - wp_schedule_event($start_timestamp, $frequency, $hook_name); |
|
235 | - } |
|
236 | - } |
|
237 | - |
|
238 | - } |
|
239 | - |
|
240 | - |
|
241 | - |
|
242 | - /** |
|
243 | - * Remove the currently-existing and now-removed cron tasks. |
|
244 | - * |
|
245 | - * @param boolean $remove_all whether to only remove the old ones, or remove absolutely ALL the EE ones |
|
246 | - * @throws \EE_Error |
|
247 | - */ |
|
248 | - public static function remove_cron_tasks($remove_all = true) |
|
249 | - { |
|
250 | - $cron_tasks_to_remove = $remove_all ? 'all' : 'old'; |
|
251 | - $crons = _get_cron_array(); |
|
252 | - $crons = is_array($crons) ? $crons : array(); |
|
253 | - /* reminder of what $crons look like: |
|
183 | + 'AHEE__EE_Cron_Tasks__update_transaction_with_payment' => EEH_Activation::cron_task_no_longer_in_use, |
|
184 | + //there may have been a bug which prevented from these cron tasks from getting unscheduled, so we might want to remove these for a few updates |
|
185 | + 'AHEE_EE_Cron_Tasks__clean_out_old_gateway_logs' => 'daily', |
|
186 | + ) |
|
187 | + ); |
|
188 | + if ($which_to_include === 'old') { |
|
189 | + $cron_tasks = array_filter( |
|
190 | + $cron_tasks, |
|
191 | + function ($value) { |
|
192 | + return $value === EEH_Activation::cron_task_no_longer_in_use; |
|
193 | + } |
|
194 | + ); |
|
195 | + } elseif ($which_to_include === 'current') { |
|
196 | + $cron_tasks = array_filter($cron_tasks); |
|
197 | + } elseif (WP_DEBUG && $which_to_include !== 'all') { |
|
198 | + throw new EE_Error( |
|
199 | + sprintf( |
|
200 | + __( |
|
201 | + 'Invalid argument of "%1$s" passed to EEH_Activation::get_cron_tasks. Valid values are "all", "old" and "current".', |
|
202 | + 'event_espresso' |
|
203 | + ), |
|
204 | + $which_to_include |
|
205 | + ) |
|
206 | + ); |
|
207 | + } |
|
208 | + return $cron_tasks; |
|
209 | + } |
|
210 | + |
|
211 | + |
|
212 | + /** |
|
213 | + * Ensure cron tasks are setup (the removal of crons should be done by remove_crons()) |
|
214 | + * |
|
215 | + * @throws \EE_Error |
|
216 | + */ |
|
217 | + public static function create_cron_tasks() |
|
218 | + { |
|
219 | + |
|
220 | + foreach (EEH_Activation::get_cron_tasks('current') as $hook_name => $frequency) { |
|
221 | + if (! wp_next_scheduled($hook_name)) { |
|
222 | + /** |
|
223 | + * This allows client code to define the initial start timestamp for this schedule. |
|
224 | + */ |
|
225 | + if (is_array($frequency) |
|
226 | + && count($frequency) === 2 |
|
227 | + && isset($frequency[0], $frequency[1]) |
|
228 | + ) { |
|
229 | + $start_timestamp = $frequency[0]; |
|
230 | + $frequency = $frequency[1]; |
|
231 | + } else { |
|
232 | + $start_timestamp = time(); |
|
233 | + } |
|
234 | + wp_schedule_event($start_timestamp, $frequency, $hook_name); |
|
235 | + } |
|
236 | + } |
|
237 | + |
|
238 | + } |
|
239 | + |
|
240 | + |
|
241 | + |
|
242 | + /** |
|
243 | + * Remove the currently-existing and now-removed cron tasks. |
|
244 | + * |
|
245 | + * @param boolean $remove_all whether to only remove the old ones, or remove absolutely ALL the EE ones |
|
246 | + * @throws \EE_Error |
|
247 | + */ |
|
248 | + public static function remove_cron_tasks($remove_all = true) |
|
249 | + { |
|
250 | + $cron_tasks_to_remove = $remove_all ? 'all' : 'old'; |
|
251 | + $crons = _get_cron_array(); |
|
252 | + $crons = is_array($crons) ? $crons : array(); |
|
253 | + /* reminder of what $crons look like: |
|
254 | 254 | * Top-level keys are timestamps, and their values are arrays. |
255 | 255 | * The 2nd level arrays have keys with each of the cron task hook names to run at that time |
256 | 256 | * and their values are arrays. |
@@ -267,912 +267,912 @@ discard block |
||
267 | 267 | * ... |
268 | 268 | * ... |
269 | 269 | */ |
270 | - $ee_cron_tasks_to_remove = EEH_Activation::get_cron_tasks($cron_tasks_to_remove); |
|
271 | - foreach ($crons as $timestamp => $hooks_to_fire_at_time) { |
|
272 | - if (is_array($hooks_to_fire_at_time)) { |
|
273 | - foreach ($hooks_to_fire_at_time as $hook_name => $hook_actions) { |
|
274 | - if (isset($ee_cron_tasks_to_remove[$hook_name]) |
|
275 | - && is_array($ee_cron_tasks_to_remove[$hook_name]) |
|
276 | - ) { |
|
277 | - unset($crons[$timestamp][$hook_name]); |
|
278 | - } |
|
279 | - } |
|
280 | - //also take care of any empty cron timestamps. |
|
281 | - if (empty($hooks_to_fire_at_time)) { |
|
282 | - unset($crons[$timestamp]); |
|
283 | - } |
|
284 | - } |
|
285 | - } |
|
286 | - _set_cron_array($crons); |
|
287 | - } |
|
288 | - |
|
289 | - |
|
290 | - /** |
|
291 | - * CPT_initialization |
|
292 | - * registers all EE CPTs ( Custom Post Types ) then flushes rewrite rules so that all endpoints exist |
|
293 | - * |
|
294 | - * @access public |
|
295 | - * @static |
|
296 | - * @return void |
|
297 | - */ |
|
298 | - public static function CPT_initialization() |
|
299 | - { |
|
300 | - // register Custom Post Types |
|
301 | - EE_Registry::instance()->load_core('Register_CPTs'); |
|
302 | - flush_rewrite_rules(); |
|
303 | - } |
|
304 | - |
|
305 | - |
|
306 | - |
|
307 | - /** |
|
308 | - * reset_and_update_config |
|
309 | - * The following code was moved over from EE_Config so that it will no longer run on every request. |
|
310 | - * If there is old calendar config data saved, then it will get converted on activation. |
|
311 | - * This was basically a DMS before we had DMS's, and will get removed after a few more versions. |
|
312 | - * |
|
313 | - * @access public |
|
314 | - * @static |
|
315 | - * @return void |
|
316 | - */ |
|
317 | - public static function reset_and_update_config() |
|
318 | - { |
|
319 | - do_action('AHEE__EE_Config___load_core_config__start', array('EEH_Activation', 'load_calendar_config')); |
|
320 | - add_filter( |
|
321 | - 'FHEE__EE_Config___load_core_config__config_settings', |
|
322 | - array('EEH_Activation', 'migrate_old_config_data'), |
|
323 | - 10, |
|
324 | - 3 |
|
325 | - ); |
|
326 | - //EE_Config::reset(); |
|
327 | - if (! EE_Config::logging_enabled()) { |
|
328 | - delete_option(EE_Config::LOG_NAME); |
|
329 | - } |
|
330 | - } |
|
331 | - |
|
332 | - |
|
333 | - /** |
|
334 | - * load_calendar_config |
|
335 | - * |
|
336 | - * @access public |
|
337 | - * @return void |
|
338 | - */ |
|
339 | - public static function load_calendar_config() |
|
340 | - { |
|
341 | - // grab array of all plugin folders and loop thru it |
|
342 | - $plugins = glob(WP_PLUGIN_DIR . DS . '*', GLOB_ONLYDIR); |
|
343 | - if (empty($plugins)) { |
|
344 | - return; |
|
345 | - } |
|
346 | - foreach ($plugins as $plugin_path) { |
|
347 | - // grab plugin folder name from path |
|
348 | - $plugin = basename($plugin_path); |
|
349 | - // drill down to Espresso plugins |
|
350 | - // then to calendar related plugins |
|
351 | - if ( |
|
352 | - strpos($plugin, 'espresso') !== false |
|
353 | - || strpos($plugin, 'Espresso') !== false |
|
354 | - || strpos($plugin, 'ee4') !== false |
|
355 | - || strpos($plugin, 'EE4') !== false |
|
356 | - || strpos($plugin, 'calendar') !== false |
|
357 | - ) { |
|
358 | - // this is what we are looking for |
|
359 | - $calendar_config = $plugin_path . DS . 'EE_Calendar_Config.php'; |
|
360 | - // does it exist in this folder ? |
|
361 | - if (is_readable($calendar_config)) { |
|
362 | - // YEAH! let's load it |
|
363 | - require_once($calendar_config); |
|
364 | - } |
|
365 | - } |
|
366 | - } |
|
367 | - } |
|
368 | - |
|
369 | - |
|
370 | - |
|
371 | - /** |
|
372 | - * _migrate_old_config_data |
|
373 | - * |
|
374 | - * @access public |
|
375 | - * @param array|stdClass $settings |
|
376 | - * @param string $config |
|
377 | - * @param \EE_Config $EE_Config |
|
378 | - * @return \stdClass |
|
379 | - */ |
|
380 | - public static function migrate_old_config_data($settings = array(), $config = '', EE_Config $EE_Config) |
|
381 | - { |
|
382 | - $convert_from_array = array('addons'); |
|
383 | - // in case old settings were saved as an array |
|
384 | - if (is_array($settings) && in_array($config, $convert_from_array)) { |
|
385 | - // convert existing settings to an object |
|
386 | - $config_array = $settings; |
|
387 | - $settings = new stdClass(); |
|
388 | - foreach ($config_array as $key => $value) { |
|
389 | - if ($key === 'calendar' && class_exists('EE_Calendar_Config')) { |
|
390 | - $EE_Config->set_config('addons', 'EE_Calendar', 'EE_Calendar_Config', $value); |
|
391 | - } else { |
|
392 | - $settings->{$key} = $value; |
|
393 | - } |
|
394 | - } |
|
395 | - add_filter('FHEE__EE_Config___load_core_config__update_espresso_config', '__return_true'); |
|
396 | - } |
|
397 | - return $settings; |
|
398 | - } |
|
399 | - |
|
400 | - |
|
401 | - /** |
|
402 | - * deactivate_event_espresso |
|
403 | - * |
|
404 | - * @access public |
|
405 | - * @static |
|
406 | - * @return void |
|
407 | - */ |
|
408 | - public static function deactivate_event_espresso() |
|
409 | - { |
|
410 | - // check permissions |
|
411 | - if (current_user_can('activate_plugins')) { |
|
412 | - deactivate_plugins(EE_PLUGIN_BASENAME, true); |
|
413 | - } |
|
414 | - } |
|
415 | - |
|
416 | - |
|
417 | - |
|
418 | - |
|
419 | - /** |
|
420 | - * verify_default_pages_exist |
|
421 | - * |
|
422 | - * @access public |
|
423 | - * @static |
|
424 | - * @return void |
|
425 | - */ |
|
426 | - public static function verify_default_pages_exist() |
|
427 | - { |
|
428 | - $critical_page_problem = false; |
|
429 | - $critical_pages = array( |
|
430 | - array( |
|
431 | - 'id' => 'reg_page_id', |
|
432 | - 'name' => __('Registration Checkout', 'event_espresso'), |
|
433 | - 'post' => null, |
|
434 | - 'code' => 'ESPRESSO_CHECKOUT', |
|
435 | - ), |
|
436 | - array( |
|
437 | - 'id' => 'txn_page_id', |
|
438 | - 'name' => __('Transactions', 'event_espresso'), |
|
439 | - 'post' => null, |
|
440 | - 'code' => 'ESPRESSO_TXN_PAGE', |
|
441 | - ), |
|
442 | - array( |
|
443 | - 'id' => 'thank_you_page_id', |
|
444 | - 'name' => __('Thank You', 'event_espresso'), |
|
445 | - 'post' => null, |
|
446 | - 'code' => 'ESPRESSO_THANK_YOU', |
|
447 | - ), |
|
448 | - array( |
|
449 | - 'id' => 'cancel_page_id', |
|
450 | - 'name' => __('Registration Cancelled', 'event_espresso'), |
|
451 | - 'post' => null, |
|
452 | - 'code' => 'ESPRESSO_CANCELLED', |
|
453 | - ), |
|
454 | - ); |
|
455 | - $EE_Core_Config = EE_Registry::instance()->CFG->core; |
|
456 | - foreach ($critical_pages as $critical_page) { |
|
457 | - // is critical page ID set in config ? |
|
458 | - if ($EE_Core_Config->{$critical_page['id']} !== false) { |
|
459 | - // attempt to find post by ID |
|
460 | - $critical_page['post'] = get_post($EE_Core_Config->{$critical_page['id']}); |
|
461 | - } |
|
462 | - // no dice? |
|
463 | - if ($critical_page['post'] === null) { |
|
464 | - // attempt to find post by title |
|
465 | - $critical_page['post'] = self::get_page_by_ee_shortcode($critical_page['code']); |
|
466 | - // still nothing? |
|
467 | - if ($critical_page['post'] === null) { |
|
468 | - $critical_page = EEH_Activation::create_critical_page($critical_page); |
|
469 | - // REALLY? Still nothing ??!?!? |
|
470 | - if ($critical_page['post'] === null) { |
|
471 | - $msg = __( |
|
472 | - 'The Event Espresso critical page configuration settings could not be updated.', |
|
473 | - 'event_espresso' |
|
474 | - ); |
|
475 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
476 | - break; |
|
477 | - } |
|
478 | - } |
|
479 | - } |
|
480 | - // check that Post ID matches critical page ID in config |
|
481 | - if ( |
|
482 | - isset($critical_page['post']->ID) |
|
483 | - && $critical_page['post']->ID !== $EE_Core_Config->{$critical_page['id']} |
|
484 | - ) { |
|
485 | - //update Config with post ID |
|
486 | - $EE_Core_Config->{$critical_page['id']} = $critical_page['post']->ID; |
|
487 | - if (! EE_Config::instance()->update_espresso_config(false, false)) { |
|
488 | - $msg = __( |
|
489 | - 'The Event Espresso critical page configuration settings could not be updated.', |
|
490 | - 'event_espresso' |
|
491 | - ); |
|
492 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
493 | - } |
|
494 | - } |
|
495 | - $critical_page_problem = |
|
496 | - ! isset($critical_page['post']->post_status) |
|
497 | - || $critical_page['post']->post_status !== 'publish' |
|
498 | - || strpos($critical_page['post']->post_content, $critical_page['code']) === false |
|
499 | - ? true |
|
500 | - : $critical_page_problem; |
|
501 | - } |
|
502 | - if ($critical_page_problem) { |
|
503 | - $msg = sprintf( |
|
504 | - __( |
|
505 | - 'A potential issue has been detected with one or more of your Event Espresso pages. Go to %s to view your Event Espresso pages.', |
|
506 | - 'event_espresso' |
|
507 | - ), |
|
508 | - '<a href="' |
|
509 | - . admin_url('admin.php?page=espresso_general_settings&action=critical_pages') |
|
510 | - . '">' |
|
511 | - . __('Event Espresso Critical Pages Settings', 'event_espresso') |
|
512 | - . '</a>' |
|
513 | - ); |
|
514 | - EE_Error::add_persistent_admin_notice('critical_page_problem', $msg); |
|
515 | - } |
|
516 | - if (EE_Error::has_notices()) { |
|
517 | - EE_Error::get_notices(false, true, true); |
|
518 | - } |
|
519 | - } |
|
520 | - |
|
521 | - |
|
522 | - |
|
523 | - /** |
|
524 | - * Returns the first post which uses the specified shortcode |
|
525 | - * |
|
526 | - * @param string $ee_shortcode usually one of the critical pages shortcodes, eg |
|
527 | - * ESPRESSO_THANK_YOU. So we will search fora post with the content |
|
528 | - * "[ESPRESSO_THANK_YOU" |
|
529 | - * (we don't search for the closing shortcode bracket because they might have added |
|
530 | - * parameter to the shortcode |
|
531 | - * @return WP_Post or NULl |
|
532 | - */ |
|
533 | - public static function get_page_by_ee_shortcode($ee_shortcode) |
|
534 | - { |
|
535 | - global $wpdb; |
|
536 | - $shortcode_and_opening_bracket = '[' . $ee_shortcode; |
|
537 | - $post_id = $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE post_content LIKE '%$shortcode_and_opening_bracket%' LIMIT 1"); |
|
538 | - if ($post_id) { |
|
539 | - return get_post($post_id); |
|
540 | - } else { |
|
541 | - return null; |
|
542 | - } |
|
543 | - } |
|
544 | - |
|
545 | - |
|
546 | - |
|
547 | - /** |
|
548 | - * This function generates a post for critical espresso pages |
|
549 | - * |
|
550 | - * @access public |
|
551 | - * @static |
|
552 | - * @param array $critical_page |
|
553 | - * @return array |
|
554 | - */ |
|
555 | - public static function create_critical_page($critical_page) |
|
556 | - { |
|
557 | - |
|
558 | - $post_args = array( |
|
559 | - 'post_title' => $critical_page['name'], |
|
560 | - 'post_status' => 'publish', |
|
561 | - 'post_type' => 'page', |
|
562 | - 'comment_status' => 'closed', |
|
563 | - 'post_content' => '[' . $critical_page['code'] . ']', |
|
564 | - ); |
|
565 | - |
|
566 | - $post_id = wp_insert_post($post_args); |
|
567 | - if (! $post_id) { |
|
568 | - $msg = sprintf( |
|
569 | - __('The Event Espresso critical page entitled "%s" could not be created.', 'event_espresso'), |
|
570 | - $critical_page['name'] |
|
571 | - ); |
|
572 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
573 | - return $critical_page; |
|
574 | - } |
|
575 | - // get newly created post's details |
|
576 | - if (! $critical_page['post'] = get_post($post_id)) { |
|
577 | - $msg = sprintf( |
|
578 | - __('The Event Espresso critical page entitled "%s" could not be retrieved.', 'event_espresso'), |
|
579 | - $critical_page['name'] |
|
580 | - ); |
|
581 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
582 | - } |
|
583 | - |
|
584 | - return $critical_page; |
|
585 | - |
|
586 | - } |
|
587 | - |
|
588 | - |
|
589 | - |
|
590 | - |
|
591 | - /** |
|
592 | - * Tries to find the oldest admin for this site. If there are no admins for this site then return NULL. |
|
593 | - * The role being used to check is filterable. |
|
594 | - * |
|
595 | - * @since 4.6.0 |
|
596 | - * @global WPDB $wpdb |
|
597 | - * @return mixed null|int WP_user ID or NULL |
|
598 | - */ |
|
599 | - public static function get_default_creator_id() |
|
600 | - { |
|
601 | - global $wpdb; |
|
602 | - if ( ! empty(self::$_default_creator_id)) { |
|
603 | - return self::$_default_creator_id; |
|
604 | - }/**/ |
|
605 | - $role_to_check = apply_filters('FHEE__EEH_Activation__get_default_creator_id__role_to_check', 'administrator'); |
|
606 | - //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. |
|
607 | - $pre_filtered_id = apply_filters( |
|
608 | - 'FHEE__EEH_Activation__get_default_creator_id__pre_filtered_id', |
|
609 | - false, |
|
610 | - $role_to_check |
|
611 | - ); |
|
612 | - if ($pre_filtered_id !== false) { |
|
613 | - return (int)$pre_filtered_id; |
|
614 | - } |
|
615 | - $capabilities_key = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('capabilities'); |
|
616 | - $query = $wpdb->prepare( |
|
617 | - "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$capabilities_key' AND meta_value LIKE %s ORDER BY user_id ASC LIMIT 0,1", |
|
618 | - '%' . $role_to_check . '%' |
|
619 | - ); |
|
620 | - $user_id = $wpdb->get_var($query); |
|
621 | - $user_id = apply_filters('FHEE__EEH_Activation_Helper__get_default_creator_id__user_id', $user_id); |
|
622 | - if ($user_id && (int)$user_id) { |
|
623 | - self::$_default_creator_id = (int)$user_id; |
|
624 | - return self::$_default_creator_id; |
|
625 | - } else { |
|
626 | - return null; |
|
627 | - } |
|
628 | - } |
|
629 | - |
|
630 | - |
|
631 | - |
|
632 | - /** |
|
633 | - * used by EE and EE addons during plugin activation to create tables. |
|
634 | - * Its a wrapper for EventEspresso\core\services\database\TableManager::createTable, |
|
635 | - * but includes extra logic regarding activations. |
|
636 | - * |
|
637 | - * @access public |
|
638 | - * @static |
|
639 | - * @param string $table_name without the $wpdb->prefix |
|
640 | - * @param string $sql SQL for creating the table (contents between brackets in an SQL create |
|
641 | - * table query) |
|
642 | - * @param string $engine like 'ENGINE=MyISAM' or 'ENGINE=InnoDB' |
|
643 | - * @param boolean $drop_pre_existing_table set to TRUE when you want to make SURE the table is completely empty |
|
644 | - * and new once this function is done (ie, you really do want to CREATE a |
|
645 | - * table, and expect it to be empty once you're done) leave as FALSE when |
|
646 | - * you just want to verify the table exists and matches this definition |
|
647 | - * (and if it HAS data in it you want to leave it be) |
|
648 | - * @return void |
|
649 | - * @throws EE_Error if there are database errors |
|
650 | - */ |
|
651 | - public static function create_table($table_name, $sql, $engine = 'ENGINE=MyISAM ', $drop_pre_existing_table = false) |
|
652 | - { |
|
653 | - if (apply_filters('FHEE__EEH_Activation__create_table__short_circuit', false, $table_name, $sql)) { |
|
654 | - return; |
|
655 | - } |
|
656 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
657 | - if ( ! function_exists('dbDelta')) { |
|
658 | - require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); |
|
659 | - } |
|
660 | - $tableAnalysis = \EEH_Activation::getTableAnalysis(); |
|
661 | - $wp_table_name = $tableAnalysis->ensureTableNameHasPrefix($table_name); |
|
662 | - // do we need to first delete an existing version of this table ? |
|
663 | - if ($drop_pre_existing_table && $tableAnalysis->tableExists($wp_table_name)) { |
|
664 | - // ok, delete the table... but ONLY if it's empty |
|
665 | - $deleted_safely = EEH_Activation::delete_db_table_if_empty($wp_table_name); |
|
666 | - // table is NOT empty, are you SURE you want to delete this table ??? |
|
667 | - if ( ! $deleted_safely && defined('EE_DROP_BAD_TABLES') && EE_DROP_BAD_TABLES) { |
|
668 | - \EEH_Activation::getTableManager()->dropTable($wp_table_name); |
|
669 | - } else if ( ! $deleted_safely) { |
|
670 | - // so we should be more cautious rather than just dropping tables so easily |
|
671 | - error_log( |
|
672 | - sprintf( |
|
673 | - __( |
|
674 | - 'It appears that database table "%1$s" exists when it shouldn\'t, and therefore may contain erroneous data. If you have previously restored your database from a backup that didn\'t remove the old tables, then we recommend: %2$s 1. create a new COMPLETE backup of your database, %2$s 2. delete ALL tables from your database, %2$s 3. restore to your previous backup. %2$s If, however, you have not restored to a backup, then somehow your "%3$s" WordPress option could not be read. You can probably ignore this message, but should investigate why that option is being removed.', |
|
675 | - 'event_espresso' |
|
676 | - ), |
|
677 | - $wp_table_name, |
|
678 | - '<br/>', |
|
679 | - 'espresso_db_update' |
|
680 | - ) |
|
681 | - ); |
|
682 | - } |
|
683 | - } |
|
684 | - $engine = str_replace('ENGINE=', '', $engine); |
|
685 | - \EEH_Activation::getTableManager()->createTable($table_name, $sql, $engine); |
|
686 | - } |
|
687 | - |
|
688 | - |
|
689 | - |
|
690 | - /** |
|
691 | - * add_column_if_it_doesn't_exist |
|
692 | - * Checks if this column already exists on the specified table. Handy for addons which want to add a column |
|
693 | - * |
|
694 | - * @access public |
|
695 | - * @static |
|
696 | - * @deprecated instead use TableManager::addColumn() |
|
697 | - * @param string $table_name (without "wp_", eg "esp_attendee" |
|
698 | - * @param string $column_name |
|
699 | - * @param string $column_info if your SQL were 'ALTER TABLE table_name ADD price VARCHAR(10)', this would be |
|
700 | - * 'VARCHAR(10)' |
|
701 | - * @return bool|int |
|
702 | - */ |
|
703 | - public static function add_column_if_it_doesnt_exist( |
|
704 | - $table_name, |
|
705 | - $column_name, |
|
706 | - $column_info = 'INT UNSIGNED NOT NULL' |
|
707 | - ) { |
|
708 | - return \EEH_Activation::getTableManager()->addColumn($table_name, $column_name, $column_info); |
|
709 | - } |
|
710 | - |
|
711 | - |
|
712 | - /** |
|
713 | - * get_fields_on_table |
|
714 | - * Gets all the fields on the database table. |
|
715 | - * |
|
716 | - * @access public |
|
717 | - * @deprecated instead use TableManager::getTableColumns() |
|
718 | - * @static |
|
719 | - * @param string $table_name , without prefixed $wpdb->prefix |
|
720 | - * @return array of database column names |
|
721 | - */ |
|
722 | - public static function get_fields_on_table($table_name = null) |
|
723 | - { |
|
724 | - return \EEH_Activation::getTableManager()->getTableColumns($table_name); |
|
725 | - } |
|
726 | - |
|
727 | - |
|
728 | - /** |
|
729 | - * db_table_is_empty |
|
730 | - * |
|
731 | - * @access public\ |
|
732 | - * @deprecated instead use TableAnalysis::tableIsEmpty() |
|
733 | - * @static |
|
734 | - * @param string $table_name |
|
735 | - * @return bool |
|
736 | - */ |
|
737 | - public static function db_table_is_empty($table_name) |
|
738 | - { |
|
739 | - return \EEH_Activation::getTableAnalysis()->tableIsEmpty($table_name); |
|
740 | - } |
|
741 | - |
|
742 | - |
|
743 | - /** |
|
744 | - * delete_db_table_if_empty |
|
745 | - * |
|
746 | - * @access public |
|
747 | - * @static |
|
748 | - * @param string $table_name |
|
749 | - * @return bool | int |
|
750 | - */ |
|
751 | - public static function delete_db_table_if_empty($table_name) |
|
752 | - { |
|
753 | - if (\EEH_Activation::getTableAnalysis()->tableIsEmpty($table_name)) { |
|
754 | - return \EEH_Activation::getTableManager()->dropTable($table_name); |
|
755 | - } |
|
756 | - return false; |
|
757 | - } |
|
758 | - |
|
759 | - |
|
760 | - /** |
|
761 | - * delete_unused_db_table |
|
762 | - * |
|
763 | - * @access public |
|
764 | - * @static |
|
765 | - * @deprecated instead use TableManager::dropTable() |
|
766 | - * @param string $table_name |
|
767 | - * @return bool | int |
|
768 | - */ |
|
769 | - public static function delete_unused_db_table($table_name) |
|
770 | - { |
|
771 | - return \EEH_Activation::getTableManager()->dropTable($table_name); |
|
772 | - } |
|
773 | - |
|
774 | - |
|
775 | - /** |
|
776 | - * drop_index |
|
777 | - * |
|
778 | - * @access public |
|
779 | - * @static |
|
780 | - * @deprecated instead use TableManager::dropIndex() |
|
781 | - * @param string $table_name |
|
782 | - * @param string $index_name |
|
783 | - * @return bool | int |
|
784 | - */ |
|
785 | - public static function drop_index($table_name, $index_name) |
|
786 | - { |
|
787 | - return \EEH_Activation::getTableManager()->dropIndex($table_name, $index_name); |
|
788 | - } |
|
789 | - |
|
790 | - |
|
791 | - |
|
792 | - /** |
|
793 | - * create_database_tables |
|
794 | - * |
|
795 | - * @access public |
|
796 | - * @static |
|
797 | - * @throws EE_Error |
|
798 | - * @return boolean success (whether database is setup properly or not) |
|
799 | - */ |
|
800 | - public static function create_database_tables() |
|
801 | - { |
|
802 | - EE_Registry::instance()->load_core('Data_Migration_Manager'); |
|
803 | - //find the migration script that sets the database to be compatible with the code |
|
804 | - $dms_name = EE_Data_Migration_Manager::instance()->get_most_up_to_date_dms(); |
|
805 | - if ($dms_name) { |
|
806 | - $current_data_migration_script = EE_Registry::instance()->load_dms($dms_name); |
|
807 | - $current_data_migration_script->set_migrating(false); |
|
808 | - $current_data_migration_script->schema_changes_before_migration(); |
|
809 | - $current_data_migration_script->schema_changes_after_migration(); |
|
810 | - if ($current_data_migration_script->get_errors()) { |
|
811 | - if (WP_DEBUG) { |
|
812 | - foreach ($current_data_migration_script->get_errors() as $error) { |
|
813 | - EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__); |
|
814 | - } |
|
815 | - } else { |
|
816 | - EE_Error::add_error( |
|
817 | - __( |
|
818 | - 'There were errors creating the Event Espresso database tables and Event Espresso has been |
|
270 | + $ee_cron_tasks_to_remove = EEH_Activation::get_cron_tasks($cron_tasks_to_remove); |
|
271 | + foreach ($crons as $timestamp => $hooks_to_fire_at_time) { |
|
272 | + if (is_array($hooks_to_fire_at_time)) { |
|
273 | + foreach ($hooks_to_fire_at_time as $hook_name => $hook_actions) { |
|
274 | + if (isset($ee_cron_tasks_to_remove[$hook_name]) |
|
275 | + && is_array($ee_cron_tasks_to_remove[$hook_name]) |
|
276 | + ) { |
|
277 | + unset($crons[$timestamp][$hook_name]); |
|
278 | + } |
|
279 | + } |
|
280 | + //also take care of any empty cron timestamps. |
|
281 | + if (empty($hooks_to_fire_at_time)) { |
|
282 | + unset($crons[$timestamp]); |
|
283 | + } |
|
284 | + } |
|
285 | + } |
|
286 | + _set_cron_array($crons); |
|
287 | + } |
|
288 | + |
|
289 | + |
|
290 | + /** |
|
291 | + * CPT_initialization |
|
292 | + * registers all EE CPTs ( Custom Post Types ) then flushes rewrite rules so that all endpoints exist |
|
293 | + * |
|
294 | + * @access public |
|
295 | + * @static |
|
296 | + * @return void |
|
297 | + */ |
|
298 | + public static function CPT_initialization() |
|
299 | + { |
|
300 | + // register Custom Post Types |
|
301 | + EE_Registry::instance()->load_core('Register_CPTs'); |
|
302 | + flush_rewrite_rules(); |
|
303 | + } |
|
304 | + |
|
305 | + |
|
306 | + |
|
307 | + /** |
|
308 | + * reset_and_update_config |
|
309 | + * The following code was moved over from EE_Config so that it will no longer run on every request. |
|
310 | + * If there is old calendar config data saved, then it will get converted on activation. |
|
311 | + * This was basically a DMS before we had DMS's, and will get removed after a few more versions. |
|
312 | + * |
|
313 | + * @access public |
|
314 | + * @static |
|
315 | + * @return void |
|
316 | + */ |
|
317 | + public static function reset_and_update_config() |
|
318 | + { |
|
319 | + do_action('AHEE__EE_Config___load_core_config__start', array('EEH_Activation', 'load_calendar_config')); |
|
320 | + add_filter( |
|
321 | + 'FHEE__EE_Config___load_core_config__config_settings', |
|
322 | + array('EEH_Activation', 'migrate_old_config_data'), |
|
323 | + 10, |
|
324 | + 3 |
|
325 | + ); |
|
326 | + //EE_Config::reset(); |
|
327 | + if (! EE_Config::logging_enabled()) { |
|
328 | + delete_option(EE_Config::LOG_NAME); |
|
329 | + } |
|
330 | + } |
|
331 | + |
|
332 | + |
|
333 | + /** |
|
334 | + * load_calendar_config |
|
335 | + * |
|
336 | + * @access public |
|
337 | + * @return void |
|
338 | + */ |
|
339 | + public static function load_calendar_config() |
|
340 | + { |
|
341 | + // grab array of all plugin folders and loop thru it |
|
342 | + $plugins = glob(WP_PLUGIN_DIR . DS . '*', GLOB_ONLYDIR); |
|
343 | + if (empty($plugins)) { |
|
344 | + return; |
|
345 | + } |
|
346 | + foreach ($plugins as $plugin_path) { |
|
347 | + // grab plugin folder name from path |
|
348 | + $plugin = basename($plugin_path); |
|
349 | + // drill down to Espresso plugins |
|
350 | + // then to calendar related plugins |
|
351 | + if ( |
|
352 | + strpos($plugin, 'espresso') !== false |
|
353 | + || strpos($plugin, 'Espresso') !== false |
|
354 | + || strpos($plugin, 'ee4') !== false |
|
355 | + || strpos($plugin, 'EE4') !== false |
|
356 | + || strpos($plugin, 'calendar') !== false |
|
357 | + ) { |
|
358 | + // this is what we are looking for |
|
359 | + $calendar_config = $plugin_path . DS . 'EE_Calendar_Config.php'; |
|
360 | + // does it exist in this folder ? |
|
361 | + if (is_readable($calendar_config)) { |
|
362 | + // YEAH! let's load it |
|
363 | + require_once($calendar_config); |
|
364 | + } |
|
365 | + } |
|
366 | + } |
|
367 | + } |
|
368 | + |
|
369 | + |
|
370 | + |
|
371 | + /** |
|
372 | + * _migrate_old_config_data |
|
373 | + * |
|
374 | + * @access public |
|
375 | + * @param array|stdClass $settings |
|
376 | + * @param string $config |
|
377 | + * @param \EE_Config $EE_Config |
|
378 | + * @return \stdClass |
|
379 | + */ |
|
380 | + public static function migrate_old_config_data($settings = array(), $config = '', EE_Config $EE_Config) |
|
381 | + { |
|
382 | + $convert_from_array = array('addons'); |
|
383 | + // in case old settings were saved as an array |
|
384 | + if (is_array($settings) && in_array($config, $convert_from_array)) { |
|
385 | + // convert existing settings to an object |
|
386 | + $config_array = $settings; |
|
387 | + $settings = new stdClass(); |
|
388 | + foreach ($config_array as $key => $value) { |
|
389 | + if ($key === 'calendar' && class_exists('EE_Calendar_Config')) { |
|
390 | + $EE_Config->set_config('addons', 'EE_Calendar', 'EE_Calendar_Config', $value); |
|
391 | + } else { |
|
392 | + $settings->{$key} = $value; |
|
393 | + } |
|
394 | + } |
|
395 | + add_filter('FHEE__EE_Config___load_core_config__update_espresso_config', '__return_true'); |
|
396 | + } |
|
397 | + return $settings; |
|
398 | + } |
|
399 | + |
|
400 | + |
|
401 | + /** |
|
402 | + * deactivate_event_espresso |
|
403 | + * |
|
404 | + * @access public |
|
405 | + * @static |
|
406 | + * @return void |
|
407 | + */ |
|
408 | + public static function deactivate_event_espresso() |
|
409 | + { |
|
410 | + // check permissions |
|
411 | + if (current_user_can('activate_plugins')) { |
|
412 | + deactivate_plugins(EE_PLUGIN_BASENAME, true); |
|
413 | + } |
|
414 | + } |
|
415 | + |
|
416 | + |
|
417 | + |
|
418 | + |
|
419 | + /** |
|
420 | + * verify_default_pages_exist |
|
421 | + * |
|
422 | + * @access public |
|
423 | + * @static |
|
424 | + * @return void |
|
425 | + */ |
|
426 | + public static function verify_default_pages_exist() |
|
427 | + { |
|
428 | + $critical_page_problem = false; |
|
429 | + $critical_pages = array( |
|
430 | + array( |
|
431 | + 'id' => 'reg_page_id', |
|
432 | + 'name' => __('Registration Checkout', 'event_espresso'), |
|
433 | + 'post' => null, |
|
434 | + 'code' => 'ESPRESSO_CHECKOUT', |
|
435 | + ), |
|
436 | + array( |
|
437 | + 'id' => 'txn_page_id', |
|
438 | + 'name' => __('Transactions', 'event_espresso'), |
|
439 | + 'post' => null, |
|
440 | + 'code' => 'ESPRESSO_TXN_PAGE', |
|
441 | + ), |
|
442 | + array( |
|
443 | + 'id' => 'thank_you_page_id', |
|
444 | + 'name' => __('Thank You', 'event_espresso'), |
|
445 | + 'post' => null, |
|
446 | + 'code' => 'ESPRESSO_THANK_YOU', |
|
447 | + ), |
|
448 | + array( |
|
449 | + 'id' => 'cancel_page_id', |
|
450 | + 'name' => __('Registration Cancelled', 'event_espresso'), |
|
451 | + 'post' => null, |
|
452 | + 'code' => 'ESPRESSO_CANCELLED', |
|
453 | + ), |
|
454 | + ); |
|
455 | + $EE_Core_Config = EE_Registry::instance()->CFG->core; |
|
456 | + foreach ($critical_pages as $critical_page) { |
|
457 | + // is critical page ID set in config ? |
|
458 | + if ($EE_Core_Config->{$critical_page['id']} !== false) { |
|
459 | + // attempt to find post by ID |
|
460 | + $critical_page['post'] = get_post($EE_Core_Config->{$critical_page['id']}); |
|
461 | + } |
|
462 | + // no dice? |
|
463 | + if ($critical_page['post'] === null) { |
|
464 | + // attempt to find post by title |
|
465 | + $critical_page['post'] = self::get_page_by_ee_shortcode($critical_page['code']); |
|
466 | + // still nothing? |
|
467 | + if ($critical_page['post'] === null) { |
|
468 | + $critical_page = EEH_Activation::create_critical_page($critical_page); |
|
469 | + // REALLY? Still nothing ??!?!? |
|
470 | + if ($critical_page['post'] === null) { |
|
471 | + $msg = __( |
|
472 | + 'The Event Espresso critical page configuration settings could not be updated.', |
|
473 | + 'event_espresso' |
|
474 | + ); |
|
475 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
476 | + break; |
|
477 | + } |
|
478 | + } |
|
479 | + } |
|
480 | + // check that Post ID matches critical page ID in config |
|
481 | + if ( |
|
482 | + isset($critical_page['post']->ID) |
|
483 | + && $critical_page['post']->ID !== $EE_Core_Config->{$critical_page['id']} |
|
484 | + ) { |
|
485 | + //update Config with post ID |
|
486 | + $EE_Core_Config->{$critical_page['id']} = $critical_page['post']->ID; |
|
487 | + if (! EE_Config::instance()->update_espresso_config(false, false)) { |
|
488 | + $msg = __( |
|
489 | + 'The Event Espresso critical page configuration settings could not be updated.', |
|
490 | + 'event_espresso' |
|
491 | + ); |
|
492 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
493 | + } |
|
494 | + } |
|
495 | + $critical_page_problem = |
|
496 | + ! isset($critical_page['post']->post_status) |
|
497 | + || $critical_page['post']->post_status !== 'publish' |
|
498 | + || strpos($critical_page['post']->post_content, $critical_page['code']) === false |
|
499 | + ? true |
|
500 | + : $critical_page_problem; |
|
501 | + } |
|
502 | + if ($critical_page_problem) { |
|
503 | + $msg = sprintf( |
|
504 | + __( |
|
505 | + 'A potential issue has been detected with one or more of your Event Espresso pages. Go to %s to view your Event Espresso pages.', |
|
506 | + 'event_espresso' |
|
507 | + ), |
|
508 | + '<a href="' |
|
509 | + . admin_url('admin.php?page=espresso_general_settings&action=critical_pages') |
|
510 | + . '">' |
|
511 | + . __('Event Espresso Critical Pages Settings', 'event_espresso') |
|
512 | + . '</a>' |
|
513 | + ); |
|
514 | + EE_Error::add_persistent_admin_notice('critical_page_problem', $msg); |
|
515 | + } |
|
516 | + if (EE_Error::has_notices()) { |
|
517 | + EE_Error::get_notices(false, true, true); |
|
518 | + } |
|
519 | + } |
|
520 | + |
|
521 | + |
|
522 | + |
|
523 | + /** |
|
524 | + * Returns the first post which uses the specified shortcode |
|
525 | + * |
|
526 | + * @param string $ee_shortcode usually one of the critical pages shortcodes, eg |
|
527 | + * ESPRESSO_THANK_YOU. So we will search fora post with the content |
|
528 | + * "[ESPRESSO_THANK_YOU" |
|
529 | + * (we don't search for the closing shortcode bracket because they might have added |
|
530 | + * parameter to the shortcode |
|
531 | + * @return WP_Post or NULl |
|
532 | + */ |
|
533 | + public static function get_page_by_ee_shortcode($ee_shortcode) |
|
534 | + { |
|
535 | + global $wpdb; |
|
536 | + $shortcode_and_opening_bracket = '[' . $ee_shortcode; |
|
537 | + $post_id = $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE post_content LIKE '%$shortcode_and_opening_bracket%' LIMIT 1"); |
|
538 | + if ($post_id) { |
|
539 | + return get_post($post_id); |
|
540 | + } else { |
|
541 | + return null; |
|
542 | + } |
|
543 | + } |
|
544 | + |
|
545 | + |
|
546 | + |
|
547 | + /** |
|
548 | + * This function generates a post for critical espresso pages |
|
549 | + * |
|
550 | + * @access public |
|
551 | + * @static |
|
552 | + * @param array $critical_page |
|
553 | + * @return array |
|
554 | + */ |
|
555 | + public static function create_critical_page($critical_page) |
|
556 | + { |
|
557 | + |
|
558 | + $post_args = array( |
|
559 | + 'post_title' => $critical_page['name'], |
|
560 | + 'post_status' => 'publish', |
|
561 | + 'post_type' => 'page', |
|
562 | + 'comment_status' => 'closed', |
|
563 | + 'post_content' => '[' . $critical_page['code'] . ']', |
|
564 | + ); |
|
565 | + |
|
566 | + $post_id = wp_insert_post($post_args); |
|
567 | + if (! $post_id) { |
|
568 | + $msg = sprintf( |
|
569 | + __('The Event Espresso critical page entitled "%s" could not be created.', 'event_espresso'), |
|
570 | + $critical_page['name'] |
|
571 | + ); |
|
572 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
573 | + return $critical_page; |
|
574 | + } |
|
575 | + // get newly created post's details |
|
576 | + if (! $critical_page['post'] = get_post($post_id)) { |
|
577 | + $msg = sprintf( |
|
578 | + __('The Event Espresso critical page entitled "%s" could not be retrieved.', 'event_espresso'), |
|
579 | + $critical_page['name'] |
|
580 | + ); |
|
581 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
582 | + } |
|
583 | + |
|
584 | + return $critical_page; |
|
585 | + |
|
586 | + } |
|
587 | + |
|
588 | + |
|
589 | + |
|
590 | + |
|
591 | + /** |
|
592 | + * Tries to find the oldest admin for this site. If there are no admins for this site then return NULL. |
|
593 | + * The role being used to check is filterable. |
|
594 | + * |
|
595 | + * @since 4.6.0 |
|
596 | + * @global WPDB $wpdb |
|
597 | + * @return mixed null|int WP_user ID or NULL |
|
598 | + */ |
|
599 | + public static function get_default_creator_id() |
|
600 | + { |
|
601 | + global $wpdb; |
|
602 | + if ( ! empty(self::$_default_creator_id)) { |
|
603 | + return self::$_default_creator_id; |
|
604 | + }/**/ |
|
605 | + $role_to_check = apply_filters('FHEE__EEH_Activation__get_default_creator_id__role_to_check', 'administrator'); |
|
606 | + //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. |
|
607 | + $pre_filtered_id = apply_filters( |
|
608 | + 'FHEE__EEH_Activation__get_default_creator_id__pre_filtered_id', |
|
609 | + false, |
|
610 | + $role_to_check |
|
611 | + ); |
|
612 | + if ($pre_filtered_id !== false) { |
|
613 | + return (int)$pre_filtered_id; |
|
614 | + } |
|
615 | + $capabilities_key = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('capabilities'); |
|
616 | + $query = $wpdb->prepare( |
|
617 | + "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$capabilities_key' AND meta_value LIKE %s ORDER BY user_id ASC LIMIT 0,1", |
|
618 | + '%' . $role_to_check . '%' |
|
619 | + ); |
|
620 | + $user_id = $wpdb->get_var($query); |
|
621 | + $user_id = apply_filters('FHEE__EEH_Activation_Helper__get_default_creator_id__user_id', $user_id); |
|
622 | + if ($user_id && (int)$user_id) { |
|
623 | + self::$_default_creator_id = (int)$user_id; |
|
624 | + return self::$_default_creator_id; |
|
625 | + } else { |
|
626 | + return null; |
|
627 | + } |
|
628 | + } |
|
629 | + |
|
630 | + |
|
631 | + |
|
632 | + /** |
|
633 | + * used by EE and EE addons during plugin activation to create tables. |
|
634 | + * Its a wrapper for EventEspresso\core\services\database\TableManager::createTable, |
|
635 | + * but includes extra logic regarding activations. |
|
636 | + * |
|
637 | + * @access public |
|
638 | + * @static |
|
639 | + * @param string $table_name without the $wpdb->prefix |
|
640 | + * @param string $sql SQL for creating the table (contents between brackets in an SQL create |
|
641 | + * table query) |
|
642 | + * @param string $engine like 'ENGINE=MyISAM' or 'ENGINE=InnoDB' |
|
643 | + * @param boolean $drop_pre_existing_table set to TRUE when you want to make SURE the table is completely empty |
|
644 | + * and new once this function is done (ie, you really do want to CREATE a |
|
645 | + * table, and expect it to be empty once you're done) leave as FALSE when |
|
646 | + * you just want to verify the table exists and matches this definition |
|
647 | + * (and if it HAS data in it you want to leave it be) |
|
648 | + * @return void |
|
649 | + * @throws EE_Error if there are database errors |
|
650 | + */ |
|
651 | + public static function create_table($table_name, $sql, $engine = 'ENGINE=MyISAM ', $drop_pre_existing_table = false) |
|
652 | + { |
|
653 | + if (apply_filters('FHEE__EEH_Activation__create_table__short_circuit', false, $table_name, $sql)) { |
|
654 | + return; |
|
655 | + } |
|
656 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
657 | + if ( ! function_exists('dbDelta')) { |
|
658 | + require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); |
|
659 | + } |
|
660 | + $tableAnalysis = \EEH_Activation::getTableAnalysis(); |
|
661 | + $wp_table_name = $tableAnalysis->ensureTableNameHasPrefix($table_name); |
|
662 | + // do we need to first delete an existing version of this table ? |
|
663 | + if ($drop_pre_existing_table && $tableAnalysis->tableExists($wp_table_name)) { |
|
664 | + // ok, delete the table... but ONLY if it's empty |
|
665 | + $deleted_safely = EEH_Activation::delete_db_table_if_empty($wp_table_name); |
|
666 | + // table is NOT empty, are you SURE you want to delete this table ??? |
|
667 | + if ( ! $deleted_safely && defined('EE_DROP_BAD_TABLES') && EE_DROP_BAD_TABLES) { |
|
668 | + \EEH_Activation::getTableManager()->dropTable($wp_table_name); |
|
669 | + } else if ( ! $deleted_safely) { |
|
670 | + // so we should be more cautious rather than just dropping tables so easily |
|
671 | + error_log( |
|
672 | + sprintf( |
|
673 | + __( |
|
674 | + 'It appears that database table "%1$s" exists when it shouldn\'t, and therefore may contain erroneous data. If you have previously restored your database from a backup that didn\'t remove the old tables, then we recommend: %2$s 1. create a new COMPLETE backup of your database, %2$s 2. delete ALL tables from your database, %2$s 3. restore to your previous backup. %2$s If, however, you have not restored to a backup, then somehow your "%3$s" WordPress option could not be read. You can probably ignore this message, but should investigate why that option is being removed.', |
|
675 | + 'event_espresso' |
|
676 | + ), |
|
677 | + $wp_table_name, |
|
678 | + '<br/>', |
|
679 | + 'espresso_db_update' |
|
680 | + ) |
|
681 | + ); |
|
682 | + } |
|
683 | + } |
|
684 | + $engine = str_replace('ENGINE=', '', $engine); |
|
685 | + \EEH_Activation::getTableManager()->createTable($table_name, $sql, $engine); |
|
686 | + } |
|
687 | + |
|
688 | + |
|
689 | + |
|
690 | + /** |
|
691 | + * add_column_if_it_doesn't_exist |
|
692 | + * Checks if this column already exists on the specified table. Handy for addons which want to add a column |
|
693 | + * |
|
694 | + * @access public |
|
695 | + * @static |
|
696 | + * @deprecated instead use TableManager::addColumn() |
|
697 | + * @param string $table_name (without "wp_", eg "esp_attendee" |
|
698 | + * @param string $column_name |
|
699 | + * @param string $column_info if your SQL were 'ALTER TABLE table_name ADD price VARCHAR(10)', this would be |
|
700 | + * 'VARCHAR(10)' |
|
701 | + * @return bool|int |
|
702 | + */ |
|
703 | + public static function add_column_if_it_doesnt_exist( |
|
704 | + $table_name, |
|
705 | + $column_name, |
|
706 | + $column_info = 'INT UNSIGNED NOT NULL' |
|
707 | + ) { |
|
708 | + return \EEH_Activation::getTableManager()->addColumn($table_name, $column_name, $column_info); |
|
709 | + } |
|
710 | + |
|
711 | + |
|
712 | + /** |
|
713 | + * get_fields_on_table |
|
714 | + * Gets all the fields on the database table. |
|
715 | + * |
|
716 | + * @access public |
|
717 | + * @deprecated instead use TableManager::getTableColumns() |
|
718 | + * @static |
|
719 | + * @param string $table_name , without prefixed $wpdb->prefix |
|
720 | + * @return array of database column names |
|
721 | + */ |
|
722 | + public static function get_fields_on_table($table_name = null) |
|
723 | + { |
|
724 | + return \EEH_Activation::getTableManager()->getTableColumns($table_name); |
|
725 | + } |
|
726 | + |
|
727 | + |
|
728 | + /** |
|
729 | + * db_table_is_empty |
|
730 | + * |
|
731 | + * @access public\ |
|
732 | + * @deprecated instead use TableAnalysis::tableIsEmpty() |
|
733 | + * @static |
|
734 | + * @param string $table_name |
|
735 | + * @return bool |
|
736 | + */ |
|
737 | + public static function db_table_is_empty($table_name) |
|
738 | + { |
|
739 | + return \EEH_Activation::getTableAnalysis()->tableIsEmpty($table_name); |
|
740 | + } |
|
741 | + |
|
742 | + |
|
743 | + /** |
|
744 | + * delete_db_table_if_empty |
|
745 | + * |
|
746 | + * @access public |
|
747 | + * @static |
|
748 | + * @param string $table_name |
|
749 | + * @return bool | int |
|
750 | + */ |
|
751 | + public static function delete_db_table_if_empty($table_name) |
|
752 | + { |
|
753 | + if (\EEH_Activation::getTableAnalysis()->tableIsEmpty($table_name)) { |
|
754 | + return \EEH_Activation::getTableManager()->dropTable($table_name); |
|
755 | + } |
|
756 | + return false; |
|
757 | + } |
|
758 | + |
|
759 | + |
|
760 | + /** |
|
761 | + * delete_unused_db_table |
|
762 | + * |
|
763 | + * @access public |
|
764 | + * @static |
|
765 | + * @deprecated instead use TableManager::dropTable() |
|
766 | + * @param string $table_name |
|
767 | + * @return bool | int |
|
768 | + */ |
|
769 | + public static function delete_unused_db_table($table_name) |
|
770 | + { |
|
771 | + return \EEH_Activation::getTableManager()->dropTable($table_name); |
|
772 | + } |
|
773 | + |
|
774 | + |
|
775 | + /** |
|
776 | + * drop_index |
|
777 | + * |
|
778 | + * @access public |
|
779 | + * @static |
|
780 | + * @deprecated instead use TableManager::dropIndex() |
|
781 | + * @param string $table_name |
|
782 | + * @param string $index_name |
|
783 | + * @return bool | int |
|
784 | + */ |
|
785 | + public static function drop_index($table_name, $index_name) |
|
786 | + { |
|
787 | + return \EEH_Activation::getTableManager()->dropIndex($table_name, $index_name); |
|
788 | + } |
|
789 | + |
|
790 | + |
|
791 | + |
|
792 | + /** |
|
793 | + * create_database_tables |
|
794 | + * |
|
795 | + * @access public |
|
796 | + * @static |
|
797 | + * @throws EE_Error |
|
798 | + * @return boolean success (whether database is setup properly or not) |
|
799 | + */ |
|
800 | + public static function create_database_tables() |
|
801 | + { |
|
802 | + EE_Registry::instance()->load_core('Data_Migration_Manager'); |
|
803 | + //find the migration script that sets the database to be compatible with the code |
|
804 | + $dms_name = EE_Data_Migration_Manager::instance()->get_most_up_to_date_dms(); |
|
805 | + if ($dms_name) { |
|
806 | + $current_data_migration_script = EE_Registry::instance()->load_dms($dms_name); |
|
807 | + $current_data_migration_script->set_migrating(false); |
|
808 | + $current_data_migration_script->schema_changes_before_migration(); |
|
809 | + $current_data_migration_script->schema_changes_after_migration(); |
|
810 | + if ($current_data_migration_script->get_errors()) { |
|
811 | + if (WP_DEBUG) { |
|
812 | + foreach ($current_data_migration_script->get_errors() as $error) { |
|
813 | + EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__); |
|
814 | + } |
|
815 | + } else { |
|
816 | + EE_Error::add_error( |
|
817 | + __( |
|
818 | + 'There were errors creating the Event Espresso database tables and Event Espresso has been |
|
819 | 819 | deactivated. To view the errors, please enable WP_DEBUG in your wp-config.php file.', |
820 | - 'event_espresso' |
|
821 | - ) |
|
822 | - ); |
|
823 | - } |
|
824 | - return false; |
|
825 | - } |
|
826 | - EE_Data_Migration_Manager::instance()->update_current_database_state_to(); |
|
827 | - } else { |
|
828 | - EE_Error::add_error( |
|
829 | - __( |
|
830 | - 'Could not determine most up-to-date data migration script from which to pull database schema |
|
820 | + 'event_espresso' |
|
821 | + ) |
|
822 | + ); |
|
823 | + } |
|
824 | + return false; |
|
825 | + } |
|
826 | + EE_Data_Migration_Manager::instance()->update_current_database_state_to(); |
|
827 | + } else { |
|
828 | + EE_Error::add_error( |
|
829 | + __( |
|
830 | + 'Could not determine most up-to-date data migration script from which to pull database schema |
|
831 | 831 | structure. So database is probably not setup properly', |
832 | - 'event_espresso' |
|
833 | - ), |
|
834 | - __FILE__, |
|
835 | - __FUNCTION__, |
|
836 | - __LINE__ |
|
837 | - ); |
|
838 | - return false; |
|
839 | - } |
|
840 | - return true; |
|
841 | - } |
|
842 | - |
|
843 | - |
|
844 | - |
|
845 | - /** |
|
846 | - * initialize_system_questions |
|
847 | - * |
|
848 | - * @access public |
|
849 | - * @static |
|
850 | - * @return void |
|
851 | - */ |
|
852 | - public static function initialize_system_questions() |
|
853 | - { |
|
854 | - // QUESTION GROUPS |
|
855 | - global $wpdb; |
|
856 | - $table_name = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('esp_question_group'); |
|
857 | - $SQL = "SELECT QSG_system FROM $table_name WHERE QSG_system != 0"; |
|
858 | - // what we have |
|
859 | - $question_groups = $wpdb->get_col($SQL); |
|
860 | - // check the response |
|
861 | - $question_groups = is_array($question_groups) ? $question_groups : array(); |
|
862 | - // what we should have |
|
863 | - $QSG_systems = array(1, 2); |
|
864 | - // loop thru what we should have and compare to what we have |
|
865 | - foreach ($QSG_systems as $QSG_system) { |
|
866 | - // reset values array |
|
867 | - $QSG_values = array(); |
|
868 | - // 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) |
|
869 | - if (! in_array("$QSG_system", $question_groups)) { |
|
870 | - // add it |
|
871 | - switch ($QSG_system) { |
|
872 | - case 1: |
|
873 | - $QSG_values = array( |
|
874 | - 'QSG_name' => __('Personal Information', 'event_espresso'), |
|
875 | - 'QSG_identifier' => 'personal-information-' . time(), |
|
876 | - 'QSG_desc' => '', |
|
877 | - 'QSG_order' => 1, |
|
878 | - 'QSG_show_group_name' => 1, |
|
879 | - 'QSG_show_group_desc' => 1, |
|
880 | - 'QSG_system' => EEM_Question_Group::system_personal, |
|
881 | - 'QSG_deleted' => 0, |
|
882 | - ); |
|
883 | - break; |
|
884 | - case 2: |
|
885 | - $QSG_values = array( |
|
886 | - 'QSG_name' => __('Address Information', 'event_espresso'), |
|
887 | - 'QSG_identifier' => 'address-information-' . time(), |
|
888 | - 'QSG_desc' => '', |
|
889 | - 'QSG_order' => 2, |
|
890 | - 'QSG_show_group_name' => 1, |
|
891 | - 'QSG_show_group_desc' => 1, |
|
892 | - 'QSG_system' => EEM_Question_Group::system_address, |
|
893 | - 'QSG_deleted' => 0, |
|
894 | - ); |
|
895 | - break; |
|
896 | - } |
|
897 | - // make sure we have some values before inserting them |
|
898 | - if (! empty($QSG_values)) { |
|
899 | - // insert system question |
|
900 | - $wpdb->insert( |
|
901 | - $table_name, |
|
902 | - $QSG_values, |
|
903 | - array('%s', '%s', '%s', '%d', '%d', '%d', '%d', '%d') |
|
904 | - ); |
|
905 | - $QSG_IDs[$QSG_system] = $wpdb->insert_id; |
|
906 | - } |
|
907 | - } |
|
908 | - } |
|
909 | - // QUESTIONS |
|
910 | - global $wpdb; |
|
911 | - $table_name = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('esp_question'); |
|
912 | - $SQL = "SELECT QST_system FROM $table_name WHERE QST_system != ''"; |
|
913 | - // what we have |
|
914 | - $questions = $wpdb->get_col($SQL); |
|
915 | - // what we should have |
|
916 | - $QST_systems = array( |
|
917 | - 'fname', |
|
918 | - 'lname', |
|
919 | - 'email', |
|
920 | - 'address', |
|
921 | - 'address2', |
|
922 | - 'city', |
|
923 | - 'country', |
|
924 | - 'state', |
|
925 | - 'zip', |
|
926 | - 'phone', |
|
927 | - ); |
|
928 | - $order_for_group_1 = 1; |
|
929 | - $order_for_group_2 = 1; |
|
930 | - // loop thru what we should have and compare to what we have |
|
931 | - foreach ($QST_systems as $QST_system) { |
|
932 | - // reset values array |
|
933 | - $QST_values = array(); |
|
934 | - // if we don't have what we should have |
|
935 | - if (! in_array($QST_system, $questions)) { |
|
936 | - // add it |
|
937 | - switch ($QST_system) { |
|
938 | - case 'fname': |
|
939 | - $QST_values = array( |
|
940 | - 'QST_display_text' => __('First Name', 'event_espresso'), |
|
941 | - 'QST_admin_label' => __('First Name - System Question', 'event_espresso'), |
|
942 | - 'QST_system' => 'fname', |
|
943 | - 'QST_type' => 'TEXT', |
|
944 | - 'QST_required' => 1, |
|
945 | - 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
946 | - 'QST_order' => 1, |
|
947 | - 'QST_admin_only' => 0, |
|
948 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
949 | - 'QST_wp_user' => self::get_default_creator_id(), |
|
950 | - 'QST_deleted' => 0, |
|
951 | - ); |
|
952 | - break; |
|
953 | - case 'lname': |
|
954 | - $QST_values = array( |
|
955 | - 'QST_display_text' => __('Last Name', 'event_espresso'), |
|
956 | - 'QST_admin_label' => __('Last Name - System Question', 'event_espresso'), |
|
957 | - 'QST_system' => 'lname', |
|
958 | - 'QST_type' => 'TEXT', |
|
959 | - 'QST_required' => 1, |
|
960 | - 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
961 | - 'QST_order' => 2, |
|
962 | - 'QST_admin_only' => 0, |
|
963 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
964 | - 'QST_wp_user' => self::get_default_creator_id(), |
|
965 | - 'QST_deleted' => 0, |
|
966 | - ); |
|
967 | - break; |
|
968 | - case 'email': |
|
969 | - $QST_values = array( |
|
970 | - 'QST_display_text' => __('Email Address', 'event_espresso'), |
|
971 | - 'QST_admin_label' => __('Email Address - System Question', 'event_espresso'), |
|
972 | - 'QST_system' => 'email', |
|
973 | - 'QST_type' => 'EMAIL', |
|
974 | - 'QST_required' => 1, |
|
975 | - 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
976 | - 'QST_order' => 3, |
|
977 | - 'QST_admin_only' => 0, |
|
978 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
979 | - 'QST_wp_user' => self::get_default_creator_id(), |
|
980 | - 'QST_deleted' => 0, |
|
981 | - ); |
|
982 | - break; |
|
983 | - case 'address': |
|
984 | - $QST_values = array( |
|
985 | - 'QST_display_text' => __('Address', 'event_espresso'), |
|
986 | - 'QST_admin_label' => __('Address - System Question', 'event_espresso'), |
|
987 | - 'QST_system' => 'address', |
|
988 | - 'QST_type' => 'TEXT', |
|
989 | - 'QST_required' => 0, |
|
990 | - 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
991 | - 'QST_order' => 4, |
|
992 | - 'QST_admin_only' => 0, |
|
993 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
994 | - 'QST_wp_user' => self::get_default_creator_id(), |
|
995 | - 'QST_deleted' => 0, |
|
996 | - ); |
|
997 | - break; |
|
998 | - case 'address2': |
|
999 | - $QST_values = array( |
|
1000 | - 'QST_display_text' => __('Address2', 'event_espresso'), |
|
1001 | - 'QST_admin_label' => __('Address2 - System Question', 'event_espresso'), |
|
1002 | - 'QST_system' => 'address2', |
|
1003 | - 'QST_type' => 'TEXT', |
|
1004 | - 'QST_required' => 0, |
|
1005 | - 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1006 | - 'QST_order' => 5, |
|
1007 | - 'QST_admin_only' => 0, |
|
1008 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
1009 | - 'QST_wp_user' => self::get_default_creator_id(), |
|
1010 | - 'QST_deleted' => 0, |
|
1011 | - ); |
|
1012 | - break; |
|
1013 | - case 'city': |
|
1014 | - $QST_values = array( |
|
1015 | - 'QST_display_text' => __('City', 'event_espresso'), |
|
1016 | - 'QST_admin_label' => __('City - System Question', 'event_espresso'), |
|
1017 | - 'QST_system' => 'city', |
|
1018 | - 'QST_type' => 'TEXT', |
|
1019 | - 'QST_required' => 0, |
|
1020 | - 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1021 | - 'QST_order' => 6, |
|
1022 | - 'QST_admin_only' => 0, |
|
1023 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
1024 | - 'QST_wp_user' => self::get_default_creator_id(), |
|
1025 | - 'QST_deleted' => 0, |
|
1026 | - ); |
|
1027 | - break; |
|
1028 | - case 'country': |
|
1029 | - $QST_values = array( |
|
1030 | - 'QST_display_text' => __('Country', 'event_espresso'), |
|
1031 | - 'QST_admin_label' => __('Country - System Question', 'event_espresso'), |
|
1032 | - 'QST_system' => 'country', |
|
1033 | - 'QST_type' => 'COUNTRY', |
|
1034 | - 'QST_required' => 0, |
|
1035 | - 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1036 | - 'QST_order' => 7, |
|
1037 | - 'QST_admin_only' => 0, |
|
1038 | - 'QST_wp_user' => self::get_default_creator_id(), |
|
1039 | - 'QST_deleted' => 0, |
|
1040 | - ); |
|
1041 | - break; |
|
1042 | - case 'state': |
|
1043 | - $QST_values = array( |
|
1044 | - 'QST_display_text' => __('State/Province', 'event_espresso'), |
|
1045 | - 'QST_admin_label' => __('State/Province - System Question', 'event_espresso'), |
|
1046 | - 'QST_system' => 'state', |
|
1047 | - 'QST_type' => 'STATE', |
|
1048 | - 'QST_required' => 0, |
|
1049 | - 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1050 | - 'QST_order' => 8, |
|
1051 | - 'QST_admin_only' => 0, |
|
1052 | - 'QST_wp_user' => self::get_default_creator_id(), |
|
1053 | - 'QST_deleted' => 0, |
|
1054 | - ); |
|
1055 | - break; |
|
1056 | - case 'zip': |
|
1057 | - $QST_values = array( |
|
1058 | - 'QST_display_text' => __('Zip/Postal Code', 'event_espresso'), |
|
1059 | - 'QST_admin_label' => __('Zip/Postal Code - System Question', 'event_espresso'), |
|
1060 | - 'QST_system' => 'zip', |
|
1061 | - 'QST_type' => 'TEXT', |
|
1062 | - 'QST_required' => 0, |
|
1063 | - 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1064 | - 'QST_order' => 9, |
|
1065 | - 'QST_admin_only' => 0, |
|
1066 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
1067 | - 'QST_wp_user' => self::get_default_creator_id(), |
|
1068 | - 'QST_deleted' => 0, |
|
1069 | - ); |
|
1070 | - break; |
|
1071 | - case 'phone': |
|
1072 | - $QST_values = array( |
|
1073 | - 'QST_display_text' => __('Phone Number', 'event_espresso'), |
|
1074 | - 'QST_admin_label' => __('Phone Number - System Question', 'event_espresso'), |
|
1075 | - 'QST_system' => 'phone', |
|
1076 | - 'QST_type' => 'TEXT', |
|
1077 | - 'QST_required' => 0, |
|
1078 | - 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1079 | - 'QST_order' => 10, |
|
1080 | - 'QST_admin_only' => 0, |
|
1081 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
1082 | - 'QST_wp_user' => self::get_default_creator_id(), |
|
1083 | - 'QST_deleted' => 0, |
|
1084 | - ); |
|
1085 | - break; |
|
1086 | - } |
|
1087 | - if (! empty($QST_values)) { |
|
1088 | - // insert system question |
|
1089 | - $wpdb->insert( |
|
1090 | - $table_name, |
|
1091 | - $QST_values, |
|
1092 | - array('%s', '%s', '%s', '%s', '%d', '%s', '%d', '%d', '%d', '%d') |
|
1093 | - ); |
|
1094 | - $QST_ID = $wpdb->insert_id; |
|
1095 | - // QUESTION GROUP QUESTIONS |
|
1096 | - if (in_array($QST_system, array('fname', 'lname', 'email'))) { |
|
1097 | - $system_question_we_want = EEM_Question_Group::system_personal; |
|
1098 | - } else { |
|
1099 | - $system_question_we_want = EEM_Question_Group::system_address; |
|
1100 | - } |
|
1101 | - if (isset($QSG_IDs[$system_question_we_want])) { |
|
1102 | - $QSG_ID = $QSG_IDs[$system_question_we_want]; |
|
1103 | - } else { |
|
1104 | - $id_col = EEM_Question_Group::instance() |
|
1105 | - ->get_col(array(array('QSG_system' => $system_question_we_want))); |
|
1106 | - if (is_array($id_col)) { |
|
1107 | - $QSG_ID = reset($id_col); |
|
1108 | - } else { |
|
1109 | - //ok so we didn't find it in the db either?? that's weird because we should have inserted it at the start of this method |
|
1110 | - EE_Log::instance()->log( |
|
1111 | - __FILE__, |
|
1112 | - __FUNCTION__, |
|
1113 | - sprintf( |
|
1114 | - __( |
|
1115 | - 'Could not associate question %1$s to a question group because no system question |
|
832 | + 'event_espresso' |
|
833 | + ), |
|
834 | + __FILE__, |
|
835 | + __FUNCTION__, |
|
836 | + __LINE__ |
|
837 | + ); |
|
838 | + return false; |
|
839 | + } |
|
840 | + return true; |
|
841 | + } |
|
842 | + |
|
843 | + |
|
844 | + |
|
845 | + /** |
|
846 | + * initialize_system_questions |
|
847 | + * |
|
848 | + * @access public |
|
849 | + * @static |
|
850 | + * @return void |
|
851 | + */ |
|
852 | + public static function initialize_system_questions() |
|
853 | + { |
|
854 | + // QUESTION GROUPS |
|
855 | + global $wpdb; |
|
856 | + $table_name = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('esp_question_group'); |
|
857 | + $SQL = "SELECT QSG_system FROM $table_name WHERE QSG_system != 0"; |
|
858 | + // what we have |
|
859 | + $question_groups = $wpdb->get_col($SQL); |
|
860 | + // check the response |
|
861 | + $question_groups = is_array($question_groups) ? $question_groups : array(); |
|
862 | + // what we should have |
|
863 | + $QSG_systems = array(1, 2); |
|
864 | + // loop thru what we should have and compare to what we have |
|
865 | + foreach ($QSG_systems as $QSG_system) { |
|
866 | + // reset values array |
|
867 | + $QSG_values = array(); |
|
868 | + // 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) |
|
869 | + if (! in_array("$QSG_system", $question_groups)) { |
|
870 | + // add it |
|
871 | + switch ($QSG_system) { |
|
872 | + case 1: |
|
873 | + $QSG_values = array( |
|
874 | + 'QSG_name' => __('Personal Information', 'event_espresso'), |
|
875 | + 'QSG_identifier' => 'personal-information-' . time(), |
|
876 | + 'QSG_desc' => '', |
|
877 | + 'QSG_order' => 1, |
|
878 | + 'QSG_show_group_name' => 1, |
|
879 | + 'QSG_show_group_desc' => 1, |
|
880 | + 'QSG_system' => EEM_Question_Group::system_personal, |
|
881 | + 'QSG_deleted' => 0, |
|
882 | + ); |
|
883 | + break; |
|
884 | + case 2: |
|
885 | + $QSG_values = array( |
|
886 | + 'QSG_name' => __('Address Information', 'event_espresso'), |
|
887 | + 'QSG_identifier' => 'address-information-' . time(), |
|
888 | + 'QSG_desc' => '', |
|
889 | + 'QSG_order' => 2, |
|
890 | + 'QSG_show_group_name' => 1, |
|
891 | + 'QSG_show_group_desc' => 1, |
|
892 | + 'QSG_system' => EEM_Question_Group::system_address, |
|
893 | + 'QSG_deleted' => 0, |
|
894 | + ); |
|
895 | + break; |
|
896 | + } |
|
897 | + // make sure we have some values before inserting them |
|
898 | + if (! empty($QSG_values)) { |
|
899 | + // insert system question |
|
900 | + $wpdb->insert( |
|
901 | + $table_name, |
|
902 | + $QSG_values, |
|
903 | + array('%s', '%s', '%s', '%d', '%d', '%d', '%d', '%d') |
|
904 | + ); |
|
905 | + $QSG_IDs[$QSG_system] = $wpdb->insert_id; |
|
906 | + } |
|
907 | + } |
|
908 | + } |
|
909 | + // QUESTIONS |
|
910 | + global $wpdb; |
|
911 | + $table_name = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('esp_question'); |
|
912 | + $SQL = "SELECT QST_system FROM $table_name WHERE QST_system != ''"; |
|
913 | + // what we have |
|
914 | + $questions = $wpdb->get_col($SQL); |
|
915 | + // what we should have |
|
916 | + $QST_systems = array( |
|
917 | + 'fname', |
|
918 | + 'lname', |
|
919 | + 'email', |
|
920 | + 'address', |
|
921 | + 'address2', |
|
922 | + 'city', |
|
923 | + 'country', |
|
924 | + 'state', |
|
925 | + 'zip', |
|
926 | + 'phone', |
|
927 | + ); |
|
928 | + $order_for_group_1 = 1; |
|
929 | + $order_for_group_2 = 1; |
|
930 | + // loop thru what we should have and compare to what we have |
|
931 | + foreach ($QST_systems as $QST_system) { |
|
932 | + // reset values array |
|
933 | + $QST_values = array(); |
|
934 | + // if we don't have what we should have |
|
935 | + if (! in_array($QST_system, $questions)) { |
|
936 | + // add it |
|
937 | + switch ($QST_system) { |
|
938 | + case 'fname': |
|
939 | + $QST_values = array( |
|
940 | + 'QST_display_text' => __('First Name', 'event_espresso'), |
|
941 | + 'QST_admin_label' => __('First Name - System Question', 'event_espresso'), |
|
942 | + 'QST_system' => 'fname', |
|
943 | + 'QST_type' => 'TEXT', |
|
944 | + 'QST_required' => 1, |
|
945 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
946 | + 'QST_order' => 1, |
|
947 | + 'QST_admin_only' => 0, |
|
948 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
949 | + 'QST_wp_user' => self::get_default_creator_id(), |
|
950 | + 'QST_deleted' => 0, |
|
951 | + ); |
|
952 | + break; |
|
953 | + case 'lname': |
|
954 | + $QST_values = array( |
|
955 | + 'QST_display_text' => __('Last Name', 'event_espresso'), |
|
956 | + 'QST_admin_label' => __('Last Name - System Question', 'event_espresso'), |
|
957 | + 'QST_system' => 'lname', |
|
958 | + 'QST_type' => 'TEXT', |
|
959 | + 'QST_required' => 1, |
|
960 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
961 | + 'QST_order' => 2, |
|
962 | + 'QST_admin_only' => 0, |
|
963 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
964 | + 'QST_wp_user' => self::get_default_creator_id(), |
|
965 | + 'QST_deleted' => 0, |
|
966 | + ); |
|
967 | + break; |
|
968 | + case 'email': |
|
969 | + $QST_values = array( |
|
970 | + 'QST_display_text' => __('Email Address', 'event_espresso'), |
|
971 | + 'QST_admin_label' => __('Email Address - System Question', 'event_espresso'), |
|
972 | + 'QST_system' => 'email', |
|
973 | + 'QST_type' => 'EMAIL', |
|
974 | + 'QST_required' => 1, |
|
975 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
976 | + 'QST_order' => 3, |
|
977 | + 'QST_admin_only' => 0, |
|
978 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
979 | + 'QST_wp_user' => self::get_default_creator_id(), |
|
980 | + 'QST_deleted' => 0, |
|
981 | + ); |
|
982 | + break; |
|
983 | + case 'address': |
|
984 | + $QST_values = array( |
|
985 | + 'QST_display_text' => __('Address', 'event_espresso'), |
|
986 | + 'QST_admin_label' => __('Address - System Question', 'event_espresso'), |
|
987 | + 'QST_system' => 'address', |
|
988 | + 'QST_type' => 'TEXT', |
|
989 | + 'QST_required' => 0, |
|
990 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
991 | + 'QST_order' => 4, |
|
992 | + 'QST_admin_only' => 0, |
|
993 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
994 | + 'QST_wp_user' => self::get_default_creator_id(), |
|
995 | + 'QST_deleted' => 0, |
|
996 | + ); |
|
997 | + break; |
|
998 | + case 'address2': |
|
999 | + $QST_values = array( |
|
1000 | + 'QST_display_text' => __('Address2', 'event_espresso'), |
|
1001 | + 'QST_admin_label' => __('Address2 - System Question', 'event_espresso'), |
|
1002 | + 'QST_system' => 'address2', |
|
1003 | + 'QST_type' => 'TEXT', |
|
1004 | + 'QST_required' => 0, |
|
1005 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1006 | + 'QST_order' => 5, |
|
1007 | + 'QST_admin_only' => 0, |
|
1008 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
1009 | + 'QST_wp_user' => self::get_default_creator_id(), |
|
1010 | + 'QST_deleted' => 0, |
|
1011 | + ); |
|
1012 | + break; |
|
1013 | + case 'city': |
|
1014 | + $QST_values = array( |
|
1015 | + 'QST_display_text' => __('City', 'event_espresso'), |
|
1016 | + 'QST_admin_label' => __('City - System Question', 'event_espresso'), |
|
1017 | + 'QST_system' => 'city', |
|
1018 | + 'QST_type' => 'TEXT', |
|
1019 | + 'QST_required' => 0, |
|
1020 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1021 | + 'QST_order' => 6, |
|
1022 | + 'QST_admin_only' => 0, |
|
1023 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
1024 | + 'QST_wp_user' => self::get_default_creator_id(), |
|
1025 | + 'QST_deleted' => 0, |
|
1026 | + ); |
|
1027 | + break; |
|
1028 | + case 'country': |
|
1029 | + $QST_values = array( |
|
1030 | + 'QST_display_text' => __('Country', 'event_espresso'), |
|
1031 | + 'QST_admin_label' => __('Country - System Question', 'event_espresso'), |
|
1032 | + 'QST_system' => 'country', |
|
1033 | + 'QST_type' => 'COUNTRY', |
|
1034 | + 'QST_required' => 0, |
|
1035 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1036 | + 'QST_order' => 7, |
|
1037 | + 'QST_admin_only' => 0, |
|
1038 | + 'QST_wp_user' => self::get_default_creator_id(), |
|
1039 | + 'QST_deleted' => 0, |
|
1040 | + ); |
|
1041 | + break; |
|
1042 | + case 'state': |
|
1043 | + $QST_values = array( |
|
1044 | + 'QST_display_text' => __('State/Province', 'event_espresso'), |
|
1045 | + 'QST_admin_label' => __('State/Province - System Question', 'event_espresso'), |
|
1046 | + 'QST_system' => 'state', |
|
1047 | + 'QST_type' => 'STATE', |
|
1048 | + 'QST_required' => 0, |
|
1049 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1050 | + 'QST_order' => 8, |
|
1051 | + 'QST_admin_only' => 0, |
|
1052 | + 'QST_wp_user' => self::get_default_creator_id(), |
|
1053 | + 'QST_deleted' => 0, |
|
1054 | + ); |
|
1055 | + break; |
|
1056 | + case 'zip': |
|
1057 | + $QST_values = array( |
|
1058 | + 'QST_display_text' => __('Zip/Postal Code', 'event_espresso'), |
|
1059 | + 'QST_admin_label' => __('Zip/Postal Code - System Question', 'event_espresso'), |
|
1060 | + 'QST_system' => 'zip', |
|
1061 | + 'QST_type' => 'TEXT', |
|
1062 | + 'QST_required' => 0, |
|
1063 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1064 | + 'QST_order' => 9, |
|
1065 | + 'QST_admin_only' => 0, |
|
1066 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
1067 | + 'QST_wp_user' => self::get_default_creator_id(), |
|
1068 | + 'QST_deleted' => 0, |
|
1069 | + ); |
|
1070 | + break; |
|
1071 | + case 'phone': |
|
1072 | + $QST_values = array( |
|
1073 | + 'QST_display_text' => __('Phone Number', 'event_espresso'), |
|
1074 | + 'QST_admin_label' => __('Phone Number - System Question', 'event_espresso'), |
|
1075 | + 'QST_system' => 'phone', |
|
1076 | + 'QST_type' => 'TEXT', |
|
1077 | + 'QST_required' => 0, |
|
1078 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1079 | + 'QST_order' => 10, |
|
1080 | + 'QST_admin_only' => 0, |
|
1081 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
1082 | + 'QST_wp_user' => self::get_default_creator_id(), |
|
1083 | + 'QST_deleted' => 0, |
|
1084 | + ); |
|
1085 | + break; |
|
1086 | + } |
|
1087 | + if (! empty($QST_values)) { |
|
1088 | + // insert system question |
|
1089 | + $wpdb->insert( |
|
1090 | + $table_name, |
|
1091 | + $QST_values, |
|
1092 | + array('%s', '%s', '%s', '%s', '%d', '%s', '%d', '%d', '%d', '%d') |
|
1093 | + ); |
|
1094 | + $QST_ID = $wpdb->insert_id; |
|
1095 | + // QUESTION GROUP QUESTIONS |
|
1096 | + if (in_array($QST_system, array('fname', 'lname', 'email'))) { |
|
1097 | + $system_question_we_want = EEM_Question_Group::system_personal; |
|
1098 | + } else { |
|
1099 | + $system_question_we_want = EEM_Question_Group::system_address; |
|
1100 | + } |
|
1101 | + if (isset($QSG_IDs[$system_question_we_want])) { |
|
1102 | + $QSG_ID = $QSG_IDs[$system_question_we_want]; |
|
1103 | + } else { |
|
1104 | + $id_col = EEM_Question_Group::instance() |
|
1105 | + ->get_col(array(array('QSG_system' => $system_question_we_want))); |
|
1106 | + if (is_array($id_col)) { |
|
1107 | + $QSG_ID = reset($id_col); |
|
1108 | + } else { |
|
1109 | + //ok so we didn't find it in the db either?? that's weird because we should have inserted it at the start of this method |
|
1110 | + EE_Log::instance()->log( |
|
1111 | + __FILE__, |
|
1112 | + __FUNCTION__, |
|
1113 | + sprintf( |
|
1114 | + __( |
|
1115 | + 'Could not associate question %1$s to a question group because no system question |
|
1116 | 1116 | group existed', |
1117 | - 'event_espresso' |
|
1118 | - ), |
|
1119 | - $QST_ID), |
|
1120 | - 'error'); |
|
1121 | - continue; |
|
1122 | - } |
|
1123 | - } |
|
1124 | - // add system questions to groups |
|
1125 | - $wpdb->insert( |
|
1126 | - \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('esp_question_group_question'), |
|
1127 | - array( |
|
1128 | - 'QSG_ID' => $QSG_ID, |
|
1129 | - 'QST_ID' => $QST_ID, |
|
1130 | - 'QGQ_order' => ($QSG_ID === 1) ? $order_for_group_1++ : $order_for_group_2++, |
|
1131 | - ), |
|
1132 | - array('%d', '%d', '%d') |
|
1133 | - ); |
|
1134 | - } |
|
1135 | - } |
|
1136 | - } |
|
1137 | - } |
|
1138 | - |
|
1139 | - |
|
1140 | - /** |
|
1141 | - * Makes sure the default payment method (Invoice) is active. |
|
1142 | - * This used to be done automatically as part of constructing the old gateways config |
|
1143 | - * |
|
1144 | - * @throws \EE_Error |
|
1145 | - */ |
|
1146 | - public static function insert_default_payment_methods() |
|
1147 | - { |
|
1148 | - if (! EEM_Payment_Method::instance()->count_active(EEM_Payment_Method::scope_cart)) { |
|
1149 | - EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
1150 | - EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type('Invoice'); |
|
1151 | - } else { |
|
1152 | - EEM_Payment_Method::instance()->verify_button_urls(); |
|
1153 | - } |
|
1154 | - } |
|
1155 | - |
|
1156 | - /** |
|
1157 | - * insert_default_status_codes |
|
1158 | - * |
|
1159 | - * @access public |
|
1160 | - * @static |
|
1161 | - * @return void |
|
1162 | - */ |
|
1163 | - public static function insert_default_status_codes() |
|
1164 | - { |
|
1165 | - |
|
1166 | - global $wpdb; |
|
1167 | - |
|
1168 | - if (\EEH_Activation::getTableAnalysis()->tableExists(EEM_Status::instance()->table())) { |
|
1169 | - |
|
1170 | - $table_name = EEM_Status::instance()->table(); |
|
1171 | - |
|
1172 | - $SQL = "DELETE FROM $table_name WHERE STS_ID IN ( 'ACT', 'NAC', 'NOP', 'OPN', 'CLS', 'PND', 'ONG', 'SEC', 'DRF', 'DEL', 'DEN', 'EXP', 'RPP', 'RCN', 'RDC', 'RAP', 'RNA', 'RWL', 'TAB', 'TIN', 'TFL', 'TCM', 'TOP', 'PAP', 'PCN', 'PFL', 'PDC', 'EDR', 'ESN', 'PPN', 'RIC', 'MSN', 'MFL', 'MID', 'MRS', 'MIC', 'MDO', 'MEX' );"; |
|
1173 | - $wpdb->query($SQL); |
|
1174 | - |
|
1175 | - $SQL = "INSERT INTO $table_name |
|
1117 | + 'event_espresso' |
|
1118 | + ), |
|
1119 | + $QST_ID), |
|
1120 | + 'error'); |
|
1121 | + continue; |
|
1122 | + } |
|
1123 | + } |
|
1124 | + // add system questions to groups |
|
1125 | + $wpdb->insert( |
|
1126 | + \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('esp_question_group_question'), |
|
1127 | + array( |
|
1128 | + 'QSG_ID' => $QSG_ID, |
|
1129 | + 'QST_ID' => $QST_ID, |
|
1130 | + 'QGQ_order' => ($QSG_ID === 1) ? $order_for_group_1++ : $order_for_group_2++, |
|
1131 | + ), |
|
1132 | + array('%d', '%d', '%d') |
|
1133 | + ); |
|
1134 | + } |
|
1135 | + } |
|
1136 | + } |
|
1137 | + } |
|
1138 | + |
|
1139 | + |
|
1140 | + /** |
|
1141 | + * Makes sure the default payment method (Invoice) is active. |
|
1142 | + * This used to be done automatically as part of constructing the old gateways config |
|
1143 | + * |
|
1144 | + * @throws \EE_Error |
|
1145 | + */ |
|
1146 | + public static function insert_default_payment_methods() |
|
1147 | + { |
|
1148 | + if (! EEM_Payment_Method::instance()->count_active(EEM_Payment_Method::scope_cart)) { |
|
1149 | + EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
1150 | + EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type('Invoice'); |
|
1151 | + } else { |
|
1152 | + EEM_Payment_Method::instance()->verify_button_urls(); |
|
1153 | + } |
|
1154 | + } |
|
1155 | + |
|
1156 | + /** |
|
1157 | + * insert_default_status_codes |
|
1158 | + * |
|
1159 | + * @access public |
|
1160 | + * @static |
|
1161 | + * @return void |
|
1162 | + */ |
|
1163 | + public static function insert_default_status_codes() |
|
1164 | + { |
|
1165 | + |
|
1166 | + global $wpdb; |
|
1167 | + |
|
1168 | + if (\EEH_Activation::getTableAnalysis()->tableExists(EEM_Status::instance()->table())) { |
|
1169 | + |
|
1170 | + $table_name = EEM_Status::instance()->table(); |
|
1171 | + |
|
1172 | + $SQL = "DELETE FROM $table_name WHERE STS_ID IN ( 'ACT', 'NAC', 'NOP', 'OPN', 'CLS', 'PND', 'ONG', 'SEC', 'DRF', 'DEL', 'DEN', 'EXP', 'RPP', 'RCN', 'RDC', 'RAP', 'RNA', 'RWL', 'TAB', 'TIN', 'TFL', 'TCM', 'TOP', 'PAP', 'PCN', 'PFL', 'PDC', 'EDR', 'ESN', 'PPN', 'RIC', 'MSN', 'MFL', 'MID', 'MRS', 'MIC', 'MDO', 'MEX' );"; |
|
1173 | + $wpdb->query($SQL); |
|
1174 | + |
|
1175 | + $SQL = "INSERT INTO $table_name |
|
1176 | 1176 | (STS_ID, STS_code, STS_type, STS_can_edit, STS_desc, STS_open) VALUES |
1177 | 1177 | ('ACT', 'ACTIVE', 'event', 0, NULL, 1), |
1178 | 1178 | ('NAC', 'NOT_ACTIVE', 'event', 0, NULL, 0), |
@@ -1212,521 +1212,521 @@ discard block |
||
1212 | 1212 | ('MID', 'IDLE', 'message', 0, NULL, 1), |
1213 | 1213 | ('MRS', 'RESEND', 'message', 0, NULL, 1), |
1214 | 1214 | ('MIC', 'INCOMPLETE', 'message', 0, NULL, 0);"; |
1215 | - $wpdb->query($SQL); |
|
1216 | - |
|
1217 | - } |
|
1218 | - |
|
1219 | - } |
|
1220 | - |
|
1221 | - |
|
1222 | - /** |
|
1223 | - * create_upload_directories |
|
1224 | - * Creates folders in the uploads directory to facilitate addons and templates |
|
1225 | - * |
|
1226 | - * @access public |
|
1227 | - * @static |
|
1228 | - * @return boolean success of verifying upload directories exist |
|
1229 | - */ |
|
1230 | - public static function create_upload_directories() |
|
1231 | - { |
|
1232 | - // Create the required folders |
|
1233 | - $folders = array( |
|
1234 | - EVENT_ESPRESSO_TEMPLATE_DIR, |
|
1235 | - EVENT_ESPRESSO_GATEWAY_DIR, |
|
1236 | - EVENT_ESPRESSO_UPLOAD_DIR . 'logs/', |
|
1237 | - EVENT_ESPRESSO_UPLOAD_DIR . 'css/', |
|
1238 | - EVENT_ESPRESSO_UPLOAD_DIR . 'tickets/', |
|
1239 | - ); |
|
1240 | - foreach ($folders as $folder) { |
|
1241 | - try { |
|
1242 | - EEH_File::ensure_folder_exists_and_is_writable($folder); |
|
1243 | - @ chmod($folder, 0755); |
|
1244 | - } catch (EE_Error $e) { |
|
1245 | - EE_Error::add_error( |
|
1246 | - sprintf( |
|
1247 | - __('Could not create the folder at "%1$s" because: %2$s', 'event_espresso'), |
|
1248 | - $folder, |
|
1249 | - '<br />' . $e->getMessage() |
|
1250 | - ), |
|
1251 | - __FILE__, __FUNCTION__, __LINE__ |
|
1252 | - ); |
|
1253 | - //indicate we'll need to fix this later |
|
1254 | - update_option(EEH_Activation::upload_directories_incomplete_option_name, true); |
|
1255 | - return false; |
|
1256 | - } |
|
1257 | - } |
|
1258 | - //just add the .htaccess file to the logs directory to begin with. Even if logging |
|
1259 | - //is disabled, there might be activation errors recorded in there |
|
1260 | - EEH_File::add_htaccess_deny_from_all(EVENT_ESPRESSO_UPLOAD_DIR . 'logs/'); |
|
1261 | - //remember EE's folders are all good |
|
1262 | - delete_option(EEH_Activation::upload_directories_incomplete_option_name); |
|
1263 | - return true; |
|
1264 | - } |
|
1265 | - |
|
1266 | - /** |
|
1267 | - * Whether the upload directories need to be fixed or not. |
|
1268 | - * If EE is installed but filesystem access isn't initially available, |
|
1269 | - * we need to get the user's filesystem credentials and THEN create them, |
|
1270 | - * so there might be period of time when EE is installed but its |
|
1271 | - * upload directories aren't available. This indicates such a state |
|
1272 | - * |
|
1273 | - * @return boolean |
|
1274 | - */ |
|
1275 | - public static function upload_directories_incomplete() |
|
1276 | - { |
|
1277 | - return get_option(EEH_Activation::upload_directories_incomplete_option_name, false); |
|
1278 | - } |
|
1279 | - |
|
1280 | - |
|
1281 | - /** |
|
1282 | - * generate_default_message_templates |
|
1283 | - * |
|
1284 | - * @static |
|
1285 | - * @throws EE_Error |
|
1286 | - * @return bool true means new templates were created. |
|
1287 | - * false means no templates were created. |
|
1288 | - * This is NOT an error flag. To check for errors you will want |
|
1289 | - * to use either EE_Error or a try catch for an EE_Error exception. |
|
1290 | - */ |
|
1291 | - public static function generate_default_message_templates() |
|
1292 | - { |
|
1293 | - /** @type EE_Message_Resource_Manager $message_resource_manager */ |
|
1294 | - $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
1295 | - /* |
|
1215 | + $wpdb->query($SQL); |
|
1216 | + |
|
1217 | + } |
|
1218 | + |
|
1219 | + } |
|
1220 | + |
|
1221 | + |
|
1222 | + /** |
|
1223 | + * create_upload_directories |
|
1224 | + * Creates folders in the uploads directory to facilitate addons and templates |
|
1225 | + * |
|
1226 | + * @access public |
|
1227 | + * @static |
|
1228 | + * @return boolean success of verifying upload directories exist |
|
1229 | + */ |
|
1230 | + public static function create_upload_directories() |
|
1231 | + { |
|
1232 | + // Create the required folders |
|
1233 | + $folders = array( |
|
1234 | + EVENT_ESPRESSO_TEMPLATE_DIR, |
|
1235 | + EVENT_ESPRESSO_GATEWAY_DIR, |
|
1236 | + EVENT_ESPRESSO_UPLOAD_DIR . 'logs/', |
|
1237 | + EVENT_ESPRESSO_UPLOAD_DIR . 'css/', |
|
1238 | + EVENT_ESPRESSO_UPLOAD_DIR . 'tickets/', |
|
1239 | + ); |
|
1240 | + foreach ($folders as $folder) { |
|
1241 | + try { |
|
1242 | + EEH_File::ensure_folder_exists_and_is_writable($folder); |
|
1243 | + @ chmod($folder, 0755); |
|
1244 | + } catch (EE_Error $e) { |
|
1245 | + EE_Error::add_error( |
|
1246 | + sprintf( |
|
1247 | + __('Could not create the folder at "%1$s" because: %2$s', 'event_espresso'), |
|
1248 | + $folder, |
|
1249 | + '<br />' . $e->getMessage() |
|
1250 | + ), |
|
1251 | + __FILE__, __FUNCTION__, __LINE__ |
|
1252 | + ); |
|
1253 | + //indicate we'll need to fix this later |
|
1254 | + update_option(EEH_Activation::upload_directories_incomplete_option_name, true); |
|
1255 | + return false; |
|
1256 | + } |
|
1257 | + } |
|
1258 | + //just add the .htaccess file to the logs directory to begin with. Even if logging |
|
1259 | + //is disabled, there might be activation errors recorded in there |
|
1260 | + EEH_File::add_htaccess_deny_from_all(EVENT_ESPRESSO_UPLOAD_DIR . 'logs/'); |
|
1261 | + //remember EE's folders are all good |
|
1262 | + delete_option(EEH_Activation::upload_directories_incomplete_option_name); |
|
1263 | + return true; |
|
1264 | + } |
|
1265 | + |
|
1266 | + /** |
|
1267 | + * Whether the upload directories need to be fixed or not. |
|
1268 | + * If EE is installed but filesystem access isn't initially available, |
|
1269 | + * we need to get the user's filesystem credentials and THEN create them, |
|
1270 | + * so there might be period of time when EE is installed but its |
|
1271 | + * upload directories aren't available. This indicates such a state |
|
1272 | + * |
|
1273 | + * @return boolean |
|
1274 | + */ |
|
1275 | + public static function upload_directories_incomplete() |
|
1276 | + { |
|
1277 | + return get_option(EEH_Activation::upload_directories_incomplete_option_name, false); |
|
1278 | + } |
|
1279 | + |
|
1280 | + |
|
1281 | + /** |
|
1282 | + * generate_default_message_templates |
|
1283 | + * |
|
1284 | + * @static |
|
1285 | + * @throws EE_Error |
|
1286 | + * @return bool true means new templates were created. |
|
1287 | + * false means no templates were created. |
|
1288 | + * This is NOT an error flag. To check for errors you will want |
|
1289 | + * to use either EE_Error or a try catch for an EE_Error exception. |
|
1290 | + */ |
|
1291 | + public static function generate_default_message_templates() |
|
1292 | + { |
|
1293 | + /** @type EE_Message_Resource_Manager $message_resource_manager */ |
|
1294 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
1295 | + /* |
|
1296 | 1296 | * This first method is taking care of ensuring any default messengers |
1297 | 1297 | * that should be made active and have templates generated are done. |
1298 | 1298 | */ |
1299 | - $new_templates_created_for_messenger = self::_activate_and_generate_default_messengers_and_message_templates( |
|
1300 | - $message_resource_manager |
|
1301 | - ); |
|
1302 | - /** |
|
1303 | - * This method is verifying there are no NEW default message types |
|
1304 | - * for ACTIVE messengers that need activated (and corresponding templates setup). |
|
1305 | - */ |
|
1306 | - $new_templates_created_for_message_type = self::_activate_new_message_types_for_active_messengers_and_generate_default_templates( |
|
1307 | - $message_resource_manager |
|
1308 | - ); |
|
1309 | - //after all is done, let's persist these changes to the db. |
|
1310 | - $message_resource_manager->update_has_activated_messengers_option(); |
|
1311 | - $message_resource_manager->update_active_messengers_option(); |
|
1312 | - // will return true if either of these are true. Otherwise will return false. |
|
1313 | - return $new_templates_created_for_message_type || $new_templates_created_for_messenger; |
|
1314 | - } |
|
1315 | - |
|
1316 | - |
|
1317 | - |
|
1318 | - /** |
|
1319 | - * @param \EE_Message_Resource_Manager $message_resource_manager |
|
1320 | - * @return array|bool |
|
1321 | - * @throws \EE_Error |
|
1322 | - */ |
|
1323 | - protected static function _activate_new_message_types_for_active_messengers_and_generate_default_templates( |
|
1324 | - EE_Message_Resource_Manager $message_resource_manager |
|
1325 | - ) { |
|
1326 | - /** @type EE_messenger[] $active_messengers */ |
|
1327 | - $active_messengers = $message_resource_manager->active_messengers(); |
|
1328 | - $installed_message_types = $message_resource_manager->installed_message_types(); |
|
1329 | - $templates_created = false; |
|
1330 | - foreach ($active_messengers as $active_messenger) { |
|
1331 | - $default_message_type_names_for_messenger = $active_messenger->get_default_message_types(); |
|
1332 | - $default_message_type_names_to_activate = array(); |
|
1333 | - // looping through each default message type reported by the messenger |
|
1334 | - // and setup the actual message types to activate. |
|
1335 | - foreach ($default_message_type_names_for_messenger as $default_message_type_name_for_messenger) { |
|
1336 | - // if already active or has already been activated before we skip |
|
1337 | - // (otherwise we might reactivate something user's intentionally deactivated.) |
|
1338 | - // we also skip if the message type is not installed. |
|
1339 | - if ( |
|
1340 | - $message_resource_manager->has_message_type_been_activated_for_messenger( |
|
1341 | - $default_message_type_name_for_messenger, |
|
1342 | - $active_messenger->name |
|
1343 | - ) |
|
1344 | - || $message_resource_manager->is_message_type_active_for_messenger( |
|
1345 | - $active_messenger->name, |
|
1346 | - $default_message_type_name_for_messenger |
|
1347 | - ) |
|
1348 | - || ! isset($installed_message_types[$default_message_type_name_for_messenger]) |
|
1349 | - ) { |
|
1350 | - continue; |
|
1351 | - } |
|
1352 | - $default_message_type_names_to_activate[] = $default_message_type_name_for_messenger; |
|
1353 | - } |
|
1354 | - //let's activate! |
|
1355 | - $message_resource_manager->ensure_message_types_are_active( |
|
1356 | - $default_message_type_names_to_activate, |
|
1357 | - $active_messenger->name, |
|
1358 | - false |
|
1359 | - ); |
|
1360 | - //activate the templates for these message types |
|
1361 | - if ( ! empty($default_message_type_names_to_activate)) { |
|
1362 | - $templates_created = EEH_MSG_Template::generate_new_templates( |
|
1363 | - $active_messenger->name, |
|
1364 | - $default_message_type_names_for_messenger, |
|
1365 | - '', |
|
1366 | - true |
|
1367 | - ); |
|
1368 | - } |
|
1369 | - } |
|
1370 | - return $templates_created; |
|
1371 | - } |
|
1372 | - |
|
1373 | - |
|
1374 | - |
|
1375 | - /** |
|
1376 | - * This will activate and generate default messengers and default message types for those messengers. |
|
1377 | - * |
|
1378 | - * @param EE_message_Resource_Manager $message_resource_manager |
|
1379 | - * @return array|bool True means there were default messengers and message type templates generated. |
|
1380 | - * False means that there were no templates generated |
|
1381 | - * (which could simply mean there are no default message types for a messenger). |
|
1382 | - * @throws EE_Error |
|
1383 | - */ |
|
1384 | - protected static function _activate_and_generate_default_messengers_and_message_templates( |
|
1385 | - EE_Message_Resource_Manager $message_resource_manager |
|
1386 | - ) { |
|
1387 | - /** @type EE_messenger[] $messengers_to_generate */ |
|
1388 | - $messengers_to_generate = self::_get_default_messengers_to_generate_on_activation($message_resource_manager); |
|
1389 | - $installed_message_types = $message_resource_manager->installed_message_types(); |
|
1390 | - $templates_generated = false; |
|
1391 | - foreach ($messengers_to_generate as $messenger_to_generate) { |
|
1392 | - $default_message_type_names_for_messenger = $messenger_to_generate->get_default_message_types(); |
|
1393 | - //verify the default message types match an installed message type. |
|
1394 | - foreach ($default_message_type_names_for_messenger as $key => $name) { |
|
1395 | - if ( |
|
1396 | - ! isset($installed_message_types[$name]) |
|
1397 | - || $message_resource_manager->has_message_type_been_activated_for_messenger( |
|
1398 | - $name, |
|
1399 | - $messenger_to_generate->name |
|
1400 | - ) |
|
1401 | - ) { |
|
1402 | - unset($default_message_type_names_for_messenger[$key]); |
|
1403 | - } |
|
1404 | - } |
|
1405 | - // in previous iterations, the active_messengers option in the db |
|
1406 | - // needed updated before calling create templates. however with the changes this may not be necessary. |
|
1407 | - // This comment is left here just in case we discover that we _do_ need to update before |
|
1408 | - // passing off to create templates (after the refactor is done). |
|
1409 | - // @todo remove this comment when determined not necessary. |
|
1410 | - $message_resource_manager->activate_messenger( |
|
1411 | - $messenger_to_generate->name, |
|
1412 | - $default_message_type_names_for_messenger, |
|
1413 | - false |
|
1414 | - ); |
|
1415 | - //create any templates needing created (or will reactivate templates already generated as necessary). |
|
1416 | - if ( ! empty($default_message_type_names_for_messenger)) { |
|
1417 | - $templates_generated = EEH_MSG_Template::generate_new_templates( |
|
1418 | - $messenger_to_generate->name, |
|
1419 | - $default_message_type_names_for_messenger, |
|
1420 | - '', |
|
1421 | - true |
|
1422 | - ); |
|
1423 | - } |
|
1424 | - } |
|
1425 | - return $templates_generated; |
|
1426 | - } |
|
1427 | - |
|
1428 | - |
|
1429 | - /** |
|
1430 | - * This returns the default messengers to generate templates for on activation of EE. |
|
1431 | - * It considers: |
|
1432 | - * - whether a messenger is already active in the db. |
|
1433 | - * - whether a messenger has been made active at any time in the past. |
|
1434 | - * |
|
1435 | - * @static |
|
1436 | - * @param EE_Message_Resource_Manager $message_resource_manager |
|
1437 | - * @return EE_messenger[] |
|
1438 | - */ |
|
1439 | - protected static function _get_default_messengers_to_generate_on_activation( |
|
1440 | - EE_Message_Resource_Manager $message_resource_manager |
|
1441 | - ) { |
|
1442 | - $active_messengers = $message_resource_manager->active_messengers(); |
|
1443 | - $installed_messengers = $message_resource_manager->installed_messengers(); |
|
1444 | - $has_activated = $message_resource_manager->get_has_activated_messengers_option(); |
|
1445 | - |
|
1446 | - $messengers_to_generate = array(); |
|
1447 | - foreach ($installed_messengers as $installed_messenger) { |
|
1448 | - //if installed messenger is a messenger that should be activated on install |
|
1449 | - //and is not already active |
|
1450 | - //and has never been activated |
|
1451 | - if ( |
|
1452 | - ! $installed_messenger->activate_on_install |
|
1453 | - || isset($active_messengers[$installed_messenger->name]) |
|
1454 | - || isset($has_activated[$installed_messenger->name]) |
|
1455 | - ) { |
|
1456 | - continue; |
|
1457 | - } |
|
1458 | - $messengers_to_generate[$installed_messenger->name] = $installed_messenger; |
|
1459 | - } |
|
1460 | - return $messengers_to_generate; |
|
1461 | - } |
|
1462 | - |
|
1463 | - |
|
1464 | - /** |
|
1465 | - * This simply validates active message types to ensure they actually match installed |
|
1466 | - * message types. If there's a mismatch then we deactivate the message type and ensure all related db |
|
1467 | - * rows are set inactive. |
|
1468 | - * Note: Messengers are no longer validated here as of 4.9.0 because they get validated automatically whenever |
|
1469 | - * EE_Messenger_Resource_Manager is constructed. Message Types are a bit more resource heavy for validation so they |
|
1470 | - * are still handled in here. |
|
1471 | - * |
|
1472 | - * @since 4.3.1 |
|
1473 | - * @return void |
|
1474 | - */ |
|
1475 | - public static function validate_messages_system() |
|
1476 | - { |
|
1477 | - /** @type EE_Message_Resource_Manager $message_resource_manager */ |
|
1478 | - $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
1479 | - $message_resource_manager->validate_active_message_types_are_installed(); |
|
1480 | - do_action('AHEE__EEH_Activation__validate_messages_system'); |
|
1481 | - } |
|
1482 | - |
|
1483 | - |
|
1484 | - /** |
|
1485 | - * create_no_ticket_prices_array |
|
1486 | - * |
|
1487 | - * @access public |
|
1488 | - * @static |
|
1489 | - * @return void |
|
1490 | - */ |
|
1491 | - public static function create_no_ticket_prices_array() |
|
1492 | - { |
|
1493 | - // this creates an array for tracking events that have no active ticket prices created |
|
1494 | - // this allows us to warn admins of the situation so that it can be corrected |
|
1495 | - $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', false); |
|
1496 | - if (! $espresso_no_ticket_prices) { |
|
1497 | - add_option('ee_no_ticket_prices', array(), '', false); |
|
1498 | - } |
|
1499 | - } |
|
1500 | - |
|
1501 | - |
|
1502 | - /** |
|
1503 | - * plugin_deactivation |
|
1504 | - * |
|
1505 | - * @access public |
|
1506 | - * @static |
|
1507 | - * @return void |
|
1508 | - */ |
|
1509 | - public static function plugin_deactivation() |
|
1510 | - { |
|
1511 | - } |
|
1512 | - |
|
1513 | - |
|
1514 | - /** |
|
1515 | - * Finds all our EE4 custom post types, and deletes them and their associated data |
|
1516 | - * (like post meta or term relations) |
|
1517 | - * |
|
1518 | - * @global wpdb $wpdb |
|
1519 | - * @throws \EE_Error |
|
1520 | - */ |
|
1521 | - public static function delete_all_espresso_cpt_data() |
|
1522 | - { |
|
1523 | - global $wpdb; |
|
1524 | - //get all the CPT post_types |
|
1525 | - $ee_post_types = array(); |
|
1526 | - foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) { |
|
1527 | - if (method_exists($model_name, 'instance')) { |
|
1528 | - $model_obj = call_user_func(array($model_name, 'instance')); |
|
1529 | - if ($model_obj instanceof EEM_CPT_Base) { |
|
1530 | - $ee_post_types[] = $wpdb->prepare("%s", $model_obj->post_type()); |
|
1531 | - } |
|
1532 | - } |
|
1533 | - } |
|
1534 | - //get all our CPTs |
|
1535 | - $query = "SELECT ID FROM {$wpdb->posts} WHERE post_type IN (" . implode(",", $ee_post_types) . ")"; |
|
1536 | - $cpt_ids = $wpdb->get_col($query); |
|
1537 | - //delete each post meta and term relations too |
|
1538 | - foreach ($cpt_ids as $post_id) { |
|
1539 | - wp_delete_post($post_id, true); |
|
1540 | - } |
|
1541 | - } |
|
1542 | - |
|
1543 | - /** |
|
1544 | - * Deletes all EE custom tables |
|
1545 | - * |
|
1546 | - * @return array |
|
1547 | - */ |
|
1548 | - public static function drop_espresso_tables() |
|
1549 | - { |
|
1550 | - $tables = array(); |
|
1551 | - // load registry |
|
1552 | - foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) { |
|
1553 | - if (method_exists($model_name, 'instance')) { |
|
1554 | - $model_obj = call_user_func(array($model_name, 'instance')); |
|
1555 | - if ($model_obj instanceof EEM_Base) { |
|
1556 | - foreach ($model_obj->get_tables() as $table) { |
|
1557 | - if (strpos($table->get_table_name(), 'esp_') |
|
1558 | - && |
|
1559 | - ( |
|
1560 | - is_main_site()//main site? nuke them all |
|
1561 | - || ! $table->is_global()//not main site,but not global either. nuke it |
|
1562 | - ) |
|
1563 | - ) { |
|
1564 | - $tables[] = $table->get_table_name(); |
|
1565 | - } |
|
1566 | - } |
|
1567 | - } |
|
1568 | - } |
|
1569 | - } |
|
1570 | - |
|
1571 | - //there are some tables whose models were removed. |
|
1572 | - //they should be removed when removing all EE core's data |
|
1573 | - $tables_without_models = array( |
|
1574 | - 'esp_promotion', |
|
1575 | - 'esp_promotion_applied', |
|
1576 | - 'esp_promotion_object', |
|
1577 | - 'esp_promotion_rule', |
|
1578 | - 'esp_rule', |
|
1579 | - ); |
|
1580 | - foreach ($tables_without_models as $table) { |
|
1581 | - $tables[] = $table; |
|
1582 | - } |
|
1583 | - return \EEH_Activation::getTableManager()->dropTables($tables); |
|
1584 | - } |
|
1585 | - |
|
1586 | - |
|
1587 | - |
|
1588 | - /** |
|
1589 | - * Drops all the tables mentioned in a single MYSQL query. Double-checks |
|
1590 | - * each table name provided has a wpdb prefix attached, and that it exists. |
|
1591 | - * Returns the list actually deleted |
|
1592 | - * |
|
1593 | - * @deprecated in 4.9.13. Instead use TableManager::dropTables() |
|
1594 | - * @global WPDB $wpdb |
|
1595 | - * @param array $table_names |
|
1596 | - * @return array of table names which we deleted |
|
1597 | - */ |
|
1598 | - public static function drop_tables($table_names) |
|
1599 | - { |
|
1600 | - return \EEH_Activation::getTableManager()->dropTables($table_names); |
|
1601 | - } |
|
1602 | - |
|
1603 | - |
|
1604 | - |
|
1605 | - /** |
|
1606 | - * plugin_uninstall |
|
1607 | - * |
|
1608 | - * @access public |
|
1609 | - * @static |
|
1610 | - * @param bool $remove_all |
|
1611 | - * @return void |
|
1612 | - */ |
|
1613 | - public static function delete_all_espresso_tables_and_data($remove_all = true) |
|
1614 | - { |
|
1615 | - global $wpdb; |
|
1616 | - self::drop_espresso_tables(); |
|
1617 | - $wp_options_to_delete = array( |
|
1618 | - 'ee_no_ticket_prices' => true, |
|
1619 | - 'ee_active_messengers' => true, |
|
1620 | - 'ee_has_activated_messenger' => true, |
|
1621 | - 'ee_flush_rewrite_rules' => true, |
|
1622 | - 'ee_config' => false, |
|
1623 | - 'ee_data_migration_current_db_state' => true, |
|
1624 | - 'ee_data_migration_mapping_' => false, |
|
1625 | - 'ee_data_migration_script_' => false, |
|
1626 | - 'ee_data_migrations' => true, |
|
1627 | - 'ee_dms_map' => false, |
|
1628 | - 'ee_notices' => true, |
|
1629 | - 'lang_file_check_' => false, |
|
1630 | - 'ee_maintenance_mode' => true, |
|
1631 | - 'ee_ueip_optin' => true, |
|
1632 | - 'ee_ueip_has_notified' => true, |
|
1633 | - 'ee_plugin_activation_errors' => true, |
|
1634 | - 'ee_id_mapping_from' => false, |
|
1635 | - 'espresso_persistent_admin_notices' => true, |
|
1636 | - 'ee_encryption_key' => true, |
|
1637 | - 'pue_force_upgrade_' => false, |
|
1638 | - 'pue_json_error_' => false, |
|
1639 | - 'pue_install_key_' => false, |
|
1640 | - 'pue_verification_error_' => false, |
|
1641 | - 'pu_dismissed_upgrade_' => false, |
|
1642 | - 'external_updates-' => false, |
|
1643 | - 'ee_extra_data' => true, |
|
1644 | - 'ee_ssn_' => false, |
|
1645 | - 'ee_rss_' => false, |
|
1646 | - 'ee_rte_n_tx_' => false, |
|
1647 | - 'ee_pers_admin_notices' => true, |
|
1648 | - 'ee_job_parameters_' => false, |
|
1649 | - 'ee_upload_directories_incomplete' => true, |
|
1650 | - 'ee_verified_db_collations' => true, |
|
1651 | - ); |
|
1652 | - if (is_main_site()) { |
|
1653 | - $wp_options_to_delete['ee_network_config'] = true; |
|
1654 | - } |
|
1655 | - $undeleted_options = array(); |
|
1656 | - foreach ($wp_options_to_delete as $option_name => $no_wildcard) { |
|
1657 | - if ($no_wildcard) { |
|
1658 | - if ( ! delete_option($option_name)) { |
|
1659 | - $undeleted_options[] = $option_name; |
|
1660 | - } |
|
1661 | - } else { |
|
1662 | - $option_names_to_delete_from_wildcard = $wpdb->get_col("SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%$option_name%'"); |
|
1663 | - foreach ($option_names_to_delete_from_wildcard as $option_name_from_wildcard) { |
|
1664 | - if ( ! delete_option($option_name_from_wildcard)) { |
|
1665 | - $undeleted_options[] = $option_name_from_wildcard; |
|
1666 | - } |
|
1667 | - } |
|
1668 | - } |
|
1669 | - } |
|
1670 | - //also, let's make sure the "ee_config_option_names" wp option stays out by removing the action that adds it |
|
1671 | - remove_action('shutdown', array(EE_Config::instance(), 'shutdown'), 10); |
|
1672 | - if ($remove_all && $espresso_db_update = get_option('espresso_db_update')) { |
|
1673 | - $db_update_sans_ee4 = array(); |
|
1674 | - foreach ($espresso_db_update as $version => $times_activated) { |
|
1675 | - if ((string)$version[0] === '3') {//if its NON EE4 |
|
1676 | - $db_update_sans_ee4[$version] = $times_activated; |
|
1677 | - } |
|
1678 | - } |
|
1679 | - update_option('espresso_db_update', $db_update_sans_ee4); |
|
1680 | - } |
|
1681 | - $errors = ''; |
|
1682 | - if ( ! empty($undeleted_options)) { |
|
1683 | - $errors .= sprintf( |
|
1684 | - __('The following wp-options could not be deleted: %s%s', 'event_espresso'), |
|
1685 | - '<br/>', |
|
1686 | - implode(',<br/>', $undeleted_options) |
|
1687 | - ); |
|
1688 | - } |
|
1689 | - if ( ! empty($errors)) { |
|
1690 | - EE_Error::add_attention($errors, __FILE__, __FUNCTION__, __LINE__); |
|
1691 | - } |
|
1692 | - } |
|
1693 | - |
|
1694 | - /** |
|
1695 | - * Gets the mysql error code from the last used query by wpdb |
|
1696 | - * |
|
1697 | - * @return int mysql error code, see https://dev.mysql.com/doc/refman/5.5/en/error-messages-server.html |
|
1698 | - */ |
|
1699 | - public static function last_wpdb_error_code() |
|
1700 | - { |
|
1701 | - global $wpdb; |
|
1702 | - if ($wpdb->use_mysqli) { |
|
1703 | - return mysqli_errno($wpdb->dbh); |
|
1704 | - } else { |
|
1705 | - return mysql_errno($wpdb->dbh); |
|
1706 | - } |
|
1707 | - } |
|
1708 | - |
|
1709 | - /** |
|
1710 | - * Checks that the database table exists. Also works on temporary tables (for unit tests mostly). |
|
1711 | - * |
|
1712 | - * @global wpdb $wpdb |
|
1713 | - * @deprecated instead use TableAnalysis::tableExists() |
|
1714 | - * @param string $table_name with or without $wpdb->prefix |
|
1715 | - * @return boolean |
|
1716 | - */ |
|
1717 | - public static function table_exists($table_name) |
|
1718 | - { |
|
1719 | - return \EEH_Activation::getTableAnalysis()->tableExists($table_name); |
|
1720 | - } |
|
1721 | - |
|
1722 | - /** |
|
1723 | - * Resets the cache on EEH_Activation |
|
1724 | - */ |
|
1725 | - public static function reset() |
|
1726 | - { |
|
1727 | - self::$_default_creator_id = null; |
|
1728 | - self::$_initialized_db_content_already_in_this_request = false; |
|
1729 | - } |
|
1299 | + $new_templates_created_for_messenger = self::_activate_and_generate_default_messengers_and_message_templates( |
|
1300 | + $message_resource_manager |
|
1301 | + ); |
|
1302 | + /** |
|
1303 | + * This method is verifying there are no NEW default message types |
|
1304 | + * for ACTIVE messengers that need activated (and corresponding templates setup). |
|
1305 | + */ |
|
1306 | + $new_templates_created_for_message_type = self::_activate_new_message_types_for_active_messengers_and_generate_default_templates( |
|
1307 | + $message_resource_manager |
|
1308 | + ); |
|
1309 | + //after all is done, let's persist these changes to the db. |
|
1310 | + $message_resource_manager->update_has_activated_messengers_option(); |
|
1311 | + $message_resource_manager->update_active_messengers_option(); |
|
1312 | + // will return true if either of these are true. Otherwise will return false. |
|
1313 | + return $new_templates_created_for_message_type || $new_templates_created_for_messenger; |
|
1314 | + } |
|
1315 | + |
|
1316 | + |
|
1317 | + |
|
1318 | + /** |
|
1319 | + * @param \EE_Message_Resource_Manager $message_resource_manager |
|
1320 | + * @return array|bool |
|
1321 | + * @throws \EE_Error |
|
1322 | + */ |
|
1323 | + protected static function _activate_new_message_types_for_active_messengers_and_generate_default_templates( |
|
1324 | + EE_Message_Resource_Manager $message_resource_manager |
|
1325 | + ) { |
|
1326 | + /** @type EE_messenger[] $active_messengers */ |
|
1327 | + $active_messengers = $message_resource_manager->active_messengers(); |
|
1328 | + $installed_message_types = $message_resource_manager->installed_message_types(); |
|
1329 | + $templates_created = false; |
|
1330 | + foreach ($active_messengers as $active_messenger) { |
|
1331 | + $default_message_type_names_for_messenger = $active_messenger->get_default_message_types(); |
|
1332 | + $default_message_type_names_to_activate = array(); |
|
1333 | + // looping through each default message type reported by the messenger |
|
1334 | + // and setup the actual message types to activate. |
|
1335 | + foreach ($default_message_type_names_for_messenger as $default_message_type_name_for_messenger) { |
|
1336 | + // if already active or has already been activated before we skip |
|
1337 | + // (otherwise we might reactivate something user's intentionally deactivated.) |
|
1338 | + // we also skip if the message type is not installed. |
|
1339 | + if ( |
|
1340 | + $message_resource_manager->has_message_type_been_activated_for_messenger( |
|
1341 | + $default_message_type_name_for_messenger, |
|
1342 | + $active_messenger->name |
|
1343 | + ) |
|
1344 | + || $message_resource_manager->is_message_type_active_for_messenger( |
|
1345 | + $active_messenger->name, |
|
1346 | + $default_message_type_name_for_messenger |
|
1347 | + ) |
|
1348 | + || ! isset($installed_message_types[$default_message_type_name_for_messenger]) |
|
1349 | + ) { |
|
1350 | + continue; |
|
1351 | + } |
|
1352 | + $default_message_type_names_to_activate[] = $default_message_type_name_for_messenger; |
|
1353 | + } |
|
1354 | + //let's activate! |
|
1355 | + $message_resource_manager->ensure_message_types_are_active( |
|
1356 | + $default_message_type_names_to_activate, |
|
1357 | + $active_messenger->name, |
|
1358 | + false |
|
1359 | + ); |
|
1360 | + //activate the templates for these message types |
|
1361 | + if ( ! empty($default_message_type_names_to_activate)) { |
|
1362 | + $templates_created = EEH_MSG_Template::generate_new_templates( |
|
1363 | + $active_messenger->name, |
|
1364 | + $default_message_type_names_for_messenger, |
|
1365 | + '', |
|
1366 | + true |
|
1367 | + ); |
|
1368 | + } |
|
1369 | + } |
|
1370 | + return $templates_created; |
|
1371 | + } |
|
1372 | + |
|
1373 | + |
|
1374 | + |
|
1375 | + /** |
|
1376 | + * This will activate and generate default messengers and default message types for those messengers. |
|
1377 | + * |
|
1378 | + * @param EE_message_Resource_Manager $message_resource_manager |
|
1379 | + * @return array|bool True means there were default messengers and message type templates generated. |
|
1380 | + * False means that there were no templates generated |
|
1381 | + * (which could simply mean there are no default message types for a messenger). |
|
1382 | + * @throws EE_Error |
|
1383 | + */ |
|
1384 | + protected static function _activate_and_generate_default_messengers_and_message_templates( |
|
1385 | + EE_Message_Resource_Manager $message_resource_manager |
|
1386 | + ) { |
|
1387 | + /** @type EE_messenger[] $messengers_to_generate */ |
|
1388 | + $messengers_to_generate = self::_get_default_messengers_to_generate_on_activation($message_resource_manager); |
|
1389 | + $installed_message_types = $message_resource_manager->installed_message_types(); |
|
1390 | + $templates_generated = false; |
|
1391 | + foreach ($messengers_to_generate as $messenger_to_generate) { |
|
1392 | + $default_message_type_names_for_messenger = $messenger_to_generate->get_default_message_types(); |
|
1393 | + //verify the default message types match an installed message type. |
|
1394 | + foreach ($default_message_type_names_for_messenger as $key => $name) { |
|
1395 | + if ( |
|
1396 | + ! isset($installed_message_types[$name]) |
|
1397 | + || $message_resource_manager->has_message_type_been_activated_for_messenger( |
|
1398 | + $name, |
|
1399 | + $messenger_to_generate->name |
|
1400 | + ) |
|
1401 | + ) { |
|
1402 | + unset($default_message_type_names_for_messenger[$key]); |
|
1403 | + } |
|
1404 | + } |
|
1405 | + // in previous iterations, the active_messengers option in the db |
|
1406 | + // needed updated before calling create templates. however with the changes this may not be necessary. |
|
1407 | + // This comment is left here just in case we discover that we _do_ need to update before |
|
1408 | + // passing off to create templates (after the refactor is done). |
|
1409 | + // @todo remove this comment when determined not necessary. |
|
1410 | + $message_resource_manager->activate_messenger( |
|
1411 | + $messenger_to_generate->name, |
|
1412 | + $default_message_type_names_for_messenger, |
|
1413 | + false |
|
1414 | + ); |
|
1415 | + //create any templates needing created (or will reactivate templates already generated as necessary). |
|
1416 | + if ( ! empty($default_message_type_names_for_messenger)) { |
|
1417 | + $templates_generated = EEH_MSG_Template::generate_new_templates( |
|
1418 | + $messenger_to_generate->name, |
|
1419 | + $default_message_type_names_for_messenger, |
|
1420 | + '', |
|
1421 | + true |
|
1422 | + ); |
|
1423 | + } |
|
1424 | + } |
|
1425 | + return $templates_generated; |
|
1426 | + } |
|
1427 | + |
|
1428 | + |
|
1429 | + /** |
|
1430 | + * This returns the default messengers to generate templates for on activation of EE. |
|
1431 | + * It considers: |
|
1432 | + * - whether a messenger is already active in the db. |
|
1433 | + * - whether a messenger has been made active at any time in the past. |
|
1434 | + * |
|
1435 | + * @static |
|
1436 | + * @param EE_Message_Resource_Manager $message_resource_manager |
|
1437 | + * @return EE_messenger[] |
|
1438 | + */ |
|
1439 | + protected static function _get_default_messengers_to_generate_on_activation( |
|
1440 | + EE_Message_Resource_Manager $message_resource_manager |
|
1441 | + ) { |
|
1442 | + $active_messengers = $message_resource_manager->active_messengers(); |
|
1443 | + $installed_messengers = $message_resource_manager->installed_messengers(); |
|
1444 | + $has_activated = $message_resource_manager->get_has_activated_messengers_option(); |
|
1445 | + |
|
1446 | + $messengers_to_generate = array(); |
|
1447 | + foreach ($installed_messengers as $installed_messenger) { |
|
1448 | + //if installed messenger is a messenger that should be activated on install |
|
1449 | + //and is not already active |
|
1450 | + //and has never been activated |
|
1451 | + if ( |
|
1452 | + ! $installed_messenger->activate_on_install |
|
1453 | + || isset($active_messengers[$installed_messenger->name]) |
|
1454 | + || isset($has_activated[$installed_messenger->name]) |
|
1455 | + ) { |
|
1456 | + continue; |
|
1457 | + } |
|
1458 | + $messengers_to_generate[$installed_messenger->name] = $installed_messenger; |
|
1459 | + } |
|
1460 | + return $messengers_to_generate; |
|
1461 | + } |
|
1462 | + |
|
1463 | + |
|
1464 | + /** |
|
1465 | + * This simply validates active message types to ensure they actually match installed |
|
1466 | + * message types. If there's a mismatch then we deactivate the message type and ensure all related db |
|
1467 | + * rows are set inactive. |
|
1468 | + * Note: Messengers are no longer validated here as of 4.9.0 because they get validated automatically whenever |
|
1469 | + * EE_Messenger_Resource_Manager is constructed. Message Types are a bit more resource heavy for validation so they |
|
1470 | + * are still handled in here. |
|
1471 | + * |
|
1472 | + * @since 4.3.1 |
|
1473 | + * @return void |
|
1474 | + */ |
|
1475 | + public static function validate_messages_system() |
|
1476 | + { |
|
1477 | + /** @type EE_Message_Resource_Manager $message_resource_manager */ |
|
1478 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
1479 | + $message_resource_manager->validate_active_message_types_are_installed(); |
|
1480 | + do_action('AHEE__EEH_Activation__validate_messages_system'); |
|
1481 | + } |
|
1482 | + |
|
1483 | + |
|
1484 | + /** |
|
1485 | + * create_no_ticket_prices_array |
|
1486 | + * |
|
1487 | + * @access public |
|
1488 | + * @static |
|
1489 | + * @return void |
|
1490 | + */ |
|
1491 | + public static function create_no_ticket_prices_array() |
|
1492 | + { |
|
1493 | + // this creates an array for tracking events that have no active ticket prices created |
|
1494 | + // this allows us to warn admins of the situation so that it can be corrected |
|
1495 | + $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', false); |
|
1496 | + if (! $espresso_no_ticket_prices) { |
|
1497 | + add_option('ee_no_ticket_prices', array(), '', false); |
|
1498 | + } |
|
1499 | + } |
|
1500 | + |
|
1501 | + |
|
1502 | + /** |
|
1503 | + * plugin_deactivation |
|
1504 | + * |
|
1505 | + * @access public |
|
1506 | + * @static |
|
1507 | + * @return void |
|
1508 | + */ |
|
1509 | + public static function plugin_deactivation() |
|
1510 | + { |
|
1511 | + } |
|
1512 | + |
|
1513 | + |
|
1514 | + /** |
|
1515 | + * Finds all our EE4 custom post types, and deletes them and their associated data |
|
1516 | + * (like post meta or term relations) |
|
1517 | + * |
|
1518 | + * @global wpdb $wpdb |
|
1519 | + * @throws \EE_Error |
|
1520 | + */ |
|
1521 | + public static function delete_all_espresso_cpt_data() |
|
1522 | + { |
|
1523 | + global $wpdb; |
|
1524 | + //get all the CPT post_types |
|
1525 | + $ee_post_types = array(); |
|
1526 | + foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) { |
|
1527 | + if (method_exists($model_name, 'instance')) { |
|
1528 | + $model_obj = call_user_func(array($model_name, 'instance')); |
|
1529 | + if ($model_obj instanceof EEM_CPT_Base) { |
|
1530 | + $ee_post_types[] = $wpdb->prepare("%s", $model_obj->post_type()); |
|
1531 | + } |
|
1532 | + } |
|
1533 | + } |
|
1534 | + //get all our CPTs |
|
1535 | + $query = "SELECT ID FROM {$wpdb->posts} WHERE post_type IN (" . implode(",", $ee_post_types) . ")"; |
|
1536 | + $cpt_ids = $wpdb->get_col($query); |
|
1537 | + //delete each post meta and term relations too |
|
1538 | + foreach ($cpt_ids as $post_id) { |
|
1539 | + wp_delete_post($post_id, true); |
|
1540 | + } |
|
1541 | + } |
|
1542 | + |
|
1543 | + /** |
|
1544 | + * Deletes all EE custom tables |
|
1545 | + * |
|
1546 | + * @return array |
|
1547 | + */ |
|
1548 | + public static function drop_espresso_tables() |
|
1549 | + { |
|
1550 | + $tables = array(); |
|
1551 | + // load registry |
|
1552 | + foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) { |
|
1553 | + if (method_exists($model_name, 'instance')) { |
|
1554 | + $model_obj = call_user_func(array($model_name, 'instance')); |
|
1555 | + if ($model_obj instanceof EEM_Base) { |
|
1556 | + foreach ($model_obj->get_tables() as $table) { |
|
1557 | + if (strpos($table->get_table_name(), 'esp_') |
|
1558 | + && |
|
1559 | + ( |
|
1560 | + is_main_site()//main site? nuke them all |
|
1561 | + || ! $table->is_global()//not main site,but not global either. nuke it |
|
1562 | + ) |
|
1563 | + ) { |
|
1564 | + $tables[] = $table->get_table_name(); |
|
1565 | + } |
|
1566 | + } |
|
1567 | + } |
|
1568 | + } |
|
1569 | + } |
|
1570 | + |
|
1571 | + //there are some tables whose models were removed. |
|
1572 | + //they should be removed when removing all EE core's data |
|
1573 | + $tables_without_models = array( |
|
1574 | + 'esp_promotion', |
|
1575 | + 'esp_promotion_applied', |
|
1576 | + 'esp_promotion_object', |
|
1577 | + 'esp_promotion_rule', |
|
1578 | + 'esp_rule', |
|
1579 | + ); |
|
1580 | + foreach ($tables_without_models as $table) { |
|
1581 | + $tables[] = $table; |
|
1582 | + } |
|
1583 | + return \EEH_Activation::getTableManager()->dropTables($tables); |
|
1584 | + } |
|
1585 | + |
|
1586 | + |
|
1587 | + |
|
1588 | + /** |
|
1589 | + * Drops all the tables mentioned in a single MYSQL query. Double-checks |
|
1590 | + * each table name provided has a wpdb prefix attached, and that it exists. |
|
1591 | + * Returns the list actually deleted |
|
1592 | + * |
|
1593 | + * @deprecated in 4.9.13. Instead use TableManager::dropTables() |
|
1594 | + * @global WPDB $wpdb |
|
1595 | + * @param array $table_names |
|
1596 | + * @return array of table names which we deleted |
|
1597 | + */ |
|
1598 | + public static function drop_tables($table_names) |
|
1599 | + { |
|
1600 | + return \EEH_Activation::getTableManager()->dropTables($table_names); |
|
1601 | + } |
|
1602 | + |
|
1603 | + |
|
1604 | + |
|
1605 | + /** |
|
1606 | + * plugin_uninstall |
|
1607 | + * |
|
1608 | + * @access public |
|
1609 | + * @static |
|
1610 | + * @param bool $remove_all |
|
1611 | + * @return void |
|
1612 | + */ |
|
1613 | + public static function delete_all_espresso_tables_and_data($remove_all = true) |
|
1614 | + { |
|
1615 | + global $wpdb; |
|
1616 | + self::drop_espresso_tables(); |
|
1617 | + $wp_options_to_delete = array( |
|
1618 | + 'ee_no_ticket_prices' => true, |
|
1619 | + 'ee_active_messengers' => true, |
|
1620 | + 'ee_has_activated_messenger' => true, |
|
1621 | + 'ee_flush_rewrite_rules' => true, |
|
1622 | + 'ee_config' => false, |
|
1623 | + 'ee_data_migration_current_db_state' => true, |
|
1624 | + 'ee_data_migration_mapping_' => false, |
|
1625 | + 'ee_data_migration_script_' => false, |
|
1626 | + 'ee_data_migrations' => true, |
|
1627 | + 'ee_dms_map' => false, |
|
1628 | + 'ee_notices' => true, |
|
1629 | + 'lang_file_check_' => false, |
|
1630 | + 'ee_maintenance_mode' => true, |
|
1631 | + 'ee_ueip_optin' => true, |
|
1632 | + 'ee_ueip_has_notified' => true, |
|
1633 | + 'ee_plugin_activation_errors' => true, |
|
1634 | + 'ee_id_mapping_from' => false, |
|
1635 | + 'espresso_persistent_admin_notices' => true, |
|
1636 | + 'ee_encryption_key' => true, |
|
1637 | + 'pue_force_upgrade_' => false, |
|
1638 | + 'pue_json_error_' => false, |
|
1639 | + 'pue_install_key_' => false, |
|
1640 | + 'pue_verification_error_' => false, |
|
1641 | + 'pu_dismissed_upgrade_' => false, |
|
1642 | + 'external_updates-' => false, |
|
1643 | + 'ee_extra_data' => true, |
|
1644 | + 'ee_ssn_' => false, |
|
1645 | + 'ee_rss_' => false, |
|
1646 | + 'ee_rte_n_tx_' => false, |
|
1647 | + 'ee_pers_admin_notices' => true, |
|
1648 | + 'ee_job_parameters_' => false, |
|
1649 | + 'ee_upload_directories_incomplete' => true, |
|
1650 | + 'ee_verified_db_collations' => true, |
|
1651 | + ); |
|
1652 | + if (is_main_site()) { |
|
1653 | + $wp_options_to_delete['ee_network_config'] = true; |
|
1654 | + } |
|
1655 | + $undeleted_options = array(); |
|
1656 | + foreach ($wp_options_to_delete as $option_name => $no_wildcard) { |
|
1657 | + if ($no_wildcard) { |
|
1658 | + if ( ! delete_option($option_name)) { |
|
1659 | + $undeleted_options[] = $option_name; |
|
1660 | + } |
|
1661 | + } else { |
|
1662 | + $option_names_to_delete_from_wildcard = $wpdb->get_col("SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%$option_name%'"); |
|
1663 | + foreach ($option_names_to_delete_from_wildcard as $option_name_from_wildcard) { |
|
1664 | + if ( ! delete_option($option_name_from_wildcard)) { |
|
1665 | + $undeleted_options[] = $option_name_from_wildcard; |
|
1666 | + } |
|
1667 | + } |
|
1668 | + } |
|
1669 | + } |
|
1670 | + //also, let's make sure the "ee_config_option_names" wp option stays out by removing the action that adds it |
|
1671 | + remove_action('shutdown', array(EE_Config::instance(), 'shutdown'), 10); |
|
1672 | + if ($remove_all && $espresso_db_update = get_option('espresso_db_update')) { |
|
1673 | + $db_update_sans_ee4 = array(); |
|
1674 | + foreach ($espresso_db_update as $version => $times_activated) { |
|
1675 | + if ((string)$version[0] === '3') {//if its NON EE4 |
|
1676 | + $db_update_sans_ee4[$version] = $times_activated; |
|
1677 | + } |
|
1678 | + } |
|
1679 | + update_option('espresso_db_update', $db_update_sans_ee4); |
|
1680 | + } |
|
1681 | + $errors = ''; |
|
1682 | + if ( ! empty($undeleted_options)) { |
|
1683 | + $errors .= sprintf( |
|
1684 | + __('The following wp-options could not be deleted: %s%s', 'event_espresso'), |
|
1685 | + '<br/>', |
|
1686 | + implode(',<br/>', $undeleted_options) |
|
1687 | + ); |
|
1688 | + } |
|
1689 | + if ( ! empty($errors)) { |
|
1690 | + EE_Error::add_attention($errors, __FILE__, __FUNCTION__, __LINE__); |
|
1691 | + } |
|
1692 | + } |
|
1693 | + |
|
1694 | + /** |
|
1695 | + * Gets the mysql error code from the last used query by wpdb |
|
1696 | + * |
|
1697 | + * @return int mysql error code, see https://dev.mysql.com/doc/refman/5.5/en/error-messages-server.html |
|
1698 | + */ |
|
1699 | + public static function last_wpdb_error_code() |
|
1700 | + { |
|
1701 | + global $wpdb; |
|
1702 | + if ($wpdb->use_mysqli) { |
|
1703 | + return mysqli_errno($wpdb->dbh); |
|
1704 | + } else { |
|
1705 | + return mysql_errno($wpdb->dbh); |
|
1706 | + } |
|
1707 | + } |
|
1708 | + |
|
1709 | + /** |
|
1710 | + * Checks that the database table exists. Also works on temporary tables (for unit tests mostly). |
|
1711 | + * |
|
1712 | + * @global wpdb $wpdb |
|
1713 | + * @deprecated instead use TableAnalysis::tableExists() |
|
1714 | + * @param string $table_name with or without $wpdb->prefix |
|
1715 | + * @return boolean |
|
1716 | + */ |
|
1717 | + public static function table_exists($table_name) |
|
1718 | + { |
|
1719 | + return \EEH_Activation::getTableAnalysis()->tableExists($table_name); |
|
1720 | + } |
|
1721 | + |
|
1722 | + /** |
|
1723 | + * Resets the cache on EEH_Activation |
|
1724 | + */ |
|
1725 | + public static function reset() |
|
1726 | + { |
|
1727 | + self::$_default_creator_id = null; |
|
1728 | + self::$_initialized_db_content_already_in_this_request = false; |
|
1729 | + } |
|
1730 | 1730 | } |
1731 | 1731 | // End of file EEH_Activation.helper.php |
1732 | 1732 | // Location: /helpers/EEH_Activation.core.php |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | use EventEspresso\core\services\shortcodes\ShortcodesManager; |
3 | 3 | |
4 | 4 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
5 | - exit('No direct script access allowed'); |
|
5 | + exit('No direct script access allowed'); |
|
6 | 6 | } |
7 | 7 | |
8 | 8 | |
@@ -19,1440 +19,1440 @@ discard block |
||
19 | 19 | { |
20 | 20 | |
21 | 21 | |
22 | - /** |
|
23 | - * indicates this is a 'normal' request. Ie, not activation, nor upgrade, nor activation. |
|
24 | - * So examples of this would be a normal GET request on the frontend or backend, or a POST, etc |
|
25 | - */ |
|
26 | - const req_type_normal = 0; |
|
27 | - |
|
28 | - /** |
|
29 | - * Indicates this is a brand new installation of EE so we should install |
|
30 | - * tables and default data etc |
|
31 | - */ |
|
32 | - const req_type_new_activation = 1; |
|
33 | - |
|
34 | - /** |
|
35 | - * we've detected that EE has been reactivated (or EE was activated during maintenance mode, |
|
36 | - * and we just exited maintenance mode). We MUST check the database is setup properly |
|
37 | - * and that default data is setup too |
|
38 | - */ |
|
39 | - const req_type_reactivation = 2; |
|
40 | - |
|
41 | - /** |
|
42 | - * indicates that EE has been upgraded since its previous request. |
|
43 | - * We may have data migration scripts to call and will want to trigger maintenance mode |
|
44 | - */ |
|
45 | - const req_type_upgrade = 3; |
|
46 | - |
|
47 | - /** |
|
48 | - * TODO will detect that EE has been DOWNGRADED. We probably don't want to run in this case... |
|
49 | - */ |
|
50 | - const req_type_downgrade = 4; |
|
51 | - |
|
52 | - /** |
|
53 | - * @deprecated since version 4.6.0.dev.006 |
|
54 | - * Now whenever a new_activation is detected the request type is still just |
|
55 | - * new_activation (same for reactivation, upgrade, downgrade etc), but if we'r ein maintenance mode |
|
56 | - * EE_System::initialize_db_if_no_migrations_required and EE_Addon::initialize_db_if_no_migrations_required |
|
57 | - * will instead enqueue that EE plugin's db initialization for when we're taken out of maintenance mode. |
|
58 | - * (Specifically, when the migration manager indicates migrations are finished |
|
59 | - * EE_Data_Migration_Manager::initialize_db_for_enqueued_ee_plugins() will be called) |
|
60 | - */ |
|
61 | - const req_type_activation_but_not_installed = 5; |
|
62 | - |
|
63 | - /** |
|
64 | - * option prefix for recording the activation history (like core's "espresso_db_update") of addons |
|
65 | - */ |
|
66 | - const addon_activation_history_option_prefix = 'ee_addon_activation_history_'; |
|
67 | - |
|
68 | - |
|
69 | - /** |
|
70 | - * instance of the EE_System object |
|
71 | - * |
|
72 | - * @var $_instance |
|
73 | - * @access private |
|
74 | - */ |
|
75 | - private static $_instance = null; |
|
76 | - |
|
77 | - /** |
|
78 | - * @type EE_Registry $Registry |
|
79 | - * @access protected |
|
80 | - */ |
|
81 | - protected $registry; |
|
82 | - |
|
83 | - /** |
|
84 | - * Stores which type of request this is, options being one of the constants on EE_System starting with req_type_*. |
|
85 | - * It can be a brand-new activation, a reactivation, an upgrade, a downgrade, or a normal request. |
|
86 | - * |
|
87 | - * @var int |
|
88 | - */ |
|
89 | - private $_req_type; |
|
90 | - |
|
91 | - /** |
|
92 | - * Whether or not there was a non-micro version change in EE core version during this request |
|
93 | - * |
|
94 | - * @var boolean |
|
95 | - */ |
|
96 | - private $_major_version_change = false; |
|
97 | - |
|
98 | - |
|
99 | - |
|
100 | - /** |
|
101 | - * @singleton method used to instantiate class object |
|
102 | - * @access public |
|
103 | - * @param \EE_Registry $Registry |
|
104 | - * @return \EE_System |
|
105 | - */ |
|
106 | - public static function instance(EE_Registry $Registry = null) |
|
107 | - { |
|
108 | - // check if class object is instantiated |
|
109 | - if ( ! self::$_instance instanceof EE_System) { |
|
110 | - self::$_instance = new self($Registry); |
|
111 | - } |
|
112 | - return self::$_instance; |
|
113 | - } |
|
114 | - |
|
115 | - |
|
116 | - |
|
117 | - /** |
|
118 | - * resets the instance and returns it |
|
119 | - * |
|
120 | - * @return EE_System |
|
121 | - */ |
|
122 | - public static function reset() |
|
123 | - { |
|
124 | - self::$_instance->_req_type = null; |
|
125 | - //make sure none of the old hooks are left hanging around |
|
126 | - remove_all_actions('AHEE__EE_System__perform_activations_upgrades_and_migrations'); |
|
127 | - //we need to reset the migration manager in order for it to detect DMSs properly |
|
128 | - EE_Data_Migration_Manager::reset(); |
|
129 | - self::instance()->detect_activations_or_upgrades(); |
|
130 | - self::instance()->perform_activations_upgrades_and_migrations(); |
|
131 | - return self::instance(); |
|
132 | - } |
|
133 | - |
|
134 | - |
|
135 | - |
|
136 | - /** |
|
137 | - * sets hooks for running rest of system |
|
138 | - * provides "AHEE__EE_System__construct__complete" hook for EE Addons to use as their starting point |
|
139 | - * starting EE Addons from any other point may lead to problems |
|
140 | - * |
|
141 | - * @access private |
|
142 | - * @param \EE_Registry $Registry |
|
143 | - */ |
|
144 | - private function __construct(EE_Registry $Registry) |
|
145 | - { |
|
146 | - $this->registry = $Registry; |
|
147 | - do_action('AHEE__EE_System__construct__begin', $this); |
|
148 | - // allow addons to load first so that they can register autoloaders, set hooks for running DMS's, etc |
|
149 | - add_action('AHEE__EE_Bootstrap__load_espresso_addons', array($this, 'load_espresso_addons')); |
|
150 | - // when an ee addon is activated, we want to call the core hook(s) again |
|
151 | - // because the newly-activated addon didn't get a chance to run at all |
|
152 | - add_action('activate_plugin', array($this, 'load_espresso_addons'), 1); |
|
153 | - // detect whether install or upgrade |
|
154 | - add_action('AHEE__EE_Bootstrap__detect_activations_or_upgrades', array($this, 'detect_activations_or_upgrades'), |
|
155 | - 3); |
|
156 | - // load EE_Config, EE_Textdomain, etc |
|
157 | - add_action('AHEE__EE_Bootstrap__load_core_configuration', array($this, 'load_core_configuration'), 5); |
|
158 | - // load EE_Config, EE_Textdomain, etc |
|
159 | - add_action('AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets', |
|
160 | - array($this, 'register_shortcodes_modules_and_widgets'), 7); |
|
161 | - // you wanna get going? I wanna get going... let's get going! |
|
162 | - add_action('AHEE__EE_Bootstrap__brew_espresso', array($this, 'brew_espresso'), 9); |
|
163 | - //other housekeeping |
|
164 | - //exclude EE critical pages from wp_list_pages |
|
165 | - add_filter('wp_list_pages_excludes', array($this, 'remove_pages_from_wp_list_pages'), 10); |
|
166 | - // ALL EE Addons should use the following hook point to attach their initial setup too |
|
167 | - // it's extremely important for EE Addons to register any class autoloaders so that they can be available when the EE_Config loads |
|
168 | - do_action('AHEE__EE_System__construct__complete', $this); |
|
169 | - } |
|
170 | - |
|
171 | - |
|
172 | - |
|
173 | - /** |
|
174 | - * load_espresso_addons |
|
175 | - * allow addons to load first so that they can set hooks for running DMS's, etc |
|
176 | - * this is hooked into both: |
|
177 | - * 'AHEE__EE_Bootstrap__load_core_configuration' |
|
178 | - * which runs during the WP 'plugins_loaded' action at priority 5 |
|
179 | - * and the WP 'activate_plugin' hookpoint |
|
180 | - * |
|
181 | - * @access public |
|
182 | - * @return void |
|
183 | - */ |
|
184 | - public function load_espresso_addons() |
|
185 | - { |
|
186 | - // set autoloaders for all of the classes implementing EEI_Plugin_API |
|
187 | - // which provide helpers for EE plugin authors to more easily register certain components with EE. |
|
188 | - EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'plugin_api'); |
|
189 | - //load and setup EE_Capabilities |
|
190 | - $this->registry->load_core('Capabilities'); |
|
191 | - do_action('AHEE__EE_System__load_espresso_addons'); |
|
192 | - //if the WP API basic auth plugin isn't already loaded, load it now. |
|
193 | - //We want it for mobile apps. Just include the entire plugin |
|
194 | - //also, don't load the basic auth when a plugin is getting activated, because |
|
195 | - //it could be the basic auth plugin, and it doesn't check if its methods are already defined |
|
196 | - //and causes a fatal error |
|
197 | - if ( ! function_exists('json_basic_auth_handler') |
|
198 | - && ! function_exists('json_basic_auth_error') |
|
199 | - && ! ( |
|
200 | - isset($_GET['action']) |
|
201 | - && in_array($_GET['action'], array('activate', 'activate-selected')) |
|
202 | - ) |
|
203 | - && ! ( |
|
204 | - isset($_GET['activate']) |
|
205 | - && $_GET['activate'] === 'true' |
|
206 | - ) |
|
207 | - ) { |
|
208 | - include_once EE_THIRD_PARTY . 'wp-api-basic-auth' . DS . 'basic-auth.php'; |
|
209 | - } |
|
210 | - $this->_maybe_brew_regular(); |
|
211 | - do_action('AHEE__EE_System__load_espresso_addons__complete'); |
|
212 | - |
|
213 | - //caps need to be initialized on every request so that capability maps are set. |
|
214 | - //@see https://events.codebasehq.com/projects/event-espresso/tickets/8674 |
|
215 | - $this->registry->CAP->init_caps(); |
|
216 | - } |
|
217 | - |
|
218 | - |
|
219 | - |
|
220 | - /** |
|
221 | - * The purpose of this method is to simply check for a file named "caffeinated/brewing_regular.php" for any hooks |
|
222 | - * that need to be setup before our EE_System launches. |
|
223 | - * |
|
224 | - * @return void |
|
225 | - */ |
|
226 | - private function _maybe_brew_regular() |
|
227 | - { |
|
228 | - if (( ! defined('EE_DECAF') || EE_DECAF !== true) && is_readable(EE_CAFF_PATH . 'brewing_regular.php')) { |
|
229 | - require_once EE_CAFF_PATH . 'brewing_regular.php'; |
|
230 | - } |
|
231 | - } |
|
232 | - |
|
233 | - |
|
234 | - |
|
235 | - /** |
|
236 | - * detect_activations_or_upgrades |
|
237 | - * Checks for activation or upgrade of core first; |
|
238 | - * then also checks if any registered addons have been activated or upgraded |
|
239 | - * This is hooked into 'AHEE__EE_Bootstrap__detect_activations_or_upgrades' |
|
240 | - * which runs during the WP 'plugins_loaded' action at priority 3 |
|
241 | - * |
|
242 | - * @access public |
|
243 | - * @return void |
|
244 | - */ |
|
245 | - public function detect_activations_or_upgrades() |
|
246 | - { |
|
247 | - //first off: let's make sure to handle core |
|
248 | - $this->detect_if_activation_or_upgrade(); |
|
249 | - foreach ($this->registry->addons as $addon) { |
|
250 | - //detect teh request type for that addon |
|
251 | - $addon->detect_activation_or_upgrade(); |
|
252 | - } |
|
253 | - } |
|
254 | - |
|
255 | - |
|
256 | - |
|
257 | - /** |
|
258 | - * detect_if_activation_or_upgrade |
|
259 | - * Takes care of detecting whether this is a brand new install or code upgrade, |
|
260 | - * and either setting up the DB or setting up maintenance mode etc. |
|
261 | - * |
|
262 | - * @access public |
|
263 | - * @return void |
|
264 | - */ |
|
265 | - public function detect_if_activation_or_upgrade() |
|
266 | - { |
|
267 | - do_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin'); |
|
268 | - // load M-Mode class |
|
269 | - $this->registry->load_core('Maintenance_Mode'); |
|
270 | - // check if db has been updated, or if its a brand-new installation |
|
271 | - $espresso_db_update = $this->fix_espresso_db_upgrade_option(); |
|
272 | - $request_type = $this->detect_req_type($espresso_db_update); |
|
273 | - //EEH_Debug_Tools::printr( $request_type, '$request_type', __FILE__, __LINE__ ); |
|
274 | - switch ($request_type) { |
|
275 | - case EE_System::req_type_new_activation: |
|
276 | - do_action('AHEE__EE_System__detect_if_activation_or_upgrade__new_activation'); |
|
277 | - $this->_handle_core_version_change($espresso_db_update); |
|
278 | - break; |
|
279 | - case EE_System::req_type_reactivation: |
|
280 | - do_action('AHEE__EE_System__detect_if_activation_or_upgrade__reactivation'); |
|
281 | - $this->_handle_core_version_change($espresso_db_update); |
|
282 | - break; |
|
283 | - case EE_System::req_type_upgrade: |
|
284 | - do_action('AHEE__EE_System__detect_if_activation_or_upgrade__upgrade'); |
|
285 | - //migrations may be required now that we've upgraded |
|
286 | - EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old(); |
|
287 | - $this->_handle_core_version_change($espresso_db_update); |
|
288 | - // echo "done upgrade";die; |
|
289 | - break; |
|
290 | - case EE_System::req_type_downgrade: |
|
291 | - do_action('AHEE__EE_System__detect_if_activation_or_upgrade__downgrade'); |
|
292 | - //its possible migrations are no longer required |
|
293 | - EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old(); |
|
294 | - $this->_handle_core_version_change($espresso_db_update); |
|
295 | - break; |
|
296 | - case EE_System::req_type_normal: |
|
297 | - default: |
|
298 | - // $this->_maybe_redirect_to_ee_about(); |
|
299 | - break; |
|
300 | - } |
|
301 | - do_action('AHEE__EE_System__detect_if_activation_or_upgrade__complete'); |
|
302 | - } |
|
303 | - |
|
304 | - |
|
305 | - |
|
306 | - /** |
|
307 | - * Updates the list of installed versions and sets hooks for |
|
308 | - * initializing the database later during the request |
|
309 | - * |
|
310 | - * @param array $espresso_db_update |
|
311 | - */ |
|
312 | - protected function _handle_core_version_change($espresso_db_update) |
|
313 | - { |
|
314 | - $this->update_list_of_installed_versions($espresso_db_update); |
|
315 | - //get ready to verify the DB is ok (provided we aren't in maintenance mode, of course) |
|
316 | - add_action('AHEE__EE_System__perform_activations_upgrades_and_migrations', |
|
317 | - array($this, 'initialize_db_if_no_migrations_required')); |
|
318 | - } |
|
319 | - |
|
320 | - |
|
321 | - |
|
322 | - /** |
|
323 | - * standardizes the wp option 'espresso_db_upgrade' which actually stores |
|
324 | - * information about what versions of EE have been installed and activated, |
|
325 | - * NOT necessarily the state of the database |
|
326 | - * |
|
327 | - * @param null $espresso_db_update |
|
328 | - * @internal param array $espresso_db_update_value the value of the WordPress option. If not supplied, fetches it |
|
329 | - * from the options table |
|
330 | - * @return array the correct value of 'espresso_db_upgrade', after saving it, if it needed correction |
|
331 | - */ |
|
332 | - private function fix_espresso_db_upgrade_option($espresso_db_update = null) |
|
333 | - { |
|
334 | - do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__begin', $espresso_db_update); |
|
335 | - if ( ! $espresso_db_update) { |
|
336 | - $espresso_db_update = get_option('espresso_db_update'); |
|
337 | - } |
|
338 | - // check that option is an array |
|
339 | - if ( ! is_array($espresso_db_update)) { |
|
340 | - // if option is FALSE, then it never existed |
|
341 | - if ($espresso_db_update === false) { |
|
342 | - // make $espresso_db_update an array and save option with autoload OFF |
|
343 | - $espresso_db_update = array(); |
|
344 | - add_option('espresso_db_update', $espresso_db_update, '', 'no'); |
|
345 | - } else { |
|
346 | - // option is NOT FALSE but also is NOT an array, so make it an array and save it |
|
347 | - $espresso_db_update = array($espresso_db_update => array()); |
|
348 | - update_option('espresso_db_update', $espresso_db_update); |
|
349 | - } |
|
350 | - } else { |
|
351 | - $corrected_db_update = array(); |
|
352 | - //if IS an array, but is it an array where KEYS are version numbers, and values are arrays? |
|
353 | - foreach ($espresso_db_update as $should_be_version_string => $should_be_array) { |
|
354 | - if (is_int($should_be_version_string) && ! is_array($should_be_array)) { |
|
355 | - //the key is an int, and the value IS NOT an array |
|
356 | - //so it must be numerically-indexed, where values are versions installed... |
|
357 | - //fix it! |
|
358 | - $version_string = $should_be_array; |
|
359 | - $corrected_db_update[$version_string] = array('unknown-date'); |
|
360 | - } else { |
|
361 | - //ok it checks out |
|
362 | - $corrected_db_update[$should_be_version_string] = $should_be_array; |
|
363 | - } |
|
364 | - } |
|
365 | - $espresso_db_update = $corrected_db_update; |
|
366 | - update_option('espresso_db_update', $espresso_db_update); |
|
367 | - } |
|
368 | - do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__complete', $espresso_db_update); |
|
369 | - return $espresso_db_update; |
|
370 | - } |
|
371 | - |
|
372 | - |
|
373 | - |
|
374 | - /** |
|
375 | - * Does the traditional work of setting up the plugin's database and adding default data. |
|
376 | - * If migration script/process did not exist, this is what would happen on every activation/reactivation/upgrade. |
|
377 | - * NOTE: if we're in maintenance mode (which would be the case if we detect there are data |
|
378 | - * migration scripts that need to be run and a version change happens), enqueues core for database initialization, |
|
379 | - * so that it will be done when migrations are finished |
|
380 | - * |
|
381 | - * @param boolean $initialize_addons_too if true, we double-check addons' database tables etc too; |
|
382 | - * @param boolean $verify_schema if true will re-check the database tables have the correct schema. |
|
383 | - * This is a resource-intensive job |
|
384 | - * so we prefer to only do it when necessary |
|
385 | - * @return void |
|
386 | - */ |
|
387 | - public function initialize_db_if_no_migrations_required($initialize_addons_too = false, $verify_schema = true) |
|
388 | - { |
|
389 | - $request_type = $this->detect_req_type(); |
|
390 | - //only initialize system if we're not in maintenance mode. |
|
391 | - if (EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance) { |
|
392 | - update_option('ee_flush_rewrite_rules', true); |
|
393 | - if ($verify_schema) { |
|
394 | - EEH_Activation::initialize_db_and_folders(); |
|
395 | - } |
|
396 | - EEH_Activation::initialize_db_content(); |
|
397 | - EEH_Activation::system_initialization(); |
|
398 | - if ($initialize_addons_too) { |
|
399 | - $this->initialize_addons(); |
|
400 | - } |
|
401 | - } else { |
|
402 | - EE_Data_Migration_Manager::instance()->enqueue_db_initialization_for('Core'); |
|
403 | - } |
|
404 | - if ($request_type === EE_System::req_type_new_activation |
|
405 | - || $request_type === EE_System::req_type_reactivation |
|
406 | - || ( |
|
407 | - $request_type === EE_System::req_type_upgrade |
|
408 | - && $this->is_major_version_change() |
|
409 | - ) |
|
410 | - ) { |
|
411 | - add_action('AHEE__EE_System__initialize_last', array($this, 'redirect_to_about_ee'), 9); |
|
412 | - } |
|
413 | - } |
|
414 | - |
|
415 | - |
|
416 | - |
|
417 | - /** |
|
418 | - * Initializes the db for all registered addons |
|
419 | - */ |
|
420 | - public function initialize_addons() |
|
421 | - { |
|
422 | - //foreach registered addon, make sure its db is up-to-date too |
|
423 | - foreach ($this->registry->addons as $addon) { |
|
424 | - $addon->initialize_db_if_no_migrations_required(); |
|
425 | - } |
|
426 | - } |
|
427 | - |
|
428 | - |
|
429 | - |
|
430 | - /** |
|
431 | - * Adds the current code version to the saved wp option which stores a list of all ee versions ever installed. |
|
432 | - * |
|
433 | - * @param array $version_history |
|
434 | - * @param string $current_version_to_add version to be added to the version history |
|
435 | - * @return boolean success as to whether or not this option was changed |
|
436 | - */ |
|
437 | - public function update_list_of_installed_versions($version_history = null, $current_version_to_add = null) |
|
438 | - { |
|
439 | - if ( ! $version_history) { |
|
440 | - $version_history = $this->fix_espresso_db_upgrade_option($version_history); |
|
441 | - } |
|
442 | - if ($current_version_to_add == null) { |
|
443 | - $current_version_to_add = espresso_version(); |
|
444 | - } |
|
445 | - $version_history[$current_version_to_add][] = date('Y-m-d H:i:s', time()); |
|
446 | - // re-save |
|
447 | - return update_option('espresso_db_update', $version_history); |
|
448 | - } |
|
449 | - |
|
450 | - |
|
451 | - |
|
452 | - /** |
|
453 | - * Detects if the current version indicated in the has existed in the list of |
|
454 | - * previously-installed versions of EE (espresso_db_update). Does NOT modify it (ie, no side-effect) |
|
455 | - * |
|
456 | - * @param array $espresso_db_update array from the wp option stored under the name 'espresso_db_update'. |
|
457 | - * If not supplied, fetches it from the options table. |
|
458 | - * Also, caches its result so later parts of the code can also know whether |
|
459 | - * there's been an update or not. This way we can add the current version to |
|
460 | - * espresso_db_update, but still know if this is a new install or not |
|
461 | - * @return int one of the constants on EE_System::req_type_ |
|
462 | - */ |
|
463 | - public function detect_req_type($espresso_db_update = null) |
|
464 | - { |
|
465 | - if ($this->_req_type === null) { |
|
466 | - $espresso_db_update = ! empty($espresso_db_update) ? $espresso_db_update |
|
467 | - : $this->fix_espresso_db_upgrade_option(); |
|
468 | - $this->_req_type = $this->detect_req_type_given_activation_history($espresso_db_update, |
|
469 | - 'ee_espresso_activation', espresso_version()); |
|
470 | - $this->_major_version_change = $this->_detect_major_version_change($espresso_db_update); |
|
471 | - } |
|
472 | - return $this->_req_type; |
|
473 | - } |
|
474 | - |
|
475 | - |
|
476 | - |
|
477 | - /** |
|
478 | - * Returns whether or not there was a non-micro version change (ie, change in either |
|
479 | - * the first or second number in the version. Eg 4.9.0.rc.001 to 4.10.0.rc.000, |
|
480 | - * but not 4.9.0.rc.0001 to 4.9.1.rc.0001 |
|
481 | - * |
|
482 | - * @param $activation_history |
|
483 | - * @return bool |
|
484 | - */ |
|
485 | - protected function _detect_major_version_change($activation_history) |
|
486 | - { |
|
487 | - $previous_version = EE_System::_get_most_recently_active_version_from_activation_history($activation_history); |
|
488 | - $previous_version_parts = explode('.', $previous_version); |
|
489 | - $current_version_parts = explode('.', espresso_version()); |
|
490 | - return isset($previous_version_parts[0], $previous_version_parts[1], $current_version_parts[0], $current_version_parts[1]) |
|
491 | - && ($previous_version_parts[0] !== $current_version_parts[0] |
|
492 | - || $previous_version_parts[1] !== $current_version_parts[1] |
|
493 | - ); |
|
494 | - } |
|
495 | - |
|
496 | - |
|
497 | - |
|
498 | - /** |
|
499 | - * Returns true if either the major or minor version of EE changed during this request. |
|
500 | - * Eg 4.9.0.rc.001 to 4.10.0.rc.000, but not 4.9.0.rc.0001 to 4.9.1.rc.0001 |
|
501 | - * |
|
502 | - * @return bool |
|
503 | - */ |
|
504 | - public function is_major_version_change() |
|
505 | - { |
|
506 | - return $this->_major_version_change; |
|
507 | - } |
|
508 | - |
|
509 | - |
|
510 | - |
|
511 | - /** |
|
512 | - * Determines the request type for any ee addon, given three piece of info: the current array of activation |
|
513 | - * histories (for core that' 'espresso_db_update' wp option); the name of the wordpress option which is temporarily |
|
514 | - * set upon activation of the plugin (for core it's 'ee_espresso_activation'); and the version that this plugin was |
|
515 | - * just activated to (for core that will always be espresso_version()) |
|
516 | - * |
|
517 | - * @param array $activation_history_for_addon the option's value which stores the activation history for this |
|
518 | - * ee plugin. for core that's 'espresso_db_update' |
|
519 | - * @param string $activation_indicator_option_name the name of the wordpress option that is temporarily set to |
|
520 | - * indicate that this plugin was just activated |
|
521 | - * @param string $version_to_upgrade_to the version that was just upgraded to (for core that will be |
|
522 | - * espresso_version()) |
|
523 | - * @return int one of the constants on EE_System::req_type_* |
|
524 | - */ |
|
525 | - public static function detect_req_type_given_activation_history( |
|
526 | - $activation_history_for_addon, |
|
527 | - $activation_indicator_option_name, |
|
528 | - $version_to_upgrade_to |
|
529 | - ) { |
|
530 | - $version_is_higher = self::_new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to); |
|
531 | - if ($activation_history_for_addon) { |
|
532 | - //it exists, so this isn't a completely new install |
|
533 | - //check if this version already in that list of previously installed versions |
|
534 | - if ( ! isset($activation_history_for_addon[$version_to_upgrade_to])) { |
|
535 | - //it a version we haven't seen before |
|
536 | - if ($version_is_higher === 1) { |
|
537 | - $req_type = EE_System::req_type_upgrade; |
|
538 | - } else { |
|
539 | - $req_type = EE_System::req_type_downgrade; |
|
540 | - } |
|
541 | - delete_option($activation_indicator_option_name); |
|
542 | - } else { |
|
543 | - // its not an update. maybe a reactivation? |
|
544 | - if (get_option($activation_indicator_option_name, false)) { |
|
545 | - if ($version_is_higher === -1) { |
|
546 | - $req_type = EE_System::req_type_downgrade; |
|
547 | - } elseif ($version_is_higher === 0) { |
|
548 | - //we've seen this version before, but it's an activation. must be a reactivation |
|
549 | - $req_type = EE_System::req_type_reactivation; |
|
550 | - } else {//$version_is_higher === 1 |
|
551 | - $req_type = EE_System::req_type_upgrade; |
|
552 | - } |
|
553 | - delete_option($activation_indicator_option_name); |
|
554 | - } else { |
|
555 | - //we've seen this version before and the activation indicate doesn't show it was just activated |
|
556 | - if ($version_is_higher === -1) { |
|
557 | - $req_type = EE_System::req_type_downgrade; |
|
558 | - } elseif ($version_is_higher === 0) { |
|
559 | - //we've seen this version before and it's not an activation. its normal request |
|
560 | - $req_type = EE_System::req_type_normal; |
|
561 | - } else {//$version_is_higher === 1 |
|
562 | - $req_type = EE_System::req_type_upgrade; |
|
563 | - } |
|
564 | - } |
|
565 | - } |
|
566 | - } else { |
|
567 | - //brand new install |
|
568 | - $req_type = EE_System::req_type_new_activation; |
|
569 | - delete_option($activation_indicator_option_name); |
|
570 | - } |
|
571 | - return $req_type; |
|
572 | - } |
|
573 | - |
|
574 | - |
|
575 | - |
|
576 | - /** |
|
577 | - * Detects if the $version_to_upgrade_to is higher than the most recent version in |
|
578 | - * the $activation_history_for_addon |
|
579 | - * |
|
580 | - * @param array $activation_history_for_addon (keys are versions, values are arrays of times activated, |
|
581 | - * sometimes containing 'unknown-date' |
|
582 | - * @param string $version_to_upgrade_to (current version) |
|
583 | - * @return int results of version_compare( $version_to_upgrade_to, $most_recently_active_version ). |
|
584 | - * ie, -1 if $version_to_upgrade_to is LOWER (downgrade); |
|
585 | - * 0 if $version_to_upgrade_to MATCHES (reactivation or normal request); |
|
586 | - * 1 if $version_to_upgrade_to is HIGHER (upgrade) ; |
|
587 | - */ |
|
588 | - protected static function _new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to) |
|
589 | - { |
|
590 | - //find the most recently-activated version |
|
591 | - $most_recently_active_version = EE_System::_get_most_recently_active_version_from_activation_history($activation_history_for_addon); |
|
592 | - return version_compare($version_to_upgrade_to, $most_recently_active_version); |
|
593 | - } |
|
594 | - |
|
595 | - |
|
596 | - |
|
597 | - /** |
|
598 | - * Gets the most recently active version listed in the activation history, |
|
599 | - * and if none are found (ie, it's a brand new install) returns '0.0.0.dev.000'. |
|
600 | - * |
|
601 | - * @param array $activation_history (keys are versions, values are arrays of times activated, |
|
602 | - * sometimes containing 'unknown-date' |
|
603 | - * @return string |
|
604 | - */ |
|
605 | - protected static function _get_most_recently_active_version_from_activation_history($activation_history) |
|
606 | - { |
|
607 | - $most_recently_active_version_activation = '1970-01-01 00:00:00'; |
|
608 | - $most_recently_active_version = '0.0.0.dev.000'; |
|
609 | - if (is_array($activation_history)) { |
|
610 | - foreach ($activation_history as $version => $times_activated) { |
|
611 | - //check there is a record of when this version was activated. Otherwise, |
|
612 | - //mark it as unknown |
|
613 | - if ( ! $times_activated) { |
|
614 | - $times_activated = array('unknown-date'); |
|
615 | - } |
|
616 | - if (is_string($times_activated)) { |
|
617 | - $times_activated = array($times_activated); |
|
618 | - } |
|
619 | - foreach ($times_activated as $an_activation) { |
|
620 | - if ($an_activation != 'unknown-date' && $an_activation > $most_recently_active_version_activation) { |
|
621 | - $most_recently_active_version = $version; |
|
622 | - $most_recently_active_version_activation = $an_activation == 'unknown-date' |
|
623 | - ? '1970-01-01 00:00:00' : $an_activation; |
|
624 | - } |
|
625 | - } |
|
626 | - } |
|
627 | - } |
|
628 | - return $most_recently_active_version; |
|
629 | - } |
|
630 | - |
|
631 | - |
|
632 | - |
|
633 | - /** |
|
634 | - * This redirects to the about EE page after activation |
|
635 | - * |
|
636 | - * @return void |
|
637 | - */ |
|
638 | - public function redirect_to_about_ee() |
|
639 | - { |
|
640 | - $notices = EE_Error::get_notices(false); |
|
641 | - //if current user is an admin and it's not an ajax or rest request |
|
642 | - if ( |
|
643 | - ! (defined('DOING_AJAX') && DOING_AJAX) |
|
644 | - && ! (defined('REST_REQUEST') && REST_REQUEST) |
|
645 | - && ! isset($notices['errors']) |
|
646 | - && apply_filters( |
|
647 | - 'FHEE__EE_System__redirect_to_about_ee__do_redirect', |
|
648 | - $this->registry->CAP->current_user_can('manage_options', 'espresso_about_default') |
|
649 | - ) |
|
650 | - ) { |
|
651 | - $query_params = array('page' => 'espresso_about'); |
|
652 | - if (EE_System::instance()->detect_req_type() == EE_System::req_type_new_activation) { |
|
653 | - $query_params['new_activation'] = true; |
|
654 | - } |
|
655 | - if (EE_System::instance()->detect_req_type() == EE_System::req_type_reactivation) { |
|
656 | - $query_params['reactivation'] = true; |
|
657 | - } |
|
658 | - $url = add_query_arg($query_params, admin_url('admin.php')); |
|
659 | - wp_safe_redirect($url); |
|
660 | - exit(); |
|
661 | - } |
|
662 | - } |
|
663 | - |
|
664 | - |
|
665 | - |
|
666 | - /** |
|
667 | - * load_core_configuration |
|
668 | - * this is hooked into 'AHEE__EE_Bootstrap__load_core_configuration' |
|
669 | - * which runs during the WP 'plugins_loaded' action at priority 5 |
|
670 | - * |
|
671 | - * @return void |
|
672 | - */ |
|
673 | - public function load_core_configuration() |
|
674 | - { |
|
675 | - do_action('AHEE__EE_System__load_core_configuration__begin', $this); |
|
676 | - $this->registry->load_core('EE_Load_Textdomain'); |
|
677 | - //load textdomain |
|
678 | - EE_Load_Textdomain::load_textdomain(); |
|
679 | - // load and setup EE_Config and EE_Network_Config |
|
680 | - $this->registry->load_core('Config'); |
|
681 | - $this->registry->load_core('Network_Config'); |
|
682 | - // setup autoloaders |
|
683 | - // enable logging? |
|
684 | - if ($this->registry->CFG->admin->use_full_logging) { |
|
685 | - $this->registry->load_core('Log'); |
|
686 | - } |
|
687 | - // check for activation errors |
|
688 | - $activation_errors = get_option('ee_plugin_activation_errors', false); |
|
689 | - if ($activation_errors) { |
|
690 | - EE_Error::add_error($activation_errors, __FILE__, __FUNCTION__, __LINE__); |
|
691 | - update_option('ee_plugin_activation_errors', false); |
|
692 | - } |
|
693 | - // get model names |
|
694 | - $this->_parse_model_names(); |
|
695 | - do_action('AHEE__EE_System__load_core_configuration__complete', $this); |
|
696 | - } |
|
697 | - |
|
698 | - |
|
699 | - |
|
700 | - /** |
|
701 | - * cycles through all of the models/*.model.php files, and assembles an array of model names |
|
702 | - * |
|
703 | - * @return void |
|
704 | - */ |
|
705 | - private function _parse_model_names() |
|
706 | - { |
|
707 | - //get all the files in the EE_MODELS folder that end in .model.php |
|
708 | - $models = glob(EE_MODELS . '*.model.php'); |
|
709 | - $model_names = array(); |
|
710 | - $non_abstract_db_models = array(); |
|
711 | - foreach ($models as $model) { |
|
712 | - // get model classname |
|
713 | - $classname = EEH_File::get_classname_from_filepath_with_standard_filename($model); |
|
714 | - $short_name = str_replace('EEM_', '', $classname); |
|
715 | - $reflectionClass = new ReflectionClass($classname); |
|
716 | - if ($reflectionClass->isSubclassOf('EEM_Base') && ! $reflectionClass->isAbstract()) { |
|
717 | - $non_abstract_db_models[$short_name] = $classname; |
|
718 | - } |
|
719 | - $model_names[$short_name] = $classname; |
|
720 | - } |
|
721 | - $this->registry->models = apply_filters('FHEE__EE_System__parse_model_names', $model_names); |
|
722 | - $this->registry->non_abstract_db_models = apply_filters('FHEE__EE_System__parse_implemented_model_names', |
|
723 | - $non_abstract_db_models); |
|
724 | - } |
|
725 | - |
|
726 | - |
|
727 | - |
|
728 | - /** |
|
729 | - * register_shortcodes_modules_and_widgets |
|
730 | - * generate lists of shortcodes and modules, then verify paths and classes |
|
731 | - * This is hooked into 'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets' |
|
732 | - * which runs during the WP 'plugins_loaded' action at priority 7 |
|
733 | - * |
|
734 | - * @access public |
|
735 | - * @return void |
|
736 | - */ |
|
737 | - public function register_shortcodes_modules_and_widgets() |
|
738 | - { |
|
739 | - try { |
|
740 | - // load, register, and add shortcodes the new way |
|
741 | - new ShortcodesManager( |
|
742 | - // and the old way, but we'll put it under control of the new system |
|
743 | - EE_Config::getLegacyShortcodesManager() |
|
744 | - ); |
|
745 | - } catch (Exception $exception) { |
|
746 | - new ExceptionStackTraceDisplay($exception); |
|
747 | - } |
|
748 | - do_action('AHEE__EE_System__register_shortcodes_modules_and_widgets'); |
|
749 | - // check for addons using old hookpoint |
|
750 | - if (has_action('AHEE__EE_System__register_shortcodes_modules_and_addons')) { |
|
751 | - $this->_incompatible_addon_error(); |
|
752 | - } |
|
753 | - } |
|
754 | - |
|
755 | - |
|
756 | - |
|
757 | - /** |
|
758 | - * _incompatible_addon_error |
|
759 | - * |
|
760 | - * @access public |
|
761 | - * @return void |
|
762 | - */ |
|
763 | - private function _incompatible_addon_error() |
|
764 | - { |
|
765 | - // get array of classes hooking into here |
|
766 | - $class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook('AHEE__EE_System__register_shortcodes_modules_and_addons'); |
|
767 | - if ( ! empty($class_names)) { |
|
768 | - $msg = __('The following plugins, addons, or modules appear to be incompatible with this version of Event Espresso and were automatically deactivated to avoid fatal errors:', |
|
769 | - 'event_espresso'); |
|
770 | - $msg .= '<ul>'; |
|
771 | - foreach ($class_names as $class_name) { |
|
772 | - $msg .= '<li><b>Event Espresso - ' . str_replace(array('EE_', 'EEM_', 'EED_', 'EES_', 'EEW_'), '', |
|
773 | - $class_name) . '</b></li>'; |
|
774 | - } |
|
775 | - $msg .= '</ul>'; |
|
776 | - $msg .= __('Compatibility issues can be avoided and/or resolved by keeping addons and plugins updated to the latest version.', |
|
777 | - 'event_espresso'); |
|
778 | - // save list of incompatible addons to wp-options for later use |
|
779 | - add_option('ee_incompatible_addons', $class_names, '', 'no'); |
|
780 | - if (is_admin()) { |
|
781 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
782 | - } |
|
783 | - } |
|
784 | - } |
|
785 | - |
|
786 | - |
|
787 | - |
|
788 | - /** |
|
789 | - * brew_espresso |
|
790 | - * begins the process of setting hooks for initializing EE in the correct order |
|
791 | - * This is happening on the 'AHEE__EE_Bootstrap__brew_espresso' hookpoint |
|
792 | - * which runs during the WP 'plugins_loaded' action at priority 9 |
|
793 | - * |
|
794 | - * @return void |
|
795 | - */ |
|
796 | - public function brew_espresso() |
|
797 | - { |
|
798 | - do_action('AHEE__EE_System__brew_espresso__begin', $this); |
|
799 | - // load some final core systems |
|
800 | - add_action('init', array($this, 'set_hooks_for_core'), 1); |
|
801 | - add_action('init', array($this, 'perform_activations_upgrades_and_migrations'), 3); |
|
802 | - add_action('init', array($this, 'load_CPTs_and_session'), 5); |
|
803 | - add_action('init', array($this, 'load_controllers'), 7); |
|
804 | - add_action('init', array($this, 'core_loaded_and_ready'), 9); |
|
805 | - add_action('init', array($this, 'initialize'), 10); |
|
806 | - add_action('init', array($this, 'initialize_last'), 100); |
|
807 | - add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 100); |
|
808 | - add_action('admin_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 100); |
|
809 | - add_action('admin_bar_menu', array($this, 'espresso_toolbar_items'), 100); |
|
810 | - if (is_admin() && apply_filters('FHEE__EE_System__brew_espresso__load_pue', true)) { |
|
811 | - // pew pew pew |
|
812 | - $this->registry->load_core('PUE'); |
|
813 | - do_action('AHEE__EE_System__brew_espresso__after_pue_init'); |
|
814 | - } |
|
815 | - do_action('AHEE__EE_System__brew_espresso__complete', $this); |
|
816 | - } |
|
817 | - |
|
818 | - |
|
819 | - |
|
820 | - /** |
|
821 | - * set_hooks_for_core |
|
822 | - * |
|
823 | - * @access public |
|
824 | - * @return void |
|
825 | - */ |
|
826 | - public function set_hooks_for_core() |
|
827 | - { |
|
828 | - $this->_deactivate_incompatible_addons(); |
|
829 | - do_action('AHEE__EE_System__set_hooks_for_core'); |
|
830 | - } |
|
831 | - |
|
832 | - |
|
833 | - |
|
834 | - /** |
|
835 | - * Using the information gathered in EE_System::_incompatible_addon_error, |
|
836 | - * deactivates any addons considered incompatible with the current version of EE |
|
837 | - */ |
|
838 | - private function _deactivate_incompatible_addons() |
|
839 | - { |
|
840 | - $incompatible_addons = get_option('ee_incompatible_addons', array()); |
|
841 | - if ( ! empty($incompatible_addons)) { |
|
842 | - $active_plugins = get_option('active_plugins', array()); |
|
843 | - foreach ($active_plugins as $active_plugin) { |
|
844 | - foreach ($incompatible_addons as $incompatible_addon) { |
|
845 | - if (strpos($active_plugin, $incompatible_addon) !== false) { |
|
846 | - unset($_GET['activate']); |
|
847 | - espresso_deactivate_plugin($active_plugin); |
|
848 | - } |
|
849 | - } |
|
850 | - } |
|
851 | - } |
|
852 | - } |
|
853 | - |
|
854 | - |
|
855 | - |
|
856 | - /** |
|
857 | - * perform_activations_upgrades_and_migrations |
|
858 | - * |
|
859 | - * @access public |
|
860 | - * @return void |
|
861 | - */ |
|
862 | - public function perform_activations_upgrades_and_migrations() |
|
863 | - { |
|
864 | - //first check if we had previously attempted to setup EE's directories but failed |
|
865 | - if (EEH_Activation::upload_directories_incomplete()) { |
|
866 | - EEH_Activation::create_upload_directories(); |
|
867 | - } |
|
868 | - do_action('AHEE__EE_System__perform_activations_upgrades_and_migrations'); |
|
869 | - } |
|
870 | - |
|
871 | - |
|
872 | - |
|
873 | - /** |
|
874 | - * load_CPTs_and_session |
|
875 | - * |
|
876 | - * @access public |
|
877 | - * @return void |
|
878 | - */ |
|
879 | - public function load_CPTs_and_session() |
|
880 | - { |
|
881 | - do_action('AHEE__EE_System__load_CPTs_and_session__start'); |
|
882 | - // register Custom Post Types |
|
883 | - $this->registry->load_core('Register_CPTs'); |
|
884 | - do_action('AHEE__EE_System__load_CPTs_and_session__complete'); |
|
885 | - } |
|
886 | - |
|
887 | - |
|
888 | - |
|
889 | - /** |
|
890 | - * load_controllers |
|
891 | - * this is the best place to load any additional controllers that needs access to EE core. |
|
892 | - * it is expected that all basic core EE systems, that are not dependant on the current request are loaded at this |
|
893 | - * time |
|
894 | - * |
|
895 | - * @access public |
|
896 | - * @return void |
|
897 | - */ |
|
898 | - public function load_controllers() |
|
899 | - { |
|
900 | - do_action('AHEE__EE_System__load_controllers__start'); |
|
901 | - // let's get it started |
|
902 | - if ( ! is_admin() && ! EE_Maintenance_Mode::instance()->level()) { |
|
903 | - do_action('AHEE__EE_System__load_controllers__load_front_controllers'); |
|
904 | - $this->registry->load_core('Front_Controller'); |
|
905 | - } else if ( ! EE_FRONT_AJAX) { |
|
906 | - do_action('AHEE__EE_System__load_controllers__load_admin_controllers'); |
|
907 | - EE_Registry::instance()->load_core('Admin'); |
|
908 | - } |
|
909 | - do_action('AHEE__EE_System__load_controllers__complete'); |
|
910 | - } |
|
911 | - |
|
912 | - |
|
913 | - |
|
914 | - /** |
|
915 | - * core_loaded_and_ready |
|
916 | - * all of the basic EE core should be loaded at this point and available regardless of M-Mode |
|
917 | - * |
|
918 | - * @access public |
|
919 | - * @return void |
|
920 | - */ |
|
921 | - public function core_loaded_and_ready() |
|
922 | - { |
|
923 | - do_action('AHEE__EE_System__core_loaded_and_ready'); |
|
924 | - // load_espresso_template_tags |
|
925 | - if (is_readable(EE_PUBLIC . 'template_tags.php')) { |
|
926 | - require_once(EE_PUBLIC . 'template_tags.php'); |
|
927 | - } |
|
928 | - do_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons'); |
|
929 | - $this->registry->load_core('Session'); |
|
930 | - } |
|
931 | - |
|
932 | - |
|
933 | - |
|
934 | - /** |
|
935 | - * initialize |
|
936 | - * this is the best place to begin initializing client code |
|
937 | - * |
|
938 | - * @access public |
|
939 | - * @return void |
|
940 | - */ |
|
941 | - public function initialize() |
|
942 | - { |
|
943 | - do_action('AHEE__EE_System__initialize'); |
|
944 | - } |
|
945 | - |
|
946 | - |
|
947 | - |
|
948 | - /** |
|
949 | - * initialize_last |
|
950 | - * this is run really late during the WP init hookpoint, and ensures that mostly everything else that needs to |
|
951 | - * initialize has done so |
|
952 | - * |
|
953 | - * @access public |
|
954 | - * @return void |
|
955 | - */ |
|
956 | - public function initialize_last() |
|
957 | - { |
|
958 | - do_action('AHEE__EE_System__initialize_last'); |
|
959 | - } |
|
960 | - |
|
961 | - |
|
962 | - |
|
963 | - /** |
|
964 | - * set_hooks_for_shortcodes_modules_and_addons |
|
965 | - * this is the best place for other systems to set callbacks for hooking into other parts of EE |
|
966 | - * this happens at the very beginning of the wp_loaded hookpoint |
|
967 | - * |
|
968 | - * @access public |
|
969 | - * @return void |
|
970 | - */ |
|
971 | - public function set_hooks_for_shortcodes_modules_and_addons() |
|
972 | - { |
|
973 | - // do_action( 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons' ); |
|
974 | - } |
|
975 | - |
|
976 | - |
|
977 | - |
|
978 | - /** |
|
979 | - * do_not_cache |
|
980 | - * sets no cache headers and defines no cache constants for WP plugins |
|
981 | - * |
|
982 | - * @access public |
|
983 | - * @return void |
|
984 | - */ |
|
985 | - public static function do_not_cache() |
|
986 | - { |
|
987 | - // set no cache constants |
|
988 | - if ( ! defined('DONOTCACHEPAGE')) { |
|
989 | - define('DONOTCACHEPAGE', true); |
|
990 | - } |
|
991 | - if ( ! defined('DONOTCACHCEOBJECT')) { |
|
992 | - define('DONOTCACHCEOBJECT', true); |
|
993 | - } |
|
994 | - if ( ! defined('DONOTCACHEDB')) { |
|
995 | - define('DONOTCACHEDB', true); |
|
996 | - } |
|
997 | - // add no cache headers |
|
998 | - add_action('send_headers', array('EE_System', 'nocache_headers'), 10); |
|
999 | - // plus a little extra for nginx and Google Chrome |
|
1000 | - add_filter('nocache_headers', array('EE_System', 'extra_nocache_headers'), 10, 1); |
|
1001 | - // prevent browsers from prefetching of the rel='next' link, because it may contain content that interferes with the registration process |
|
1002 | - remove_action('wp_head', 'adjacent_posts_rel_link_wp_head'); |
|
1003 | - } |
|
1004 | - |
|
1005 | - |
|
1006 | - |
|
1007 | - /** |
|
1008 | - * extra_nocache_headers |
|
1009 | - * |
|
1010 | - * @access public |
|
1011 | - * @param $headers |
|
1012 | - * @return array |
|
1013 | - */ |
|
1014 | - public static function extra_nocache_headers($headers) |
|
1015 | - { |
|
1016 | - // for NGINX |
|
1017 | - $headers['X-Accel-Expires'] = 0; |
|
1018 | - // plus extra for Google Chrome since it doesn't seem to respect "no-cache", but WILL respect "no-store" |
|
1019 | - $headers['Cache-Control'] = 'no-store, no-cache, must-revalidate, max-age=0'; |
|
1020 | - return $headers; |
|
1021 | - } |
|
1022 | - |
|
1023 | - |
|
1024 | - |
|
1025 | - /** |
|
1026 | - * nocache_headers |
|
1027 | - * |
|
1028 | - * @access public |
|
1029 | - * @return void |
|
1030 | - */ |
|
1031 | - public static function nocache_headers() |
|
1032 | - { |
|
1033 | - nocache_headers(); |
|
1034 | - } |
|
1035 | - |
|
1036 | - |
|
1037 | - |
|
1038 | - /** |
|
1039 | - * espresso_toolbar_items |
|
1040 | - * |
|
1041 | - * @access public |
|
1042 | - * @param WP_Admin_Bar $admin_bar |
|
1043 | - * @return void |
|
1044 | - */ |
|
1045 | - public function espresso_toolbar_items(WP_Admin_Bar $admin_bar) |
|
1046 | - { |
|
1047 | - // if in full M-Mode, or its an AJAX request, or user is NOT an admin |
|
1048 | - if (EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance |
|
1049 | - || defined('DOING_AJAX') |
|
1050 | - || ! $this->registry->CAP->current_user_can('ee_read_ee', 'ee_admin_bar_menu_top_level') |
|
1051 | - ) { |
|
1052 | - return; |
|
1053 | - } |
|
1054 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1055 | - $menu_class = 'espresso_menu_item_class'; |
|
1056 | - //we don't use the constants EVENTS_ADMIN_URL or REG_ADMIN_URL |
|
1057 | - //because they're only defined in each of their respective constructors |
|
1058 | - //and this might be a frontend request, in which case they aren't available |
|
1059 | - $events_admin_url = admin_url("admin.php?page=espresso_events"); |
|
1060 | - $reg_admin_url = admin_url("admin.php?page=espresso_registrations"); |
|
1061 | - $extensions_admin_url = admin_url("admin.php?page=espresso_packages"); |
|
1062 | - //Top Level |
|
1063 | - $admin_bar->add_menu(array( |
|
1064 | - 'id' => 'espresso-toolbar', |
|
1065 | - 'title' => '<span class="ee-icon ee-icon-ee-cup-thick ee-icon-size-20"></span><span class="ab-label">' |
|
1066 | - . _x('Event Espresso', 'admin bar menu group label', 'event_espresso') |
|
1067 | - . '</span>', |
|
1068 | - 'href' => $events_admin_url, |
|
1069 | - 'meta' => array( |
|
1070 | - 'title' => __('Event Espresso', 'event_espresso'), |
|
1071 | - 'class' => $menu_class . 'first', |
|
1072 | - ), |
|
1073 | - )); |
|
1074 | - //Events |
|
1075 | - if ($this->registry->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events')) { |
|
1076 | - $admin_bar->add_menu(array( |
|
1077 | - 'id' => 'espresso-toolbar-events', |
|
1078 | - 'parent' => 'espresso-toolbar', |
|
1079 | - 'title' => __('Events', 'event_espresso'), |
|
1080 | - 'href' => $events_admin_url, |
|
1081 | - 'meta' => array( |
|
1082 | - 'title' => __('Events', 'event_espresso'), |
|
1083 | - 'target' => '', |
|
1084 | - 'class' => $menu_class, |
|
1085 | - ), |
|
1086 | - )); |
|
1087 | - } |
|
1088 | - if ($this->registry->CAP->current_user_can('ee_edit_events', 'ee_admin_bar_menu_espresso-toolbar-events-new')) { |
|
1089 | - //Events Add New |
|
1090 | - $admin_bar->add_menu(array( |
|
1091 | - 'id' => 'espresso-toolbar-events-new', |
|
1092 | - 'parent' => 'espresso-toolbar-events', |
|
1093 | - 'title' => __('Add New', 'event_espresso'), |
|
1094 | - 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'create_new'), $events_admin_url), |
|
1095 | - 'meta' => array( |
|
1096 | - 'title' => __('Add New', 'event_espresso'), |
|
1097 | - 'target' => '', |
|
1098 | - 'class' => $menu_class, |
|
1099 | - ), |
|
1100 | - )); |
|
1101 | - } |
|
1102 | - if (is_single() && (get_post_type() == 'espresso_events')) { |
|
1103 | - //Current post |
|
1104 | - global $post; |
|
1105 | - if ($this->registry->CAP->current_user_can('ee_edit_event', |
|
1106 | - 'ee_admin_bar_menu_espresso-toolbar-events-edit', $post->ID) |
|
1107 | - ) { |
|
1108 | - //Events Edit Current Event |
|
1109 | - $admin_bar->add_menu(array( |
|
1110 | - 'id' => 'espresso-toolbar-events-edit', |
|
1111 | - 'parent' => 'espresso-toolbar-events', |
|
1112 | - 'title' => __('Edit Event', 'event_espresso'), |
|
1113 | - 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'edit', 'post' => $post->ID), |
|
1114 | - $events_admin_url), |
|
1115 | - 'meta' => array( |
|
1116 | - 'title' => __('Edit Event', 'event_espresso'), |
|
1117 | - 'target' => '', |
|
1118 | - 'class' => $menu_class, |
|
1119 | - ), |
|
1120 | - )); |
|
1121 | - } |
|
1122 | - } |
|
1123 | - //Events View |
|
1124 | - if ($this->registry->CAP->current_user_can('ee_read_events', |
|
1125 | - 'ee_admin_bar_menu_espresso-toolbar-events-view') |
|
1126 | - ) { |
|
1127 | - $admin_bar->add_menu(array( |
|
1128 | - 'id' => 'espresso-toolbar-events-view', |
|
1129 | - 'parent' => 'espresso-toolbar-events', |
|
1130 | - 'title' => __('View', 'event_espresso'), |
|
1131 | - 'href' => $events_admin_url, |
|
1132 | - 'meta' => array( |
|
1133 | - 'title' => __('View', 'event_espresso'), |
|
1134 | - 'target' => '', |
|
1135 | - 'class' => $menu_class, |
|
1136 | - ), |
|
1137 | - )); |
|
1138 | - } |
|
1139 | - if ($this->registry->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-all')) { |
|
1140 | - //Events View All |
|
1141 | - $admin_bar->add_menu(array( |
|
1142 | - 'id' => 'espresso-toolbar-events-all', |
|
1143 | - 'parent' => 'espresso-toolbar-events-view', |
|
1144 | - 'title' => __('All', 'event_espresso'), |
|
1145 | - 'href' => $events_admin_url, |
|
1146 | - 'meta' => array( |
|
1147 | - 'title' => __('All', 'event_espresso'), |
|
1148 | - 'target' => '', |
|
1149 | - 'class' => $menu_class, |
|
1150 | - ), |
|
1151 | - )); |
|
1152 | - } |
|
1153 | - if ($this->registry->CAP->current_user_can('ee_read_events', |
|
1154 | - 'ee_admin_bar_menu_espresso-toolbar-events-today') |
|
1155 | - ) { |
|
1156 | - //Events View Today |
|
1157 | - $admin_bar->add_menu(array( |
|
1158 | - 'id' => 'espresso-toolbar-events-today', |
|
1159 | - 'parent' => 'espresso-toolbar-events-view', |
|
1160 | - 'title' => __('Today', 'event_espresso'), |
|
1161 | - 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'default', 'status' => 'today'), |
|
1162 | - $events_admin_url), |
|
1163 | - 'meta' => array( |
|
1164 | - 'title' => __('Today', 'event_espresso'), |
|
1165 | - 'target' => '', |
|
1166 | - 'class' => $menu_class, |
|
1167 | - ), |
|
1168 | - )); |
|
1169 | - } |
|
1170 | - if ($this->registry->CAP->current_user_can('ee_read_events', |
|
1171 | - 'ee_admin_bar_menu_espresso-toolbar-events-month') |
|
1172 | - ) { |
|
1173 | - //Events View This Month |
|
1174 | - $admin_bar->add_menu(array( |
|
1175 | - 'id' => 'espresso-toolbar-events-month', |
|
1176 | - 'parent' => 'espresso-toolbar-events-view', |
|
1177 | - 'title' => __('This Month', 'event_espresso'), |
|
1178 | - 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'default', 'status' => 'month'), |
|
1179 | - $events_admin_url), |
|
1180 | - 'meta' => array( |
|
1181 | - 'title' => __('This Month', 'event_espresso'), |
|
1182 | - 'target' => '', |
|
1183 | - 'class' => $menu_class, |
|
1184 | - ), |
|
1185 | - )); |
|
1186 | - } |
|
1187 | - //Registration Overview |
|
1188 | - if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1189 | - 'ee_admin_bar_menu_espresso-toolbar-registrations') |
|
1190 | - ) { |
|
1191 | - $admin_bar->add_menu(array( |
|
1192 | - 'id' => 'espresso-toolbar-registrations', |
|
1193 | - 'parent' => 'espresso-toolbar', |
|
1194 | - 'title' => __('Registrations', 'event_espresso'), |
|
1195 | - 'href' => $reg_admin_url, |
|
1196 | - 'meta' => array( |
|
1197 | - 'title' => __('Registrations', 'event_espresso'), |
|
1198 | - 'target' => '', |
|
1199 | - 'class' => $menu_class, |
|
1200 | - ), |
|
1201 | - )); |
|
1202 | - } |
|
1203 | - //Registration Overview Today |
|
1204 | - if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1205 | - 'ee_admin_bar_menu_espresso-toolbar-registrations-today') |
|
1206 | - ) { |
|
1207 | - $admin_bar->add_menu(array( |
|
1208 | - 'id' => 'espresso-toolbar-registrations-today', |
|
1209 | - 'parent' => 'espresso-toolbar-registrations', |
|
1210 | - 'title' => __('Today', 'event_espresso'), |
|
1211 | - 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'default', 'status' => 'today'), |
|
1212 | - $reg_admin_url), |
|
1213 | - 'meta' => array( |
|
1214 | - 'title' => __('Today', 'event_espresso'), |
|
1215 | - 'target' => '', |
|
1216 | - 'class' => $menu_class, |
|
1217 | - ), |
|
1218 | - )); |
|
1219 | - } |
|
1220 | - //Registration Overview Today Completed |
|
1221 | - if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1222 | - 'ee_admin_bar_menu_espresso-toolbar-registrations-today-approved') |
|
1223 | - ) { |
|
1224 | - $admin_bar->add_menu(array( |
|
1225 | - 'id' => 'espresso-toolbar-registrations-today-approved', |
|
1226 | - 'parent' => 'espresso-toolbar-registrations-today', |
|
1227 | - 'title' => __('Approved', 'event_espresso'), |
|
1228 | - 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1229 | - 'action' => 'default', |
|
1230 | - 'status' => 'today', |
|
1231 | - '_reg_status' => EEM_Registration::status_id_approved, |
|
1232 | - ), $reg_admin_url), |
|
1233 | - 'meta' => array( |
|
1234 | - 'title' => __('Approved', 'event_espresso'), |
|
1235 | - 'target' => '', |
|
1236 | - 'class' => $menu_class, |
|
1237 | - ), |
|
1238 | - )); |
|
1239 | - } |
|
1240 | - //Registration Overview Today Pending\ |
|
1241 | - if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1242 | - 'ee_admin_bar_menu_espresso-toolbar-registrations-today-pending') |
|
1243 | - ) { |
|
1244 | - $admin_bar->add_menu(array( |
|
1245 | - 'id' => 'espresso-toolbar-registrations-today-pending', |
|
1246 | - 'parent' => 'espresso-toolbar-registrations-today', |
|
1247 | - 'title' => __('Pending', 'event_espresso'), |
|
1248 | - 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1249 | - 'action' => 'default', |
|
1250 | - 'status' => 'today', |
|
1251 | - 'reg_status' => EEM_Registration::status_id_pending_payment, |
|
1252 | - ), $reg_admin_url), |
|
1253 | - 'meta' => array( |
|
1254 | - 'title' => __('Pending Payment', 'event_espresso'), |
|
1255 | - 'target' => '', |
|
1256 | - 'class' => $menu_class, |
|
1257 | - ), |
|
1258 | - )); |
|
1259 | - } |
|
1260 | - //Registration Overview Today Incomplete |
|
1261 | - if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1262 | - 'ee_admin_bar_menu_espresso-toolbar-registrations-today-not-approved') |
|
1263 | - ) { |
|
1264 | - $admin_bar->add_menu(array( |
|
1265 | - 'id' => 'espresso-toolbar-registrations-today-not-approved', |
|
1266 | - 'parent' => 'espresso-toolbar-registrations-today', |
|
1267 | - 'title' => __('Not Approved', 'event_espresso'), |
|
1268 | - 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1269 | - 'action' => 'default', |
|
1270 | - 'status' => 'today', |
|
1271 | - '_reg_status' => EEM_Registration::status_id_not_approved, |
|
1272 | - ), $reg_admin_url), |
|
1273 | - 'meta' => array( |
|
1274 | - 'title' => __('Not Approved', 'event_espresso'), |
|
1275 | - 'target' => '', |
|
1276 | - 'class' => $menu_class, |
|
1277 | - ), |
|
1278 | - )); |
|
1279 | - } |
|
1280 | - //Registration Overview Today Incomplete |
|
1281 | - if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1282 | - 'ee_admin_bar_menu_espresso-toolbar-registrations-today-cancelled') |
|
1283 | - ) { |
|
1284 | - $admin_bar->add_menu(array( |
|
1285 | - 'id' => 'espresso-toolbar-registrations-today-cancelled', |
|
1286 | - 'parent' => 'espresso-toolbar-registrations-today', |
|
1287 | - 'title' => __('Cancelled', 'event_espresso'), |
|
1288 | - 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1289 | - 'action' => 'default', |
|
1290 | - 'status' => 'today', |
|
1291 | - '_reg_status' => EEM_Registration::status_id_cancelled, |
|
1292 | - ), $reg_admin_url), |
|
1293 | - 'meta' => array( |
|
1294 | - 'title' => __('Cancelled', 'event_espresso'), |
|
1295 | - 'target' => '', |
|
1296 | - 'class' => $menu_class, |
|
1297 | - ), |
|
1298 | - )); |
|
1299 | - } |
|
1300 | - //Registration Overview This Month |
|
1301 | - if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1302 | - 'ee_admin_bar_menu_espresso-toolbar-registrations-month') |
|
1303 | - ) { |
|
1304 | - $admin_bar->add_menu(array( |
|
1305 | - 'id' => 'espresso-toolbar-registrations-month', |
|
1306 | - 'parent' => 'espresso-toolbar-registrations', |
|
1307 | - 'title' => __('This Month', 'event_espresso'), |
|
1308 | - 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'default', 'status' => 'month'), |
|
1309 | - $reg_admin_url), |
|
1310 | - 'meta' => array( |
|
1311 | - 'title' => __('This Month', 'event_espresso'), |
|
1312 | - 'target' => '', |
|
1313 | - 'class' => $menu_class, |
|
1314 | - ), |
|
1315 | - )); |
|
1316 | - } |
|
1317 | - //Registration Overview This Month Approved |
|
1318 | - if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1319 | - 'ee_admin_bar_menu_espresso-toolbar-registrations-month-approved') |
|
1320 | - ) { |
|
1321 | - $admin_bar->add_menu(array( |
|
1322 | - 'id' => 'espresso-toolbar-registrations-month-approved', |
|
1323 | - 'parent' => 'espresso-toolbar-registrations-month', |
|
1324 | - 'title' => __('Approved', 'event_espresso'), |
|
1325 | - 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1326 | - 'action' => 'default', |
|
1327 | - 'status' => 'month', |
|
1328 | - '_reg_status' => EEM_Registration::status_id_approved, |
|
1329 | - ), $reg_admin_url), |
|
1330 | - 'meta' => array( |
|
1331 | - 'title' => __('Approved', 'event_espresso'), |
|
1332 | - 'target' => '', |
|
1333 | - 'class' => $menu_class, |
|
1334 | - ), |
|
1335 | - )); |
|
1336 | - } |
|
1337 | - //Registration Overview This Month Pending |
|
1338 | - if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1339 | - 'ee_admin_bar_menu_espresso-toolbar-registrations-month-pending') |
|
1340 | - ) { |
|
1341 | - $admin_bar->add_menu(array( |
|
1342 | - 'id' => 'espresso-toolbar-registrations-month-pending', |
|
1343 | - 'parent' => 'espresso-toolbar-registrations-month', |
|
1344 | - 'title' => __('Pending', 'event_espresso'), |
|
1345 | - 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1346 | - 'action' => 'default', |
|
1347 | - 'status' => 'month', |
|
1348 | - '_reg_status' => EEM_Registration::status_id_pending_payment, |
|
1349 | - ), $reg_admin_url), |
|
1350 | - 'meta' => array( |
|
1351 | - 'title' => __('Pending', 'event_espresso'), |
|
1352 | - 'target' => '', |
|
1353 | - 'class' => $menu_class, |
|
1354 | - ), |
|
1355 | - )); |
|
1356 | - } |
|
1357 | - //Registration Overview This Month Not Approved |
|
1358 | - if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1359 | - 'ee_admin_bar_menu_espresso-toolbar-registrations-month-not-approved') |
|
1360 | - ) { |
|
1361 | - $admin_bar->add_menu(array( |
|
1362 | - 'id' => 'espresso-toolbar-registrations-month-not-approved', |
|
1363 | - 'parent' => 'espresso-toolbar-registrations-month', |
|
1364 | - 'title' => __('Not Approved', 'event_espresso'), |
|
1365 | - 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1366 | - 'action' => 'default', |
|
1367 | - 'status' => 'month', |
|
1368 | - '_reg_status' => EEM_Registration::status_id_not_approved, |
|
1369 | - ), $reg_admin_url), |
|
1370 | - 'meta' => array( |
|
1371 | - 'title' => __('Not Approved', 'event_espresso'), |
|
1372 | - 'target' => '', |
|
1373 | - 'class' => $menu_class, |
|
1374 | - ), |
|
1375 | - )); |
|
1376 | - } |
|
1377 | - //Registration Overview This Month Cancelled |
|
1378 | - if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1379 | - 'ee_admin_bar_menu_espresso-toolbar-registrations-month-cancelled') |
|
1380 | - ) { |
|
1381 | - $admin_bar->add_menu(array( |
|
1382 | - 'id' => 'espresso-toolbar-registrations-month-cancelled', |
|
1383 | - 'parent' => 'espresso-toolbar-registrations-month', |
|
1384 | - 'title' => __('Cancelled', 'event_espresso'), |
|
1385 | - 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1386 | - 'action' => 'default', |
|
1387 | - 'status' => 'month', |
|
1388 | - '_reg_status' => EEM_Registration::status_id_cancelled, |
|
1389 | - ), $reg_admin_url), |
|
1390 | - 'meta' => array( |
|
1391 | - 'title' => __('Cancelled', 'event_espresso'), |
|
1392 | - 'target' => '', |
|
1393 | - 'class' => $menu_class, |
|
1394 | - ), |
|
1395 | - )); |
|
1396 | - } |
|
1397 | - //Extensions & Services |
|
1398 | - if ($this->registry->CAP->current_user_can('ee_read_ee', |
|
1399 | - 'ee_admin_bar_menu_espresso-toolbar-extensions-and-services') |
|
1400 | - ) { |
|
1401 | - $admin_bar->add_menu(array( |
|
1402 | - 'id' => 'espresso-toolbar-extensions-and-services', |
|
1403 | - 'parent' => 'espresso-toolbar', |
|
1404 | - 'title' => __('Extensions & Services', 'event_espresso'), |
|
1405 | - 'href' => $extensions_admin_url, |
|
1406 | - 'meta' => array( |
|
1407 | - 'title' => __('Extensions & Services', 'event_espresso'), |
|
1408 | - 'target' => '', |
|
1409 | - 'class' => $menu_class, |
|
1410 | - ), |
|
1411 | - )); |
|
1412 | - } |
|
1413 | - } |
|
1414 | - |
|
1415 | - |
|
1416 | - |
|
1417 | - /** |
|
1418 | - * simply hooks into "wp_list_pages_exclude" filter (for wp_list_pages method) and makes sure EE critical pages are |
|
1419 | - * never returned with the function. |
|
1420 | - * |
|
1421 | - * @param array $exclude_array any existing pages being excluded are in this array. |
|
1422 | - * @return array |
|
1423 | - */ |
|
1424 | - public function remove_pages_from_wp_list_pages($exclude_array) |
|
1425 | - { |
|
1426 | - return array_merge($exclude_array, $this->registry->CFG->core->get_critical_pages_array()); |
|
1427 | - } |
|
1428 | - |
|
1429 | - |
|
1430 | - |
|
1431 | - |
|
1432 | - |
|
1433 | - |
|
1434 | - /*********************************************** WP_ENQUEUE_SCRIPTS HOOK ***********************************************/ |
|
1435 | - /** |
|
1436 | - * wp_enqueue_scripts |
|
1437 | - * |
|
1438 | - * @access public |
|
1439 | - * @return void |
|
1440 | - */ |
|
1441 | - public function wp_enqueue_scripts() |
|
1442 | - { |
|
1443 | - // unlike other systems, EE_System_scripts loading is turned ON by default, but prior to the init hook, can be turned off via: add_filter( 'FHEE_load_EE_System_scripts', '__return_false' ); |
|
1444 | - if (apply_filters('FHEE_load_EE_System_scripts', true)) { |
|
1445 | - // jquery_validate loading is turned OFF by default, but prior to the wp_enqueue_scripts hook, can be turned back on again via: add_filter( 'FHEE_load_jquery_validate', '__return_true' ); |
|
1446 | - if (apply_filters('FHEE_load_jquery_validate', false)) { |
|
1447 | - // register jQuery Validate and additional methods |
|
1448 | - wp_register_script('jquery-validate', EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js', |
|
1449 | - array('jquery'), '1.15.0', true); |
|
1450 | - wp_register_script('jquery-validate-extra-methods', |
|
1451 | - EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js', |
|
1452 | - array('jquery', 'jquery-validate'), '1.15.0', true); |
|
1453 | - } |
|
1454 | - } |
|
1455 | - } |
|
22 | + /** |
|
23 | + * indicates this is a 'normal' request. Ie, not activation, nor upgrade, nor activation. |
|
24 | + * So examples of this would be a normal GET request on the frontend or backend, or a POST, etc |
|
25 | + */ |
|
26 | + const req_type_normal = 0; |
|
27 | + |
|
28 | + /** |
|
29 | + * Indicates this is a brand new installation of EE so we should install |
|
30 | + * tables and default data etc |
|
31 | + */ |
|
32 | + const req_type_new_activation = 1; |
|
33 | + |
|
34 | + /** |
|
35 | + * we've detected that EE has been reactivated (or EE was activated during maintenance mode, |
|
36 | + * and we just exited maintenance mode). We MUST check the database is setup properly |
|
37 | + * and that default data is setup too |
|
38 | + */ |
|
39 | + const req_type_reactivation = 2; |
|
40 | + |
|
41 | + /** |
|
42 | + * indicates that EE has been upgraded since its previous request. |
|
43 | + * We may have data migration scripts to call and will want to trigger maintenance mode |
|
44 | + */ |
|
45 | + const req_type_upgrade = 3; |
|
46 | + |
|
47 | + /** |
|
48 | + * TODO will detect that EE has been DOWNGRADED. We probably don't want to run in this case... |
|
49 | + */ |
|
50 | + const req_type_downgrade = 4; |
|
51 | + |
|
52 | + /** |
|
53 | + * @deprecated since version 4.6.0.dev.006 |
|
54 | + * Now whenever a new_activation is detected the request type is still just |
|
55 | + * new_activation (same for reactivation, upgrade, downgrade etc), but if we'r ein maintenance mode |
|
56 | + * EE_System::initialize_db_if_no_migrations_required and EE_Addon::initialize_db_if_no_migrations_required |
|
57 | + * will instead enqueue that EE plugin's db initialization for when we're taken out of maintenance mode. |
|
58 | + * (Specifically, when the migration manager indicates migrations are finished |
|
59 | + * EE_Data_Migration_Manager::initialize_db_for_enqueued_ee_plugins() will be called) |
|
60 | + */ |
|
61 | + const req_type_activation_but_not_installed = 5; |
|
62 | + |
|
63 | + /** |
|
64 | + * option prefix for recording the activation history (like core's "espresso_db_update") of addons |
|
65 | + */ |
|
66 | + const addon_activation_history_option_prefix = 'ee_addon_activation_history_'; |
|
67 | + |
|
68 | + |
|
69 | + /** |
|
70 | + * instance of the EE_System object |
|
71 | + * |
|
72 | + * @var $_instance |
|
73 | + * @access private |
|
74 | + */ |
|
75 | + private static $_instance = null; |
|
76 | + |
|
77 | + /** |
|
78 | + * @type EE_Registry $Registry |
|
79 | + * @access protected |
|
80 | + */ |
|
81 | + protected $registry; |
|
82 | + |
|
83 | + /** |
|
84 | + * Stores which type of request this is, options being one of the constants on EE_System starting with req_type_*. |
|
85 | + * It can be a brand-new activation, a reactivation, an upgrade, a downgrade, or a normal request. |
|
86 | + * |
|
87 | + * @var int |
|
88 | + */ |
|
89 | + private $_req_type; |
|
90 | + |
|
91 | + /** |
|
92 | + * Whether or not there was a non-micro version change in EE core version during this request |
|
93 | + * |
|
94 | + * @var boolean |
|
95 | + */ |
|
96 | + private $_major_version_change = false; |
|
97 | + |
|
98 | + |
|
99 | + |
|
100 | + /** |
|
101 | + * @singleton method used to instantiate class object |
|
102 | + * @access public |
|
103 | + * @param \EE_Registry $Registry |
|
104 | + * @return \EE_System |
|
105 | + */ |
|
106 | + public static function instance(EE_Registry $Registry = null) |
|
107 | + { |
|
108 | + // check if class object is instantiated |
|
109 | + if ( ! self::$_instance instanceof EE_System) { |
|
110 | + self::$_instance = new self($Registry); |
|
111 | + } |
|
112 | + return self::$_instance; |
|
113 | + } |
|
114 | + |
|
115 | + |
|
116 | + |
|
117 | + /** |
|
118 | + * resets the instance and returns it |
|
119 | + * |
|
120 | + * @return EE_System |
|
121 | + */ |
|
122 | + public static function reset() |
|
123 | + { |
|
124 | + self::$_instance->_req_type = null; |
|
125 | + //make sure none of the old hooks are left hanging around |
|
126 | + remove_all_actions('AHEE__EE_System__perform_activations_upgrades_and_migrations'); |
|
127 | + //we need to reset the migration manager in order for it to detect DMSs properly |
|
128 | + EE_Data_Migration_Manager::reset(); |
|
129 | + self::instance()->detect_activations_or_upgrades(); |
|
130 | + self::instance()->perform_activations_upgrades_and_migrations(); |
|
131 | + return self::instance(); |
|
132 | + } |
|
133 | + |
|
134 | + |
|
135 | + |
|
136 | + /** |
|
137 | + * sets hooks for running rest of system |
|
138 | + * provides "AHEE__EE_System__construct__complete" hook for EE Addons to use as their starting point |
|
139 | + * starting EE Addons from any other point may lead to problems |
|
140 | + * |
|
141 | + * @access private |
|
142 | + * @param \EE_Registry $Registry |
|
143 | + */ |
|
144 | + private function __construct(EE_Registry $Registry) |
|
145 | + { |
|
146 | + $this->registry = $Registry; |
|
147 | + do_action('AHEE__EE_System__construct__begin', $this); |
|
148 | + // allow addons to load first so that they can register autoloaders, set hooks for running DMS's, etc |
|
149 | + add_action('AHEE__EE_Bootstrap__load_espresso_addons', array($this, 'load_espresso_addons')); |
|
150 | + // when an ee addon is activated, we want to call the core hook(s) again |
|
151 | + // because the newly-activated addon didn't get a chance to run at all |
|
152 | + add_action('activate_plugin', array($this, 'load_espresso_addons'), 1); |
|
153 | + // detect whether install or upgrade |
|
154 | + add_action('AHEE__EE_Bootstrap__detect_activations_or_upgrades', array($this, 'detect_activations_or_upgrades'), |
|
155 | + 3); |
|
156 | + // load EE_Config, EE_Textdomain, etc |
|
157 | + add_action('AHEE__EE_Bootstrap__load_core_configuration', array($this, 'load_core_configuration'), 5); |
|
158 | + // load EE_Config, EE_Textdomain, etc |
|
159 | + add_action('AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets', |
|
160 | + array($this, 'register_shortcodes_modules_and_widgets'), 7); |
|
161 | + // you wanna get going? I wanna get going... let's get going! |
|
162 | + add_action('AHEE__EE_Bootstrap__brew_espresso', array($this, 'brew_espresso'), 9); |
|
163 | + //other housekeeping |
|
164 | + //exclude EE critical pages from wp_list_pages |
|
165 | + add_filter('wp_list_pages_excludes', array($this, 'remove_pages_from_wp_list_pages'), 10); |
|
166 | + // ALL EE Addons should use the following hook point to attach their initial setup too |
|
167 | + // it's extremely important for EE Addons to register any class autoloaders so that they can be available when the EE_Config loads |
|
168 | + do_action('AHEE__EE_System__construct__complete', $this); |
|
169 | + } |
|
170 | + |
|
171 | + |
|
172 | + |
|
173 | + /** |
|
174 | + * load_espresso_addons |
|
175 | + * allow addons to load first so that they can set hooks for running DMS's, etc |
|
176 | + * this is hooked into both: |
|
177 | + * 'AHEE__EE_Bootstrap__load_core_configuration' |
|
178 | + * which runs during the WP 'plugins_loaded' action at priority 5 |
|
179 | + * and the WP 'activate_plugin' hookpoint |
|
180 | + * |
|
181 | + * @access public |
|
182 | + * @return void |
|
183 | + */ |
|
184 | + public function load_espresso_addons() |
|
185 | + { |
|
186 | + // set autoloaders for all of the classes implementing EEI_Plugin_API |
|
187 | + // which provide helpers for EE plugin authors to more easily register certain components with EE. |
|
188 | + EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'plugin_api'); |
|
189 | + //load and setup EE_Capabilities |
|
190 | + $this->registry->load_core('Capabilities'); |
|
191 | + do_action('AHEE__EE_System__load_espresso_addons'); |
|
192 | + //if the WP API basic auth plugin isn't already loaded, load it now. |
|
193 | + //We want it for mobile apps. Just include the entire plugin |
|
194 | + //also, don't load the basic auth when a plugin is getting activated, because |
|
195 | + //it could be the basic auth plugin, and it doesn't check if its methods are already defined |
|
196 | + //and causes a fatal error |
|
197 | + if ( ! function_exists('json_basic_auth_handler') |
|
198 | + && ! function_exists('json_basic_auth_error') |
|
199 | + && ! ( |
|
200 | + isset($_GET['action']) |
|
201 | + && in_array($_GET['action'], array('activate', 'activate-selected')) |
|
202 | + ) |
|
203 | + && ! ( |
|
204 | + isset($_GET['activate']) |
|
205 | + && $_GET['activate'] === 'true' |
|
206 | + ) |
|
207 | + ) { |
|
208 | + include_once EE_THIRD_PARTY . 'wp-api-basic-auth' . DS . 'basic-auth.php'; |
|
209 | + } |
|
210 | + $this->_maybe_brew_regular(); |
|
211 | + do_action('AHEE__EE_System__load_espresso_addons__complete'); |
|
212 | + |
|
213 | + //caps need to be initialized on every request so that capability maps are set. |
|
214 | + //@see https://events.codebasehq.com/projects/event-espresso/tickets/8674 |
|
215 | + $this->registry->CAP->init_caps(); |
|
216 | + } |
|
217 | + |
|
218 | + |
|
219 | + |
|
220 | + /** |
|
221 | + * The purpose of this method is to simply check for a file named "caffeinated/brewing_regular.php" for any hooks |
|
222 | + * that need to be setup before our EE_System launches. |
|
223 | + * |
|
224 | + * @return void |
|
225 | + */ |
|
226 | + private function _maybe_brew_regular() |
|
227 | + { |
|
228 | + if (( ! defined('EE_DECAF') || EE_DECAF !== true) && is_readable(EE_CAFF_PATH . 'brewing_regular.php')) { |
|
229 | + require_once EE_CAFF_PATH . 'brewing_regular.php'; |
|
230 | + } |
|
231 | + } |
|
232 | + |
|
233 | + |
|
234 | + |
|
235 | + /** |
|
236 | + * detect_activations_or_upgrades |
|
237 | + * Checks for activation or upgrade of core first; |
|
238 | + * then also checks if any registered addons have been activated or upgraded |
|
239 | + * This is hooked into 'AHEE__EE_Bootstrap__detect_activations_or_upgrades' |
|
240 | + * which runs during the WP 'plugins_loaded' action at priority 3 |
|
241 | + * |
|
242 | + * @access public |
|
243 | + * @return void |
|
244 | + */ |
|
245 | + public function detect_activations_or_upgrades() |
|
246 | + { |
|
247 | + //first off: let's make sure to handle core |
|
248 | + $this->detect_if_activation_or_upgrade(); |
|
249 | + foreach ($this->registry->addons as $addon) { |
|
250 | + //detect teh request type for that addon |
|
251 | + $addon->detect_activation_or_upgrade(); |
|
252 | + } |
|
253 | + } |
|
254 | + |
|
255 | + |
|
256 | + |
|
257 | + /** |
|
258 | + * detect_if_activation_or_upgrade |
|
259 | + * Takes care of detecting whether this is a brand new install or code upgrade, |
|
260 | + * and either setting up the DB or setting up maintenance mode etc. |
|
261 | + * |
|
262 | + * @access public |
|
263 | + * @return void |
|
264 | + */ |
|
265 | + public function detect_if_activation_or_upgrade() |
|
266 | + { |
|
267 | + do_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin'); |
|
268 | + // load M-Mode class |
|
269 | + $this->registry->load_core('Maintenance_Mode'); |
|
270 | + // check if db has been updated, or if its a brand-new installation |
|
271 | + $espresso_db_update = $this->fix_espresso_db_upgrade_option(); |
|
272 | + $request_type = $this->detect_req_type($espresso_db_update); |
|
273 | + //EEH_Debug_Tools::printr( $request_type, '$request_type', __FILE__, __LINE__ ); |
|
274 | + switch ($request_type) { |
|
275 | + case EE_System::req_type_new_activation: |
|
276 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__new_activation'); |
|
277 | + $this->_handle_core_version_change($espresso_db_update); |
|
278 | + break; |
|
279 | + case EE_System::req_type_reactivation: |
|
280 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__reactivation'); |
|
281 | + $this->_handle_core_version_change($espresso_db_update); |
|
282 | + break; |
|
283 | + case EE_System::req_type_upgrade: |
|
284 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__upgrade'); |
|
285 | + //migrations may be required now that we've upgraded |
|
286 | + EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old(); |
|
287 | + $this->_handle_core_version_change($espresso_db_update); |
|
288 | + // echo "done upgrade";die; |
|
289 | + break; |
|
290 | + case EE_System::req_type_downgrade: |
|
291 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__downgrade'); |
|
292 | + //its possible migrations are no longer required |
|
293 | + EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old(); |
|
294 | + $this->_handle_core_version_change($espresso_db_update); |
|
295 | + break; |
|
296 | + case EE_System::req_type_normal: |
|
297 | + default: |
|
298 | + // $this->_maybe_redirect_to_ee_about(); |
|
299 | + break; |
|
300 | + } |
|
301 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__complete'); |
|
302 | + } |
|
303 | + |
|
304 | + |
|
305 | + |
|
306 | + /** |
|
307 | + * Updates the list of installed versions and sets hooks for |
|
308 | + * initializing the database later during the request |
|
309 | + * |
|
310 | + * @param array $espresso_db_update |
|
311 | + */ |
|
312 | + protected function _handle_core_version_change($espresso_db_update) |
|
313 | + { |
|
314 | + $this->update_list_of_installed_versions($espresso_db_update); |
|
315 | + //get ready to verify the DB is ok (provided we aren't in maintenance mode, of course) |
|
316 | + add_action('AHEE__EE_System__perform_activations_upgrades_and_migrations', |
|
317 | + array($this, 'initialize_db_if_no_migrations_required')); |
|
318 | + } |
|
319 | + |
|
320 | + |
|
321 | + |
|
322 | + /** |
|
323 | + * standardizes the wp option 'espresso_db_upgrade' which actually stores |
|
324 | + * information about what versions of EE have been installed and activated, |
|
325 | + * NOT necessarily the state of the database |
|
326 | + * |
|
327 | + * @param null $espresso_db_update |
|
328 | + * @internal param array $espresso_db_update_value the value of the WordPress option. If not supplied, fetches it |
|
329 | + * from the options table |
|
330 | + * @return array the correct value of 'espresso_db_upgrade', after saving it, if it needed correction |
|
331 | + */ |
|
332 | + private function fix_espresso_db_upgrade_option($espresso_db_update = null) |
|
333 | + { |
|
334 | + do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__begin', $espresso_db_update); |
|
335 | + if ( ! $espresso_db_update) { |
|
336 | + $espresso_db_update = get_option('espresso_db_update'); |
|
337 | + } |
|
338 | + // check that option is an array |
|
339 | + if ( ! is_array($espresso_db_update)) { |
|
340 | + // if option is FALSE, then it never existed |
|
341 | + if ($espresso_db_update === false) { |
|
342 | + // make $espresso_db_update an array and save option with autoload OFF |
|
343 | + $espresso_db_update = array(); |
|
344 | + add_option('espresso_db_update', $espresso_db_update, '', 'no'); |
|
345 | + } else { |
|
346 | + // option is NOT FALSE but also is NOT an array, so make it an array and save it |
|
347 | + $espresso_db_update = array($espresso_db_update => array()); |
|
348 | + update_option('espresso_db_update', $espresso_db_update); |
|
349 | + } |
|
350 | + } else { |
|
351 | + $corrected_db_update = array(); |
|
352 | + //if IS an array, but is it an array where KEYS are version numbers, and values are arrays? |
|
353 | + foreach ($espresso_db_update as $should_be_version_string => $should_be_array) { |
|
354 | + if (is_int($should_be_version_string) && ! is_array($should_be_array)) { |
|
355 | + //the key is an int, and the value IS NOT an array |
|
356 | + //so it must be numerically-indexed, where values are versions installed... |
|
357 | + //fix it! |
|
358 | + $version_string = $should_be_array; |
|
359 | + $corrected_db_update[$version_string] = array('unknown-date'); |
|
360 | + } else { |
|
361 | + //ok it checks out |
|
362 | + $corrected_db_update[$should_be_version_string] = $should_be_array; |
|
363 | + } |
|
364 | + } |
|
365 | + $espresso_db_update = $corrected_db_update; |
|
366 | + update_option('espresso_db_update', $espresso_db_update); |
|
367 | + } |
|
368 | + do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__complete', $espresso_db_update); |
|
369 | + return $espresso_db_update; |
|
370 | + } |
|
371 | + |
|
372 | + |
|
373 | + |
|
374 | + /** |
|
375 | + * Does the traditional work of setting up the plugin's database and adding default data. |
|
376 | + * If migration script/process did not exist, this is what would happen on every activation/reactivation/upgrade. |
|
377 | + * NOTE: if we're in maintenance mode (which would be the case if we detect there are data |
|
378 | + * migration scripts that need to be run and a version change happens), enqueues core for database initialization, |
|
379 | + * so that it will be done when migrations are finished |
|
380 | + * |
|
381 | + * @param boolean $initialize_addons_too if true, we double-check addons' database tables etc too; |
|
382 | + * @param boolean $verify_schema if true will re-check the database tables have the correct schema. |
|
383 | + * This is a resource-intensive job |
|
384 | + * so we prefer to only do it when necessary |
|
385 | + * @return void |
|
386 | + */ |
|
387 | + public function initialize_db_if_no_migrations_required($initialize_addons_too = false, $verify_schema = true) |
|
388 | + { |
|
389 | + $request_type = $this->detect_req_type(); |
|
390 | + //only initialize system if we're not in maintenance mode. |
|
391 | + if (EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance) { |
|
392 | + update_option('ee_flush_rewrite_rules', true); |
|
393 | + if ($verify_schema) { |
|
394 | + EEH_Activation::initialize_db_and_folders(); |
|
395 | + } |
|
396 | + EEH_Activation::initialize_db_content(); |
|
397 | + EEH_Activation::system_initialization(); |
|
398 | + if ($initialize_addons_too) { |
|
399 | + $this->initialize_addons(); |
|
400 | + } |
|
401 | + } else { |
|
402 | + EE_Data_Migration_Manager::instance()->enqueue_db_initialization_for('Core'); |
|
403 | + } |
|
404 | + if ($request_type === EE_System::req_type_new_activation |
|
405 | + || $request_type === EE_System::req_type_reactivation |
|
406 | + || ( |
|
407 | + $request_type === EE_System::req_type_upgrade |
|
408 | + && $this->is_major_version_change() |
|
409 | + ) |
|
410 | + ) { |
|
411 | + add_action('AHEE__EE_System__initialize_last', array($this, 'redirect_to_about_ee'), 9); |
|
412 | + } |
|
413 | + } |
|
414 | + |
|
415 | + |
|
416 | + |
|
417 | + /** |
|
418 | + * Initializes the db for all registered addons |
|
419 | + */ |
|
420 | + public function initialize_addons() |
|
421 | + { |
|
422 | + //foreach registered addon, make sure its db is up-to-date too |
|
423 | + foreach ($this->registry->addons as $addon) { |
|
424 | + $addon->initialize_db_if_no_migrations_required(); |
|
425 | + } |
|
426 | + } |
|
427 | + |
|
428 | + |
|
429 | + |
|
430 | + /** |
|
431 | + * Adds the current code version to the saved wp option which stores a list of all ee versions ever installed. |
|
432 | + * |
|
433 | + * @param array $version_history |
|
434 | + * @param string $current_version_to_add version to be added to the version history |
|
435 | + * @return boolean success as to whether or not this option was changed |
|
436 | + */ |
|
437 | + public function update_list_of_installed_versions($version_history = null, $current_version_to_add = null) |
|
438 | + { |
|
439 | + if ( ! $version_history) { |
|
440 | + $version_history = $this->fix_espresso_db_upgrade_option($version_history); |
|
441 | + } |
|
442 | + if ($current_version_to_add == null) { |
|
443 | + $current_version_to_add = espresso_version(); |
|
444 | + } |
|
445 | + $version_history[$current_version_to_add][] = date('Y-m-d H:i:s', time()); |
|
446 | + // re-save |
|
447 | + return update_option('espresso_db_update', $version_history); |
|
448 | + } |
|
449 | + |
|
450 | + |
|
451 | + |
|
452 | + /** |
|
453 | + * Detects if the current version indicated in the has existed in the list of |
|
454 | + * previously-installed versions of EE (espresso_db_update). Does NOT modify it (ie, no side-effect) |
|
455 | + * |
|
456 | + * @param array $espresso_db_update array from the wp option stored under the name 'espresso_db_update'. |
|
457 | + * If not supplied, fetches it from the options table. |
|
458 | + * Also, caches its result so later parts of the code can also know whether |
|
459 | + * there's been an update or not. This way we can add the current version to |
|
460 | + * espresso_db_update, but still know if this is a new install or not |
|
461 | + * @return int one of the constants on EE_System::req_type_ |
|
462 | + */ |
|
463 | + public function detect_req_type($espresso_db_update = null) |
|
464 | + { |
|
465 | + if ($this->_req_type === null) { |
|
466 | + $espresso_db_update = ! empty($espresso_db_update) ? $espresso_db_update |
|
467 | + : $this->fix_espresso_db_upgrade_option(); |
|
468 | + $this->_req_type = $this->detect_req_type_given_activation_history($espresso_db_update, |
|
469 | + 'ee_espresso_activation', espresso_version()); |
|
470 | + $this->_major_version_change = $this->_detect_major_version_change($espresso_db_update); |
|
471 | + } |
|
472 | + return $this->_req_type; |
|
473 | + } |
|
474 | + |
|
475 | + |
|
476 | + |
|
477 | + /** |
|
478 | + * Returns whether or not there was a non-micro version change (ie, change in either |
|
479 | + * the first or second number in the version. Eg 4.9.0.rc.001 to 4.10.0.rc.000, |
|
480 | + * but not 4.9.0.rc.0001 to 4.9.1.rc.0001 |
|
481 | + * |
|
482 | + * @param $activation_history |
|
483 | + * @return bool |
|
484 | + */ |
|
485 | + protected function _detect_major_version_change($activation_history) |
|
486 | + { |
|
487 | + $previous_version = EE_System::_get_most_recently_active_version_from_activation_history($activation_history); |
|
488 | + $previous_version_parts = explode('.', $previous_version); |
|
489 | + $current_version_parts = explode('.', espresso_version()); |
|
490 | + return isset($previous_version_parts[0], $previous_version_parts[1], $current_version_parts[0], $current_version_parts[1]) |
|
491 | + && ($previous_version_parts[0] !== $current_version_parts[0] |
|
492 | + || $previous_version_parts[1] !== $current_version_parts[1] |
|
493 | + ); |
|
494 | + } |
|
495 | + |
|
496 | + |
|
497 | + |
|
498 | + /** |
|
499 | + * Returns true if either the major or minor version of EE changed during this request. |
|
500 | + * Eg 4.9.0.rc.001 to 4.10.0.rc.000, but not 4.9.0.rc.0001 to 4.9.1.rc.0001 |
|
501 | + * |
|
502 | + * @return bool |
|
503 | + */ |
|
504 | + public function is_major_version_change() |
|
505 | + { |
|
506 | + return $this->_major_version_change; |
|
507 | + } |
|
508 | + |
|
509 | + |
|
510 | + |
|
511 | + /** |
|
512 | + * Determines the request type for any ee addon, given three piece of info: the current array of activation |
|
513 | + * histories (for core that' 'espresso_db_update' wp option); the name of the wordpress option which is temporarily |
|
514 | + * set upon activation of the plugin (for core it's 'ee_espresso_activation'); and the version that this plugin was |
|
515 | + * just activated to (for core that will always be espresso_version()) |
|
516 | + * |
|
517 | + * @param array $activation_history_for_addon the option's value which stores the activation history for this |
|
518 | + * ee plugin. for core that's 'espresso_db_update' |
|
519 | + * @param string $activation_indicator_option_name the name of the wordpress option that is temporarily set to |
|
520 | + * indicate that this plugin was just activated |
|
521 | + * @param string $version_to_upgrade_to the version that was just upgraded to (for core that will be |
|
522 | + * espresso_version()) |
|
523 | + * @return int one of the constants on EE_System::req_type_* |
|
524 | + */ |
|
525 | + public static function detect_req_type_given_activation_history( |
|
526 | + $activation_history_for_addon, |
|
527 | + $activation_indicator_option_name, |
|
528 | + $version_to_upgrade_to |
|
529 | + ) { |
|
530 | + $version_is_higher = self::_new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to); |
|
531 | + if ($activation_history_for_addon) { |
|
532 | + //it exists, so this isn't a completely new install |
|
533 | + //check if this version already in that list of previously installed versions |
|
534 | + if ( ! isset($activation_history_for_addon[$version_to_upgrade_to])) { |
|
535 | + //it a version we haven't seen before |
|
536 | + if ($version_is_higher === 1) { |
|
537 | + $req_type = EE_System::req_type_upgrade; |
|
538 | + } else { |
|
539 | + $req_type = EE_System::req_type_downgrade; |
|
540 | + } |
|
541 | + delete_option($activation_indicator_option_name); |
|
542 | + } else { |
|
543 | + // its not an update. maybe a reactivation? |
|
544 | + if (get_option($activation_indicator_option_name, false)) { |
|
545 | + if ($version_is_higher === -1) { |
|
546 | + $req_type = EE_System::req_type_downgrade; |
|
547 | + } elseif ($version_is_higher === 0) { |
|
548 | + //we've seen this version before, but it's an activation. must be a reactivation |
|
549 | + $req_type = EE_System::req_type_reactivation; |
|
550 | + } else {//$version_is_higher === 1 |
|
551 | + $req_type = EE_System::req_type_upgrade; |
|
552 | + } |
|
553 | + delete_option($activation_indicator_option_name); |
|
554 | + } else { |
|
555 | + //we've seen this version before and the activation indicate doesn't show it was just activated |
|
556 | + if ($version_is_higher === -1) { |
|
557 | + $req_type = EE_System::req_type_downgrade; |
|
558 | + } elseif ($version_is_higher === 0) { |
|
559 | + //we've seen this version before and it's not an activation. its normal request |
|
560 | + $req_type = EE_System::req_type_normal; |
|
561 | + } else {//$version_is_higher === 1 |
|
562 | + $req_type = EE_System::req_type_upgrade; |
|
563 | + } |
|
564 | + } |
|
565 | + } |
|
566 | + } else { |
|
567 | + //brand new install |
|
568 | + $req_type = EE_System::req_type_new_activation; |
|
569 | + delete_option($activation_indicator_option_name); |
|
570 | + } |
|
571 | + return $req_type; |
|
572 | + } |
|
573 | + |
|
574 | + |
|
575 | + |
|
576 | + /** |
|
577 | + * Detects if the $version_to_upgrade_to is higher than the most recent version in |
|
578 | + * the $activation_history_for_addon |
|
579 | + * |
|
580 | + * @param array $activation_history_for_addon (keys are versions, values are arrays of times activated, |
|
581 | + * sometimes containing 'unknown-date' |
|
582 | + * @param string $version_to_upgrade_to (current version) |
|
583 | + * @return int results of version_compare( $version_to_upgrade_to, $most_recently_active_version ). |
|
584 | + * ie, -1 if $version_to_upgrade_to is LOWER (downgrade); |
|
585 | + * 0 if $version_to_upgrade_to MATCHES (reactivation or normal request); |
|
586 | + * 1 if $version_to_upgrade_to is HIGHER (upgrade) ; |
|
587 | + */ |
|
588 | + protected static function _new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to) |
|
589 | + { |
|
590 | + //find the most recently-activated version |
|
591 | + $most_recently_active_version = EE_System::_get_most_recently_active_version_from_activation_history($activation_history_for_addon); |
|
592 | + return version_compare($version_to_upgrade_to, $most_recently_active_version); |
|
593 | + } |
|
594 | + |
|
595 | + |
|
596 | + |
|
597 | + /** |
|
598 | + * Gets the most recently active version listed in the activation history, |
|
599 | + * and if none are found (ie, it's a brand new install) returns '0.0.0.dev.000'. |
|
600 | + * |
|
601 | + * @param array $activation_history (keys are versions, values are arrays of times activated, |
|
602 | + * sometimes containing 'unknown-date' |
|
603 | + * @return string |
|
604 | + */ |
|
605 | + protected static function _get_most_recently_active_version_from_activation_history($activation_history) |
|
606 | + { |
|
607 | + $most_recently_active_version_activation = '1970-01-01 00:00:00'; |
|
608 | + $most_recently_active_version = '0.0.0.dev.000'; |
|
609 | + if (is_array($activation_history)) { |
|
610 | + foreach ($activation_history as $version => $times_activated) { |
|
611 | + //check there is a record of when this version was activated. Otherwise, |
|
612 | + //mark it as unknown |
|
613 | + if ( ! $times_activated) { |
|
614 | + $times_activated = array('unknown-date'); |
|
615 | + } |
|
616 | + if (is_string($times_activated)) { |
|
617 | + $times_activated = array($times_activated); |
|
618 | + } |
|
619 | + foreach ($times_activated as $an_activation) { |
|
620 | + if ($an_activation != 'unknown-date' && $an_activation > $most_recently_active_version_activation) { |
|
621 | + $most_recently_active_version = $version; |
|
622 | + $most_recently_active_version_activation = $an_activation == 'unknown-date' |
|
623 | + ? '1970-01-01 00:00:00' : $an_activation; |
|
624 | + } |
|
625 | + } |
|
626 | + } |
|
627 | + } |
|
628 | + return $most_recently_active_version; |
|
629 | + } |
|
630 | + |
|
631 | + |
|
632 | + |
|
633 | + /** |
|
634 | + * This redirects to the about EE page after activation |
|
635 | + * |
|
636 | + * @return void |
|
637 | + */ |
|
638 | + public function redirect_to_about_ee() |
|
639 | + { |
|
640 | + $notices = EE_Error::get_notices(false); |
|
641 | + //if current user is an admin and it's not an ajax or rest request |
|
642 | + if ( |
|
643 | + ! (defined('DOING_AJAX') && DOING_AJAX) |
|
644 | + && ! (defined('REST_REQUEST') && REST_REQUEST) |
|
645 | + && ! isset($notices['errors']) |
|
646 | + && apply_filters( |
|
647 | + 'FHEE__EE_System__redirect_to_about_ee__do_redirect', |
|
648 | + $this->registry->CAP->current_user_can('manage_options', 'espresso_about_default') |
|
649 | + ) |
|
650 | + ) { |
|
651 | + $query_params = array('page' => 'espresso_about'); |
|
652 | + if (EE_System::instance()->detect_req_type() == EE_System::req_type_new_activation) { |
|
653 | + $query_params['new_activation'] = true; |
|
654 | + } |
|
655 | + if (EE_System::instance()->detect_req_type() == EE_System::req_type_reactivation) { |
|
656 | + $query_params['reactivation'] = true; |
|
657 | + } |
|
658 | + $url = add_query_arg($query_params, admin_url('admin.php')); |
|
659 | + wp_safe_redirect($url); |
|
660 | + exit(); |
|
661 | + } |
|
662 | + } |
|
663 | + |
|
664 | + |
|
665 | + |
|
666 | + /** |
|
667 | + * load_core_configuration |
|
668 | + * this is hooked into 'AHEE__EE_Bootstrap__load_core_configuration' |
|
669 | + * which runs during the WP 'plugins_loaded' action at priority 5 |
|
670 | + * |
|
671 | + * @return void |
|
672 | + */ |
|
673 | + public function load_core_configuration() |
|
674 | + { |
|
675 | + do_action('AHEE__EE_System__load_core_configuration__begin', $this); |
|
676 | + $this->registry->load_core('EE_Load_Textdomain'); |
|
677 | + //load textdomain |
|
678 | + EE_Load_Textdomain::load_textdomain(); |
|
679 | + // load and setup EE_Config and EE_Network_Config |
|
680 | + $this->registry->load_core('Config'); |
|
681 | + $this->registry->load_core('Network_Config'); |
|
682 | + // setup autoloaders |
|
683 | + // enable logging? |
|
684 | + if ($this->registry->CFG->admin->use_full_logging) { |
|
685 | + $this->registry->load_core('Log'); |
|
686 | + } |
|
687 | + // check for activation errors |
|
688 | + $activation_errors = get_option('ee_plugin_activation_errors', false); |
|
689 | + if ($activation_errors) { |
|
690 | + EE_Error::add_error($activation_errors, __FILE__, __FUNCTION__, __LINE__); |
|
691 | + update_option('ee_plugin_activation_errors', false); |
|
692 | + } |
|
693 | + // get model names |
|
694 | + $this->_parse_model_names(); |
|
695 | + do_action('AHEE__EE_System__load_core_configuration__complete', $this); |
|
696 | + } |
|
697 | + |
|
698 | + |
|
699 | + |
|
700 | + /** |
|
701 | + * cycles through all of the models/*.model.php files, and assembles an array of model names |
|
702 | + * |
|
703 | + * @return void |
|
704 | + */ |
|
705 | + private function _parse_model_names() |
|
706 | + { |
|
707 | + //get all the files in the EE_MODELS folder that end in .model.php |
|
708 | + $models = glob(EE_MODELS . '*.model.php'); |
|
709 | + $model_names = array(); |
|
710 | + $non_abstract_db_models = array(); |
|
711 | + foreach ($models as $model) { |
|
712 | + // get model classname |
|
713 | + $classname = EEH_File::get_classname_from_filepath_with_standard_filename($model); |
|
714 | + $short_name = str_replace('EEM_', '', $classname); |
|
715 | + $reflectionClass = new ReflectionClass($classname); |
|
716 | + if ($reflectionClass->isSubclassOf('EEM_Base') && ! $reflectionClass->isAbstract()) { |
|
717 | + $non_abstract_db_models[$short_name] = $classname; |
|
718 | + } |
|
719 | + $model_names[$short_name] = $classname; |
|
720 | + } |
|
721 | + $this->registry->models = apply_filters('FHEE__EE_System__parse_model_names', $model_names); |
|
722 | + $this->registry->non_abstract_db_models = apply_filters('FHEE__EE_System__parse_implemented_model_names', |
|
723 | + $non_abstract_db_models); |
|
724 | + } |
|
725 | + |
|
726 | + |
|
727 | + |
|
728 | + /** |
|
729 | + * register_shortcodes_modules_and_widgets |
|
730 | + * generate lists of shortcodes and modules, then verify paths and classes |
|
731 | + * This is hooked into 'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets' |
|
732 | + * which runs during the WP 'plugins_loaded' action at priority 7 |
|
733 | + * |
|
734 | + * @access public |
|
735 | + * @return void |
|
736 | + */ |
|
737 | + public function register_shortcodes_modules_and_widgets() |
|
738 | + { |
|
739 | + try { |
|
740 | + // load, register, and add shortcodes the new way |
|
741 | + new ShortcodesManager( |
|
742 | + // and the old way, but we'll put it under control of the new system |
|
743 | + EE_Config::getLegacyShortcodesManager() |
|
744 | + ); |
|
745 | + } catch (Exception $exception) { |
|
746 | + new ExceptionStackTraceDisplay($exception); |
|
747 | + } |
|
748 | + do_action('AHEE__EE_System__register_shortcodes_modules_and_widgets'); |
|
749 | + // check for addons using old hookpoint |
|
750 | + if (has_action('AHEE__EE_System__register_shortcodes_modules_and_addons')) { |
|
751 | + $this->_incompatible_addon_error(); |
|
752 | + } |
|
753 | + } |
|
754 | + |
|
755 | + |
|
756 | + |
|
757 | + /** |
|
758 | + * _incompatible_addon_error |
|
759 | + * |
|
760 | + * @access public |
|
761 | + * @return void |
|
762 | + */ |
|
763 | + private function _incompatible_addon_error() |
|
764 | + { |
|
765 | + // get array of classes hooking into here |
|
766 | + $class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook('AHEE__EE_System__register_shortcodes_modules_and_addons'); |
|
767 | + if ( ! empty($class_names)) { |
|
768 | + $msg = __('The following plugins, addons, or modules appear to be incompatible with this version of Event Espresso and were automatically deactivated to avoid fatal errors:', |
|
769 | + 'event_espresso'); |
|
770 | + $msg .= '<ul>'; |
|
771 | + foreach ($class_names as $class_name) { |
|
772 | + $msg .= '<li><b>Event Espresso - ' . str_replace(array('EE_', 'EEM_', 'EED_', 'EES_', 'EEW_'), '', |
|
773 | + $class_name) . '</b></li>'; |
|
774 | + } |
|
775 | + $msg .= '</ul>'; |
|
776 | + $msg .= __('Compatibility issues can be avoided and/or resolved by keeping addons and plugins updated to the latest version.', |
|
777 | + 'event_espresso'); |
|
778 | + // save list of incompatible addons to wp-options for later use |
|
779 | + add_option('ee_incompatible_addons', $class_names, '', 'no'); |
|
780 | + if (is_admin()) { |
|
781 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
782 | + } |
|
783 | + } |
|
784 | + } |
|
785 | + |
|
786 | + |
|
787 | + |
|
788 | + /** |
|
789 | + * brew_espresso |
|
790 | + * begins the process of setting hooks for initializing EE in the correct order |
|
791 | + * This is happening on the 'AHEE__EE_Bootstrap__brew_espresso' hookpoint |
|
792 | + * which runs during the WP 'plugins_loaded' action at priority 9 |
|
793 | + * |
|
794 | + * @return void |
|
795 | + */ |
|
796 | + public function brew_espresso() |
|
797 | + { |
|
798 | + do_action('AHEE__EE_System__brew_espresso__begin', $this); |
|
799 | + // load some final core systems |
|
800 | + add_action('init', array($this, 'set_hooks_for_core'), 1); |
|
801 | + add_action('init', array($this, 'perform_activations_upgrades_and_migrations'), 3); |
|
802 | + add_action('init', array($this, 'load_CPTs_and_session'), 5); |
|
803 | + add_action('init', array($this, 'load_controllers'), 7); |
|
804 | + add_action('init', array($this, 'core_loaded_and_ready'), 9); |
|
805 | + add_action('init', array($this, 'initialize'), 10); |
|
806 | + add_action('init', array($this, 'initialize_last'), 100); |
|
807 | + add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 100); |
|
808 | + add_action('admin_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 100); |
|
809 | + add_action('admin_bar_menu', array($this, 'espresso_toolbar_items'), 100); |
|
810 | + if (is_admin() && apply_filters('FHEE__EE_System__brew_espresso__load_pue', true)) { |
|
811 | + // pew pew pew |
|
812 | + $this->registry->load_core('PUE'); |
|
813 | + do_action('AHEE__EE_System__brew_espresso__after_pue_init'); |
|
814 | + } |
|
815 | + do_action('AHEE__EE_System__brew_espresso__complete', $this); |
|
816 | + } |
|
817 | + |
|
818 | + |
|
819 | + |
|
820 | + /** |
|
821 | + * set_hooks_for_core |
|
822 | + * |
|
823 | + * @access public |
|
824 | + * @return void |
|
825 | + */ |
|
826 | + public function set_hooks_for_core() |
|
827 | + { |
|
828 | + $this->_deactivate_incompatible_addons(); |
|
829 | + do_action('AHEE__EE_System__set_hooks_for_core'); |
|
830 | + } |
|
831 | + |
|
832 | + |
|
833 | + |
|
834 | + /** |
|
835 | + * Using the information gathered in EE_System::_incompatible_addon_error, |
|
836 | + * deactivates any addons considered incompatible with the current version of EE |
|
837 | + */ |
|
838 | + private function _deactivate_incompatible_addons() |
|
839 | + { |
|
840 | + $incompatible_addons = get_option('ee_incompatible_addons', array()); |
|
841 | + if ( ! empty($incompatible_addons)) { |
|
842 | + $active_plugins = get_option('active_plugins', array()); |
|
843 | + foreach ($active_plugins as $active_plugin) { |
|
844 | + foreach ($incompatible_addons as $incompatible_addon) { |
|
845 | + if (strpos($active_plugin, $incompatible_addon) !== false) { |
|
846 | + unset($_GET['activate']); |
|
847 | + espresso_deactivate_plugin($active_plugin); |
|
848 | + } |
|
849 | + } |
|
850 | + } |
|
851 | + } |
|
852 | + } |
|
853 | + |
|
854 | + |
|
855 | + |
|
856 | + /** |
|
857 | + * perform_activations_upgrades_and_migrations |
|
858 | + * |
|
859 | + * @access public |
|
860 | + * @return void |
|
861 | + */ |
|
862 | + public function perform_activations_upgrades_and_migrations() |
|
863 | + { |
|
864 | + //first check if we had previously attempted to setup EE's directories but failed |
|
865 | + if (EEH_Activation::upload_directories_incomplete()) { |
|
866 | + EEH_Activation::create_upload_directories(); |
|
867 | + } |
|
868 | + do_action('AHEE__EE_System__perform_activations_upgrades_and_migrations'); |
|
869 | + } |
|
870 | + |
|
871 | + |
|
872 | + |
|
873 | + /** |
|
874 | + * load_CPTs_and_session |
|
875 | + * |
|
876 | + * @access public |
|
877 | + * @return void |
|
878 | + */ |
|
879 | + public function load_CPTs_and_session() |
|
880 | + { |
|
881 | + do_action('AHEE__EE_System__load_CPTs_and_session__start'); |
|
882 | + // register Custom Post Types |
|
883 | + $this->registry->load_core('Register_CPTs'); |
|
884 | + do_action('AHEE__EE_System__load_CPTs_and_session__complete'); |
|
885 | + } |
|
886 | + |
|
887 | + |
|
888 | + |
|
889 | + /** |
|
890 | + * load_controllers |
|
891 | + * this is the best place to load any additional controllers that needs access to EE core. |
|
892 | + * it is expected that all basic core EE systems, that are not dependant on the current request are loaded at this |
|
893 | + * time |
|
894 | + * |
|
895 | + * @access public |
|
896 | + * @return void |
|
897 | + */ |
|
898 | + public function load_controllers() |
|
899 | + { |
|
900 | + do_action('AHEE__EE_System__load_controllers__start'); |
|
901 | + // let's get it started |
|
902 | + if ( ! is_admin() && ! EE_Maintenance_Mode::instance()->level()) { |
|
903 | + do_action('AHEE__EE_System__load_controllers__load_front_controllers'); |
|
904 | + $this->registry->load_core('Front_Controller'); |
|
905 | + } else if ( ! EE_FRONT_AJAX) { |
|
906 | + do_action('AHEE__EE_System__load_controllers__load_admin_controllers'); |
|
907 | + EE_Registry::instance()->load_core('Admin'); |
|
908 | + } |
|
909 | + do_action('AHEE__EE_System__load_controllers__complete'); |
|
910 | + } |
|
911 | + |
|
912 | + |
|
913 | + |
|
914 | + /** |
|
915 | + * core_loaded_and_ready |
|
916 | + * all of the basic EE core should be loaded at this point and available regardless of M-Mode |
|
917 | + * |
|
918 | + * @access public |
|
919 | + * @return void |
|
920 | + */ |
|
921 | + public function core_loaded_and_ready() |
|
922 | + { |
|
923 | + do_action('AHEE__EE_System__core_loaded_and_ready'); |
|
924 | + // load_espresso_template_tags |
|
925 | + if (is_readable(EE_PUBLIC . 'template_tags.php')) { |
|
926 | + require_once(EE_PUBLIC . 'template_tags.php'); |
|
927 | + } |
|
928 | + do_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons'); |
|
929 | + $this->registry->load_core('Session'); |
|
930 | + } |
|
931 | + |
|
932 | + |
|
933 | + |
|
934 | + /** |
|
935 | + * initialize |
|
936 | + * this is the best place to begin initializing client code |
|
937 | + * |
|
938 | + * @access public |
|
939 | + * @return void |
|
940 | + */ |
|
941 | + public function initialize() |
|
942 | + { |
|
943 | + do_action('AHEE__EE_System__initialize'); |
|
944 | + } |
|
945 | + |
|
946 | + |
|
947 | + |
|
948 | + /** |
|
949 | + * initialize_last |
|
950 | + * this is run really late during the WP init hookpoint, and ensures that mostly everything else that needs to |
|
951 | + * initialize has done so |
|
952 | + * |
|
953 | + * @access public |
|
954 | + * @return void |
|
955 | + */ |
|
956 | + public function initialize_last() |
|
957 | + { |
|
958 | + do_action('AHEE__EE_System__initialize_last'); |
|
959 | + } |
|
960 | + |
|
961 | + |
|
962 | + |
|
963 | + /** |
|
964 | + * set_hooks_for_shortcodes_modules_and_addons |
|
965 | + * this is the best place for other systems to set callbacks for hooking into other parts of EE |
|
966 | + * this happens at the very beginning of the wp_loaded hookpoint |
|
967 | + * |
|
968 | + * @access public |
|
969 | + * @return void |
|
970 | + */ |
|
971 | + public function set_hooks_for_shortcodes_modules_and_addons() |
|
972 | + { |
|
973 | + // do_action( 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons' ); |
|
974 | + } |
|
975 | + |
|
976 | + |
|
977 | + |
|
978 | + /** |
|
979 | + * do_not_cache |
|
980 | + * sets no cache headers and defines no cache constants for WP plugins |
|
981 | + * |
|
982 | + * @access public |
|
983 | + * @return void |
|
984 | + */ |
|
985 | + public static function do_not_cache() |
|
986 | + { |
|
987 | + // set no cache constants |
|
988 | + if ( ! defined('DONOTCACHEPAGE')) { |
|
989 | + define('DONOTCACHEPAGE', true); |
|
990 | + } |
|
991 | + if ( ! defined('DONOTCACHCEOBJECT')) { |
|
992 | + define('DONOTCACHCEOBJECT', true); |
|
993 | + } |
|
994 | + if ( ! defined('DONOTCACHEDB')) { |
|
995 | + define('DONOTCACHEDB', true); |
|
996 | + } |
|
997 | + // add no cache headers |
|
998 | + add_action('send_headers', array('EE_System', 'nocache_headers'), 10); |
|
999 | + // plus a little extra for nginx and Google Chrome |
|
1000 | + add_filter('nocache_headers', array('EE_System', 'extra_nocache_headers'), 10, 1); |
|
1001 | + // prevent browsers from prefetching of the rel='next' link, because it may contain content that interferes with the registration process |
|
1002 | + remove_action('wp_head', 'adjacent_posts_rel_link_wp_head'); |
|
1003 | + } |
|
1004 | + |
|
1005 | + |
|
1006 | + |
|
1007 | + /** |
|
1008 | + * extra_nocache_headers |
|
1009 | + * |
|
1010 | + * @access public |
|
1011 | + * @param $headers |
|
1012 | + * @return array |
|
1013 | + */ |
|
1014 | + public static function extra_nocache_headers($headers) |
|
1015 | + { |
|
1016 | + // for NGINX |
|
1017 | + $headers['X-Accel-Expires'] = 0; |
|
1018 | + // plus extra for Google Chrome since it doesn't seem to respect "no-cache", but WILL respect "no-store" |
|
1019 | + $headers['Cache-Control'] = 'no-store, no-cache, must-revalidate, max-age=0'; |
|
1020 | + return $headers; |
|
1021 | + } |
|
1022 | + |
|
1023 | + |
|
1024 | + |
|
1025 | + /** |
|
1026 | + * nocache_headers |
|
1027 | + * |
|
1028 | + * @access public |
|
1029 | + * @return void |
|
1030 | + */ |
|
1031 | + public static function nocache_headers() |
|
1032 | + { |
|
1033 | + nocache_headers(); |
|
1034 | + } |
|
1035 | + |
|
1036 | + |
|
1037 | + |
|
1038 | + /** |
|
1039 | + * espresso_toolbar_items |
|
1040 | + * |
|
1041 | + * @access public |
|
1042 | + * @param WP_Admin_Bar $admin_bar |
|
1043 | + * @return void |
|
1044 | + */ |
|
1045 | + public function espresso_toolbar_items(WP_Admin_Bar $admin_bar) |
|
1046 | + { |
|
1047 | + // if in full M-Mode, or its an AJAX request, or user is NOT an admin |
|
1048 | + if (EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance |
|
1049 | + || defined('DOING_AJAX') |
|
1050 | + || ! $this->registry->CAP->current_user_can('ee_read_ee', 'ee_admin_bar_menu_top_level') |
|
1051 | + ) { |
|
1052 | + return; |
|
1053 | + } |
|
1054 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1055 | + $menu_class = 'espresso_menu_item_class'; |
|
1056 | + //we don't use the constants EVENTS_ADMIN_URL or REG_ADMIN_URL |
|
1057 | + //because they're only defined in each of their respective constructors |
|
1058 | + //and this might be a frontend request, in which case they aren't available |
|
1059 | + $events_admin_url = admin_url("admin.php?page=espresso_events"); |
|
1060 | + $reg_admin_url = admin_url("admin.php?page=espresso_registrations"); |
|
1061 | + $extensions_admin_url = admin_url("admin.php?page=espresso_packages"); |
|
1062 | + //Top Level |
|
1063 | + $admin_bar->add_menu(array( |
|
1064 | + 'id' => 'espresso-toolbar', |
|
1065 | + 'title' => '<span class="ee-icon ee-icon-ee-cup-thick ee-icon-size-20"></span><span class="ab-label">' |
|
1066 | + . _x('Event Espresso', 'admin bar menu group label', 'event_espresso') |
|
1067 | + . '</span>', |
|
1068 | + 'href' => $events_admin_url, |
|
1069 | + 'meta' => array( |
|
1070 | + 'title' => __('Event Espresso', 'event_espresso'), |
|
1071 | + 'class' => $menu_class . 'first', |
|
1072 | + ), |
|
1073 | + )); |
|
1074 | + //Events |
|
1075 | + if ($this->registry->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events')) { |
|
1076 | + $admin_bar->add_menu(array( |
|
1077 | + 'id' => 'espresso-toolbar-events', |
|
1078 | + 'parent' => 'espresso-toolbar', |
|
1079 | + 'title' => __('Events', 'event_espresso'), |
|
1080 | + 'href' => $events_admin_url, |
|
1081 | + 'meta' => array( |
|
1082 | + 'title' => __('Events', 'event_espresso'), |
|
1083 | + 'target' => '', |
|
1084 | + 'class' => $menu_class, |
|
1085 | + ), |
|
1086 | + )); |
|
1087 | + } |
|
1088 | + if ($this->registry->CAP->current_user_can('ee_edit_events', 'ee_admin_bar_menu_espresso-toolbar-events-new')) { |
|
1089 | + //Events Add New |
|
1090 | + $admin_bar->add_menu(array( |
|
1091 | + 'id' => 'espresso-toolbar-events-new', |
|
1092 | + 'parent' => 'espresso-toolbar-events', |
|
1093 | + 'title' => __('Add New', 'event_espresso'), |
|
1094 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'create_new'), $events_admin_url), |
|
1095 | + 'meta' => array( |
|
1096 | + 'title' => __('Add New', 'event_espresso'), |
|
1097 | + 'target' => '', |
|
1098 | + 'class' => $menu_class, |
|
1099 | + ), |
|
1100 | + )); |
|
1101 | + } |
|
1102 | + if (is_single() && (get_post_type() == 'espresso_events')) { |
|
1103 | + //Current post |
|
1104 | + global $post; |
|
1105 | + if ($this->registry->CAP->current_user_can('ee_edit_event', |
|
1106 | + 'ee_admin_bar_menu_espresso-toolbar-events-edit', $post->ID) |
|
1107 | + ) { |
|
1108 | + //Events Edit Current Event |
|
1109 | + $admin_bar->add_menu(array( |
|
1110 | + 'id' => 'espresso-toolbar-events-edit', |
|
1111 | + 'parent' => 'espresso-toolbar-events', |
|
1112 | + 'title' => __('Edit Event', 'event_espresso'), |
|
1113 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'edit', 'post' => $post->ID), |
|
1114 | + $events_admin_url), |
|
1115 | + 'meta' => array( |
|
1116 | + 'title' => __('Edit Event', 'event_espresso'), |
|
1117 | + 'target' => '', |
|
1118 | + 'class' => $menu_class, |
|
1119 | + ), |
|
1120 | + )); |
|
1121 | + } |
|
1122 | + } |
|
1123 | + //Events View |
|
1124 | + if ($this->registry->CAP->current_user_can('ee_read_events', |
|
1125 | + 'ee_admin_bar_menu_espresso-toolbar-events-view') |
|
1126 | + ) { |
|
1127 | + $admin_bar->add_menu(array( |
|
1128 | + 'id' => 'espresso-toolbar-events-view', |
|
1129 | + 'parent' => 'espresso-toolbar-events', |
|
1130 | + 'title' => __('View', 'event_espresso'), |
|
1131 | + 'href' => $events_admin_url, |
|
1132 | + 'meta' => array( |
|
1133 | + 'title' => __('View', 'event_espresso'), |
|
1134 | + 'target' => '', |
|
1135 | + 'class' => $menu_class, |
|
1136 | + ), |
|
1137 | + )); |
|
1138 | + } |
|
1139 | + if ($this->registry->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-all')) { |
|
1140 | + //Events View All |
|
1141 | + $admin_bar->add_menu(array( |
|
1142 | + 'id' => 'espresso-toolbar-events-all', |
|
1143 | + 'parent' => 'espresso-toolbar-events-view', |
|
1144 | + 'title' => __('All', 'event_espresso'), |
|
1145 | + 'href' => $events_admin_url, |
|
1146 | + 'meta' => array( |
|
1147 | + 'title' => __('All', 'event_espresso'), |
|
1148 | + 'target' => '', |
|
1149 | + 'class' => $menu_class, |
|
1150 | + ), |
|
1151 | + )); |
|
1152 | + } |
|
1153 | + if ($this->registry->CAP->current_user_can('ee_read_events', |
|
1154 | + 'ee_admin_bar_menu_espresso-toolbar-events-today') |
|
1155 | + ) { |
|
1156 | + //Events View Today |
|
1157 | + $admin_bar->add_menu(array( |
|
1158 | + 'id' => 'espresso-toolbar-events-today', |
|
1159 | + 'parent' => 'espresso-toolbar-events-view', |
|
1160 | + 'title' => __('Today', 'event_espresso'), |
|
1161 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'default', 'status' => 'today'), |
|
1162 | + $events_admin_url), |
|
1163 | + 'meta' => array( |
|
1164 | + 'title' => __('Today', 'event_espresso'), |
|
1165 | + 'target' => '', |
|
1166 | + 'class' => $menu_class, |
|
1167 | + ), |
|
1168 | + )); |
|
1169 | + } |
|
1170 | + if ($this->registry->CAP->current_user_can('ee_read_events', |
|
1171 | + 'ee_admin_bar_menu_espresso-toolbar-events-month') |
|
1172 | + ) { |
|
1173 | + //Events View This Month |
|
1174 | + $admin_bar->add_menu(array( |
|
1175 | + 'id' => 'espresso-toolbar-events-month', |
|
1176 | + 'parent' => 'espresso-toolbar-events-view', |
|
1177 | + 'title' => __('This Month', 'event_espresso'), |
|
1178 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'default', 'status' => 'month'), |
|
1179 | + $events_admin_url), |
|
1180 | + 'meta' => array( |
|
1181 | + 'title' => __('This Month', 'event_espresso'), |
|
1182 | + 'target' => '', |
|
1183 | + 'class' => $menu_class, |
|
1184 | + ), |
|
1185 | + )); |
|
1186 | + } |
|
1187 | + //Registration Overview |
|
1188 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1189 | + 'ee_admin_bar_menu_espresso-toolbar-registrations') |
|
1190 | + ) { |
|
1191 | + $admin_bar->add_menu(array( |
|
1192 | + 'id' => 'espresso-toolbar-registrations', |
|
1193 | + 'parent' => 'espresso-toolbar', |
|
1194 | + 'title' => __('Registrations', 'event_espresso'), |
|
1195 | + 'href' => $reg_admin_url, |
|
1196 | + 'meta' => array( |
|
1197 | + 'title' => __('Registrations', 'event_espresso'), |
|
1198 | + 'target' => '', |
|
1199 | + 'class' => $menu_class, |
|
1200 | + ), |
|
1201 | + )); |
|
1202 | + } |
|
1203 | + //Registration Overview Today |
|
1204 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1205 | + 'ee_admin_bar_menu_espresso-toolbar-registrations-today') |
|
1206 | + ) { |
|
1207 | + $admin_bar->add_menu(array( |
|
1208 | + 'id' => 'espresso-toolbar-registrations-today', |
|
1209 | + 'parent' => 'espresso-toolbar-registrations', |
|
1210 | + 'title' => __('Today', 'event_espresso'), |
|
1211 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'default', 'status' => 'today'), |
|
1212 | + $reg_admin_url), |
|
1213 | + 'meta' => array( |
|
1214 | + 'title' => __('Today', 'event_espresso'), |
|
1215 | + 'target' => '', |
|
1216 | + 'class' => $menu_class, |
|
1217 | + ), |
|
1218 | + )); |
|
1219 | + } |
|
1220 | + //Registration Overview Today Completed |
|
1221 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1222 | + 'ee_admin_bar_menu_espresso-toolbar-registrations-today-approved') |
|
1223 | + ) { |
|
1224 | + $admin_bar->add_menu(array( |
|
1225 | + 'id' => 'espresso-toolbar-registrations-today-approved', |
|
1226 | + 'parent' => 'espresso-toolbar-registrations-today', |
|
1227 | + 'title' => __('Approved', 'event_espresso'), |
|
1228 | + 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1229 | + 'action' => 'default', |
|
1230 | + 'status' => 'today', |
|
1231 | + '_reg_status' => EEM_Registration::status_id_approved, |
|
1232 | + ), $reg_admin_url), |
|
1233 | + 'meta' => array( |
|
1234 | + 'title' => __('Approved', 'event_espresso'), |
|
1235 | + 'target' => '', |
|
1236 | + 'class' => $menu_class, |
|
1237 | + ), |
|
1238 | + )); |
|
1239 | + } |
|
1240 | + //Registration Overview Today Pending\ |
|
1241 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1242 | + 'ee_admin_bar_menu_espresso-toolbar-registrations-today-pending') |
|
1243 | + ) { |
|
1244 | + $admin_bar->add_menu(array( |
|
1245 | + 'id' => 'espresso-toolbar-registrations-today-pending', |
|
1246 | + 'parent' => 'espresso-toolbar-registrations-today', |
|
1247 | + 'title' => __('Pending', 'event_espresso'), |
|
1248 | + 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1249 | + 'action' => 'default', |
|
1250 | + 'status' => 'today', |
|
1251 | + 'reg_status' => EEM_Registration::status_id_pending_payment, |
|
1252 | + ), $reg_admin_url), |
|
1253 | + 'meta' => array( |
|
1254 | + 'title' => __('Pending Payment', 'event_espresso'), |
|
1255 | + 'target' => '', |
|
1256 | + 'class' => $menu_class, |
|
1257 | + ), |
|
1258 | + )); |
|
1259 | + } |
|
1260 | + //Registration Overview Today Incomplete |
|
1261 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1262 | + 'ee_admin_bar_menu_espresso-toolbar-registrations-today-not-approved') |
|
1263 | + ) { |
|
1264 | + $admin_bar->add_menu(array( |
|
1265 | + 'id' => 'espresso-toolbar-registrations-today-not-approved', |
|
1266 | + 'parent' => 'espresso-toolbar-registrations-today', |
|
1267 | + 'title' => __('Not Approved', 'event_espresso'), |
|
1268 | + 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1269 | + 'action' => 'default', |
|
1270 | + 'status' => 'today', |
|
1271 | + '_reg_status' => EEM_Registration::status_id_not_approved, |
|
1272 | + ), $reg_admin_url), |
|
1273 | + 'meta' => array( |
|
1274 | + 'title' => __('Not Approved', 'event_espresso'), |
|
1275 | + 'target' => '', |
|
1276 | + 'class' => $menu_class, |
|
1277 | + ), |
|
1278 | + )); |
|
1279 | + } |
|
1280 | + //Registration Overview Today Incomplete |
|
1281 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1282 | + 'ee_admin_bar_menu_espresso-toolbar-registrations-today-cancelled') |
|
1283 | + ) { |
|
1284 | + $admin_bar->add_menu(array( |
|
1285 | + 'id' => 'espresso-toolbar-registrations-today-cancelled', |
|
1286 | + 'parent' => 'espresso-toolbar-registrations-today', |
|
1287 | + 'title' => __('Cancelled', 'event_espresso'), |
|
1288 | + 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1289 | + 'action' => 'default', |
|
1290 | + 'status' => 'today', |
|
1291 | + '_reg_status' => EEM_Registration::status_id_cancelled, |
|
1292 | + ), $reg_admin_url), |
|
1293 | + 'meta' => array( |
|
1294 | + 'title' => __('Cancelled', 'event_espresso'), |
|
1295 | + 'target' => '', |
|
1296 | + 'class' => $menu_class, |
|
1297 | + ), |
|
1298 | + )); |
|
1299 | + } |
|
1300 | + //Registration Overview This Month |
|
1301 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1302 | + 'ee_admin_bar_menu_espresso-toolbar-registrations-month') |
|
1303 | + ) { |
|
1304 | + $admin_bar->add_menu(array( |
|
1305 | + 'id' => 'espresso-toolbar-registrations-month', |
|
1306 | + 'parent' => 'espresso-toolbar-registrations', |
|
1307 | + 'title' => __('This Month', 'event_espresso'), |
|
1308 | + 'href' => EEH_URL::add_query_args_and_nonce(array('action' => 'default', 'status' => 'month'), |
|
1309 | + $reg_admin_url), |
|
1310 | + 'meta' => array( |
|
1311 | + 'title' => __('This Month', 'event_espresso'), |
|
1312 | + 'target' => '', |
|
1313 | + 'class' => $menu_class, |
|
1314 | + ), |
|
1315 | + )); |
|
1316 | + } |
|
1317 | + //Registration Overview This Month Approved |
|
1318 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1319 | + 'ee_admin_bar_menu_espresso-toolbar-registrations-month-approved') |
|
1320 | + ) { |
|
1321 | + $admin_bar->add_menu(array( |
|
1322 | + 'id' => 'espresso-toolbar-registrations-month-approved', |
|
1323 | + 'parent' => 'espresso-toolbar-registrations-month', |
|
1324 | + 'title' => __('Approved', 'event_espresso'), |
|
1325 | + 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1326 | + 'action' => 'default', |
|
1327 | + 'status' => 'month', |
|
1328 | + '_reg_status' => EEM_Registration::status_id_approved, |
|
1329 | + ), $reg_admin_url), |
|
1330 | + 'meta' => array( |
|
1331 | + 'title' => __('Approved', 'event_espresso'), |
|
1332 | + 'target' => '', |
|
1333 | + 'class' => $menu_class, |
|
1334 | + ), |
|
1335 | + )); |
|
1336 | + } |
|
1337 | + //Registration Overview This Month Pending |
|
1338 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1339 | + 'ee_admin_bar_menu_espresso-toolbar-registrations-month-pending') |
|
1340 | + ) { |
|
1341 | + $admin_bar->add_menu(array( |
|
1342 | + 'id' => 'espresso-toolbar-registrations-month-pending', |
|
1343 | + 'parent' => 'espresso-toolbar-registrations-month', |
|
1344 | + 'title' => __('Pending', 'event_espresso'), |
|
1345 | + 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1346 | + 'action' => 'default', |
|
1347 | + 'status' => 'month', |
|
1348 | + '_reg_status' => EEM_Registration::status_id_pending_payment, |
|
1349 | + ), $reg_admin_url), |
|
1350 | + 'meta' => array( |
|
1351 | + 'title' => __('Pending', 'event_espresso'), |
|
1352 | + 'target' => '', |
|
1353 | + 'class' => $menu_class, |
|
1354 | + ), |
|
1355 | + )); |
|
1356 | + } |
|
1357 | + //Registration Overview This Month Not Approved |
|
1358 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1359 | + 'ee_admin_bar_menu_espresso-toolbar-registrations-month-not-approved') |
|
1360 | + ) { |
|
1361 | + $admin_bar->add_menu(array( |
|
1362 | + 'id' => 'espresso-toolbar-registrations-month-not-approved', |
|
1363 | + 'parent' => 'espresso-toolbar-registrations-month', |
|
1364 | + 'title' => __('Not Approved', 'event_espresso'), |
|
1365 | + 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1366 | + 'action' => 'default', |
|
1367 | + 'status' => 'month', |
|
1368 | + '_reg_status' => EEM_Registration::status_id_not_approved, |
|
1369 | + ), $reg_admin_url), |
|
1370 | + 'meta' => array( |
|
1371 | + 'title' => __('Not Approved', 'event_espresso'), |
|
1372 | + 'target' => '', |
|
1373 | + 'class' => $menu_class, |
|
1374 | + ), |
|
1375 | + )); |
|
1376 | + } |
|
1377 | + //Registration Overview This Month Cancelled |
|
1378 | + if ($this->registry->CAP->current_user_can('ee_read_registrations', |
|
1379 | + 'ee_admin_bar_menu_espresso-toolbar-registrations-month-cancelled') |
|
1380 | + ) { |
|
1381 | + $admin_bar->add_menu(array( |
|
1382 | + 'id' => 'espresso-toolbar-registrations-month-cancelled', |
|
1383 | + 'parent' => 'espresso-toolbar-registrations-month', |
|
1384 | + 'title' => __('Cancelled', 'event_espresso'), |
|
1385 | + 'href' => EEH_URL::add_query_args_and_nonce(array( |
|
1386 | + 'action' => 'default', |
|
1387 | + 'status' => 'month', |
|
1388 | + '_reg_status' => EEM_Registration::status_id_cancelled, |
|
1389 | + ), $reg_admin_url), |
|
1390 | + 'meta' => array( |
|
1391 | + 'title' => __('Cancelled', 'event_espresso'), |
|
1392 | + 'target' => '', |
|
1393 | + 'class' => $menu_class, |
|
1394 | + ), |
|
1395 | + )); |
|
1396 | + } |
|
1397 | + //Extensions & Services |
|
1398 | + if ($this->registry->CAP->current_user_can('ee_read_ee', |
|
1399 | + 'ee_admin_bar_menu_espresso-toolbar-extensions-and-services') |
|
1400 | + ) { |
|
1401 | + $admin_bar->add_menu(array( |
|
1402 | + 'id' => 'espresso-toolbar-extensions-and-services', |
|
1403 | + 'parent' => 'espresso-toolbar', |
|
1404 | + 'title' => __('Extensions & Services', 'event_espresso'), |
|
1405 | + 'href' => $extensions_admin_url, |
|
1406 | + 'meta' => array( |
|
1407 | + 'title' => __('Extensions & Services', 'event_espresso'), |
|
1408 | + 'target' => '', |
|
1409 | + 'class' => $menu_class, |
|
1410 | + ), |
|
1411 | + )); |
|
1412 | + } |
|
1413 | + } |
|
1414 | + |
|
1415 | + |
|
1416 | + |
|
1417 | + /** |
|
1418 | + * simply hooks into "wp_list_pages_exclude" filter (for wp_list_pages method) and makes sure EE critical pages are |
|
1419 | + * never returned with the function. |
|
1420 | + * |
|
1421 | + * @param array $exclude_array any existing pages being excluded are in this array. |
|
1422 | + * @return array |
|
1423 | + */ |
|
1424 | + public function remove_pages_from_wp_list_pages($exclude_array) |
|
1425 | + { |
|
1426 | + return array_merge($exclude_array, $this->registry->CFG->core->get_critical_pages_array()); |
|
1427 | + } |
|
1428 | + |
|
1429 | + |
|
1430 | + |
|
1431 | + |
|
1432 | + |
|
1433 | + |
|
1434 | + /*********************************************** WP_ENQUEUE_SCRIPTS HOOK ***********************************************/ |
|
1435 | + /** |
|
1436 | + * wp_enqueue_scripts |
|
1437 | + * |
|
1438 | + * @access public |
|
1439 | + * @return void |
|
1440 | + */ |
|
1441 | + public function wp_enqueue_scripts() |
|
1442 | + { |
|
1443 | + // unlike other systems, EE_System_scripts loading is turned ON by default, but prior to the init hook, can be turned off via: add_filter( 'FHEE_load_EE_System_scripts', '__return_false' ); |
|
1444 | + if (apply_filters('FHEE_load_EE_System_scripts', true)) { |
|
1445 | + // jquery_validate loading is turned OFF by default, but prior to the wp_enqueue_scripts hook, can be turned back on again via: add_filter( 'FHEE_load_jquery_validate', '__return_true' ); |
|
1446 | + if (apply_filters('FHEE_load_jquery_validate', false)) { |
|
1447 | + // register jQuery Validate and additional methods |
|
1448 | + wp_register_script('jquery-validate', EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js', |
|
1449 | + array('jquery'), '1.15.0', true); |
|
1450 | + wp_register_script('jquery-validate-extra-methods', |
|
1451 | + EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js', |
|
1452 | + array('jquery', 'jquery-validate'), '1.15.0', true); |
|
1453 | + } |
|
1454 | + } |
|
1455 | + } |
|
1456 | 1456 | |
1457 | 1457 | |
1458 | 1458 |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | { |
186 | 186 | // set autoloaders for all of the classes implementing EEI_Plugin_API |
187 | 187 | // which provide helpers for EE plugin authors to more easily register certain components with EE. |
188 | - EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'plugin_api'); |
|
188 | + EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_LIBRARIES.'plugin_api'); |
|
189 | 189 | //load and setup EE_Capabilities |
190 | 190 | $this->registry->load_core('Capabilities'); |
191 | 191 | do_action('AHEE__EE_System__load_espresso_addons'); |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | && $_GET['activate'] === 'true' |
206 | 206 | ) |
207 | 207 | ) { |
208 | - include_once EE_THIRD_PARTY . 'wp-api-basic-auth' . DS . 'basic-auth.php'; |
|
208 | + include_once EE_THIRD_PARTY.'wp-api-basic-auth'.DS.'basic-auth.php'; |
|
209 | 209 | } |
210 | 210 | $this->_maybe_brew_regular(); |
211 | 211 | do_action('AHEE__EE_System__load_espresso_addons__complete'); |
@@ -225,8 +225,8 @@ discard block |
||
225 | 225 | */ |
226 | 226 | private function _maybe_brew_regular() |
227 | 227 | { |
228 | - if (( ! defined('EE_DECAF') || EE_DECAF !== true) && is_readable(EE_CAFF_PATH . 'brewing_regular.php')) { |
|
229 | - require_once EE_CAFF_PATH . 'brewing_regular.php'; |
|
228 | + if (( ! defined('EE_DECAF') || EE_DECAF !== true) && is_readable(EE_CAFF_PATH.'brewing_regular.php')) { |
|
229 | + require_once EE_CAFF_PATH.'brewing_regular.php'; |
|
230 | 230 | } |
231 | 231 | } |
232 | 232 | |
@@ -705,7 +705,7 @@ discard block |
||
705 | 705 | private function _parse_model_names() |
706 | 706 | { |
707 | 707 | //get all the files in the EE_MODELS folder that end in .model.php |
708 | - $models = glob(EE_MODELS . '*.model.php'); |
|
708 | + $models = glob(EE_MODELS.'*.model.php'); |
|
709 | 709 | $model_names = array(); |
710 | 710 | $non_abstract_db_models = array(); |
711 | 711 | foreach ($models as $model) { |
@@ -769,8 +769,8 @@ discard block |
||
769 | 769 | 'event_espresso'); |
770 | 770 | $msg .= '<ul>'; |
771 | 771 | foreach ($class_names as $class_name) { |
772 | - $msg .= '<li><b>Event Espresso - ' . str_replace(array('EE_', 'EEM_', 'EED_', 'EES_', 'EEW_'), '', |
|
773 | - $class_name) . '</b></li>'; |
|
772 | + $msg .= '<li><b>Event Espresso - '.str_replace(array('EE_', 'EEM_', 'EED_', 'EES_', 'EEW_'), '', |
|
773 | + $class_name).'</b></li>'; |
|
774 | 774 | } |
775 | 775 | $msg .= '</ul>'; |
776 | 776 | $msg .= __('Compatibility issues can be avoided and/or resolved by keeping addons and plugins updated to the latest version.', |
@@ -922,8 +922,8 @@ discard block |
||
922 | 922 | { |
923 | 923 | do_action('AHEE__EE_System__core_loaded_and_ready'); |
924 | 924 | // load_espresso_template_tags |
925 | - if (is_readable(EE_PUBLIC . 'template_tags.php')) { |
|
926 | - require_once(EE_PUBLIC . 'template_tags.php'); |
|
925 | + if (is_readable(EE_PUBLIC.'template_tags.php')) { |
|
926 | + require_once(EE_PUBLIC.'template_tags.php'); |
|
927 | 927 | } |
928 | 928 | do_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons'); |
929 | 929 | $this->registry->load_core('Session'); |
@@ -1068,7 +1068,7 @@ discard block |
||
1068 | 1068 | 'href' => $events_admin_url, |
1069 | 1069 | 'meta' => array( |
1070 | 1070 | 'title' => __('Event Espresso', 'event_espresso'), |
1071 | - 'class' => $menu_class . 'first', |
|
1071 | + 'class' => $menu_class.'first', |
|
1072 | 1072 | ), |
1073 | 1073 | )); |
1074 | 1074 | //Events |
@@ -1445,10 +1445,10 @@ discard block |
||
1445 | 1445 | // jquery_validate loading is turned OFF by default, but prior to the wp_enqueue_scripts hook, can be turned back on again via: add_filter( 'FHEE_load_jquery_validate', '__return_true' ); |
1446 | 1446 | if (apply_filters('FHEE_load_jquery_validate', false)) { |
1447 | 1447 | // register jQuery Validate and additional methods |
1448 | - wp_register_script('jquery-validate', EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js', |
|
1448 | + wp_register_script('jquery-validate', EE_GLOBAL_ASSETS_URL.'scripts/jquery.validate.min.js', |
|
1449 | 1449 | array('jquery'), '1.15.0', true); |
1450 | 1450 | wp_register_script('jquery-validate-extra-methods', |
1451 | - EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js', |
|
1451 | + EE_GLOBAL_ASSETS_URL.'scripts/jquery.validate.additional-methods.min.js', |
|
1452 | 1452 | array('jquery', 'jquery-validate'), '1.15.0', true); |
1453 | 1453 | } |
1454 | 1454 | } |
@@ -17,323 +17,323 @@ |
||
17 | 17 | { |
18 | 18 | |
19 | 19 | |
20 | - /** |
|
21 | - * @return EED_Bot_Trap|EED_Module |
|
22 | - */ |
|
23 | - public static function instance() |
|
24 | - { |
|
25 | - return parent::get_instance(__CLASS__); |
|
26 | - } |
|
20 | + /** |
|
21 | + * @return EED_Bot_Trap|EED_Module |
|
22 | + */ |
|
23 | + public static function instance() |
|
24 | + { |
|
25 | + return parent::get_instance(__CLASS__); |
|
26 | + } |
|
27 | 27 | |
28 | 28 | |
29 | - /** |
|
30 | - * set_hooks - for hooking into EE Core, other modules, etc |
|
31 | - * |
|
32 | - * @return void |
|
33 | - */ |
|
34 | - public static function set_hooks() |
|
35 | - { |
|
36 | - if ( |
|
37 | - apply_filters('FHEE__EED_Bot_Trap__set_hooks__use_bot_trap', true) && |
|
38 | - \EE_Registry::instance()->CFG->registration->use_bot_trap |
|
39 | - ) { |
|
40 | - \EED_Bot_Trap::set_trap(); |
|
41 | - // redirect bots to bogus success page |
|
42 | - \EE_Config::register_route('ticket_selection_received', 'EED_Bot_Trap', 'display_bot_trap_success'); |
|
43 | - } |
|
44 | - } |
|
29 | + /** |
|
30 | + * set_hooks - for hooking into EE Core, other modules, etc |
|
31 | + * |
|
32 | + * @return void |
|
33 | + */ |
|
34 | + public static function set_hooks() |
|
35 | + { |
|
36 | + if ( |
|
37 | + apply_filters('FHEE__EED_Bot_Trap__set_hooks__use_bot_trap', true) && |
|
38 | + \EE_Registry::instance()->CFG->registration->use_bot_trap |
|
39 | + ) { |
|
40 | + \EED_Bot_Trap::set_trap(); |
|
41 | + // redirect bots to bogus success page |
|
42 | + \EE_Config::register_route('ticket_selection_received', 'EED_Bot_Trap', 'display_bot_trap_success'); |
|
43 | + } |
|
44 | + } |
|
45 | 45 | |
46 | 46 | |
47 | - /** |
|
48 | - * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
49 | - * |
|
50 | - * @return void |
|
51 | - */ |
|
52 | - public static function set_trap() |
|
53 | - { |
|
54 | - define('EE_BOT_TRAP_BASE_URL', plugin_dir_url(__FILE__) . DS); |
|
55 | - add_action( |
|
56 | - 'AHEE__ticket_selector_chart__template__after_ticket_selector', |
|
57 | - array('EED_Bot_Trap', 'generate_bot_trap'), |
|
58 | - 10, 2 |
|
59 | - ); |
|
60 | - add_action( |
|
61 | - 'EED_Ticket_Selector__process_ticket_selections__before', |
|
62 | - array('EED_Bot_Trap', 'process_bot_trap'), |
|
63 | - 1, 2 |
|
64 | - ); |
|
65 | - } |
|
47 | + /** |
|
48 | + * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
49 | + * |
|
50 | + * @return void |
|
51 | + */ |
|
52 | + public static function set_trap() |
|
53 | + { |
|
54 | + define('EE_BOT_TRAP_BASE_URL', plugin_dir_url(__FILE__) . DS); |
|
55 | + add_action( |
|
56 | + 'AHEE__ticket_selector_chart__template__after_ticket_selector', |
|
57 | + array('EED_Bot_Trap', 'generate_bot_trap'), |
|
58 | + 10, 2 |
|
59 | + ); |
|
60 | + add_action( |
|
61 | + 'EED_Ticket_Selector__process_ticket_selections__before', |
|
62 | + array('EED_Bot_Trap', 'process_bot_trap'), |
|
63 | + 1, 2 |
|
64 | + ); |
|
65 | + } |
|
66 | 66 | |
67 | 67 | |
68 | - /** |
|
69 | - * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
70 | - * |
|
71 | - * @return void |
|
72 | - */ |
|
73 | - public static function set_hooks_admin() |
|
74 | - { |
|
75 | - if ( |
|
76 | - defined('DOING_AJAX') |
|
77 | - && DOING_AJAX |
|
78 | - && apply_filters('FHEE__EED_Bot_Trap__set_hooks__use_bot_trap', true) |
|
79 | - && \EE_Registry::instance()->CFG->registration->use_bot_trap |
|
80 | - ) { |
|
81 | - \EED_Bot_Trap::set_trap(); |
|
82 | - } |
|
83 | - add_action( |
|
84 | - 'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template', |
|
85 | - array('EED_Bot_Trap', 'bot_trap_settings_form'), |
|
86 | - 5 |
|
87 | - ); |
|
88 | - add_filter( |
|
89 | - 'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration', |
|
90 | - array('EED_Bot_Trap', 'update_bot_trap_settings_form'), |
|
91 | - 10, 1 |
|
92 | - ); |
|
93 | - } |
|
68 | + /** |
|
69 | + * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
70 | + * |
|
71 | + * @return void |
|
72 | + */ |
|
73 | + public static function set_hooks_admin() |
|
74 | + { |
|
75 | + if ( |
|
76 | + defined('DOING_AJAX') |
|
77 | + && DOING_AJAX |
|
78 | + && apply_filters('FHEE__EED_Bot_Trap__set_hooks__use_bot_trap', true) |
|
79 | + && \EE_Registry::instance()->CFG->registration->use_bot_trap |
|
80 | + ) { |
|
81 | + \EED_Bot_Trap::set_trap(); |
|
82 | + } |
|
83 | + add_action( |
|
84 | + 'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template', |
|
85 | + array('EED_Bot_Trap', 'bot_trap_settings_form'), |
|
86 | + 5 |
|
87 | + ); |
|
88 | + add_filter( |
|
89 | + 'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration', |
|
90 | + array('EED_Bot_Trap', 'update_bot_trap_settings_form'), |
|
91 | + 10, 1 |
|
92 | + ); |
|
93 | + } |
|
94 | 94 | |
95 | 95 | |
96 | - /** |
|
97 | - * run - initial module setup |
|
98 | - * |
|
99 | - * @param WP $WP |
|
100 | - * @return void |
|
101 | - */ |
|
102 | - public function run($WP) |
|
103 | - { |
|
104 | - } |
|
96 | + /** |
|
97 | + * run - initial module setup |
|
98 | + * |
|
99 | + * @param WP $WP |
|
100 | + * @return void |
|
101 | + */ |
|
102 | + public function run($WP) |
|
103 | + { |
|
104 | + } |
|
105 | 105 | |
106 | 106 | |
107 | - /** |
|
108 | - * generate_bot_trap |
|
109 | - * |
|
110 | - * @return void |
|
111 | - * @throws RuntimeException |
|
112 | - */ |
|
113 | - public static function generate_bot_trap() |
|
114 | - { |
|
115 | - $do_not_enter = esc_html__('please do not enter anything in this input', 'event_espresso'); |
|
116 | - $time = microtime(true); |
|
117 | - $html = '<div class="tkt-slctr-request-processor-dv" style="float:left; margin:0 0 0 -999em; height: 0;">'; |
|
118 | - $html .= '<label for="tkt-slctr-request-processor-email-' . $time . '">' . $do_not_enter . '</label>'; |
|
119 | - $html .= '<input type="email" id="tkt-slctr-request-processor-email-'; |
|
120 | - $html .= $time . '" name="tkt-slctr-request-processor-email" value=""/>'; |
|
121 | - $html .= '<input type="hidden" name="tkt-slctr-request-processor-token" value="'; |
|
122 | - if (EE_Registry::instance()->CFG->registration->use_encryption) { |
|
123 | - EE_Registry::instance()->load_core('EE_Encryption'); |
|
124 | - $html .= EE_Encryption::instance()->encrypt($time); |
|
125 | - } else { |
|
126 | - $html .= $time; |
|
127 | - } |
|
128 | - $html .= '"/>'; |
|
129 | - $html .= '</div><!-- .tkt-slctr-request-processor-dv -->'; |
|
130 | - echo $html; |
|
131 | - } |
|
107 | + /** |
|
108 | + * generate_bot_trap |
|
109 | + * |
|
110 | + * @return void |
|
111 | + * @throws RuntimeException |
|
112 | + */ |
|
113 | + public static function generate_bot_trap() |
|
114 | + { |
|
115 | + $do_not_enter = esc_html__('please do not enter anything in this input', 'event_espresso'); |
|
116 | + $time = microtime(true); |
|
117 | + $html = '<div class="tkt-slctr-request-processor-dv" style="float:left; margin:0 0 0 -999em; height: 0;">'; |
|
118 | + $html .= '<label for="tkt-slctr-request-processor-email-' . $time . '">' . $do_not_enter . '</label>'; |
|
119 | + $html .= '<input type="email" id="tkt-slctr-request-processor-email-'; |
|
120 | + $html .= $time . '" name="tkt-slctr-request-processor-email" value=""/>'; |
|
121 | + $html .= '<input type="hidden" name="tkt-slctr-request-processor-token" value="'; |
|
122 | + if (EE_Registry::instance()->CFG->registration->use_encryption) { |
|
123 | + EE_Registry::instance()->load_core('EE_Encryption'); |
|
124 | + $html .= EE_Encryption::instance()->encrypt($time); |
|
125 | + } else { |
|
126 | + $html .= $time; |
|
127 | + } |
|
128 | + $html .= '"/>'; |
|
129 | + $html .= '</div><!-- .tkt-slctr-request-processor-dv -->'; |
|
130 | + echo $html; |
|
131 | + } |
|
132 | 132 | |
133 | 133 | |
134 | - /** |
|
135 | - * process_bot_trap |
|
136 | - * |
|
137 | - * @param array|string $triggered_trap_callback Callback that will be executed for handling the |
|
138 | - * response if the bot trap is triggered. |
|
139 | - * It should receive one argument: a boolean indicating |
|
140 | - * whether the trap was triggered by suspicious timing or not. |
|
141 | - * @throws RuntimeException |
|
142 | - */ |
|
143 | - public static function process_bot_trap($triggered_trap_callback = array()) |
|
144 | - { |
|
145 | - // what's your email address Mr. Bot ? |
|
146 | - $empty_trap = isset($_REQUEST['tkt-slctr-request-processor-email']) |
|
147 | - && $_REQUEST['tkt-slctr-request-processor-email'] === ''; |
|
148 | - // get encrypted timestamp for when the form was originally displayed |
|
149 | - $bot_trap_timestamp = isset($_REQUEST['tkt-slctr-request-processor-token']) |
|
150 | - ? sanitize_text_field($_REQUEST['tkt-slctr-request-processor-token']) |
|
151 | - : ''; |
|
152 | - // decrypt and convert to absolute integer |
|
153 | - if (EE_Registry::instance()->CFG->registration->use_encryption) { |
|
154 | - EE_Registry::instance()->load_core('EE_Encryption'); |
|
155 | - $bot_trap_timestamp = absint(EE_Encryption::instance()->decrypt($bot_trap_timestamp)); |
|
156 | - } else { |
|
157 | - $bot_trap_timestamp = absint($bot_trap_timestamp); |
|
158 | - } |
|
159 | - // ticket form submitted too impossibly fast ( after now ) or more than an hour later ??? |
|
160 | - $suspicious_timing = $bot_trap_timestamp > time() || $bot_trap_timestamp < (time() - HOUR_IN_SECONDS); |
|
161 | - // are we human ? |
|
162 | - if ($empty_trap && !$suspicious_timing) { |
|
163 | - do_action('AHEE__EED_Bot_Trap__process_bot_trap__trap_not_triggered'); |
|
164 | - return; |
|
165 | - } |
|
166 | - // check the given callback is valid first before executing |
|
167 | - if (!is_callable($triggered_trap_callback)) { |
|
168 | - // invalid callback so lets just sub in our default. |
|
169 | - $triggered_trap_callback = array('EED_Bot_Trap', 'triggered_trap_response'); |
|
170 | - } |
|
171 | - call_user_func($triggered_trap_callback, $suspicious_timing); |
|
172 | - } |
|
134 | + /** |
|
135 | + * process_bot_trap |
|
136 | + * |
|
137 | + * @param array|string $triggered_trap_callback Callback that will be executed for handling the |
|
138 | + * response if the bot trap is triggered. |
|
139 | + * It should receive one argument: a boolean indicating |
|
140 | + * whether the trap was triggered by suspicious timing or not. |
|
141 | + * @throws RuntimeException |
|
142 | + */ |
|
143 | + public static function process_bot_trap($triggered_trap_callback = array()) |
|
144 | + { |
|
145 | + // what's your email address Mr. Bot ? |
|
146 | + $empty_trap = isset($_REQUEST['tkt-slctr-request-processor-email']) |
|
147 | + && $_REQUEST['tkt-slctr-request-processor-email'] === ''; |
|
148 | + // get encrypted timestamp for when the form was originally displayed |
|
149 | + $bot_trap_timestamp = isset($_REQUEST['tkt-slctr-request-processor-token']) |
|
150 | + ? sanitize_text_field($_REQUEST['tkt-slctr-request-processor-token']) |
|
151 | + : ''; |
|
152 | + // decrypt and convert to absolute integer |
|
153 | + if (EE_Registry::instance()->CFG->registration->use_encryption) { |
|
154 | + EE_Registry::instance()->load_core('EE_Encryption'); |
|
155 | + $bot_trap_timestamp = absint(EE_Encryption::instance()->decrypt($bot_trap_timestamp)); |
|
156 | + } else { |
|
157 | + $bot_trap_timestamp = absint($bot_trap_timestamp); |
|
158 | + } |
|
159 | + // ticket form submitted too impossibly fast ( after now ) or more than an hour later ??? |
|
160 | + $suspicious_timing = $bot_trap_timestamp > time() || $bot_trap_timestamp < (time() - HOUR_IN_SECONDS); |
|
161 | + // are we human ? |
|
162 | + if ($empty_trap && !$suspicious_timing) { |
|
163 | + do_action('AHEE__EED_Bot_Trap__process_bot_trap__trap_not_triggered'); |
|
164 | + return; |
|
165 | + } |
|
166 | + // check the given callback is valid first before executing |
|
167 | + if (!is_callable($triggered_trap_callback)) { |
|
168 | + // invalid callback so lets just sub in our default. |
|
169 | + $triggered_trap_callback = array('EED_Bot_Trap', 'triggered_trap_response'); |
|
170 | + } |
|
171 | + call_user_func($triggered_trap_callback, $suspicious_timing); |
|
172 | + } |
|
173 | 173 | |
174 | 174 | |
175 | - /** |
|
176 | - * This is the default callback executed by EED_Bot_Trap::process_bot_trap that handles the response. |
|
177 | - * |
|
178 | - * @param bool $suspicious_timing If true, then the bot trap was triggered due to the suspicious timing test. |
|
179 | - */ |
|
180 | - public static function triggered_trap_response($suspicious_timing) |
|
181 | - { |
|
182 | - // UH OH... |
|
183 | - $redirect_url = add_query_arg( |
|
184 | - array('ee' => 'ticket_selection_received'), |
|
185 | - EE_Registry::instance()->CFG->core->reg_page_url() |
|
186 | - ); |
|
187 | - if ($suspicious_timing) { |
|
188 | - $redirect_url = add_query_arg( |
|
189 | - array( |
|
190 | - 'ee-notice' => urlencode( |
|
191 | - esc_html__( |
|
192 | - 'We\'re sorry, but your ticket selections could not be processed due to a server timing error. Please hit the back button on your browser and try again.', |
|
193 | - 'event_espresso' |
|
194 | - ) |
|
195 | - ) |
|
196 | - ), |
|
197 | - $redirect_url |
|
198 | - ); |
|
199 | - } |
|
200 | - $redirect_url = apply_filters('FHEE__EED_Bot_Trap__process_bot_trap__redirect_url', $redirect_url); |
|
201 | - // if AJAX, return the redirect URL |
|
202 | - if (defined('DOING_AJAX') && DOING_AJAX) { |
|
203 | - echo wp_json_encode( |
|
204 | - array_merge( |
|
205 | - EE_Error::get_notices(false), |
|
206 | - array( |
|
207 | - 'redirect_url' => $redirect_url |
|
208 | - ) |
|
209 | - ) |
|
210 | - ); |
|
211 | - exit(); |
|
212 | - } |
|
213 | - wp_safe_redirect($redirect_url); |
|
214 | - exit(); |
|
215 | - } |
|
175 | + /** |
|
176 | + * This is the default callback executed by EED_Bot_Trap::process_bot_trap that handles the response. |
|
177 | + * |
|
178 | + * @param bool $suspicious_timing If true, then the bot trap was triggered due to the suspicious timing test. |
|
179 | + */ |
|
180 | + public static function triggered_trap_response($suspicious_timing) |
|
181 | + { |
|
182 | + // UH OH... |
|
183 | + $redirect_url = add_query_arg( |
|
184 | + array('ee' => 'ticket_selection_received'), |
|
185 | + EE_Registry::instance()->CFG->core->reg_page_url() |
|
186 | + ); |
|
187 | + if ($suspicious_timing) { |
|
188 | + $redirect_url = add_query_arg( |
|
189 | + array( |
|
190 | + 'ee-notice' => urlencode( |
|
191 | + esc_html__( |
|
192 | + 'We\'re sorry, but your ticket selections could not be processed due to a server timing error. Please hit the back button on your browser and try again.', |
|
193 | + 'event_espresso' |
|
194 | + ) |
|
195 | + ) |
|
196 | + ), |
|
197 | + $redirect_url |
|
198 | + ); |
|
199 | + } |
|
200 | + $redirect_url = apply_filters('FHEE__EED_Bot_Trap__process_bot_trap__redirect_url', $redirect_url); |
|
201 | + // if AJAX, return the redirect URL |
|
202 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
203 | + echo wp_json_encode( |
|
204 | + array_merge( |
|
205 | + EE_Error::get_notices(false), |
|
206 | + array( |
|
207 | + 'redirect_url' => $redirect_url |
|
208 | + ) |
|
209 | + ) |
|
210 | + ); |
|
211 | + exit(); |
|
212 | + } |
|
213 | + wp_safe_redirect($redirect_url); |
|
214 | + exit(); |
|
215 | + } |
|
216 | 216 | |
217 | 217 | |
218 | - /** |
|
219 | - * display_bot_trap_success |
|
220 | - * shows a "success" screen to bots so that they (ie: the ppl managing them) |
|
221 | - * think the form was submitted successfully |
|
222 | - * |
|
223 | - * @return void |
|
224 | - */ |
|
225 | - public static function display_bot_trap_success() |
|
226 | - { |
|
227 | - add_filter('FHEE__EED_Single_Page_Checkout__run', '__return_false'); |
|
228 | - $bot_notice = esc_html__( |
|
229 | - 'Thank you so much. Your ticket selections have been received for consideration.', |
|
230 | - 'event_espresso' |
|
231 | - ); |
|
232 | - $bot_notice = isset($_REQUEST['ee-notice']) && $_REQUEST['ee-notice'] !== '' |
|
233 | - ? sanitize_text_field(stripslashes($_REQUEST['ee-notice'])) |
|
234 | - : $bot_notice; |
|
235 | - EE_Registry::instance()->REQ->add_output(EEH_HTML::div($bot_notice, '', 'ee-attention')); |
|
236 | - } |
|
218 | + /** |
|
219 | + * display_bot_trap_success |
|
220 | + * shows a "success" screen to bots so that they (ie: the ppl managing them) |
|
221 | + * think the form was submitted successfully |
|
222 | + * |
|
223 | + * @return void |
|
224 | + */ |
|
225 | + public static function display_bot_trap_success() |
|
226 | + { |
|
227 | + add_filter('FHEE__EED_Single_Page_Checkout__run', '__return_false'); |
|
228 | + $bot_notice = esc_html__( |
|
229 | + 'Thank you so much. Your ticket selections have been received for consideration.', |
|
230 | + 'event_espresso' |
|
231 | + ); |
|
232 | + $bot_notice = isset($_REQUEST['ee-notice']) && $_REQUEST['ee-notice'] !== '' |
|
233 | + ? sanitize_text_field(stripslashes($_REQUEST['ee-notice'])) |
|
234 | + : $bot_notice; |
|
235 | + EE_Registry::instance()->REQ->add_output(EEH_HTML::div($bot_notice, '', 'ee-attention')); |
|
236 | + } |
|
237 | 237 | |
238 | 238 | |
239 | 239 | |
240 | - /*********************************** ADMIN **********************************/ |
|
240 | + /*********************************** ADMIN **********************************/ |
|
241 | 241 | |
242 | 242 | |
243 | - /** |
|
244 | - * bot_trap_settings_form |
|
245 | - * |
|
246 | - * @return void |
|
247 | - * @throws EE_Error |
|
248 | - */ |
|
249 | - public static function bot_trap_settings_form() |
|
250 | - { |
|
251 | - EED_Bot_Trap::_bot_trap_settings_form()->enqueue_js(); |
|
252 | - echo EED_Bot_Trap::_bot_trap_settings_form()->get_html(); |
|
253 | - } |
|
243 | + /** |
|
244 | + * bot_trap_settings_form |
|
245 | + * |
|
246 | + * @return void |
|
247 | + * @throws EE_Error |
|
248 | + */ |
|
249 | + public static function bot_trap_settings_form() |
|
250 | + { |
|
251 | + EED_Bot_Trap::_bot_trap_settings_form()->enqueue_js(); |
|
252 | + echo EED_Bot_Trap::_bot_trap_settings_form()->get_html(); |
|
253 | + } |
|
254 | 254 | |
255 | 255 | |
256 | - /** |
|
257 | - * _bot_trap_settings_form |
|
258 | - * |
|
259 | - * @return EE_Form_Section_Proper |
|
260 | - * @throws EE_Error |
|
261 | - */ |
|
262 | - protected static function _bot_trap_settings_form() |
|
263 | - { |
|
264 | - return new EE_Form_Section_Proper( |
|
265 | - array( |
|
266 | - 'name' => 'bot_trap_settings', |
|
267 | - 'html_id' => 'bot_trap_settings', |
|
268 | - 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
269 | - 'subsections' => array( |
|
270 | - 'bot_trap_hdr' => new EE_Form_Section_HTML(EEH_HTML::h2(esc_html__('Bot Trap Settings', 'event_espresso'))), |
|
271 | - 'use_bot_trap' => new EE_Yes_No_Input( |
|
272 | - array( |
|
273 | - 'html_label_text' => esc_html__('Enable Bot Trap', 'event_espresso'), |
|
274 | - 'html_help_text' => esc_html__('The Event Espresso Bot Trap will insert a fake input into your Ticket Selector forms that is hidden from regular site visitors, but visible to spam bots. Because the input asks for an email address, it is irresistible to spam bots who will of course enter text into it. Since regular site visitors can not see this input, any value detected during form submission means a bot has been detected, which will then be blocked from submitting the form.', 'event_espresso'), |
|
275 | - 'default' => EE_Registry::instance()->CFG->registration->use_bot_trap !== null |
|
276 | - ? EE_Registry::instance()->CFG->registration->use_bot_trap |
|
277 | - : true, |
|
278 | - 'required' => false |
|
279 | - ) |
|
280 | - ), |
|
281 | - 'use_encryption' => new EE_Yes_No_Input( |
|
282 | - array( |
|
283 | - 'html_label_text' => esc_html__('Encrypt Bot Trap Data', 'event_espresso'), |
|
284 | - 'html_help_text' => esc_html__( |
|
285 | - 'One way to detect spam bots is by looking at how long it takes them to submit a form. They are often inhumanly fast, or will submit forms hours, days, or even weeks after the form was first scraped off the web. The Event Espresso Bot Trap will send a timestamp with the Ticket Selector form when it is submitted. By default, this timestamp is encrypted so that the spam bots can not change it, but encryption may cause issues on some servers due to configuration "conflicts". If you continuously get caught in the bot trap, then try setting this option to "No". This may increase the number of spam submissions you receive, but increases server compatibility.', |
|
286 | - 'event_espresso' |
|
287 | - ), |
|
288 | - 'default' => EE_Registry::instance()->CFG->registration->use_encryption !== null |
|
289 | - ? EE_Registry::instance()->CFG->registration->use_encryption |
|
290 | - : true, |
|
291 | - 'required' => false |
|
292 | - ) |
|
293 | - ), |
|
294 | - ) |
|
295 | - ) |
|
296 | - ); |
|
297 | - } |
|
256 | + /** |
|
257 | + * _bot_trap_settings_form |
|
258 | + * |
|
259 | + * @return EE_Form_Section_Proper |
|
260 | + * @throws EE_Error |
|
261 | + */ |
|
262 | + protected static function _bot_trap_settings_form() |
|
263 | + { |
|
264 | + return new EE_Form_Section_Proper( |
|
265 | + array( |
|
266 | + 'name' => 'bot_trap_settings', |
|
267 | + 'html_id' => 'bot_trap_settings', |
|
268 | + 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
269 | + 'subsections' => array( |
|
270 | + 'bot_trap_hdr' => new EE_Form_Section_HTML(EEH_HTML::h2(esc_html__('Bot Trap Settings', 'event_espresso'))), |
|
271 | + 'use_bot_trap' => new EE_Yes_No_Input( |
|
272 | + array( |
|
273 | + 'html_label_text' => esc_html__('Enable Bot Trap', 'event_espresso'), |
|
274 | + 'html_help_text' => esc_html__('The Event Espresso Bot Trap will insert a fake input into your Ticket Selector forms that is hidden from regular site visitors, but visible to spam bots. Because the input asks for an email address, it is irresistible to spam bots who will of course enter text into it. Since regular site visitors can not see this input, any value detected during form submission means a bot has been detected, which will then be blocked from submitting the form.', 'event_espresso'), |
|
275 | + 'default' => EE_Registry::instance()->CFG->registration->use_bot_trap !== null |
|
276 | + ? EE_Registry::instance()->CFG->registration->use_bot_trap |
|
277 | + : true, |
|
278 | + 'required' => false |
|
279 | + ) |
|
280 | + ), |
|
281 | + 'use_encryption' => new EE_Yes_No_Input( |
|
282 | + array( |
|
283 | + 'html_label_text' => esc_html__('Encrypt Bot Trap Data', 'event_espresso'), |
|
284 | + 'html_help_text' => esc_html__( |
|
285 | + 'One way to detect spam bots is by looking at how long it takes them to submit a form. They are often inhumanly fast, or will submit forms hours, days, or even weeks after the form was first scraped off the web. The Event Espresso Bot Trap will send a timestamp with the Ticket Selector form when it is submitted. By default, this timestamp is encrypted so that the spam bots can not change it, but encryption may cause issues on some servers due to configuration "conflicts". If you continuously get caught in the bot trap, then try setting this option to "No". This may increase the number of spam submissions you receive, but increases server compatibility.', |
|
286 | + 'event_espresso' |
|
287 | + ), |
|
288 | + 'default' => EE_Registry::instance()->CFG->registration->use_encryption !== null |
|
289 | + ? EE_Registry::instance()->CFG->registration->use_encryption |
|
290 | + : true, |
|
291 | + 'required' => false |
|
292 | + ) |
|
293 | + ), |
|
294 | + ) |
|
295 | + ) |
|
296 | + ); |
|
297 | + } |
|
298 | 298 | |
299 | 299 | |
300 | - /** |
|
301 | - * update_bot_trap_settings_form |
|
302 | - * |
|
303 | - * @param EE_Registration_Config $EE_Registration_Config |
|
304 | - * @return EE_Registration_Config |
|
305 | - * @throws ReflectionException |
|
306 | - * @throws EE_Error |
|
307 | - */ |
|
308 | - public static function update_bot_trap_settings_form(EE_Registration_Config $EE_Registration_Config) |
|
309 | - { |
|
310 | - try { |
|
311 | - $bot_trap_settings_form = EED_Bot_Trap::_bot_trap_settings_form(); |
|
312 | - // if not displaying a form, then check for form submission |
|
313 | - if ($bot_trap_settings_form->was_submitted()) { |
|
314 | - // capture form data |
|
315 | - $bot_trap_settings_form->receive_form_submission(); |
|
316 | - // validate form data |
|
317 | - if ($bot_trap_settings_form->is_valid()) { |
|
318 | - // grab validated data from form |
|
319 | - $valid_data = $bot_trap_settings_form->valid_data(); |
|
320 | - if (isset($valid_data['use_bot_trap'], $valid_data['use_encryption'])) { |
|
321 | - $EE_Registration_Config->use_bot_trap = $valid_data['use_bot_trap']; |
|
322 | - $EE_Registration_Config->use_encryption = $valid_data['use_encryption']; |
|
323 | - } else { |
|
324 | - EE_Error::add_error(esc_html__('Invalid or missing Bot Trap settings. Please refresh the form and try again.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
325 | - } |
|
326 | - } else { |
|
327 | - if ($bot_trap_settings_form->submission_error_message() !== '') { |
|
328 | - EE_Error::add_error($bot_trap_settings_form->submission_error_message(), __FILE__, __FUNCTION__, __LINE__); |
|
329 | - } |
|
330 | - } |
|
331 | - } |
|
332 | - } catch (EE_Error $e) { |
|
333 | - $e->get_error(); |
|
334 | - } |
|
335 | - return $EE_Registration_Config; |
|
336 | - } |
|
300 | + /** |
|
301 | + * update_bot_trap_settings_form |
|
302 | + * |
|
303 | + * @param EE_Registration_Config $EE_Registration_Config |
|
304 | + * @return EE_Registration_Config |
|
305 | + * @throws ReflectionException |
|
306 | + * @throws EE_Error |
|
307 | + */ |
|
308 | + public static function update_bot_trap_settings_form(EE_Registration_Config $EE_Registration_Config) |
|
309 | + { |
|
310 | + try { |
|
311 | + $bot_trap_settings_form = EED_Bot_Trap::_bot_trap_settings_form(); |
|
312 | + // if not displaying a form, then check for form submission |
|
313 | + if ($bot_trap_settings_form->was_submitted()) { |
|
314 | + // capture form data |
|
315 | + $bot_trap_settings_form->receive_form_submission(); |
|
316 | + // validate form data |
|
317 | + if ($bot_trap_settings_form->is_valid()) { |
|
318 | + // grab validated data from form |
|
319 | + $valid_data = $bot_trap_settings_form->valid_data(); |
|
320 | + if (isset($valid_data['use_bot_trap'], $valid_data['use_encryption'])) { |
|
321 | + $EE_Registration_Config->use_bot_trap = $valid_data['use_bot_trap']; |
|
322 | + $EE_Registration_Config->use_encryption = $valid_data['use_encryption']; |
|
323 | + } else { |
|
324 | + EE_Error::add_error(esc_html__('Invalid or missing Bot Trap settings. Please refresh the form and try again.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
325 | + } |
|
326 | + } else { |
|
327 | + if ($bot_trap_settings_form->submission_error_message() !== '') { |
|
328 | + EE_Error::add_error($bot_trap_settings_form->submission_error_message(), __FILE__, __FUNCTION__, __LINE__); |
|
329 | + } |
|
330 | + } |
|
331 | + } |
|
332 | + } catch (EE_Error $e) { |
|
333 | + $e->get_error(); |
|
334 | + } |
|
335 | + return $EE_Registration_Config; |
|
336 | + } |
|
337 | 337 | |
338 | 338 | |
339 | 339 | } |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | */ |
52 | 52 | public static function set_trap() |
53 | 53 | { |
54 | - define('EE_BOT_TRAP_BASE_URL', plugin_dir_url(__FILE__) . DS); |
|
54 | + define('EE_BOT_TRAP_BASE_URL', plugin_dir_url(__FILE__).DS); |
|
55 | 55 | add_action( |
56 | 56 | 'AHEE__ticket_selector_chart__template__after_ticket_selector', |
57 | 57 | array('EED_Bot_Trap', 'generate_bot_trap'), |
@@ -115,9 +115,9 @@ discard block |
||
115 | 115 | $do_not_enter = esc_html__('please do not enter anything in this input', 'event_espresso'); |
116 | 116 | $time = microtime(true); |
117 | 117 | $html = '<div class="tkt-slctr-request-processor-dv" style="float:left; margin:0 0 0 -999em; height: 0;">'; |
118 | - $html .= '<label for="tkt-slctr-request-processor-email-' . $time . '">' . $do_not_enter . '</label>'; |
|
118 | + $html .= '<label for="tkt-slctr-request-processor-email-'.$time.'">'.$do_not_enter.'</label>'; |
|
119 | 119 | $html .= '<input type="email" id="tkt-slctr-request-processor-email-'; |
120 | - $html .= $time . '" name="tkt-slctr-request-processor-email" value=""/>'; |
|
120 | + $html .= $time.'" name="tkt-slctr-request-processor-email" value=""/>'; |
|
121 | 121 | $html .= '<input type="hidden" name="tkt-slctr-request-processor-token" value="'; |
122 | 122 | if (EE_Registry::instance()->CFG->registration->use_encryption) { |
123 | 123 | EE_Registry::instance()->load_core('EE_Encryption'); |
@@ -159,12 +159,12 @@ discard block |
||
159 | 159 | // ticket form submitted too impossibly fast ( after now ) or more than an hour later ??? |
160 | 160 | $suspicious_timing = $bot_trap_timestamp > time() || $bot_trap_timestamp < (time() - HOUR_IN_SECONDS); |
161 | 161 | // are we human ? |
162 | - if ($empty_trap && !$suspicious_timing) { |
|
162 | + if ($empty_trap && ! $suspicious_timing) { |
|
163 | 163 | do_action('AHEE__EED_Bot_Trap__process_bot_trap__trap_not_triggered'); |
164 | 164 | return; |
165 | 165 | } |
166 | 166 | // check the given callback is valid first before executing |
167 | - if (!is_callable($triggered_trap_callback)) { |
|
167 | + if ( ! is_callable($triggered_trap_callback)) { |
|
168 | 168 | // invalid callback so lets just sub in our default. |
169 | 169 | $triggered_trap_callback = array('EED_Bot_Trap', 'triggered_trap_response'); |
170 | 170 | } |
@@ -118,37 +118,37 @@ |
||
118 | 118 | * @return EE_Template_Config |
119 | 119 | */ |
120 | 120 | public static function update_template_settings( $CFG, $REQ ) { |
121 | - $display_order_event = $CFG->EED_Event_Single->display_order_event !== null |
|
122 | - ? $CFG->EED_Event_Single->display_order_event |
|
123 | - : EED_Event_Single::EVENT_DETAILS_PRIORITY; |
|
121 | + $display_order_event = $CFG->EED_Event_Single->display_order_event !== null |
|
122 | + ? $CFG->EED_Event_Single->display_order_event |
|
123 | + : EED_Event_Single::EVENT_DETAILS_PRIORITY; |
|
124 | 124 | $display_order_datetimes = $CFG->EED_Event_Single->display_order_datetimes !== null |
125 | - ? $CFG->EED_Event_Single->display_order_datetimes |
|
126 | - : EED_Event_Single::EVENT_DATETIMES_PRIORITY; |
|
127 | - $display_order_tickets = $CFG->EED_Event_Single->display_order_tickets !== null |
|
128 | - ? $CFG->EED_Event_Single->display_order_tickets |
|
129 | - : EED_Event_Single::EVENT_TICKETS_PRIORITY; |
|
125 | + ? $CFG->EED_Event_Single->display_order_datetimes |
|
126 | + : EED_Event_Single::EVENT_DATETIMES_PRIORITY; |
|
127 | + $display_order_tickets = $CFG->EED_Event_Single->display_order_tickets !== null |
|
128 | + ? $CFG->EED_Event_Single->display_order_tickets |
|
129 | + : EED_Event_Single::EVENT_TICKETS_PRIORITY; |
|
130 | 130 | $display_order_venue = $CFG->EED_Event_Single->display_order_venue !== null |
131 | - ? $CFG->EED_Event_Single->display_order_venue |
|
132 | - : EED_Event_Single::EVENT_VENUES_PRIORITY; |
|
131 | + ? $CFG->EED_Event_Single->display_order_venue |
|
132 | + : EED_Event_Single::EVENT_VENUES_PRIORITY; |
|
133 | 133 | $CFG->EED_Event_Single = new EE_Event_Single_Config(); |
134 | 134 | $CFG->EED_Event_Single->display_status_banner_single = ! empty( $REQ['display_status_banner_single'] ) |
135 | - && $REQ['display_status_banner_single']; |
|
135 | + && $REQ['display_status_banner_single']; |
|
136 | 136 | $CFG->EED_Event_Single->display_venue = ! empty( $REQ['display_venue'] ) && $REQ['display_venue']; |
137 | 137 | $CFG->EED_Event_Single->use_sortable_display_order = ! empty( $REQ[ 'EED_Events_Single_use_sortable_display_order' ] ) |
138 | - ? absint( $REQ[ 'EED_Events_Single_use_sortable_display_order' ] ) |
|
139 | - : 0; |
|
138 | + ? absint( $REQ[ 'EED_Events_Single_use_sortable_display_order' ] ) |
|
139 | + : 0; |
|
140 | 140 | $CFG->EED_Event_Single->display_order_event = $CFG->EED_Event_Single->use_sortable_display_order |
141 | - ? $display_order_event |
|
142 | - : EED_Event_Single::EVENT_DETAILS_PRIORITY; |
|
141 | + ? $display_order_event |
|
142 | + : EED_Event_Single::EVENT_DETAILS_PRIORITY; |
|
143 | 143 | $CFG->EED_Event_Single->display_order_datetimes = $CFG->EED_Event_Single->use_sortable_display_order |
144 | - ? $display_order_datetimes |
|
145 | - : EED_Event_Single::EVENT_DATETIMES_PRIORITY; |
|
144 | + ? $display_order_datetimes |
|
145 | + : EED_Event_Single::EVENT_DATETIMES_PRIORITY; |
|
146 | 146 | $CFG->EED_Event_Single->display_order_tickets = $CFG->EED_Event_Single->use_sortable_display_order |
147 | - ? $display_order_tickets |
|
148 | - : EED_Event_Single::EVENT_TICKETS_PRIORITY; |
|
147 | + ? $display_order_tickets |
|
148 | + : EED_Event_Single::EVENT_TICKETS_PRIORITY; |
|
149 | 149 | $CFG->EED_Event_Single->display_order_venue = $CFG->EED_Event_Single->use_sortable_display_order |
150 | - ? $display_order_venue |
|
151 | - : EED_Event_Single::EVENT_VENUES_PRIORITY; |
|
150 | + ? $display_order_venue |
|
151 | + : EED_Event_Single::EVENT_VENUES_PRIORITY; |
|
152 | 152 | do_action( 'AHEE__EED_Event_Single__update_template_settings__after_update', $CFG, $REQ ); |
153 | 153 | return $CFG; |
154 | 154 | } |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | * @return EED_Event_Single_Caff |
30 | 30 | */ |
31 | 31 | public static function instance() { |
32 | - return parent::get_instance( __CLASS__ ); |
|
32 | + return parent::get_instance(__CLASS__); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | |
@@ -50,34 +50,34 @@ discard block |
||
50 | 50 | * @return void |
51 | 51 | */ |
52 | 52 | public static function set_hooks_admin() { |
53 | - define( 'EVENT_SINGLE_CAFF_TEMPLATES_PATH', plugin_dir_path( __FILE__ ) . 'templates' . DS ); |
|
54 | - define( 'EVENT_SINGLE_CAFF_ASSETS_URL', plugin_dir_url( __FILE__ ) . 'assets' . DS ); |
|
53 | + define('EVENT_SINGLE_CAFF_TEMPLATES_PATH', plugin_dir_path(__FILE__).'templates'.DS); |
|
54 | + define('EVENT_SINGLE_CAFF_ASSETS_URL', plugin_dir_url(__FILE__).'assets'.DS); |
|
55 | 55 | add_action( |
56 | 56 | 'FHEE__EE_Admin_Page___load_page_dependencies__after_load__espresso_events__template_settings', |
57 | - array( 'EED_Event_Single_Caff', 'load_scripts_styles' ), |
|
57 | + array('EED_Event_Single_Caff', 'load_scripts_styles'), |
|
58 | 58 | 10 |
59 | 59 | ); |
60 | - add_action( 'AHEE__template_settings__template__before_settings_form', array( 'EED_Event_Single_Caff', 'template_settings_form' ), 10 ); |
|
61 | - add_filter( 'FHEE__General_Settings_Admin_Page__update_template_settings__data', array( 'EED_Event_Single_Caff', 'update_template_settings' ), 10, 2 ); |
|
60 | + add_action('AHEE__template_settings__template__before_settings_form', array('EED_Event_Single_Caff', 'template_settings_form'), 10); |
|
61 | + add_filter('FHEE__General_Settings_Admin_Page__update_template_settings__data', array('EED_Event_Single_Caff', 'update_template_settings'), 10, 2); |
|
62 | 62 | // AJAX |
63 | - add_action( 'wp_ajax_espresso_update_event_single_order', array( 'EED_Event_Single_Caff', 'update_event_single_order' ) ); |
|
64 | - add_action( 'wp_ajax_nopriv_espresso_update_event_single_order', array( 'EED_Event_Single_Caff', 'update_event_single_order' ) ); |
|
63 | + add_action('wp_ajax_espresso_update_event_single_order', array('EED_Event_Single_Caff', 'update_event_single_order')); |
|
64 | + add_action('wp_ajax_nopriv_espresso_update_event_single_order', array('EED_Event_Single_Caff', 'update_event_single_order')); |
|
65 | 65 | |
66 | 66 | } |
67 | 67 | |
68 | 68 | |
69 | 69 | |
70 | 70 | public static function load_scripts_styles() { |
71 | - add_action( 'admin_enqueue_scripts', array( 'EED_Event_Single_Caff', 'enqueue_scripts_styles' ), 10 ); |
|
71 | + add_action('admin_enqueue_scripts', array('EED_Event_Single_Caff', 'enqueue_scripts_styles'), 10); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | |
75 | 75 | |
76 | 76 | public static function enqueue_scripts_styles() { |
77 | - wp_register_style( 'eed-event-single-sortable', EVENT_SINGLE_CAFF_ASSETS_URL . 'eed_event_single_sortable.css', array(), EVENT_ESPRESSO_VERSION ); |
|
78 | - wp_enqueue_style( 'eed-event-single-sortable' ); |
|
79 | - wp_register_script( 'eed-event-single-sortable', EVENT_SINGLE_CAFF_ASSETS_URL . 'eed_event_single_sortable.js', array( 'jquery-ui-sortable' ), EVENT_ESPRESSO_VERSION, true ); |
|
80 | - wp_enqueue_script( 'eed-event-single-sortable' ); |
|
77 | + wp_register_style('eed-event-single-sortable', EVENT_SINGLE_CAFF_ASSETS_URL.'eed_event_single_sortable.css', array(), EVENT_ESPRESSO_VERSION); |
|
78 | + wp_enqueue_style('eed-event-single-sortable'); |
|
79 | + wp_register_script('eed-event-single-sortable', EVENT_SINGLE_CAFF_ASSETS_URL.'eed_event_single_sortable.js', array('jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, true); |
|
80 | + wp_enqueue_script('eed-event-single-sortable'); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | |
@@ -91,21 +91,21 @@ discard block |
||
91 | 91 | */ |
92 | 92 | public static function template_settings_form() { |
93 | 93 | $config = EE_Registry::instance()->CFG->template_settings; |
94 | - $config = isset( $config->EED_Event_Single ) && $config->EED_Event_Single instanceof EE_Event_Single_Config ? $config->EED_Event_Single : new EE_Event_Single_Config(); |
|
95 | - $config->use_sortable_display_order = isset( $config->use_sortable_display_order ) ? $config->use_sortable_display_order : false; |
|
96 | - $config = apply_filters( 'FHEE__EED_Event_Single__template_settings_form__event_list_config', $config ); |
|
94 | + $config = isset($config->EED_Event_Single) && $config->EED_Event_Single instanceof EE_Event_Single_Config ? $config->EED_Event_Single : new EE_Event_Single_Config(); |
|
95 | + $config->use_sortable_display_order = isset($config->use_sortable_display_order) ? $config->use_sortable_display_order : false; |
|
96 | + $config = apply_filters('FHEE__EED_Event_Single__template_settings_form__event_list_config', $config); |
|
97 | 97 | |
98 | 98 | $event_single_order_array = array(); |
99 | - $event_single_order_array[ $config->display_order_tickets ] = 'tickets'; |
|
100 | - $event_single_order_array[ $config->display_order_datetimes ] = 'datetimes'; |
|
101 | - $event_single_order_array[ $config->display_order_event ] = 'event'; |
|
102 | - $event_single_order_array[ $config->display_order_venue ] = 'venue'; |
|
99 | + $event_single_order_array[$config->display_order_tickets] = 'tickets'; |
|
100 | + $event_single_order_array[$config->display_order_datetimes] = 'datetimes'; |
|
101 | + $event_single_order_array[$config->display_order_event] = 'event'; |
|
102 | + $event_single_order_array[$config->display_order_venue] = 'venue'; |
|
103 | 103 | // get template parts |
104 | - $template_parts = EED_Event_Single::instance()->initialize_template_parts( $config ); |
|
104 | + $template_parts = EED_Event_Single::instance()->initialize_template_parts($config); |
|
105 | 105 | // convert to array so that we can add more properties |
106 | - $config = get_object_vars( $config ); |
|
107 | - $config[ 'event_single_display_order' ] = $template_parts->generate_sortable_list_of_template_parts( 'event-single-sortable-js', '', 'single-sortable-li single-sortable-js' ); |
|
108 | - EEH_Template::display_template( EVENT_SINGLE_CAFF_TEMPLATES_PATH . 'admin-event-single-settings.template.php', $config ); |
|
106 | + $config = get_object_vars($config); |
|
107 | + $config['event_single_display_order'] = $template_parts->generate_sortable_list_of_template_parts('event-single-sortable-js', '', 'single-sortable-li single-sortable-js'); |
|
108 | + EEH_Template::display_template(EVENT_SINGLE_CAFF_TEMPLATES_PATH.'admin-event-single-settings.template.php', $config); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | * @param array $REQ |
118 | 118 | * @return EE_Template_Config |
119 | 119 | */ |
120 | - public static function update_template_settings( $CFG, $REQ ) { |
|
120 | + public static function update_template_settings($CFG, $REQ) { |
|
121 | 121 | $display_order_event = $CFG->EED_Event_Single->display_order_event !== null |
122 | 122 | ? $CFG->EED_Event_Single->display_order_event |
123 | 123 | : EED_Event_Single::EVENT_DETAILS_PRIORITY; |
@@ -131,11 +131,11 @@ discard block |
||
131 | 131 | ? $CFG->EED_Event_Single->display_order_venue |
132 | 132 | : EED_Event_Single::EVENT_VENUES_PRIORITY; |
133 | 133 | $CFG->EED_Event_Single = new EE_Event_Single_Config(); |
134 | - $CFG->EED_Event_Single->display_status_banner_single = ! empty( $REQ['display_status_banner_single'] ) |
|
134 | + $CFG->EED_Event_Single->display_status_banner_single = ! empty($REQ['display_status_banner_single']) |
|
135 | 135 | && $REQ['display_status_banner_single']; |
136 | - $CFG->EED_Event_Single->display_venue = ! empty( $REQ['display_venue'] ) && $REQ['display_venue']; |
|
137 | - $CFG->EED_Event_Single->use_sortable_display_order = ! empty( $REQ[ 'EED_Events_Single_use_sortable_display_order' ] ) |
|
138 | - ? absint( $REQ[ 'EED_Events_Single_use_sortable_display_order' ] ) |
|
136 | + $CFG->EED_Event_Single->display_venue = ! empty($REQ['display_venue']) && $REQ['display_venue']; |
|
137 | + $CFG->EED_Event_Single->use_sortable_display_order = ! empty($REQ['EED_Events_Single_use_sortable_display_order']) |
|
138 | + ? absint($REQ['EED_Events_Single_use_sortable_display_order']) |
|
139 | 139 | : 0; |
140 | 140 | $CFG->EED_Event_Single->display_order_event = $CFG->EED_Event_Single->use_sortable_display_order |
141 | 141 | ? $display_order_event |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | $CFG->EED_Event_Single->display_order_venue = $CFG->EED_Event_Single->use_sortable_display_order |
150 | 150 | ? $display_order_venue |
151 | 151 | : EED_Event_Single::EVENT_VENUES_PRIORITY; |
152 | - do_action( 'AHEE__EED_Event_Single__update_template_settings__after_update', $CFG, $REQ ); |
|
152 | + do_action('AHEE__EED_Event_Single__update_template_settings__after_update', $CFG, $REQ); |
|
153 | 153 | return $CFG; |
154 | 154 | } |
155 | 155 | |
@@ -163,23 +163,23 @@ discard block |
||
163 | 163 | */ |
164 | 164 | public static function update_event_single_order() { |
165 | 165 | $config_saved = false; |
166 | - $template_parts = sanitize_text_field( $_POST[ 'elements' ] ); |
|
167 | - if ( ! empty( $template_parts ) ) { |
|
168 | - $template_parts = explode( ',', trim( $template_parts, ',' ) ); |
|
169 | - foreach ( $template_parts as $key => $template_part ) { |
|
166 | + $template_parts = sanitize_text_field($_POST['elements']); |
|
167 | + if ( ! empty($template_parts)) { |
|
168 | + $template_parts = explode(',', trim($template_parts, ',')); |
|
169 | + foreach ($template_parts as $key => $template_part) { |
|
170 | 170 | $template_part = "display_order_$template_part"; |
171 | - $priority = ( $key * 10 ) + EED_Event_Single::EVENT_DETAILS_PRIORITY; |
|
171 | + $priority = ($key * 10) + EED_Event_Single::EVENT_DETAILS_PRIORITY; |
|
172 | 172 | EE_Registry::instance()->CFG->template_settings->EED_Event_Single->{$template_part} = $priority; |
173 | - do_action( "AHEE__EED_Event_Single__update_event_single_order__$template_part", $priority ); |
|
173 | + do_action("AHEE__EED_Event_Single__update_event_single_order__$template_part", $priority); |
|
174 | 174 | } |
175 | - $config_saved = EE_Registry::instance()->CFG->update_espresso_config( false, false ); |
|
175 | + $config_saved = EE_Registry::instance()->CFG->update_espresso_config(false, false); |
|
176 | 176 | } |
177 | - if ( $config_saved ) { |
|
178 | - EE_Error::add_success( __( 'Display Order has been successfully updated.', 'event_espresso' ) ); |
|
177 | + if ($config_saved) { |
|
178 | + EE_Error::add_success(__('Display Order has been successfully updated.', 'event_espresso')); |
|
179 | 179 | } else { |
180 | - EE_Error::add_error( __( 'Display Order was not updated.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
180 | + EE_Error::add_error(__('Display Order was not updated.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
181 | 181 | } |
182 | - echo wp_json_encode( EE_Error::get_notices( false )); |
|
182 | + echo wp_json_encode(EE_Error::get_notices(false)); |
|
183 | 183 | exit(); |
184 | 184 | } |
185 | 185 | |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | * @param WP $WP |
193 | 193 | * @return void |
194 | 194 | */ |
195 | - public function run( $WP ) { |
|
195 | + public function run($WP) { |
|
196 | 196 | } |
197 | 197 | |
198 | 198 |
@@ -86,52 +86,52 @@ discard block |
||
86 | 86 | $gen_set_admin = EE_Registry::instance()->LIB->EE_Admin_Page_Loader->get_admin_page_object( 'general_settings' ); |
87 | 87 | if ( $gen_set_admin instanceof General_Settings_Admin_Page ) { |
88 | 88 | remove_action( |
89 | - 'AHEE__template_settings__template__before_settings_form', |
|
90 | - array( $gen_set_admin, 'template_settings_caff_features' ), |
|
91 | - 100 |
|
92 | - ); |
|
89 | + 'AHEE__template_settings__template__before_settings_form', |
|
90 | + array( $gen_set_admin, 'template_settings_caff_features' ), |
|
91 | + 100 |
|
92 | + ); |
|
93 | 93 | } |
94 | 94 | // first just grab the template settings |
95 | 95 | $config = EE_Registry::instance()->CFG->template_settings; |
96 | 96 | // then if the Event Archive config is valid, use that, else create a new one |
97 | 97 | $config = isset( $config->EED_Events_Archive ) && $config->EED_Events_Archive instanceof EE_Events_Archive_Config |
98 | - ? $config->EED_Events_Archive |
|
99 | - : new EE_Events_Archive_Config(); |
|
98 | + ? $config->EED_Events_Archive |
|
99 | + : new EE_Events_Archive_Config(); |
|
100 | 100 | $config = apply_filters( 'FHEE__EED_Events_Archive__template_settings_form__event_list_config', $config ); |
101 | 101 | $config->display_status_banner = isset( $config->display_status_banner ) |
102 | - ? $config->display_status_banner |
|
103 | - : 0; |
|
102 | + ? $config->display_status_banner |
|
103 | + : 0; |
|
104 | 104 | $config->display_description = isset( $config->display_description ) |
105 | - ? $config->display_description |
|
106 | - : 1; |
|
105 | + ? $config->display_description |
|
106 | + : 1; |
|
107 | 107 | $config->display_ticket_selector = isset( $config->display_ticket_selector ) |
108 | - ? $config->display_ticket_selector |
|
109 | - : 0; |
|
108 | + ? $config->display_ticket_selector |
|
109 | + : 0; |
|
110 | 110 | $config->display_datetimes = isset( $config->display_datetimes ) |
111 | - ? $config->display_datetimes |
|
112 | - : 1; |
|
111 | + ? $config->display_datetimes |
|
112 | + : 1; |
|
113 | 113 | $config->display_venue = isset( $config->display_venue ) |
114 | - ? $config->display_venue |
|
115 | - : 0; |
|
114 | + ? $config->display_venue |
|
115 | + : 0; |
|
116 | 116 | $config->display_expired_events = isset( $config->display_expired_events ) |
117 | - ? $config->display_expired_events |
|
118 | - : 0; |
|
117 | + ? $config->display_expired_events |
|
118 | + : 0; |
|
119 | 119 | // display order options |
120 | 120 | $config->use_sortable_display_order = isset( $config->use_sortable_display_order ) |
121 | - ? $config->use_sortable_display_order |
|
122 | - : false; |
|
121 | + ? $config->use_sortable_display_order |
|
122 | + : false; |
|
123 | 123 | $config->display_order_tickets = isset( $config->display_order_tickets ) |
124 | - ? $config->display_order_tickets |
|
125 | - : 120; |
|
124 | + ? $config->display_order_tickets |
|
125 | + : 120; |
|
126 | 126 | $config->display_order_datetimes = isset( $config->display_order_datetimes ) |
127 | - ? $config->display_order_datetimes |
|
128 | - : 110; |
|
127 | + ? $config->display_order_datetimes |
|
128 | + : 110; |
|
129 | 129 | $config->display_order_event = isset( $config->display_order_event ) |
130 | - ? $config->display_order_event |
|
131 | - : 100; |
|
130 | + ? $config->display_order_event |
|
131 | + : 100; |
|
132 | 132 | $config->display_order_venue = isset( $config->display_order_venue ) |
133 | - ? $config->display_order_venue |
|
134 | - : 130; |
|
133 | + ? $config->display_order_venue |
|
134 | + : 130; |
|
135 | 135 | // get template parts |
136 | 136 | $template_parts = EED_Events_Archive::instance()->initialize_template_parts( $config ); |
137 | 137 | // convert to array so that we can add more properties |
@@ -165,17 +165,17 @@ discard block |
||
165 | 165 | $config->display_expired_events = isset( $REQ['EED_Events_Archive_display_expired_events'] ) ? absint( $REQ['EED_Events_Archive_display_expired_events'] ) : 0; |
166 | 166 | $config->use_sortable_display_order = isset( $REQ['EED_Events_Archive_use_sortable_display_order'] ) ? absint( $REQ['EED_Events_Archive_use_sortable_display_order'] ) : 0; |
167 | 167 | $config->display_order_event = isset( $CFG->EED_Events_Archive->display_order_event ) && $config->use_sortable_display_order |
168 | - ? $CFG->EED_Events_Archive->display_order_event |
|
169 | - : EED_Events_Archive::EVENT_DETAILS_PRIORITY; |
|
168 | + ? $CFG->EED_Events_Archive->display_order_event |
|
169 | + : EED_Events_Archive::EVENT_DETAILS_PRIORITY; |
|
170 | 170 | $config->display_order_datetimes = isset( $CFG->EED_Events_Archive->display_order_datetimes ) && $config->use_sortable_display_order |
171 | - ? $CFG->EED_Events_Archive->display_order_datetimes |
|
172 | - : EED_Events_Archive::EVENT_DATETIMES_PRIORITY; |
|
171 | + ? $CFG->EED_Events_Archive->display_order_datetimes |
|
172 | + : EED_Events_Archive::EVENT_DATETIMES_PRIORITY; |
|
173 | 173 | $config->display_order_tickets = isset( $CFG->EED_Events_Archive->display_order_tickets ) && $config->use_sortable_display_order |
174 | - ? $CFG->EED_Events_Archive->display_order_tickets |
|
175 | - : EED_Events_Archive::EVENT_TICKETS_PRIORITY; |
|
174 | + ? $CFG->EED_Events_Archive->display_order_tickets |
|
175 | + : EED_Events_Archive::EVENT_TICKETS_PRIORITY; |
|
176 | 176 | $config->display_order_venue = isset( $CFG->EED_Events_Archive->display_order_venue ) && $config->use_sortable_display_order |
177 | - ? $CFG->EED_Events_Archive->display_order_venue |
|
178 | - : EED_Events_Archive::EVENT_VENUES_PRIORITY; |
|
177 | + ? $CFG->EED_Events_Archive->display_order_venue |
|
178 | + : EED_Events_Archive::EVENT_VENUES_PRIORITY; |
|
179 | 179 | } |
180 | 180 | $CFG->EED_Events_Archive = $config; |
181 | 181 | do_action( 'AHEE__EED_Events_Archive__update_template_settings__after_update', $CFG, $REQ ); |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | * @return EED_Events_Archive_Caff |
29 | 29 | */ |
30 | 30 | public static function instance() { |
31 | - return parent::get_instance( __CLASS__ ); |
|
31 | + return parent::get_instance(__CLASS__); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | |
@@ -49,13 +49,13 @@ discard block |
||
49 | 49 | * @return void |
50 | 50 | */ |
51 | 51 | public static function set_hooks_admin() { |
52 | - define( 'EVENTS_ARCHIVE_CAFF_TEMPLATES_PATH', str_replace( '\\', DS, plugin_dir_path( __FILE__ )) . 'templates' . DS ); |
|
53 | - define( 'EVENT_ARCHIVE_CAFF_ASSETS_URL', plugin_dir_url( __FILE__ ) . 'assets' . DS ); |
|
54 | - add_action( 'AHEE__template_settings__template__before_settings_form', array( 'EED_Events_Archive_Caff', 'template_settings_form' ), 10 ); |
|
55 | - add_filter( 'FHEE__General_Settings_Admin_Page__update_template_settings__data', array( 'EED_Events_Archive_Caff', 'update_template_settings' ), 10, 2 ); |
|
52 | + define('EVENTS_ARCHIVE_CAFF_TEMPLATES_PATH', str_replace('\\', DS, plugin_dir_path(__FILE__)).'templates'.DS); |
|
53 | + define('EVENT_ARCHIVE_CAFF_ASSETS_URL', plugin_dir_url(__FILE__).'assets'.DS); |
|
54 | + add_action('AHEE__template_settings__template__before_settings_form', array('EED_Events_Archive_Caff', 'template_settings_form'), 10); |
|
55 | + add_filter('FHEE__General_Settings_Admin_Page__update_template_settings__data', array('EED_Events_Archive_Caff', 'update_template_settings'), 10, 2); |
|
56 | 56 | // AJAX |
57 | - add_action( 'wp_ajax_espresso_update_event_archive_order', array( 'EED_Events_Archive_Caff', 'update_event_archive_order' ) ); |
|
58 | - add_action( 'wp_ajax_nopriv_espresso_update_event_archive_order', array( 'EED_Events_Archive_Caff', 'update_event_archive_order' ) ); |
|
57 | + add_action('wp_ajax_espresso_update_event_archive_order', array('EED_Events_Archive_Caff', 'update_event_archive_order')); |
|
58 | + add_action('wp_ajax_nopriv_espresso_update_event_archive_order', array('EED_Events_Archive_Caff', 'update_event_archive_order')); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | * @param WP $WP |
69 | 69 | * @return void |
70 | 70 | */ |
71 | - public function run( $WP ) { |
|
71 | + public function run($WP) { |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | |
@@ -83,61 +83,61 @@ discard block |
||
83 | 83 | */ |
84 | 84 | public static function template_settings_form() { |
85 | 85 | // grab general settings admin page and remove the existing hook callback |
86 | - $gen_set_admin = EE_Registry::instance()->LIB->EE_Admin_Page_Loader->get_admin_page_object( 'general_settings' ); |
|
87 | - if ( $gen_set_admin instanceof General_Settings_Admin_Page ) { |
|
86 | + $gen_set_admin = EE_Registry::instance()->LIB->EE_Admin_Page_Loader->get_admin_page_object('general_settings'); |
|
87 | + if ($gen_set_admin instanceof General_Settings_Admin_Page) { |
|
88 | 88 | remove_action( |
89 | 89 | 'AHEE__template_settings__template__before_settings_form', |
90 | - array( $gen_set_admin, 'template_settings_caff_features' ), |
|
90 | + array($gen_set_admin, 'template_settings_caff_features'), |
|
91 | 91 | 100 |
92 | 92 | ); |
93 | 93 | } |
94 | 94 | // first just grab the template settings |
95 | 95 | $config = EE_Registry::instance()->CFG->template_settings; |
96 | 96 | // then if the Event Archive config is valid, use that, else create a new one |
97 | - $config = isset( $config->EED_Events_Archive ) && $config->EED_Events_Archive instanceof EE_Events_Archive_Config |
|
97 | + $config = isset($config->EED_Events_Archive) && $config->EED_Events_Archive instanceof EE_Events_Archive_Config |
|
98 | 98 | ? $config->EED_Events_Archive |
99 | 99 | : new EE_Events_Archive_Config(); |
100 | - $config = apply_filters( 'FHEE__EED_Events_Archive__template_settings_form__event_list_config', $config ); |
|
101 | - $config->display_status_banner = isset( $config->display_status_banner ) |
|
100 | + $config = apply_filters('FHEE__EED_Events_Archive__template_settings_form__event_list_config', $config); |
|
101 | + $config->display_status_banner = isset($config->display_status_banner) |
|
102 | 102 | ? $config->display_status_banner |
103 | 103 | : 0; |
104 | - $config->display_description = isset( $config->display_description ) |
|
104 | + $config->display_description = isset($config->display_description) |
|
105 | 105 | ? $config->display_description |
106 | 106 | : 1; |
107 | - $config->display_ticket_selector = isset( $config->display_ticket_selector ) |
|
107 | + $config->display_ticket_selector = isset($config->display_ticket_selector) |
|
108 | 108 | ? $config->display_ticket_selector |
109 | 109 | : 0; |
110 | - $config->display_datetimes = isset( $config->display_datetimes ) |
|
110 | + $config->display_datetimes = isset($config->display_datetimes) |
|
111 | 111 | ? $config->display_datetimes |
112 | 112 | : 1; |
113 | - $config->display_venue = isset( $config->display_venue ) |
|
113 | + $config->display_venue = isset($config->display_venue) |
|
114 | 114 | ? $config->display_venue |
115 | 115 | : 0; |
116 | - $config->display_expired_events = isset( $config->display_expired_events ) |
|
116 | + $config->display_expired_events = isset($config->display_expired_events) |
|
117 | 117 | ? $config->display_expired_events |
118 | 118 | : 0; |
119 | 119 | // display order options |
120 | - $config->use_sortable_display_order = isset( $config->use_sortable_display_order ) |
|
120 | + $config->use_sortable_display_order = isset($config->use_sortable_display_order) |
|
121 | 121 | ? $config->use_sortable_display_order |
122 | 122 | : false; |
123 | - $config->display_order_tickets = isset( $config->display_order_tickets ) |
|
123 | + $config->display_order_tickets = isset($config->display_order_tickets) |
|
124 | 124 | ? $config->display_order_tickets |
125 | 125 | : 120; |
126 | - $config->display_order_datetimes = isset( $config->display_order_datetimes ) |
|
126 | + $config->display_order_datetimes = isset($config->display_order_datetimes) |
|
127 | 127 | ? $config->display_order_datetimes |
128 | 128 | : 110; |
129 | - $config->display_order_event = isset( $config->display_order_event ) |
|
129 | + $config->display_order_event = isset($config->display_order_event) |
|
130 | 130 | ? $config->display_order_event |
131 | 131 | : 100; |
132 | - $config->display_order_venue = isset( $config->display_order_venue ) |
|
132 | + $config->display_order_venue = isset($config->display_order_venue) |
|
133 | 133 | ? $config->display_order_venue |
134 | 134 | : 130; |
135 | 135 | // get template parts |
136 | - $template_parts = EED_Events_Archive::instance()->initialize_template_parts( $config ); |
|
136 | + $template_parts = EED_Events_Archive::instance()->initialize_template_parts($config); |
|
137 | 137 | // convert to array so that we can add more properties |
138 | - $config = get_object_vars( $config ); |
|
139 | - $config[ 'event_archive_display_order' ] = $template_parts->generate_sortable_list_of_template_parts( 'event-archive-sortable-js', '', 'archive-sortable-li archive-sortable-js' ); |
|
140 | - EEH_Template::display_template( EVENTS_ARCHIVE_CAFF_TEMPLATES_PATH . 'admin-event-list-settings.template.php', $config ); |
|
138 | + $config = get_object_vars($config); |
|
139 | + $config['event_archive_display_order'] = $template_parts->generate_sortable_list_of_template_parts('event-archive-sortable-js', '', 'archive-sortable-li archive-sortable-js'); |
|
140 | + EEH_Template::display_template(EVENTS_ARCHIVE_CAFF_TEMPLATES_PATH.'admin-event-list-settings.template.php', $config); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | |
@@ -153,32 +153,32 @@ discard block |
||
153 | 153 | * @param array $REQ |
154 | 154 | * @return EE_Events_Archive_Config |
155 | 155 | */ |
156 | - public static function update_template_settings( $CFG, $REQ ) { |
|
156 | + public static function update_template_settings($CFG, $REQ) { |
|
157 | 157 | $config = new EE_Events_Archive_Config(); |
158 | 158 | // unless we are resetting the config... |
159 | - if ( ! isset( $REQ['EED_Events_Archive_reset_event_list_settings'] ) || absint( $REQ['EED_Events_Archive_reset_event_list_settings'] ) !== 1 ) { |
|
160 | - $config->display_status_banner = isset( $REQ['EED_Events_Archive_display_status_banner'] ) ? absint( $REQ['EED_Events_Archive_display_status_banner'] ) : 0; |
|
161 | - $config->display_description = isset( $REQ['EED_Events_Archive_display_description'] ) ? absint( $REQ['EED_Events_Archive_display_description'] ) : 1; |
|
162 | - $config->display_ticket_selector = isset( $REQ['EED_Events_Archive_display_ticket_selector'] ) ? absint( $REQ['EED_Events_Archive_display_ticket_selector'] ) : 0; |
|
163 | - $config->display_datetimes = isset( $REQ['EED_Events_Archive_display_datetimes'] ) ? absint( $REQ['EED_Events_Archive_display_datetimes'] ) : 1; |
|
164 | - $config->display_venue = isset( $REQ['EED_Events_Archive_display_venue'] ) ? absint( $REQ['EED_Events_Archive_display_venue'] ) : 0; |
|
165 | - $config->display_expired_events = isset( $REQ['EED_Events_Archive_display_expired_events'] ) ? absint( $REQ['EED_Events_Archive_display_expired_events'] ) : 0; |
|
166 | - $config->use_sortable_display_order = isset( $REQ['EED_Events_Archive_use_sortable_display_order'] ) ? absint( $REQ['EED_Events_Archive_use_sortable_display_order'] ) : 0; |
|
167 | - $config->display_order_event = isset( $CFG->EED_Events_Archive->display_order_event ) && $config->use_sortable_display_order |
|
159 | + if ( ! isset($REQ['EED_Events_Archive_reset_event_list_settings']) || absint($REQ['EED_Events_Archive_reset_event_list_settings']) !== 1) { |
|
160 | + $config->display_status_banner = isset($REQ['EED_Events_Archive_display_status_banner']) ? absint($REQ['EED_Events_Archive_display_status_banner']) : 0; |
|
161 | + $config->display_description = isset($REQ['EED_Events_Archive_display_description']) ? absint($REQ['EED_Events_Archive_display_description']) : 1; |
|
162 | + $config->display_ticket_selector = isset($REQ['EED_Events_Archive_display_ticket_selector']) ? absint($REQ['EED_Events_Archive_display_ticket_selector']) : 0; |
|
163 | + $config->display_datetimes = isset($REQ['EED_Events_Archive_display_datetimes']) ? absint($REQ['EED_Events_Archive_display_datetimes']) : 1; |
|
164 | + $config->display_venue = isset($REQ['EED_Events_Archive_display_venue']) ? absint($REQ['EED_Events_Archive_display_venue']) : 0; |
|
165 | + $config->display_expired_events = isset($REQ['EED_Events_Archive_display_expired_events']) ? absint($REQ['EED_Events_Archive_display_expired_events']) : 0; |
|
166 | + $config->use_sortable_display_order = isset($REQ['EED_Events_Archive_use_sortable_display_order']) ? absint($REQ['EED_Events_Archive_use_sortable_display_order']) : 0; |
|
167 | + $config->display_order_event = isset($CFG->EED_Events_Archive->display_order_event) && $config->use_sortable_display_order |
|
168 | 168 | ? $CFG->EED_Events_Archive->display_order_event |
169 | 169 | : EED_Events_Archive::EVENT_DETAILS_PRIORITY; |
170 | - $config->display_order_datetimes = isset( $CFG->EED_Events_Archive->display_order_datetimes ) && $config->use_sortable_display_order |
|
170 | + $config->display_order_datetimes = isset($CFG->EED_Events_Archive->display_order_datetimes) && $config->use_sortable_display_order |
|
171 | 171 | ? $CFG->EED_Events_Archive->display_order_datetimes |
172 | 172 | : EED_Events_Archive::EVENT_DATETIMES_PRIORITY; |
173 | - $config->display_order_tickets = isset( $CFG->EED_Events_Archive->display_order_tickets ) && $config->use_sortable_display_order |
|
173 | + $config->display_order_tickets = isset($CFG->EED_Events_Archive->display_order_tickets) && $config->use_sortable_display_order |
|
174 | 174 | ? $CFG->EED_Events_Archive->display_order_tickets |
175 | 175 | : EED_Events_Archive::EVENT_TICKETS_PRIORITY; |
176 | - $config->display_order_venue = isset( $CFG->EED_Events_Archive->display_order_venue ) && $config->use_sortable_display_order |
|
176 | + $config->display_order_venue = isset($CFG->EED_Events_Archive->display_order_venue) && $config->use_sortable_display_order |
|
177 | 177 | ? $CFG->EED_Events_Archive->display_order_venue |
178 | 178 | : EED_Events_Archive::EVENT_VENUES_PRIORITY; |
179 | 179 | } |
180 | 180 | $CFG->EED_Events_Archive = $config; |
181 | - do_action( 'AHEE__EED_Events_Archive__update_template_settings__after_update', $CFG, $REQ ); |
|
181 | + do_action('AHEE__EED_Events_Archive__update_template_settings__after_update', $CFG, $REQ); |
|
182 | 182 | return $CFG; |
183 | 183 | } |
184 | 184 | |
@@ -192,12 +192,12 @@ discard block |
||
192 | 192 | */ |
193 | 193 | public static function update_event_archive_order() { |
194 | 194 | $config_saved = false; |
195 | - $template_parts = sanitize_text_field( $_POST[ 'elements' ] ); |
|
196 | - if ( ! empty( $template_parts ) ) { |
|
197 | - $template_parts = explode( ',', trim( $template_parts, ',' ) ); |
|
198 | - foreach ( $template_parts as $key => $template_part ) { |
|
195 | + $template_parts = sanitize_text_field($_POST['elements']); |
|
196 | + if ( ! empty($template_parts)) { |
|
197 | + $template_parts = explode(',', trim($template_parts, ',')); |
|
198 | + foreach ($template_parts as $key => $template_part) { |
|
199 | 199 | $template_part = "display_order_$template_part"; |
200 | - $priority = ( $key * 10 ) + EED_Events_Archive::EVENT_DETAILS_PRIORITY; |
|
200 | + $priority = ($key * 10) + EED_Events_Archive::EVENT_DETAILS_PRIORITY; |
|
201 | 201 | if ( |
202 | 202 | property_exists( |
203 | 203 | EE_Registry::instance()->CFG->template_settings->EED_Events_Archive, |
@@ -206,16 +206,16 @@ discard block |
||
206 | 206 | ) { |
207 | 207 | EE_Registry::instance()->CFG->template_settings->EED_Events_Archive->{$template_part} = $priority; |
208 | 208 | } |
209 | - do_action( "AHEE__EED_Events_Archive__update_event_archive_order__$template_part", $priority ); |
|
209 | + do_action("AHEE__EED_Events_Archive__update_event_archive_order__$template_part", $priority); |
|
210 | 210 | } |
211 | - $config_saved = EE_Registry::instance()->CFG->update_espresso_config( false, false ); |
|
211 | + $config_saved = EE_Registry::instance()->CFG->update_espresso_config(false, false); |
|
212 | 212 | } |
213 | - if ( $config_saved ) { |
|
214 | - EE_Error::add_success( __( 'Display Order has been successfully updated.', 'event_espresso' ) ); |
|
213 | + if ($config_saved) { |
|
214 | + EE_Error::add_success(__('Display Order has been successfully updated.', 'event_espresso')); |
|
215 | 215 | } else { |
216 | - EE_Error::add_error( __( 'Display Order was not updated.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
216 | + EE_Error::add_error(__('Display Order was not updated.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
217 | 217 | } |
218 | - echo wp_json_encode( EE_Error::get_notices( false ) ); |
|
218 | + echo wp_json_encode(EE_Error::get_notices(false)); |
|
219 | 219 | exit(); |
220 | 220 | } |
221 | 221 |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | //namespace EventEspresso\core\libraries\templates; |
3 | 3 | if (!defined('EVENT_ESPRESSO_VERSION')) { |
4 | - exit('No direct script access allowed'); |
|
4 | + exit('No direct script access allowed'); |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | |
@@ -19,198 +19,198 @@ discard block |
||
19 | 19 | class EE_Template_Part_Manager |
20 | 20 | { |
21 | 21 | |
22 | - /** |
|
23 | - * @param EE_Template_Part_PriorityQueue $template_parts |
|
24 | - */ |
|
25 | - protected $template_parts; |
|
26 | - |
|
27 | - /** |
|
28 | - * @param array $priorities |
|
29 | - */ |
|
30 | - protected $priorities = array(); |
|
31 | - |
|
32 | - /** |
|
33 | - * @param int $event_desc_priority |
|
34 | - */ |
|
35 | - protected $event_desc_priority; |
|
36 | - |
|
37 | - /** |
|
38 | - * @param string $before_event_content |
|
39 | - */ |
|
40 | - protected $before_event_content; |
|
41 | - |
|
42 | - /** |
|
43 | - * @param string $event_content |
|
44 | - */ |
|
45 | - protected $event_content; |
|
46 | - |
|
47 | - /** |
|
48 | - * @param string $after_event_content |
|
49 | - */ |
|
50 | - protected $after_event_content; |
|
51 | - |
|
52 | - |
|
53 | - /** |
|
54 | - * class constructor |
|
55 | - */ |
|
56 | - public function __construct() |
|
57 | - { |
|
58 | - $this->template_parts = new EE_Template_Part_PriorityQueue(); |
|
59 | - } |
|
60 | - |
|
61 | - |
|
62 | - /** |
|
63 | - * add_template_part |
|
64 | - * |
|
65 | - * used for setting the details about a particular template part |
|
66 | - * |
|
67 | - * @param string $name - just a simple string identifier - do NOT use 'event' |
|
68 | - * @param string $label - template part label displayed in admin |
|
69 | - * @param string $template - name or path of template to be used by EEH_Template::locate_template() |
|
70 | - * @param int $priority - order in which template parts should be applied |
|
71 | - */ |
|
72 | - public function add_template_part($name, $label, $template, $priority) |
|
73 | - { |
|
74 | - // SplPriorityQueue doesn't play nice with multiple items having the same priority |
|
75 | - // so if the incoming priority is already occupied, then let's increment it by one, |
|
76 | - // and then pass everything back into this method and try again with the new priority |
|
77 | - if (isset($this->priorities[$priority])) { |
|
78 | - $priority++; |
|
79 | - $this->add_template_part($name, $label, $template, $priority); |
|
80 | - return; |
|
81 | - } |
|
82 | - // kk now we can mark this priority as being occupied |
|
83 | - $this->priorities[$priority] = true; |
|
84 | - // create the template part and add to the queue |
|
85 | - $this->template_parts->insert( |
|
86 | - new EE_Template_Part($name, $label, $template, $priority), |
|
87 | - $priority |
|
88 | - ); |
|
89 | - if ($name === 'event') { |
|
90 | - $this->event_desc_priority = $priority; |
|
91 | - } |
|
92 | - } |
|
93 | - |
|
94 | - |
|
95 | - /** |
|
96 | - * apply_template_part_filters |
|
97 | - * |
|
98 | - * adds template parts to the supplied content |
|
99 | - * according to the details set when the template parts were added |
|
100 | - * |
|
101 | - * @access public |
|
102 | - * @param string $content |
|
103 | - * @return string |
|
104 | - */ |
|
105 | - public function apply_template_part_filters($content = '') |
|
106 | - { |
|
107 | - $this->template_parts->rewind(); |
|
108 | - // loop through template parts and position content |
|
109 | - while ($this->template_parts->valid()) { |
|
110 | - $this->_position_template_part( |
|
111 | - $content, |
|
112 | - $this->template_parts->current()->template(), |
|
113 | - $this->template_parts->current()->priority() |
|
114 | - ); |
|
115 | - $this->template_parts->next(); |
|
116 | - } |
|
117 | - // now simply add our three strings of content together |
|
118 | - return $this->before_event_content . $this->event_content . $this->after_event_content; |
|
119 | - } |
|
120 | - |
|
121 | - |
|
122 | - /** |
|
123 | - * position_template_part |
|
124 | - * |
|
125 | - * based on the priority of the incoming template part |
|
126 | - * relative to the known event description template part priority, |
|
127 | - * this method will assign template parts to one of the following: |
|
128 | - * $this->before_event_content |
|
129 | - * $this->event_content |
|
130 | - * $this->after_event_content |
|
131 | - * |
|
132 | - * @access protected |
|
133 | - * @param string $content |
|
134 | - * @param string $template |
|
135 | - * @param int $priority |
|
136 | - * @return void |
|
137 | - */ |
|
138 | - protected function _position_template_part($content, $template, $priority) |
|
139 | - { |
|
140 | - // Event Description content is the actual incoming content itself |
|
141 | - if ($priority === $this->event_desc_priority) { |
|
142 | - $this->event_content = $content; |
|
143 | - } else if ($priority < $this->event_desc_priority) { |
|
144 | - // everything BEFORE the Event Description |
|
145 | - $this->before_event_content .= EEH_Template::locate_template($template); |
|
146 | - } else if ($priority > $this->event_desc_priority) { |
|
147 | - // everything AFTER the Event Description |
|
148 | - $this->after_event_content .= EEH_Template::locate_template($template); |
|
149 | - } |
|
150 | - } |
|
151 | - |
|
152 | - |
|
153 | - /** |
|
154 | - * generate_sortable_list_of_template_parts |
|
155 | - * |
|
156 | - * creates an HTML list (<ul>) with list items (<li>) for each template part, |
|
157 | - * in a format that can be used as a sortable list in the admin |
|
158 | - * |
|
159 | - * @access public |
|
160 | - * @param string $list_css_id |
|
161 | - * @param string $list_css_class |
|
162 | - * @param string $list_item_css_class |
|
163 | - * @param string $list_item_css_id_prefix |
|
164 | - * @return string |
|
165 | - */ |
|
166 | - public function generate_sortable_list_of_template_parts( |
|
167 | - $list_css_id = '', |
|
168 | - $list_css_class = '', |
|
169 | - $list_item_css_class = '', |
|
170 | - $list_item_css_id_prefix = '' |
|
171 | - ) |
|
172 | - { |
|
173 | - $event_archive_display_order = EEH_HTML::ul($list_css_id, $list_css_class); |
|
174 | - $this->template_parts->rewind(); |
|
175 | - // loop through template parts and add template content |
|
176 | - while ($this->template_parts->valid()) { |
|
177 | - $event_archive_display_order .= EEH_HTML::li( |
|
178 | - EEH_HTML::span('', '', 'dashicons dashicons-arrow-up-alt2') . |
|
179 | - EEH_HTML::span('', '', 'dashicons dashicons-arrow-down-alt2') . |
|
180 | - $this->template_parts->current()->label(), |
|
181 | - $list_item_css_id_prefix . $this->template_parts->current()->name(), |
|
182 | - $list_item_css_class |
|
183 | - ); |
|
184 | - $this->template_parts->next(); |
|
185 | - } |
|
186 | - $event_archive_display_order .= EEH_HTML::ulx(); |
|
187 | - return $event_archive_display_order; |
|
188 | - } |
|
189 | - |
|
190 | - |
|
191 | - /** |
|
192 | - * display_template_parts |
|
193 | - * |
|
194 | - * just for debugging purposes |
|
195 | - * |
|
196 | - * @access public |
|
197 | - * @return void |
|
198 | - */ |
|
199 | - public function display_template_parts() |
|
200 | - { |
|
201 | - if (WP_DEBUG) { |
|
202 | - $this->template_parts->rewind(); |
|
203 | - while ($this->template_parts->valid()) { |
|
204 | - EEH_Debug_Tools::printr( |
|
205 | - $this->template_parts->current(), |
|
206 | - 'template_part', |
|
207 | - __FILE__, |
|
208 | - __LINE__ |
|
209 | - ); |
|
210 | - $this->template_parts->next(); |
|
211 | - } |
|
212 | - } |
|
213 | - } |
|
22 | + /** |
|
23 | + * @param EE_Template_Part_PriorityQueue $template_parts |
|
24 | + */ |
|
25 | + protected $template_parts; |
|
26 | + |
|
27 | + /** |
|
28 | + * @param array $priorities |
|
29 | + */ |
|
30 | + protected $priorities = array(); |
|
31 | + |
|
32 | + /** |
|
33 | + * @param int $event_desc_priority |
|
34 | + */ |
|
35 | + protected $event_desc_priority; |
|
36 | + |
|
37 | + /** |
|
38 | + * @param string $before_event_content |
|
39 | + */ |
|
40 | + protected $before_event_content; |
|
41 | + |
|
42 | + /** |
|
43 | + * @param string $event_content |
|
44 | + */ |
|
45 | + protected $event_content; |
|
46 | + |
|
47 | + /** |
|
48 | + * @param string $after_event_content |
|
49 | + */ |
|
50 | + protected $after_event_content; |
|
51 | + |
|
52 | + |
|
53 | + /** |
|
54 | + * class constructor |
|
55 | + */ |
|
56 | + public function __construct() |
|
57 | + { |
|
58 | + $this->template_parts = new EE_Template_Part_PriorityQueue(); |
|
59 | + } |
|
60 | + |
|
61 | + |
|
62 | + /** |
|
63 | + * add_template_part |
|
64 | + * |
|
65 | + * used for setting the details about a particular template part |
|
66 | + * |
|
67 | + * @param string $name - just a simple string identifier - do NOT use 'event' |
|
68 | + * @param string $label - template part label displayed in admin |
|
69 | + * @param string $template - name or path of template to be used by EEH_Template::locate_template() |
|
70 | + * @param int $priority - order in which template parts should be applied |
|
71 | + */ |
|
72 | + public function add_template_part($name, $label, $template, $priority) |
|
73 | + { |
|
74 | + // SplPriorityQueue doesn't play nice with multiple items having the same priority |
|
75 | + // so if the incoming priority is already occupied, then let's increment it by one, |
|
76 | + // and then pass everything back into this method and try again with the new priority |
|
77 | + if (isset($this->priorities[$priority])) { |
|
78 | + $priority++; |
|
79 | + $this->add_template_part($name, $label, $template, $priority); |
|
80 | + return; |
|
81 | + } |
|
82 | + // kk now we can mark this priority as being occupied |
|
83 | + $this->priorities[$priority] = true; |
|
84 | + // create the template part and add to the queue |
|
85 | + $this->template_parts->insert( |
|
86 | + new EE_Template_Part($name, $label, $template, $priority), |
|
87 | + $priority |
|
88 | + ); |
|
89 | + if ($name === 'event') { |
|
90 | + $this->event_desc_priority = $priority; |
|
91 | + } |
|
92 | + } |
|
93 | + |
|
94 | + |
|
95 | + /** |
|
96 | + * apply_template_part_filters |
|
97 | + * |
|
98 | + * adds template parts to the supplied content |
|
99 | + * according to the details set when the template parts were added |
|
100 | + * |
|
101 | + * @access public |
|
102 | + * @param string $content |
|
103 | + * @return string |
|
104 | + */ |
|
105 | + public function apply_template_part_filters($content = '') |
|
106 | + { |
|
107 | + $this->template_parts->rewind(); |
|
108 | + // loop through template parts and position content |
|
109 | + while ($this->template_parts->valid()) { |
|
110 | + $this->_position_template_part( |
|
111 | + $content, |
|
112 | + $this->template_parts->current()->template(), |
|
113 | + $this->template_parts->current()->priority() |
|
114 | + ); |
|
115 | + $this->template_parts->next(); |
|
116 | + } |
|
117 | + // now simply add our three strings of content together |
|
118 | + return $this->before_event_content . $this->event_content . $this->after_event_content; |
|
119 | + } |
|
120 | + |
|
121 | + |
|
122 | + /** |
|
123 | + * position_template_part |
|
124 | + * |
|
125 | + * based on the priority of the incoming template part |
|
126 | + * relative to the known event description template part priority, |
|
127 | + * this method will assign template parts to one of the following: |
|
128 | + * $this->before_event_content |
|
129 | + * $this->event_content |
|
130 | + * $this->after_event_content |
|
131 | + * |
|
132 | + * @access protected |
|
133 | + * @param string $content |
|
134 | + * @param string $template |
|
135 | + * @param int $priority |
|
136 | + * @return void |
|
137 | + */ |
|
138 | + protected function _position_template_part($content, $template, $priority) |
|
139 | + { |
|
140 | + // Event Description content is the actual incoming content itself |
|
141 | + if ($priority === $this->event_desc_priority) { |
|
142 | + $this->event_content = $content; |
|
143 | + } else if ($priority < $this->event_desc_priority) { |
|
144 | + // everything BEFORE the Event Description |
|
145 | + $this->before_event_content .= EEH_Template::locate_template($template); |
|
146 | + } else if ($priority > $this->event_desc_priority) { |
|
147 | + // everything AFTER the Event Description |
|
148 | + $this->after_event_content .= EEH_Template::locate_template($template); |
|
149 | + } |
|
150 | + } |
|
151 | + |
|
152 | + |
|
153 | + /** |
|
154 | + * generate_sortable_list_of_template_parts |
|
155 | + * |
|
156 | + * creates an HTML list (<ul>) with list items (<li>) for each template part, |
|
157 | + * in a format that can be used as a sortable list in the admin |
|
158 | + * |
|
159 | + * @access public |
|
160 | + * @param string $list_css_id |
|
161 | + * @param string $list_css_class |
|
162 | + * @param string $list_item_css_class |
|
163 | + * @param string $list_item_css_id_prefix |
|
164 | + * @return string |
|
165 | + */ |
|
166 | + public function generate_sortable_list_of_template_parts( |
|
167 | + $list_css_id = '', |
|
168 | + $list_css_class = '', |
|
169 | + $list_item_css_class = '', |
|
170 | + $list_item_css_id_prefix = '' |
|
171 | + ) |
|
172 | + { |
|
173 | + $event_archive_display_order = EEH_HTML::ul($list_css_id, $list_css_class); |
|
174 | + $this->template_parts->rewind(); |
|
175 | + // loop through template parts and add template content |
|
176 | + while ($this->template_parts->valid()) { |
|
177 | + $event_archive_display_order .= EEH_HTML::li( |
|
178 | + EEH_HTML::span('', '', 'dashicons dashicons-arrow-up-alt2') . |
|
179 | + EEH_HTML::span('', '', 'dashicons dashicons-arrow-down-alt2') . |
|
180 | + $this->template_parts->current()->label(), |
|
181 | + $list_item_css_id_prefix . $this->template_parts->current()->name(), |
|
182 | + $list_item_css_class |
|
183 | + ); |
|
184 | + $this->template_parts->next(); |
|
185 | + } |
|
186 | + $event_archive_display_order .= EEH_HTML::ulx(); |
|
187 | + return $event_archive_display_order; |
|
188 | + } |
|
189 | + |
|
190 | + |
|
191 | + /** |
|
192 | + * display_template_parts |
|
193 | + * |
|
194 | + * just for debugging purposes |
|
195 | + * |
|
196 | + * @access public |
|
197 | + * @return void |
|
198 | + */ |
|
199 | + public function display_template_parts() |
|
200 | + { |
|
201 | + if (WP_DEBUG) { |
|
202 | + $this->template_parts->rewind(); |
|
203 | + while ($this->template_parts->valid()) { |
|
204 | + EEH_Debug_Tools::printr( |
|
205 | + $this->template_parts->current(), |
|
206 | + 'template_part', |
|
207 | + __FILE__, |
|
208 | + __LINE__ |
|
209 | + ); |
|
210 | + $this->template_parts->next(); |
|
211 | + } |
|
212 | + } |
|
213 | + } |
|
214 | 214 | } |
215 | 215 | // End of file EE_Template_Part_Manager.class.php |
216 | 216 | // Location: /EE_Template_Part_Manager.class.php |
217 | 217 | \ No newline at end of file |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | //namespace EventEspresso\core\libraries\templates; |
3 | -if (!defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
4 | 4 | exit('No direct script access allowed'); |
5 | 5 | } |
6 | 6 | |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | $this->template_parts->next(); |
116 | 116 | } |
117 | 117 | // now simply add our three strings of content together |
118 | - return $this->before_event_content . $this->event_content . $this->after_event_content; |
|
118 | + return $this->before_event_content.$this->event_content.$this->after_event_content; |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | |
@@ -175,10 +175,10 @@ discard block |
||
175 | 175 | // loop through template parts and add template content |
176 | 176 | while ($this->template_parts->valid()) { |
177 | 177 | $event_archive_display_order .= EEH_HTML::li( |
178 | - EEH_HTML::span('', '', 'dashicons dashicons-arrow-up-alt2') . |
|
179 | - EEH_HTML::span('', '', 'dashicons dashicons-arrow-down-alt2') . |
|
178 | + EEH_HTML::span('', '', 'dashicons dashicons-arrow-up-alt2'). |
|
179 | + EEH_HTML::span('', '', 'dashicons dashicons-arrow-down-alt2'). |
|
180 | 180 | $this->template_parts->current()->label(), |
181 | - $list_item_css_id_prefix . $this->template_parts->current()->name(), |
|
181 | + $list_item_css_id_prefix.$this->template_parts->current()->name(), |
|
182 | 182 | $list_item_css_class |
183 | 183 | ); |
184 | 184 | $this->template_parts->next(); |
@@ -12,145 +12,145 @@ |
||
12 | 12 | abstract class EE_Configurable extends EE_Base |
13 | 13 | { |
14 | 14 | |
15 | - /** |
|
16 | - * @var $_config |
|
17 | - * @type EE_Config_Base |
|
18 | - */ |
|
19 | - protected $_config; |
|
20 | - |
|
21 | - /** |
|
22 | - * @var $_config_section |
|
23 | - * @type string |
|
24 | - */ |
|
25 | - protected $_config_section = ''; |
|
26 | - |
|
27 | - /** |
|
28 | - * @var $_config_class |
|
29 | - * @type string |
|
30 | - */ |
|
31 | - protected $_config_class = ''; |
|
32 | - |
|
33 | - /** |
|
34 | - * @var $_config_name |
|
35 | - * @type string |
|
36 | - */ |
|
37 | - protected $_config_name = ''; |
|
38 | - |
|
39 | - |
|
40 | - /** |
|
41 | - * @param string $config_section |
|
42 | - */ |
|
43 | - public function set_config_section($config_section = '') |
|
44 | - { |
|
45 | - $this->_config_section = !empty($config_section) ? $config_section : 'modules'; |
|
46 | - } |
|
47 | - |
|
48 | - |
|
49 | - /** |
|
50 | - * @return mixed |
|
51 | - */ |
|
52 | - public function config_section() |
|
53 | - { |
|
54 | - return $this->_config_section; |
|
55 | - } |
|
56 | - |
|
57 | - |
|
58 | - /** |
|
59 | - * @param string $config_class |
|
60 | - */ |
|
61 | - public function set_config_class($config_class = '') |
|
62 | - { |
|
63 | - $this->_config_class = $config_class; |
|
64 | - } |
|
65 | - |
|
66 | - |
|
67 | - /** |
|
68 | - * @return mixed |
|
69 | - */ |
|
70 | - public function config_class() |
|
71 | - { |
|
72 | - return $this->_config_class; |
|
73 | - } |
|
74 | - |
|
75 | - |
|
76 | - /** |
|
77 | - * @param mixed $config_name |
|
78 | - */ |
|
79 | - public function set_config_name($config_name) |
|
80 | - { |
|
81 | - $this->_config_name = !empty($config_name) ? $config_name : get_called_class(); |
|
82 | - } |
|
83 | - |
|
84 | - |
|
85 | - /** |
|
86 | - * @return mixed |
|
87 | - */ |
|
88 | - public function config_name() |
|
89 | - { |
|
90 | - return $this->_config_name; |
|
91 | - } |
|
92 | - |
|
93 | - |
|
94 | - /** |
|
95 | - * set_config |
|
96 | - * this method integrates directly with EE_Config to set up the config object for this class |
|
97 | - * |
|
98 | - * @access protected |
|
99 | - * @param EE_Config_Base $config_obj |
|
100 | - * @return mixed EE_Config_Base | NULL |
|
101 | - */ |
|
102 | - protected function _set_config(EE_Config_Base $config_obj = null) |
|
103 | - { |
|
104 | - return EE_Config::instance()->set_config( |
|
105 | - $this->config_section(), |
|
106 | - $this->config_name(), |
|
107 | - $this->config_class(), |
|
108 | - $config_obj |
|
109 | - ); |
|
110 | - } |
|
111 | - |
|
112 | - |
|
113 | - /** |
|
114 | - * _update_config |
|
115 | - * this method integrates directly with EE_Config to update an existing config object for this class |
|
116 | - * |
|
117 | - * @access protected |
|
118 | - * @param EE_Config_Base $config_obj |
|
119 | - * @throws \EE_Error |
|
120 | - * @return mixed EE_Config_Base | NULL |
|
121 | - */ |
|
122 | - public function _update_config(EE_Config_Base $config_obj = null) |
|
123 | - { |
|
124 | - $config_class = $this->config_class(); |
|
125 | - if (!$config_obj instanceof $config_class) { |
|
126 | - throw new EE_Error( |
|
127 | - sprintf( |
|
128 | - __('The "%1$s" class is not an instance of %2$s.', 'event_espresso'), |
|
129 | - print_r($config_obj, true), |
|
130 | - $config_class |
|
131 | - ) |
|
132 | - ); |
|
133 | - } |
|
134 | - return EE_Config::instance()->update_config($this->config_section(), $this->config_name(), $config_obj); |
|
135 | - } |
|
136 | - |
|
137 | - |
|
138 | - /** |
|
139 | - * gets the class's config object |
|
140 | - * |
|
141 | - * @return EE_Config_Base |
|
142 | - */ |
|
143 | - public function config() |
|
144 | - { |
|
145 | - if (empty($this->_config)) { |
|
146 | - $this->_config = EE_Config::instance()->get_config( |
|
147 | - $this->config_section(), |
|
148 | - $this->config_name(), |
|
149 | - $this->config_class() |
|
150 | - ); |
|
151 | - } |
|
152 | - return $this->_config; |
|
153 | - } |
|
15 | + /** |
|
16 | + * @var $_config |
|
17 | + * @type EE_Config_Base |
|
18 | + */ |
|
19 | + protected $_config; |
|
20 | + |
|
21 | + /** |
|
22 | + * @var $_config_section |
|
23 | + * @type string |
|
24 | + */ |
|
25 | + protected $_config_section = ''; |
|
26 | + |
|
27 | + /** |
|
28 | + * @var $_config_class |
|
29 | + * @type string |
|
30 | + */ |
|
31 | + protected $_config_class = ''; |
|
32 | + |
|
33 | + /** |
|
34 | + * @var $_config_name |
|
35 | + * @type string |
|
36 | + */ |
|
37 | + protected $_config_name = ''; |
|
38 | + |
|
39 | + |
|
40 | + /** |
|
41 | + * @param string $config_section |
|
42 | + */ |
|
43 | + public function set_config_section($config_section = '') |
|
44 | + { |
|
45 | + $this->_config_section = !empty($config_section) ? $config_section : 'modules'; |
|
46 | + } |
|
47 | + |
|
48 | + |
|
49 | + /** |
|
50 | + * @return mixed |
|
51 | + */ |
|
52 | + public function config_section() |
|
53 | + { |
|
54 | + return $this->_config_section; |
|
55 | + } |
|
56 | + |
|
57 | + |
|
58 | + /** |
|
59 | + * @param string $config_class |
|
60 | + */ |
|
61 | + public function set_config_class($config_class = '') |
|
62 | + { |
|
63 | + $this->_config_class = $config_class; |
|
64 | + } |
|
65 | + |
|
66 | + |
|
67 | + /** |
|
68 | + * @return mixed |
|
69 | + */ |
|
70 | + public function config_class() |
|
71 | + { |
|
72 | + return $this->_config_class; |
|
73 | + } |
|
74 | + |
|
75 | + |
|
76 | + /** |
|
77 | + * @param mixed $config_name |
|
78 | + */ |
|
79 | + public function set_config_name($config_name) |
|
80 | + { |
|
81 | + $this->_config_name = !empty($config_name) ? $config_name : get_called_class(); |
|
82 | + } |
|
83 | + |
|
84 | + |
|
85 | + /** |
|
86 | + * @return mixed |
|
87 | + */ |
|
88 | + public function config_name() |
|
89 | + { |
|
90 | + return $this->_config_name; |
|
91 | + } |
|
92 | + |
|
93 | + |
|
94 | + /** |
|
95 | + * set_config |
|
96 | + * this method integrates directly with EE_Config to set up the config object for this class |
|
97 | + * |
|
98 | + * @access protected |
|
99 | + * @param EE_Config_Base $config_obj |
|
100 | + * @return mixed EE_Config_Base | NULL |
|
101 | + */ |
|
102 | + protected function _set_config(EE_Config_Base $config_obj = null) |
|
103 | + { |
|
104 | + return EE_Config::instance()->set_config( |
|
105 | + $this->config_section(), |
|
106 | + $this->config_name(), |
|
107 | + $this->config_class(), |
|
108 | + $config_obj |
|
109 | + ); |
|
110 | + } |
|
111 | + |
|
112 | + |
|
113 | + /** |
|
114 | + * _update_config |
|
115 | + * this method integrates directly with EE_Config to update an existing config object for this class |
|
116 | + * |
|
117 | + * @access protected |
|
118 | + * @param EE_Config_Base $config_obj |
|
119 | + * @throws \EE_Error |
|
120 | + * @return mixed EE_Config_Base | NULL |
|
121 | + */ |
|
122 | + public function _update_config(EE_Config_Base $config_obj = null) |
|
123 | + { |
|
124 | + $config_class = $this->config_class(); |
|
125 | + if (!$config_obj instanceof $config_class) { |
|
126 | + throw new EE_Error( |
|
127 | + sprintf( |
|
128 | + __('The "%1$s" class is not an instance of %2$s.', 'event_espresso'), |
|
129 | + print_r($config_obj, true), |
|
130 | + $config_class |
|
131 | + ) |
|
132 | + ); |
|
133 | + } |
|
134 | + return EE_Config::instance()->update_config($this->config_section(), $this->config_name(), $config_obj); |
|
135 | + } |
|
136 | + |
|
137 | + |
|
138 | + /** |
|
139 | + * gets the class's config object |
|
140 | + * |
|
141 | + * @return EE_Config_Base |
|
142 | + */ |
|
143 | + public function config() |
|
144 | + { |
|
145 | + if (empty($this->_config)) { |
|
146 | + $this->_config = EE_Config::instance()->get_config( |
|
147 | + $this->config_section(), |
|
148 | + $this->config_name(), |
|
149 | + $this->config_class() |
|
150 | + ); |
|
151 | + } |
|
152 | + return $this->_config; |
|
153 | + } |
|
154 | 154 | |
155 | 155 | |
156 | 156 | } |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | */ |
43 | 43 | public function set_config_section($config_section = '') |
44 | 44 | { |
45 | - $this->_config_section = !empty($config_section) ? $config_section : 'modules'; |
|
45 | + $this->_config_section = ! empty($config_section) ? $config_section : 'modules'; |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | */ |
79 | 79 | public function set_config_name($config_name) |
80 | 80 | { |
81 | - $this->_config_name = !empty($config_name) ? $config_name : get_called_class(); |
|
81 | + $this->_config_name = ! empty($config_name) ? $config_name : get_called_class(); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | public function _update_config(EE_Config_Base $config_obj = null) |
123 | 123 | { |
124 | 124 | $config_class = $this->config_class(); |
125 | - if (!$config_obj instanceof $config_class) { |
|
125 | + if ( ! $config_obj instanceof $config_class) { |
|
126 | 126 | throw new EE_Error( |
127 | 127 | sprintf( |
128 | 128 | __('The "%1$s" class is not an instance of %2$s.', 'event_espresso'), |
@@ -14,13 +14,13 @@ discard block |
||
14 | 14 | */ |
15 | 15 | class EED_Events_Archive extends EED_Module { |
16 | 16 | |
17 | - const EVENT_DETAILS_PRIORITY = 100; |
|
18 | - const EVENT_DATETIMES_PRIORITY = 110; |
|
19 | - const EVENT_TICKETS_PRIORITY = 120; |
|
20 | - const EVENT_VENUES_PRIORITY = 130; |
|
17 | + const EVENT_DETAILS_PRIORITY = 100; |
|
18 | + const EVENT_DATETIMES_PRIORITY = 110; |
|
19 | + const EVENT_TICKETS_PRIORITY = 120; |
|
20 | + const EVENT_VENUES_PRIORITY = 130; |
|
21 | 21 | |
22 | 22 | |
23 | - public static $espresso_event_list_ID = 0; |
|
23 | + public static $espresso_event_list_ID = 0; |
|
24 | 24 | public static $espresso_grid_event_lists = array(); |
25 | 25 | |
26 | 26 | /** |
@@ -28,19 +28,19 @@ discard block |
||
28 | 28 | */ |
29 | 29 | protected static $using_get_the_excerpt = false; |
30 | 30 | |
31 | - /** |
|
32 | - * Used to flag when the event list is being called from an external iframe. |
|
33 | - * |
|
34 | - * @var bool $iframe |
|
35 | - */ |
|
36 | - protected static $iframe = false; |
|
31 | + /** |
|
32 | + * Used to flag when the event list is being called from an external iframe. |
|
33 | + * |
|
34 | + * @var bool $iframe |
|
35 | + */ |
|
36 | + protected static $iframe = false; |
|
37 | 37 | |
38 | - /** |
|
38 | + /** |
|
39 | 39 | * @var \EventEspresso\core\libraries\iframe_display\EventListIframeEmbedButton $_iframe_embed_button |
40 | 40 | */ |
41 | 41 | private static $_iframe_embed_button; |
42 | 42 | |
43 | - /** |
|
43 | + /** |
|
44 | 44 | * @type EE_Template_Part_Manager $template_parts |
45 | 45 | */ |
46 | 46 | protected $template_parts; |
@@ -210,9 +210,9 @@ discard block |
||
210 | 210 | |
211 | 211 | |
212 | 212 | /** |
213 | - * most likely called by the ESPRESSO_EVENTS shortcode which uses this module to do some of it's lifting |
|
214 | - * |
|
215 | - * @return void |
|
213 | + * most likely called by the ESPRESSO_EVENTS shortcode which uses this module to do some of it's lifting |
|
214 | + * |
|
215 | + * @return void |
|
216 | 216 | */ |
217 | 217 | public function event_list() { |
218 | 218 | // ensure valid EE_Events_Archive_Config() object exists |
@@ -223,36 +223,36 @@ discard block |
||
223 | 223 | |
224 | 224 | |
225 | 225 | |
226 | - /** |
|
227 | - * @access public |
|
228 | - * @return void |
|
229 | - * @throws \EE_Error |
|
230 | - * @throws \DomainException |
|
231 | - */ |
|
226 | + /** |
|
227 | + * @access public |
|
228 | + * @return void |
|
229 | + * @throws \EE_Error |
|
230 | + * @throws \DomainException |
|
231 | + */ |
|
232 | 232 | public function event_list_iframe() { |
233 | - \EED_Events_Archive::$iframe = true; |
|
233 | + \EED_Events_Archive::$iframe = true; |
|
234 | 234 | $event_list_iframe = new EventsArchiveIframe( $this ); |
235 | 235 | $event_list_iframe->display(); |
236 | 236 | } |
237 | 237 | |
238 | 238 | |
239 | 239 | |
240 | - /** |
|
241 | - * @access public |
|
242 | - * @return string |
|
243 | - */ |
|
240 | + /** |
|
241 | + * @access public |
|
242 | + * @return string |
|
243 | + */ |
|
244 | 244 | public static function is_iframe() { |
245 | - return \EED_Events_Archive::$iframe; |
|
245 | + return \EED_Events_Archive::$iframe; |
|
246 | 246 | } |
247 | 247 | |
248 | 248 | |
249 | 249 | |
250 | - /** |
|
251 | - * @access public |
|
252 | - * @return string |
|
253 | - */ |
|
250 | + /** |
|
251 | + * @access public |
|
252 | + * @return string |
|
253 | + */ |
|
254 | 254 | public static function link_target() { |
255 | - return \EED_Events_Archive::$iframe ? ' target="_blank"' : ''; |
|
255 | + return \EED_Events_Archive::$iframe ? ' target="_blank"' : ''; |
|
256 | 256 | } |
257 | 257 | |
258 | 258 | |
@@ -280,10 +280,10 @@ discard block |
||
280 | 280 | } |
281 | 281 | // if NOT a custom template |
282 | 282 | if ( |
283 | - apply_filters('FHEE__EED_Event_Archive__template_include__allow_custom_selected_template', false) |
|
283 | + apply_filters('FHEE__EED_Event_Archive__template_include__allow_custom_selected_template', false) |
|
284 | 284 | || EE_Registry::instance() |
285 | - ->load_core( 'Front_Controller' ) |
|
286 | - ->get_selected_template() !== 'archive-espresso_events.php' |
|
285 | + ->load_core( 'Front_Controller' ) |
|
286 | + ->get_selected_template() !== 'archive-espresso_events.php' |
|
287 | 287 | ) { |
288 | 288 | // don't display entry meta because the existing theme will take care of that |
289 | 289 | add_filter( 'FHEE__EED_Events_Archive__template_include__events_list_active', '__return_true' ); |
@@ -291,16 +291,16 @@ discard block |
||
291 | 291 | EEH_Template::load_espresso_theme_functions(); |
292 | 292 | // because we don't know if the theme is using the_excerpt() |
293 | 293 | add_filter( |
294 | - 'the_excerpt', |
|
295 | - array( 'EED_Events_Archive', 'event_details' ), |
|
296 | - EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
297 | - ); |
|
294 | + 'the_excerpt', |
|
295 | + array( 'EED_Events_Archive', 'event_details' ), |
|
296 | + EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
297 | + ); |
|
298 | 298 | // or the_content |
299 | 299 | add_filter( |
300 | - 'the_content', |
|
301 | - array( 'EED_Events_Archive', 'event_details' ), |
|
302 | - EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
303 | - ); |
|
300 | + 'the_content', |
|
301 | + array( 'EED_Events_Archive', 'event_details' ), |
|
302 | + EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
303 | + ); |
|
304 | 304 | // and just in case they are running get_the_excerpt() which DESTROYS things |
305 | 305 | add_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1, 1 ); |
306 | 306 | // don't display entry meta because the existing theme will take care of that |
@@ -325,15 +325,15 @@ discard block |
||
325 | 325 | } |
326 | 326 | if ( apply_filters( 'FHEE__EED_Events_Archive__get_the_excerpt__theme_uses_get_the_excerpt', false ) ) { |
327 | 327 | remove_filter( |
328 | - 'the_excerpt', |
|
329 | - array( 'EED_Events_Archive', 'event_details' ), |
|
330 | - EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
331 | - ); |
|
328 | + 'the_excerpt', |
|
329 | + array( 'EED_Events_Archive', 'event_details' ), |
|
330 | + EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
331 | + ); |
|
332 | 332 | remove_filter( |
333 | - 'the_content', |
|
334 | - array( 'EED_Events_Archive', 'event_details' ), |
|
335 | - EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
336 | - ); |
|
333 | + 'the_content', |
|
334 | + array( 'EED_Events_Archive', 'event_details' ), |
|
335 | + EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
336 | + ); |
|
337 | 337 | $excerpt = EED_Events_Archive::event_details( $excerpt ); |
338 | 338 | } else { |
339 | 339 | EED_Events_Archive::$using_get_the_excerpt = true; |
@@ -424,17 +424,17 @@ discard block |
||
424 | 424 | // no further password checks required atm |
425 | 425 | add_filter( 'FHEE__EED_Events_Archive__event_details__no_post_password_required', '__return_true' ); |
426 | 426 | // we need to first remove this callback from being applied to the_content() or the_excerpt() |
427 | - // (otherwise it will recurse and blow up the interweb) |
|
427 | + // (otherwise it will recurse and blow up the interweb) |
|
428 | 428 | remove_filter( |
429 | - 'the_excerpt', |
|
430 | - array( 'EED_Events_Archive', 'event_details' ), |
|
431 | - EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
432 | - ); |
|
429 | + 'the_excerpt', |
|
430 | + array( 'EED_Events_Archive', 'event_details' ), |
|
431 | + EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
432 | + ); |
|
433 | 433 | remove_filter( |
434 | - 'the_content', |
|
435 | - array( 'EED_Events_Archive', 'event_details' ), |
|
436 | - EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
437 | - ); |
|
434 | + 'the_content', |
|
435 | + array( 'EED_Events_Archive', 'event_details' ), |
|
436 | + EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
437 | + ); |
|
438 | 438 | remove_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1 ); |
439 | 439 | // now add additional content depending on whether event is using the_excerpt() or the_content() |
440 | 440 | EED_Events_Archive::instance()->template_parts = EED_Events_Archive::instance()->initialize_template_parts(); |
@@ -442,20 +442,20 @@ discard block |
||
442 | 442 | $content = EED_Events_Archive::instance()->template_parts->apply_template_part_filters( $content ); |
443 | 443 | // re-add our main filters (or else the next event won't have them) |
444 | 444 | add_filter( |
445 | - 'the_excerpt', |
|
446 | - array( 'EED_Events_Archive', 'event_details' ), |
|
447 | - EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
448 | - ); |
|
445 | + 'the_excerpt', |
|
446 | + array( 'EED_Events_Archive', 'event_details' ), |
|
447 | + EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
448 | + ); |
|
449 | 449 | add_filter( |
450 | - 'the_content', |
|
451 | - array( 'EED_Events_Archive', 'event_details' ), |
|
452 | - EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
453 | - ); |
|
450 | + 'the_content', |
|
451 | + array( 'EED_Events_Archive', 'event_details' ), |
|
452 | + EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
453 | + ); |
|
454 | 454 | add_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1, 1 ); |
455 | 455 | remove_filter( |
456 | - 'FHEE__EED_Events_Archive__event_details__no_post_password_required', |
|
457 | - '__return_true' |
|
458 | - ); |
|
456 | + 'FHEE__EED_Events_Archive__event_details__no_post_password_required', |
|
457 | + '__return_true' |
|
458 | + ); |
|
459 | 459 | return $content; |
460 | 460 | } |
461 | 461 | |
@@ -471,15 +471,15 @@ discard block |
||
471 | 471 | // we need to first remove this callback from being applied to the_content() |
472 | 472 | // (otherwise it will recurse and blow up the interweb) |
473 | 473 | remove_filter( |
474 | - 'the_excerpt', |
|
475 | - array( 'EED_Events_Archive', 'event_details' ), |
|
476 | - EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
477 | - ); |
|
474 | + 'the_excerpt', |
|
475 | + array( 'EED_Events_Archive', 'event_details' ), |
|
476 | + EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
477 | + ); |
|
478 | 478 | remove_filter( |
479 | - 'the_content', |
|
480 | - array( 'EED_Events_Archive', 'event_details' ), |
|
481 | - EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
482 | - ); |
|
479 | + 'the_content', |
|
480 | + array( 'EED_Events_Archive', 'event_details' ), |
|
481 | + EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
482 | + ); |
|
483 | 483 | remove_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1 ); |
484 | 484 | //now add additional content depending on whether event is using the_excerpt() or the_content() |
485 | 485 | EED_Events_Archive::_add_additional_excerpt_filters(); |
@@ -489,15 +489,15 @@ discard block |
||
489 | 489 | $content = EEH_Template::locate_template( 'content-espresso_events-details.php' ); |
490 | 490 | // re-add our main filters (or else the next event won't have them) |
491 | 491 | add_filter( |
492 | - 'the_excerpt', |
|
493 | - array( 'EED_Events_Archive', 'event_details' ), |
|
494 | - EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
495 | - ); |
|
492 | + 'the_excerpt', |
|
493 | + array( 'EED_Events_Archive', 'event_details' ), |
|
494 | + EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
495 | + ); |
|
496 | 496 | add_filter( |
497 | - 'the_content', |
|
498 | - array( 'EED_Events_Archive', 'event_details' ), |
|
499 | - EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
500 | - ); |
|
497 | + 'the_content', |
|
498 | + array( 'EED_Events_Archive', 'event_details' ), |
|
499 | + EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
500 | + ); |
|
501 | 501 | add_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1, 1 ); |
502 | 502 | // but remove the other filters so that they don't get applied to the next post |
503 | 503 | EED_Events_Archive::_remove_additional_events_archive_filters(); |
@@ -574,20 +574,20 @@ discard block |
||
574 | 574 | */ |
575 | 575 | private static function _add_additional_excerpt_filters() { |
576 | 576 | add_filter( |
577 | - 'the_excerpt', |
|
578 | - array( 'EED_Events_Archive', 'event_datetimes' ), |
|
579 | - EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
|
580 | - ); |
|
577 | + 'the_excerpt', |
|
578 | + array( 'EED_Events_Archive', 'event_datetimes' ), |
|
579 | + EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
|
580 | + ); |
|
581 | 581 | add_filter( |
582 | - 'the_excerpt', |
|
583 | - array( 'EED_Events_Archive', 'event_tickets' ), |
|
584 | - EED_Events_Archive::EVENT_TICKETS_PRIORITY |
|
585 | - ); |
|
582 | + 'the_excerpt', |
|
583 | + array( 'EED_Events_Archive', 'event_tickets' ), |
|
584 | + EED_Events_Archive::EVENT_TICKETS_PRIORITY |
|
585 | + ); |
|
586 | 586 | add_filter( |
587 | - 'the_excerpt', |
|
588 | - array( 'EED_Events_Archive', 'event_venues' ), |
|
589 | - EED_Events_Archive::EVENT_VENUES_PRIORITY |
|
590 | - ); |
|
587 | + 'the_excerpt', |
|
588 | + array( 'EED_Events_Archive', 'event_venues' ), |
|
589 | + EED_Events_Archive::EVENT_VENUES_PRIORITY |
|
590 | + ); |
|
591 | 591 | } |
592 | 592 | |
593 | 593 | |
@@ -600,20 +600,20 @@ discard block |
||
600 | 600 | */ |
601 | 601 | private static function _add_additional_content_filters() { |
602 | 602 | add_filter( |
603 | - 'the_content', |
|
604 | - array( 'EED_Events_Archive', 'event_datetimes' ), |
|
605 | - EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
|
606 | - ); |
|
603 | + 'the_content', |
|
604 | + array( 'EED_Events_Archive', 'event_datetimes' ), |
|
605 | + EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
|
606 | + ); |
|
607 | 607 | add_filter( |
608 | - 'the_content', |
|
609 | - array( 'EED_Events_Archive', 'event_tickets' ), |
|
610 | - EED_Events_Archive::EVENT_TICKETS_PRIORITY |
|
611 | - ); |
|
608 | + 'the_content', |
|
609 | + array( 'EED_Events_Archive', 'event_tickets' ), |
|
610 | + EED_Events_Archive::EVENT_TICKETS_PRIORITY |
|
611 | + ); |
|
612 | 612 | add_filter( |
613 | - 'the_content', |
|
614 | - array( 'EED_Events_Archive', 'event_venues' ), |
|
615 | - EED_Events_Archive::EVENT_VENUES_PRIORITY |
|
616 | - ); |
|
613 | + 'the_content', |
|
614 | + array( 'EED_Events_Archive', 'event_venues' ), |
|
615 | + EED_Events_Archive::EVENT_VENUES_PRIORITY |
|
616 | + ); |
|
617 | 617 | } |
618 | 618 | |
619 | 619 | |
@@ -626,35 +626,35 @@ discard block |
||
626 | 626 | */ |
627 | 627 | private static function _remove_additional_events_archive_filters() { |
628 | 628 | remove_filter( |
629 | - 'the_excerpt', |
|
630 | - array( 'EED_Events_Archive', 'event_datetimes' ), |
|
631 | - EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
|
632 | - ); |
|
629 | + 'the_excerpt', |
|
630 | + array( 'EED_Events_Archive', 'event_datetimes' ), |
|
631 | + EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
|
632 | + ); |
|
633 | 633 | remove_filter( |
634 | - 'the_excerpt', |
|
635 | - array( 'EED_Events_Archive', 'event_tickets' ), |
|
636 | - EED_Events_Archive::EVENT_TICKETS_PRIORITY |
|
637 | - ); |
|
634 | + 'the_excerpt', |
|
635 | + array( 'EED_Events_Archive', 'event_tickets' ), |
|
636 | + EED_Events_Archive::EVENT_TICKETS_PRIORITY |
|
637 | + ); |
|
638 | 638 | remove_filter( |
639 | - 'the_excerpt', |
|
640 | - array( 'EED_Events_Archive', 'event_venues' ), |
|
641 | - EED_Events_Archive::EVENT_VENUES_PRIORITY |
|
642 | - ); |
|
639 | + 'the_excerpt', |
|
640 | + array( 'EED_Events_Archive', 'event_venues' ), |
|
641 | + EED_Events_Archive::EVENT_VENUES_PRIORITY |
|
642 | + ); |
|
643 | 643 | remove_filter( |
644 | - 'the_content', |
|
645 | - array( 'EED_Events_Archive', 'event_datetimes' ), |
|
646 | - EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
|
647 | - ); |
|
644 | + 'the_content', |
|
645 | + array( 'EED_Events_Archive', 'event_datetimes' ), |
|
646 | + EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
|
647 | + ); |
|
648 | 648 | remove_filter( |
649 | - 'the_content', |
|
650 | - array( 'EED_Events_Archive', 'event_tickets' ), |
|
651 | - EED_Events_Archive::EVENT_TICKETS_PRIORITY |
|
652 | - ); |
|
649 | + 'the_content', |
|
650 | + array( 'EED_Events_Archive', 'event_tickets' ), |
|
651 | + EED_Events_Archive::EVENT_TICKETS_PRIORITY |
|
652 | + ); |
|
653 | 653 | remove_filter( |
654 | - 'the_content', |
|
655 | - array( 'EED_Events_Archive', 'event_venues' ), |
|
656 | - EED_Events_Archive::EVENT_VENUES_PRIORITY |
|
657 | - ); |
|
654 | + 'the_content', |
|
655 | + array( 'EED_Events_Archive', 'event_venues' ), |
|
656 | + EED_Events_Archive::EVENT_VENUES_PRIORITY |
|
657 | + ); |
|
658 | 658 | } |
659 | 659 | |
660 | 660 | |
@@ -669,50 +669,50 @@ discard block |
||
669 | 669 | //remove_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1 ); |
670 | 670 | remove_filter( 'the_title', array( 'EED_Events_Archive', 'the_title' ), 1 ); |
671 | 671 | remove_filter( |
672 | - 'the_excerpt', |
|
673 | - array( 'EED_Events_Archive', 'event_details' ), |
|
674 | - EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
675 | - ); |
|
672 | + 'the_excerpt', |
|
673 | + array( 'EED_Events_Archive', 'event_details' ), |
|
674 | + EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
675 | + ); |
|
676 | 676 | remove_filter( |
677 | - 'the_excerpt', |
|
678 | - array( 'EED_Events_Archive', 'event_datetimes' ), |
|
679 | - EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
|
680 | - ); |
|
677 | + 'the_excerpt', |
|
678 | + array( 'EED_Events_Archive', 'event_datetimes' ), |
|
679 | + EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
|
680 | + ); |
|
681 | 681 | remove_filter( |
682 | - 'the_excerpt', |
|
683 | - array( 'EED_Events_Archive', 'event_tickets' ), |
|
684 | - EED_Events_Archive::EVENT_TICKETS_PRIORITY |
|
685 | - ); |
|
682 | + 'the_excerpt', |
|
683 | + array( 'EED_Events_Archive', 'event_tickets' ), |
|
684 | + EED_Events_Archive::EVENT_TICKETS_PRIORITY |
|
685 | + ); |
|
686 | 686 | remove_filter( |
687 | - 'the_excerpt', |
|
688 | - array( 'EED_Events_Archive', 'event_venues' ), |
|
689 | - EED_Events_Archive::EVENT_VENUES_PRIORITY |
|
690 | - ); |
|
687 | + 'the_excerpt', |
|
688 | + array( 'EED_Events_Archive', 'event_venues' ), |
|
689 | + EED_Events_Archive::EVENT_VENUES_PRIORITY |
|
690 | + ); |
|
691 | 691 | remove_filter( |
692 | - 'the_content', |
|
693 | - array( 'EED_Events_Archive', 'event_details' ), |
|
694 | - EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
695 | - ); |
|
692 | + 'the_content', |
|
693 | + array( 'EED_Events_Archive', 'event_details' ), |
|
694 | + EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
695 | + ); |
|
696 | 696 | remove_filter( |
697 | - 'the_content', |
|
698 | - array( 'EED_Events_Archive', 'event_datetimes' ), |
|
699 | - EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
|
700 | - ); |
|
697 | + 'the_content', |
|
698 | + array( 'EED_Events_Archive', 'event_datetimes' ), |
|
699 | + EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
|
700 | + ); |
|
701 | 701 | remove_filter( |
702 | - 'the_content', |
|
703 | - array( 'EED_Events_Archive', 'event_tickets' ), |
|
704 | - EED_Events_Archive::EVENT_TICKETS_PRIORITY |
|
705 | - ); |
|
702 | + 'the_content', |
|
703 | + array( 'EED_Events_Archive', 'event_tickets' ), |
|
704 | + EED_Events_Archive::EVENT_TICKETS_PRIORITY |
|
705 | + ); |
|
706 | 706 | remove_filter( |
707 | - 'the_content', |
|
708 | - array( 'EED_Events_Archive', 'event_venues' ), |
|
709 | - EED_Events_Archive::EVENT_VENUES_PRIORITY |
|
710 | - ); |
|
707 | + 'the_content', |
|
708 | + array( 'EED_Events_Archive', 'event_venues' ), |
|
709 | + EED_Events_Archive::EVENT_VENUES_PRIORITY |
|
710 | + ); |
|
711 | 711 | // don't display entry meta because the existing theme will take care of that |
712 | 712 | remove_filter( |
713 | - 'FHEE__content_espresso_events_details_template__display_entry_meta', |
|
714 | - '__return_false' |
|
715 | - ); |
|
713 | + 'FHEE__content_espresso_events_details_template__display_entry_meta', |
|
714 | + '__return_false' |
|
715 | + ); |
|
716 | 716 | } |
717 | 717 | |
718 | 718 | |
@@ -727,7 +727,7 @@ discard block |
||
727 | 727 | * @return void |
728 | 728 | */ |
729 | 729 | public function load_event_list_assets() { |
730 | - do_action( 'AHEE__EED_Events_Archive__before_load_assets' ); |
|
730 | + do_action( 'AHEE__EED_Events_Archive__before_load_assets' ); |
|
731 | 731 | add_filter( 'FHEE_load_EE_Session', '__return_true' ); |
732 | 732 | add_filter( 'FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true' ); |
733 | 733 | add_action('wp_enqueue_scripts', array( $this, 'wp_enqueue_scripts' ), 10 ); |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | use EventEspresso\core\libraries\iframe_display\EventListIframeEmbedButton; |
4 | 4 | use EventEspresso\modules\events_archive\EventsArchiveIframe; |
5 | 5 | |
6 | -defined( 'EVENT_ESPRESSO_VERSION') || exit('No direct script access allowed'); |
|
6 | +defined('EVENT_ESPRESSO_VERSION') || exit('No direct script access allowed'); |
|
7 | 7 | |
8 | 8 | /** |
9 | 9 | * Event List |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | * @return EED_Events_Archive |
52 | 52 | */ |
53 | 53 | public static function instance() { |
54 | - return parent::get_instance( __CLASS__ ); |
|
54 | + return parent::get_instance(__CLASS__); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | |
@@ -63,10 +63,10 @@ discard block |
||
63 | 63 | * @return void |
64 | 64 | */ |
65 | 65 | public static function set_hooks() { |
66 | - EE_Config::register_route( EE_Registry::instance()->CFG->core->event_cpt_slug, 'Events_Archive', 'run' ); |
|
67 | - EE_Config::register_route( 'event_list', 'Events_Archive', 'event_list' ); |
|
68 | - EE_Config::register_route( 'iframe', 'Events_Archive', 'event_list_iframe', 'event_list' ); |
|
69 | - add_action( 'wp_loaded', array( 'EED_Events_Archive', 'set_definitions' ), 2 ); |
|
66 | + EE_Config::register_route(EE_Registry::instance()->CFG->core->event_cpt_slug, 'Events_Archive', 'run'); |
|
67 | + EE_Config::register_route('event_list', 'Events_Archive', 'event_list'); |
|
68 | + EE_Config::register_route('iframe', 'Events_Archive', 'event_list_iframe', 'event_list'); |
|
69 | + add_action('wp_loaded', array('EED_Events_Archive', 'set_definitions'), 2); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
@@ -76,12 +76,12 @@ discard block |
||
76 | 76 | * @return void |
77 | 77 | */ |
78 | 78 | public static function set_hooks_admin() { |
79 | - add_action( 'wp_loaded', array( 'EED_Events_Archive', 'set_definitions' ), 2 ); |
|
79 | + add_action('wp_loaded', array('EED_Events_Archive', 'set_definitions'), 2); |
|
80 | 80 | // hook into the end of the \EE_Admin_Page::_load_page_dependencies() |
81 | 81 | // to load assets for "espresso_events" page on the "default" route (action) |
82 | 82 | add_action( |
83 | 83 | 'FHEE__EE_Admin_Page___load_page_dependencies__after_load__espresso_events__default', |
84 | - array( 'EED_Events_Archive', 'event_list_iframe_embed_button' ), |
|
84 | + array('EED_Events_Archive', 'event_list_iframe_embed_button'), |
|
85 | 85 | 10 |
86 | 86 | ); |
87 | 87 | } |
@@ -96,8 +96,8 @@ discard block |
||
96 | 96 | * @return void |
97 | 97 | */ |
98 | 98 | public static function set_definitions() { |
99 | - define( 'EVENTS_ARCHIVE_ASSETS_URL', plugin_dir_url( __FILE__ ) . 'assets' . DS ); |
|
100 | - define( 'EVENTS_ARCHIVE_TEMPLATES_PATH', str_replace( '\\', DS, plugin_dir_path( __FILE__ )) . 'templates' . DS ); |
|
99 | + define('EVENTS_ARCHIVE_ASSETS_URL', plugin_dir_url(__FILE__).'assets'.DS); |
|
100 | + define('EVENTS_ARCHIVE_TEMPLATES_PATH', str_replace('\\', DS, plugin_dir_path(__FILE__)).'templates'.DS); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | |
@@ -105,10 +105,10 @@ discard block |
||
105 | 105 | /** |
106 | 106 | * set up EE_Events_Archive_Config |
107 | 107 | */ |
108 | - protected function set_config(){ |
|
109 | - $this->set_config_section( 'template_settings' ); |
|
110 | - $this->set_config_class( 'EE_Events_Archive_Config' ); |
|
111 | - $this->set_config_name( 'EED_Events_Archive' ); |
|
108 | + protected function set_config() { |
|
109 | + $this->set_config_section('template_settings'); |
|
110 | + $this->set_config_class('EE_Events_Archive_Config'); |
|
111 | + $this->set_config_name('EED_Events_Archive'); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | * @return EventListIframeEmbedButton |
118 | 118 | */ |
119 | 119 | public static function get_iframe_embed_button() { |
120 | - if ( ! self::$_iframe_embed_button instanceof EventListIframeEmbedButton ) { |
|
120 | + if ( ! self::$_iframe_embed_button instanceof EventListIframeEmbedButton) { |
|
121 | 121 | self::$_iframe_embed_button = new EventListIframeEmbedButton(); |
122 | 122 | } |
123 | 123 | return self::$_iframe_embed_button; |
@@ -143,35 +143,35 @@ discard block |
||
143 | 143 | * @param \EE_Events_Archive_Config $config |
144 | 144 | * @return \EE_Template_Part_Manager |
145 | 145 | */ |
146 | - public function initialize_template_parts( EE_Events_Archive_Config $config = null ) { |
|
146 | + public function initialize_template_parts(EE_Events_Archive_Config $config = null) { |
|
147 | 147 | $config = $config instanceof EE_Events_Archive_Config ? $config : $this->config(); |
148 | 148 | EEH_Autoloader::instance()->register_template_part_autoloaders(); |
149 | 149 | $template_parts = new EE_Template_Part_Manager(); |
150 | 150 | $template_parts->add_template_part( |
151 | 151 | 'tickets', |
152 | - __( 'Ticket Selector', 'event_espresso' ), |
|
152 | + __('Ticket Selector', 'event_espresso'), |
|
153 | 153 | 'content-espresso_events-tickets.php', |
154 | 154 | $config->display_order_tickets |
155 | 155 | ); |
156 | 156 | $template_parts->add_template_part( |
157 | 157 | 'datetimes', |
158 | - __( 'Dates and Times', 'event_espresso' ), |
|
158 | + __('Dates and Times', 'event_espresso'), |
|
159 | 159 | 'content-espresso_events-datetimes.php', |
160 | 160 | $config->display_order_datetimes |
161 | 161 | ); |
162 | 162 | $template_parts->add_template_part( |
163 | 163 | 'event', |
164 | - __( 'Event Description', 'event_espresso' ), |
|
164 | + __('Event Description', 'event_espresso'), |
|
165 | 165 | 'content-espresso_events-details.php', |
166 | 166 | $config->display_order_event |
167 | 167 | ); |
168 | 168 | $template_parts->add_template_part( |
169 | 169 | 'venue', |
170 | - __( 'Venue Information', 'event_espresso' ), |
|
170 | + __('Venue Information', 'event_espresso'), |
|
171 | 171 | 'content-espresso_events-venues.php', |
172 | 172 | $config->display_order_venue |
173 | 173 | ); |
174 | - do_action( 'AHEE__EED_Event_Archive__initialize_template_parts', $template_parts ); |
|
174 | + do_action('AHEE__EED_Event_Archive__initialize_template_parts', $template_parts); |
|
175 | 175 | return $template_parts; |
176 | 176 | } |
177 | 177 | |
@@ -184,8 +184,8 @@ discard block |
||
184 | 184 | * @param WP $WP |
185 | 185 | * @return void |
186 | 186 | */ |
187 | - public function run( $WP ) { |
|
188 | - do_action( 'AHEE__EED_Events_Archive__before_run' ); |
|
187 | + public function run($WP) { |
|
188 | + do_action('AHEE__EED_Events_Archive__before_run'); |
|
189 | 189 | // ensure valid EE_Events_Archive_Config() object exists |
190 | 190 | $this->set_config(); |
191 | 191 | /** @type EE_Events_Archive_Config $config */ |
@@ -197,14 +197,14 @@ discard block |
||
197 | 197 | EEH_Event_Query::add_query_filters(); |
198 | 198 | // set params that will get used by the filters |
199 | 199 | EEH_Event_Query::set_query_params( |
200 | - '', // month |
|
201 | - '', // category |
|
202 | - $config->display_expired_events, // show_expired |
|
203 | - 'start_date', // orderby |
|
200 | + '', // month |
|
201 | + '', // category |
|
202 | + $config->display_expired_events, // show_expired |
|
203 | + 'start_date', // orderby |
|
204 | 204 | 'ASC' // sort |
205 | 205 | ); |
206 | 206 | // check what template is loaded |
207 | - add_filter( 'template_include', array( $this, 'template_include' ), 999, 1 ); |
|
207 | + add_filter('template_include', array($this, 'template_include'), 999, 1); |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | */ |
232 | 232 | public function event_list_iframe() { |
233 | 233 | \EED_Events_Archive::$iframe = true; |
234 | - $event_list_iframe = new EventsArchiveIframe( $this ); |
|
234 | + $event_list_iframe = new EventsArchiveIframe($this); |
|
235 | 235 | $event_list_iframe->display(); |
236 | 236 | } |
237 | 237 | |
@@ -269,42 +269,42 @@ discard block |
||
269 | 269 | * @param string $template |
270 | 270 | * @return string |
271 | 271 | */ |
272 | - public function template_include( $template = '' ) { |
|
272 | + public function template_include($template = '') { |
|
273 | 273 | // don't add content filter for dedicated EE child themes or private posts |
274 | - if ( ! EEH_Template::is_espresso_theme() ) { |
|
274 | + if ( ! EEH_Template::is_espresso_theme()) { |
|
275 | 275 | /** @type EE_Events_Archive_Config $config */ |
276 | 276 | $config = $this->config(); |
277 | 277 | // add status banner ? |
278 | - if ( $config->display_status_banner ) { |
|
279 | - add_filter( 'the_title', array( 'EED_Events_Archive', 'the_title' ), 100, 2 ); |
|
278 | + if ($config->display_status_banner) { |
|
279 | + add_filter('the_title', array('EED_Events_Archive', 'the_title'), 100, 2); |
|
280 | 280 | } |
281 | 281 | // if NOT a custom template |
282 | 282 | if ( |
283 | 283 | apply_filters('FHEE__EED_Event_Archive__template_include__allow_custom_selected_template', false) |
284 | 284 | || EE_Registry::instance() |
285 | - ->load_core( 'Front_Controller' ) |
|
285 | + ->load_core('Front_Controller') |
|
286 | 286 | ->get_selected_template() !== 'archive-espresso_events.php' |
287 | 287 | ) { |
288 | 288 | // don't display entry meta because the existing theme will take care of that |
289 | - add_filter( 'FHEE__EED_Events_Archive__template_include__events_list_active', '__return_true' ); |
|
289 | + add_filter('FHEE__EED_Events_Archive__template_include__events_list_active', '__return_true'); |
|
290 | 290 | // load functions.php file for the theme (loaded by WP if using child theme) |
291 | 291 | EEH_Template::load_espresso_theme_functions(); |
292 | 292 | // because we don't know if the theme is using the_excerpt() |
293 | 293 | add_filter( |
294 | 294 | 'the_excerpt', |
295 | - array( 'EED_Events_Archive', 'event_details' ), |
|
295 | + array('EED_Events_Archive', 'event_details'), |
|
296 | 296 | EED_Events_Archive::EVENT_DETAILS_PRIORITY |
297 | 297 | ); |
298 | 298 | // or the_content |
299 | 299 | add_filter( |
300 | 300 | 'the_content', |
301 | - array( 'EED_Events_Archive', 'event_details' ), |
|
301 | + array('EED_Events_Archive', 'event_details'), |
|
302 | 302 | EED_Events_Archive::EVENT_DETAILS_PRIORITY |
303 | 303 | ); |
304 | 304 | // and just in case they are running get_the_excerpt() which DESTROYS things |
305 | - add_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1, 1 ); |
|
305 | + add_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1, 1); |
|
306 | 306 | // don't display entry meta because the existing theme will take care of that |
307 | - add_filter( 'FHEE__content_espresso_events_details_template__display_entry_meta', '__return_false' ); |
|
307 | + add_filter('FHEE__content_espresso_events_details_template__display_entry_meta', '__return_false'); |
|
308 | 308 | } |
309 | 309 | } |
310 | 310 | return $template; |
@@ -319,25 +319,25 @@ discard block |
||
319 | 319 | * @param string $excerpt |
320 | 320 | * @return string |
321 | 321 | */ |
322 | - public static function get_the_excerpt( $excerpt = '' ) { |
|
323 | - if ( post_password_required() ) { |
|
322 | + public static function get_the_excerpt($excerpt = '') { |
|
323 | + if (post_password_required()) { |
|
324 | 324 | return $excerpt; |
325 | 325 | } |
326 | - if ( apply_filters( 'FHEE__EED_Events_Archive__get_the_excerpt__theme_uses_get_the_excerpt', false ) ) { |
|
326 | + if (apply_filters('FHEE__EED_Events_Archive__get_the_excerpt__theme_uses_get_the_excerpt', false)) { |
|
327 | 327 | remove_filter( |
328 | 328 | 'the_excerpt', |
329 | - array( 'EED_Events_Archive', 'event_details' ), |
|
329 | + array('EED_Events_Archive', 'event_details'), |
|
330 | 330 | EED_Events_Archive::EVENT_DETAILS_PRIORITY |
331 | 331 | ); |
332 | 332 | remove_filter( |
333 | 333 | 'the_content', |
334 | - array( 'EED_Events_Archive', 'event_details' ), |
|
334 | + array('EED_Events_Archive', 'event_details'), |
|
335 | 335 | EED_Events_Archive::EVENT_DETAILS_PRIORITY |
336 | 336 | ); |
337 | - $excerpt = EED_Events_Archive::event_details( $excerpt ); |
|
337 | + $excerpt = EED_Events_Archive::event_details($excerpt); |
|
338 | 338 | } else { |
339 | 339 | EED_Events_Archive::$using_get_the_excerpt = true; |
340 | - add_filter( 'wp_trim_excerpt', array( 'EED_Events_Archive', 'end_get_the_excerpt' ), 999, 1 ); |
|
340 | + add_filter('wp_trim_excerpt', array('EED_Events_Archive', 'end_get_the_excerpt'), 999, 1); |
|
341 | 341 | } |
342 | 342 | return $excerpt; |
343 | 343 | } |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | * @param string $text |
352 | 352 | * @return string |
353 | 353 | */ |
354 | - public static function end_get_the_excerpt( $text = '' ) { |
|
354 | + public static function end_get_the_excerpt($text = '') { |
|
355 | 355 | EED_Events_Archive::$using_get_the_excerpt = false; |
356 | 356 | return $text; |
357 | 357 | } |
@@ -366,10 +366,10 @@ discard block |
||
366 | 366 | * @param string $id |
367 | 367 | * @return string |
368 | 368 | */ |
369 | - public static function the_title( $title = '', $id = '' ) { |
|
369 | + public static function the_title($title = '', $id = '') { |
|
370 | 370 | global $post; |
371 | - if ( $post instanceof WP_Post ) { |
|
372 | - return in_the_loop() && $post->ID == $id ? espresso_event_status_banner( $post->ID ) . $title : $title; |
|
371 | + if ($post instanceof WP_Post) { |
|
372 | + return in_the_loop() && $post->ID == $id ? espresso_event_status_banner($post->ID).$title : $title; |
|
373 | 373 | } |
374 | 374 | return $title; |
375 | 375 | } |
@@ -383,7 +383,7 @@ discard block |
||
383 | 383 | * @param string $content |
384 | 384 | * @return string |
385 | 385 | */ |
386 | - public static function event_details( $content ) { |
|
386 | + public static function event_details($content) { |
|
387 | 387 | global $post; |
388 | 388 | static $current_post_ID = 0; |
389 | 389 | if ( |
@@ -392,8 +392,8 @@ discard block |
||
392 | 392 | && ! EED_Events_Archive::$using_get_the_excerpt |
393 | 393 | && ! post_password_required() |
394 | 394 | && ( |
395 | - apply_filters( 'FHEE__EES_Espresso_Events__process_shortcode__true', false ) |
|
396 | - || ! apply_filters( 'FHEE__content_espresso_events__template_loaded', false ) |
|
395 | + apply_filters('FHEE__EES_Espresso_Events__process_shortcode__true', false) |
|
396 | + || ! apply_filters('FHEE__content_espresso_events__template_loaded', false) |
|
397 | 397 | ) |
398 | 398 | ) { |
399 | 399 | // Set current post ID to prevent showing content twice, but only if headers have definitely been sent. |
@@ -402,8 +402,8 @@ discard block |
||
402 | 402 | // We want to allow those plugins to still do their thing and have access to our content, but depending on |
403 | 403 | // how your event content is being displayed (shortcode, CPT route, etc), this filter can get applied twice, |
404 | 404 | // so the following allows this filter to be applied multiple times, but only once for real |
405 | - $current_post_ID = did_action( 'loop_start' ) ? $post->ID : 0; |
|
406 | - if ( EE_Registry::instance()->CFG->template_settings->EED_Events_Archive->use_sortable_display_order ) { |
|
405 | + $current_post_ID = did_action('loop_start') ? $post->ID : 0; |
|
406 | + if (EE_Registry::instance()->CFG->template_settings->EED_Events_Archive->use_sortable_display_order) { |
|
407 | 407 | $content = \EED_Events_Archive::use_sortable_display_order(); |
408 | 408 | } else { |
409 | 409 | $content = \EED_Events_Archive::use_filterable_display_order(); |
@@ -422,36 +422,36 @@ discard block |
||
422 | 422 | */ |
423 | 423 | protected static function use_sortable_display_order() { |
424 | 424 | // no further password checks required atm |
425 | - add_filter( 'FHEE__EED_Events_Archive__event_details__no_post_password_required', '__return_true' ); |
|
425 | + add_filter('FHEE__EED_Events_Archive__event_details__no_post_password_required', '__return_true'); |
|
426 | 426 | // we need to first remove this callback from being applied to the_content() or the_excerpt() |
427 | 427 | // (otherwise it will recurse and blow up the interweb) |
428 | 428 | remove_filter( |
429 | 429 | 'the_excerpt', |
430 | - array( 'EED_Events_Archive', 'event_details' ), |
|
430 | + array('EED_Events_Archive', 'event_details'), |
|
431 | 431 | EED_Events_Archive::EVENT_DETAILS_PRIORITY |
432 | 432 | ); |
433 | 433 | remove_filter( |
434 | 434 | 'the_content', |
435 | - array( 'EED_Events_Archive', 'event_details' ), |
|
435 | + array('EED_Events_Archive', 'event_details'), |
|
436 | 436 | EED_Events_Archive::EVENT_DETAILS_PRIORITY |
437 | 437 | ); |
438 | - remove_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1 ); |
|
438 | + remove_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1); |
|
439 | 439 | // now add additional content depending on whether event is using the_excerpt() or the_content() |
440 | 440 | EED_Events_Archive::instance()->template_parts = EED_Events_Archive::instance()->initialize_template_parts(); |
441 | - $content = EEH_Template::locate_template( 'content-espresso_events-details.php' ); |
|
442 | - $content = EED_Events_Archive::instance()->template_parts->apply_template_part_filters( $content ); |
|
441 | + $content = EEH_Template::locate_template('content-espresso_events-details.php'); |
|
442 | + $content = EED_Events_Archive::instance()->template_parts->apply_template_part_filters($content); |
|
443 | 443 | // re-add our main filters (or else the next event won't have them) |
444 | 444 | add_filter( |
445 | 445 | 'the_excerpt', |
446 | - array( 'EED_Events_Archive', 'event_details' ), |
|
446 | + array('EED_Events_Archive', 'event_details'), |
|
447 | 447 | EED_Events_Archive::EVENT_DETAILS_PRIORITY |
448 | 448 | ); |
449 | 449 | add_filter( |
450 | 450 | 'the_content', |
451 | - array( 'EED_Events_Archive', 'event_details' ), |
|
451 | + array('EED_Events_Archive', 'event_details'), |
|
452 | 452 | EED_Events_Archive::EVENT_DETAILS_PRIORITY |
453 | 453 | ); |
454 | - add_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1, 1 ); |
|
454 | + add_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1, 1); |
|
455 | 455 | remove_filter( |
456 | 456 | 'FHEE__EED_Events_Archive__event_details__no_post_password_required', |
457 | 457 | '__return_true' |
@@ -472,36 +472,36 @@ discard block |
||
472 | 472 | // (otherwise it will recurse and blow up the interweb) |
473 | 473 | remove_filter( |
474 | 474 | 'the_excerpt', |
475 | - array( 'EED_Events_Archive', 'event_details' ), |
|
475 | + array('EED_Events_Archive', 'event_details'), |
|
476 | 476 | EED_Events_Archive::EVENT_DETAILS_PRIORITY |
477 | 477 | ); |
478 | 478 | remove_filter( |
479 | 479 | 'the_content', |
480 | - array( 'EED_Events_Archive', 'event_details' ), |
|
480 | + array('EED_Events_Archive', 'event_details'), |
|
481 | 481 | EED_Events_Archive::EVENT_DETAILS_PRIORITY |
482 | 482 | ); |
483 | - remove_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1 ); |
|
483 | + remove_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1); |
|
484 | 484 | //now add additional content depending on whether event is using the_excerpt() or the_content() |
485 | 485 | EED_Events_Archive::_add_additional_excerpt_filters(); |
486 | 486 | EED_Events_Archive::_add_additional_content_filters(); |
487 | - do_action( 'AHEE__EED_Events_Archive__use_filterable_display_order__after_add_filters' ); |
|
487 | + do_action('AHEE__EED_Events_Archive__use_filterable_display_order__after_add_filters'); |
|
488 | 488 | // now load our template |
489 | - $content = EEH_Template::locate_template( 'content-espresso_events-details.php' ); |
|
489 | + $content = EEH_Template::locate_template('content-espresso_events-details.php'); |
|
490 | 490 | // re-add our main filters (or else the next event won't have them) |
491 | 491 | add_filter( |
492 | 492 | 'the_excerpt', |
493 | - array( 'EED_Events_Archive', 'event_details' ), |
|
493 | + array('EED_Events_Archive', 'event_details'), |
|
494 | 494 | EED_Events_Archive::EVENT_DETAILS_PRIORITY |
495 | 495 | ); |
496 | 496 | add_filter( |
497 | 497 | 'the_content', |
498 | - array( 'EED_Events_Archive', 'event_details' ), |
|
498 | + array('EED_Events_Archive', 'event_details'), |
|
499 | 499 | EED_Events_Archive::EVENT_DETAILS_PRIORITY |
500 | 500 | ); |
501 | - add_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1, 1 ); |
|
501 | + add_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1, 1); |
|
502 | 502 | // but remove the other filters so that they don't get applied to the next post |
503 | 503 | EED_Events_Archive::_remove_additional_events_archive_filters(); |
504 | - do_action( 'AHEE__EED_Events_Archive__use_filterable_display_order__after_remove_filters' ); |
|
504 | + do_action('AHEE__EED_Events_Archive__use_filterable_display_order__after_remove_filters'); |
|
505 | 505 | // we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt) |
506 | 506 | //return ! empty( $template ) ? $template : $content; |
507 | 507 | return $content; |
@@ -516,11 +516,11 @@ discard block |
||
516 | 516 | * @param string $content |
517 | 517 | * @return string |
518 | 518 | */ |
519 | - public static function event_datetimes( $content ) { |
|
520 | - if ( post_password_required() ) { |
|
519 | + public static function event_datetimes($content) { |
|
520 | + if (post_password_required()) { |
|
521 | 521 | return $content; |
522 | 522 | } |
523 | - return EEH_Template::locate_template( 'content-espresso_events-datetimes.php' ) . $content; |
|
523 | + return EEH_Template::locate_template('content-espresso_events-datetimes.php').$content; |
|
524 | 524 | } |
525 | 525 | |
526 | 526 | /** |
@@ -530,11 +530,11 @@ discard block |
||
530 | 530 | * @param string $content |
531 | 531 | * @return string |
532 | 532 | */ |
533 | - public static function event_tickets( $content ) { |
|
534 | - if ( post_password_required() ) { |
|
533 | + public static function event_tickets($content) { |
|
534 | + if (post_password_required()) { |
|
535 | 535 | return $content; |
536 | 536 | } |
537 | - return EEH_Template::locate_template( 'content-espresso_events-tickets.php' ) . $content; |
|
537 | + return EEH_Template::locate_template('content-espresso_events-tickets.php').$content; |
|
538 | 538 | } |
539 | 539 | |
540 | 540 | |
@@ -546,8 +546,8 @@ discard block |
||
546 | 546 | * @param string $content |
547 | 547 | * @return string |
548 | 548 | */ |
549 | - public static function event_venue( $content ) { |
|
550 | - return EED_Events_Archive::event_venues( $content ); |
|
549 | + public static function event_venue($content) { |
|
550 | + return EED_Events_Archive::event_venues($content); |
|
551 | 551 | } |
552 | 552 | |
553 | 553 | /** |
@@ -557,11 +557,11 @@ discard block |
||
557 | 557 | * @param string $content |
558 | 558 | * @return string |
559 | 559 | */ |
560 | - public static function event_venues( $content ) { |
|
561 | - if ( post_password_required() ) { |
|
560 | + public static function event_venues($content) { |
|
561 | + if (post_password_required()) { |
|
562 | 562 | return $content; |
563 | 563 | } |
564 | - return $content . EEH_Template::locate_template( 'content-espresso_events-venues.php' ); |
|
564 | + return $content.EEH_Template::locate_template('content-espresso_events-venues.php'); |
|
565 | 565 | } |
566 | 566 | |
567 | 567 | |
@@ -575,17 +575,17 @@ discard block |
||
575 | 575 | private static function _add_additional_excerpt_filters() { |
576 | 576 | add_filter( |
577 | 577 | 'the_excerpt', |
578 | - array( 'EED_Events_Archive', 'event_datetimes' ), |
|
578 | + array('EED_Events_Archive', 'event_datetimes'), |
|
579 | 579 | EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
580 | 580 | ); |
581 | 581 | add_filter( |
582 | 582 | 'the_excerpt', |
583 | - array( 'EED_Events_Archive', 'event_tickets' ), |
|
583 | + array('EED_Events_Archive', 'event_tickets'), |
|
584 | 584 | EED_Events_Archive::EVENT_TICKETS_PRIORITY |
585 | 585 | ); |
586 | 586 | add_filter( |
587 | 587 | 'the_excerpt', |
588 | - array( 'EED_Events_Archive', 'event_venues' ), |
|
588 | + array('EED_Events_Archive', 'event_venues'), |
|
589 | 589 | EED_Events_Archive::EVENT_VENUES_PRIORITY |
590 | 590 | ); |
591 | 591 | } |
@@ -601,17 +601,17 @@ discard block |
||
601 | 601 | private static function _add_additional_content_filters() { |
602 | 602 | add_filter( |
603 | 603 | 'the_content', |
604 | - array( 'EED_Events_Archive', 'event_datetimes' ), |
|
604 | + array('EED_Events_Archive', 'event_datetimes'), |
|
605 | 605 | EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
606 | 606 | ); |
607 | 607 | add_filter( |
608 | 608 | 'the_content', |
609 | - array( 'EED_Events_Archive', 'event_tickets' ), |
|
609 | + array('EED_Events_Archive', 'event_tickets'), |
|
610 | 610 | EED_Events_Archive::EVENT_TICKETS_PRIORITY |
611 | 611 | ); |
612 | 612 | add_filter( |
613 | 613 | 'the_content', |
614 | - array( 'EED_Events_Archive', 'event_venues' ), |
|
614 | + array('EED_Events_Archive', 'event_venues'), |
|
615 | 615 | EED_Events_Archive::EVENT_VENUES_PRIORITY |
616 | 616 | ); |
617 | 617 | } |
@@ -627,32 +627,32 @@ discard block |
||
627 | 627 | private static function _remove_additional_events_archive_filters() { |
628 | 628 | remove_filter( |
629 | 629 | 'the_excerpt', |
630 | - array( 'EED_Events_Archive', 'event_datetimes' ), |
|
630 | + array('EED_Events_Archive', 'event_datetimes'), |
|
631 | 631 | EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
632 | 632 | ); |
633 | 633 | remove_filter( |
634 | 634 | 'the_excerpt', |
635 | - array( 'EED_Events_Archive', 'event_tickets' ), |
|
635 | + array('EED_Events_Archive', 'event_tickets'), |
|
636 | 636 | EED_Events_Archive::EVENT_TICKETS_PRIORITY |
637 | 637 | ); |
638 | 638 | remove_filter( |
639 | 639 | 'the_excerpt', |
640 | - array( 'EED_Events_Archive', 'event_venues' ), |
|
640 | + array('EED_Events_Archive', 'event_venues'), |
|
641 | 641 | EED_Events_Archive::EVENT_VENUES_PRIORITY |
642 | 642 | ); |
643 | 643 | remove_filter( |
644 | 644 | 'the_content', |
645 | - array( 'EED_Events_Archive', 'event_datetimes' ), |
|
645 | + array('EED_Events_Archive', 'event_datetimes'), |
|
646 | 646 | EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
647 | 647 | ); |
648 | 648 | remove_filter( |
649 | 649 | 'the_content', |
650 | - array( 'EED_Events_Archive', 'event_tickets' ), |
|
650 | + array('EED_Events_Archive', 'event_tickets'), |
|
651 | 651 | EED_Events_Archive::EVENT_TICKETS_PRIORITY |
652 | 652 | ); |
653 | 653 | remove_filter( |
654 | 654 | 'the_content', |
655 | - array( 'EED_Events_Archive', 'event_venues' ), |
|
655 | + array('EED_Events_Archive', 'event_venues'), |
|
656 | 656 | EED_Events_Archive::EVENT_VENUES_PRIORITY |
657 | 657 | ); |
658 | 658 | } |
@@ -667,45 +667,45 @@ discard block |
||
667 | 667 | */ |
668 | 668 | public static function remove_all_events_archive_filters() { |
669 | 669 | //remove_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1 ); |
670 | - remove_filter( 'the_title', array( 'EED_Events_Archive', 'the_title' ), 1 ); |
|
670 | + remove_filter('the_title', array('EED_Events_Archive', 'the_title'), 1); |
|
671 | 671 | remove_filter( |
672 | 672 | 'the_excerpt', |
673 | - array( 'EED_Events_Archive', 'event_details' ), |
|
673 | + array('EED_Events_Archive', 'event_details'), |
|
674 | 674 | EED_Events_Archive::EVENT_DETAILS_PRIORITY |
675 | 675 | ); |
676 | 676 | remove_filter( |
677 | 677 | 'the_excerpt', |
678 | - array( 'EED_Events_Archive', 'event_datetimes' ), |
|
678 | + array('EED_Events_Archive', 'event_datetimes'), |
|
679 | 679 | EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
680 | 680 | ); |
681 | 681 | remove_filter( |
682 | 682 | 'the_excerpt', |
683 | - array( 'EED_Events_Archive', 'event_tickets' ), |
|
683 | + array('EED_Events_Archive', 'event_tickets'), |
|
684 | 684 | EED_Events_Archive::EVENT_TICKETS_PRIORITY |
685 | 685 | ); |
686 | 686 | remove_filter( |
687 | 687 | 'the_excerpt', |
688 | - array( 'EED_Events_Archive', 'event_venues' ), |
|
688 | + array('EED_Events_Archive', 'event_venues'), |
|
689 | 689 | EED_Events_Archive::EVENT_VENUES_PRIORITY |
690 | 690 | ); |
691 | 691 | remove_filter( |
692 | 692 | 'the_content', |
693 | - array( 'EED_Events_Archive', 'event_details' ), |
|
693 | + array('EED_Events_Archive', 'event_details'), |
|
694 | 694 | EED_Events_Archive::EVENT_DETAILS_PRIORITY |
695 | 695 | ); |
696 | 696 | remove_filter( |
697 | 697 | 'the_content', |
698 | - array( 'EED_Events_Archive', 'event_datetimes' ), |
|
698 | + array('EED_Events_Archive', 'event_datetimes'), |
|
699 | 699 | EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
700 | 700 | ); |
701 | 701 | remove_filter( |
702 | 702 | 'the_content', |
703 | - array( 'EED_Events_Archive', 'event_tickets' ), |
|
703 | + array('EED_Events_Archive', 'event_tickets'), |
|
704 | 704 | EED_Events_Archive::EVENT_TICKETS_PRIORITY |
705 | 705 | ); |
706 | 706 | remove_filter( |
707 | 707 | 'the_content', |
708 | - array( 'EED_Events_Archive', 'event_venues' ), |
|
708 | + array('EED_Events_Archive', 'event_venues'), |
|
709 | 709 | EED_Events_Archive::EVENT_VENUES_PRIORITY |
710 | 710 | ); |
711 | 711 | // don't display entry meta because the existing theme will take care of that |
@@ -727,12 +727,12 @@ discard block |
||
727 | 727 | * @return void |
728 | 728 | */ |
729 | 729 | public function load_event_list_assets() { |
730 | - do_action( 'AHEE__EED_Events_Archive__before_load_assets' ); |
|
731 | - add_filter( 'FHEE_load_EE_Session', '__return_true' ); |
|
732 | - add_filter( 'FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true' ); |
|
733 | - add_action('wp_enqueue_scripts', array( $this, 'wp_enqueue_scripts' ), 10 ); |
|
734 | - if ( EE_Registry::instance()->CFG->map_settings->use_google_maps ) { |
|
735 | - add_action('wp_enqueue_scripts', array( 'EEH_Maps', 'espresso_google_map_js' ), 11 ); |
|
730 | + do_action('AHEE__EED_Events_Archive__before_load_assets'); |
|
731 | + add_filter('FHEE_load_EE_Session', '__return_true'); |
|
732 | + add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true'); |
|
733 | + add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10); |
|
734 | + if (EE_Registry::instance()->CFG->map_settings->use_google_maps) { |
|
735 | + add_action('wp_enqueue_scripts', array('EEH_Maps', 'espresso_google_map_js'), 11); |
|
736 | 736 | } |
737 | 737 | } |
738 | 738 | |
@@ -749,13 +749,13 @@ discard block |
||
749 | 749 | */ |
750 | 750 | public function wp_enqueue_scripts() { |
751 | 751 | // get some style |
752 | - if ( apply_filters( 'FHEE_enable_default_espresso_css', FALSE ) ) { |
|
752 | + if (apply_filters('FHEE_enable_default_espresso_css', FALSE)) { |
|
753 | 753 | // first check uploads folder |
754 | - if ( EEH_File::is_readable( get_stylesheet_directory() . $this->theme . DS . 'style.css' )) { |
|
755 | - wp_register_style( $this->theme, get_stylesheet_directory_uri() . $this->theme . DS . 'style.css', array( 'dashicons', 'espresso_default' )); |
|
754 | + if (EEH_File::is_readable(get_stylesheet_directory().$this->theme.DS.'style.css')) { |
|
755 | + wp_register_style($this->theme, get_stylesheet_directory_uri().$this->theme.DS.'style.css', array('dashicons', 'espresso_default')); |
|
756 | 756 | } else { |
757 | 757 | } |
758 | - wp_enqueue_style( $this->theme ); |
|
758 | + wp_enqueue_style($this->theme); |
|
759 | 759 | |
760 | 760 | } |
761 | 761 | } |
@@ -773,8 +773,8 @@ discard block |
||
773 | 773 | */ |
774 | 774 | public static function template_settings_form() { |
775 | 775 | $template_settings = EE_Registry::instance()->CFG->template_settings; |
776 | - $template_settings->EED_Events_Archive = isset( $template_settings->EED_Events_Archive ) ? $template_settings->EED_Events_Archive : new EE_Events_Archive_Config(); |
|
777 | - $template_settings->EED_Events_Archive = apply_filters( 'FHEE__EED_Events_Archive__template_settings_form__event_list_config', $template_settings->EED_Events_Archive ); |
|
776 | + $template_settings->EED_Events_Archive = isset($template_settings->EED_Events_Archive) ? $template_settings->EED_Events_Archive : new EE_Events_Archive_Config(); |
|
777 | + $template_settings->EED_Events_Archive = apply_filters('FHEE__EED_Events_Archive__template_settings_form__event_list_config', $template_settings->EED_Events_Archive); |
|
778 | 778 | $events_archive_settings = array( |
779 | 779 | 'display_status_banner' => 0, |
780 | 780 | 'display_description' => 1, |
@@ -783,8 +783,8 @@ discard block |
||
783 | 783 | 'display_venue' => 0, |
784 | 784 | 'display_expired_events' => 0 |
785 | 785 | ); |
786 | - $events_archive_settings = array_merge( $events_archive_settings, (array)$template_settings->EED_Events_Archive ); |
|
787 | - EEH_Template::display_template( EVENTS_ARCHIVE_TEMPLATES_PATH . 'admin-event-list-settings.template.php', $events_archive_settings ); |
|
786 | + $events_archive_settings = array_merge($events_archive_settings, (array) $template_settings->EED_Events_Archive); |
|
787 | + EEH_Template::display_template(EVENTS_ARCHIVE_TEMPLATES_PATH.'admin-event-list-settings.template.php', $events_archive_settings); |
|
788 | 788 | } |
789 | 789 | |
790 | 790 | |
@@ -800,16 +800,16 @@ discard block |
||
800 | 800 | * @param EE_Request_Handler $REQ |
801 | 801 | * @return EE_Template_Config |
802 | 802 | */ |
803 | - public static function update_template_settings( $CFG, $REQ ) { |
|
803 | + public static function update_template_settings($CFG, $REQ) { |
|
804 | 804 | $CFG->EED_Events_Archive = new EE_Events_Archive_Config(); |
805 | 805 | // unless we are resetting the config... |
806 | - if ( ! isset( $REQ['EED_Events_Archive_reset_event_list_settings'] ) || absint( $REQ['EED_Events_Archive_reset_event_list_settings'] ) !== 1 ) { |
|
807 | - $CFG->EED_Events_Archive->display_status_banner = isset( $REQ['EED_Events_Archive_display_status_banner'] ) ? absint( $REQ['EED_Events_Archive_display_status_banner'] ) : 0; |
|
808 | - $CFG->EED_Events_Archive->display_description = isset( $REQ['EED_Events_Archive_display_description'] ) ? absint( $REQ['EED_Events_Archive_display_description'] ) : 1; |
|
809 | - $CFG->EED_Events_Archive->display_ticket_selector = isset( $REQ['EED_Events_Archive_display_ticket_selector'] ) ? absint( $REQ['EED_Events_Archive_display_ticket_selector'] ) : 0; |
|
810 | - $CFG->EED_Events_Archive->display_datetimes = isset( $REQ['EED_Events_Archive_display_datetimes'] ) ? absint( $REQ['EED_Events_Archive_display_datetimes'] ) : 1; |
|
811 | - $CFG->EED_Events_Archive->display_venue = isset( $REQ['EED_Events_Archive_display_venue'] ) ? absint( $REQ['EED_Events_Archive_display_venue'] ) : 0; |
|
812 | - $CFG->EED_Events_Archive->display_expired_events = isset( $REQ['EED_Events_Archive_display_expired_events'] ) ? absint( $REQ['EED_Events_Archive_display_expired_events'] ) : 0; } |
|
806 | + if ( ! isset($REQ['EED_Events_Archive_reset_event_list_settings']) || absint($REQ['EED_Events_Archive_reset_event_list_settings']) !== 1) { |
|
807 | + $CFG->EED_Events_Archive->display_status_banner = isset($REQ['EED_Events_Archive_display_status_banner']) ? absint($REQ['EED_Events_Archive_display_status_banner']) : 0; |
|
808 | + $CFG->EED_Events_Archive->display_description = isset($REQ['EED_Events_Archive_display_description']) ? absint($REQ['EED_Events_Archive_display_description']) : 1; |
|
809 | + $CFG->EED_Events_Archive->display_ticket_selector = isset($REQ['EED_Events_Archive_display_ticket_selector']) ? absint($REQ['EED_Events_Archive_display_ticket_selector']) : 0; |
|
810 | + $CFG->EED_Events_Archive->display_datetimes = isset($REQ['EED_Events_Archive_display_datetimes']) ? absint($REQ['EED_Events_Archive_display_datetimes']) : 1; |
|
811 | + $CFG->EED_Events_Archive->display_venue = isset($REQ['EED_Events_Archive_display_venue']) ? absint($REQ['EED_Events_Archive_display_venue']) : 0; |
|
812 | + $CFG->EED_Events_Archive->display_expired_events = isset($REQ['EED_Events_Archive_display_expired_events']) ? absint($REQ['EED_Events_Archive_display_expired_events']) : 0; } |
|
813 | 813 | return $CFG; |
814 | 814 | } |
815 | 815 | |
@@ -822,10 +822,10 @@ discard block |
||
822 | 822 | * @param string $extra_class |
823 | 823 | * @return string |
824 | 824 | */ |
825 | - public static function event_list_css( $extra_class = '' ) { |
|
826 | - $event_list_css = ! empty( $extra_class ) ? array( $extra_class ) : array(); |
|
825 | + public static function event_list_css($extra_class = '') { |
|
826 | + $event_list_css = ! empty($extra_class) ? array($extra_class) : array(); |
|
827 | 827 | $event_list_css[] = 'espresso-event-list-event'; |
828 | - return implode( ' ', $event_list_css ); |
|
828 | + return implode(' ', $event_list_css); |
|
829 | 829 | } |
830 | 830 | |
831 | 831 | |
@@ -852,9 +852,9 @@ discard block |
||
852 | 852 | * @param $value |
853 | 853 | * @return bool |
854 | 854 | */ |
855 | - public static function display_description( $value ) { |
|
855 | + public static function display_description($value) { |
|
856 | 856 | $config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive; |
857 | - $display_description= isset( $config->display_description ) ? $config->display_description : 1; |
|
857 | + $display_description = isset($config->display_description) ? $config->display_description : 1; |
|
858 | 858 | return $display_description === $value ? TRUE : FALSE; |
859 | 859 | } |
860 | 860 | |
@@ -867,7 +867,7 @@ discard block |
||
867 | 867 | */ |
868 | 868 | public static function display_ticket_selector() { |
869 | 869 | $config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive; |
870 | - return isset( $config->display_ticket_selector ) && $config->display_ticket_selector ? TRUE : FALSE; |
|
870 | + return isset($config->display_ticket_selector) && $config->display_ticket_selector ? TRUE : FALSE; |
|
871 | 871 | } |
872 | 872 | |
873 | 873 | |
@@ -880,7 +880,7 @@ discard block |
||
880 | 880 | */ |
881 | 881 | public static function display_venue() { |
882 | 882 | $config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive; |
883 | - return isset( $config->display_venue ) && $config->display_venue && EEH_Venue_View::venue_name() ? TRUE : FALSE; |
|
883 | + return isset($config->display_venue) && $config->display_venue && EEH_Venue_View::venue_name() ? TRUE : FALSE; |
|
884 | 884 | } |
885 | 885 | |
886 | 886 | |
@@ -892,7 +892,7 @@ discard block |
||
892 | 892 | */ |
893 | 893 | public static function display_datetimes() { |
894 | 894 | $config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive; |
895 | - return isset( $config->display_datetimes ) && $config->display_datetimes ? TRUE : FALSE; |
|
895 | + return isset($config->display_datetimes) && $config->display_datetimes ? TRUE : FALSE; |
|
896 | 896 | } |
897 | 897 | |
898 | 898 | |
@@ -907,7 +907,7 @@ discard block |
||
907 | 907 | * @return string |
908 | 908 | */ |
909 | 909 | public static function event_list_title() { |
910 | - return apply_filters( 'FHEE__archive_espresso_events_template__upcoming_events_h1', __( 'Upcoming Events', 'event_espresso' )); |
|
910 | + return apply_filters('FHEE__archive_espresso_events_template__upcoming_events_h1', __('Upcoming Events', 'event_espresso')); |
|
911 | 911 | } |
912 | 912 | |
913 | 913 | |
@@ -916,11 +916,11 @@ discard block |
||
916 | 916 | /** |
917 | 917 | * @since 4.4.0 |
918 | 918 | */ |
919 | - public static function _doing_it_wrong_notice( $function = '' ) { |
|
919 | + public static function _doing_it_wrong_notice($function = '') { |
|
920 | 920 | EE_Error::doing_it_wrong( |
921 | 921 | __FUNCTION__, |
922 | 922 | sprintf( |
923 | - __( 'EED_Events_Archive::%1$s was moved to EEH_Event_Query::%1$s:%2$sPlease update your existing code because the method it calls will be removed in version %3$s', 'event_espresso' ), |
|
923 | + __('EED_Events_Archive::%1$s was moved to EEH_Event_Query::%1$s:%2$sPlease update your existing code because the method it calls will be removed in version %3$s', 'event_espresso'), |
|
924 | 924 | $function, |
925 | 925 | '<br />', |
926 | 926 | '4.6.0' |
@@ -942,89 +942,89 @@ discard block |
||
942 | 942 | * @deprecated |
943 | 943 | * @since 4.4.0 |
944 | 944 | */ |
945 | - public function posts_fields( $SQL, WP_Query $wp_query ) { |
|
946 | - EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ ); |
|
947 | - return EEH_Event_Query::posts_fields( $SQL, $wp_query ); |
|
945 | + public function posts_fields($SQL, WP_Query $wp_query) { |
|
946 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
947 | + return EEH_Event_Query::posts_fields($SQL, $wp_query); |
|
948 | 948 | } |
949 | 949 | /** |
950 | 950 | * @deprecated |
951 | 951 | * @since 4.4.0 |
952 | 952 | */ |
953 | - public static function posts_fields_sql_for_orderby( $orderby_params = array() ) { |
|
954 | - EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ ); |
|
955 | - return EEH_Event_Query::posts_fields_sql_for_orderby( $orderby_params ); |
|
953 | + public static function posts_fields_sql_for_orderby($orderby_params = array()) { |
|
954 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
955 | + return EEH_Event_Query::posts_fields_sql_for_orderby($orderby_params); |
|
956 | 956 | } |
957 | 957 | /** |
958 | 958 | * @deprecated |
959 | 959 | * @since 4.4.0 |
960 | 960 | */ |
961 | - public function posts_join( $SQL, WP_Query $wp_query ) { |
|
962 | - EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ ); |
|
963 | - return EEH_Event_Query::posts_join( $SQL, $wp_query ); |
|
961 | + public function posts_join($SQL, WP_Query $wp_query) { |
|
962 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
963 | + return EEH_Event_Query::posts_join($SQL, $wp_query); |
|
964 | 964 | } |
965 | 965 | /** |
966 | 966 | * @deprecated |
967 | 967 | * @since 4.4.0 |
968 | 968 | */ |
969 | - public static function posts_join_sql_for_terms( $join_terms = NULL ) { |
|
970 | - EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ ); |
|
971 | - return EEH_Event_Query::posts_join_sql_for_terms( $join_terms ); |
|
969 | + public static function posts_join_sql_for_terms($join_terms = NULL) { |
|
970 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
971 | + return EEH_Event_Query::posts_join_sql_for_terms($join_terms); |
|
972 | 972 | } |
973 | 973 | /** |
974 | 974 | * @deprecated |
975 | 975 | * @since 4.4.0 |
976 | 976 | */ |
977 | - public static function posts_join_for_orderby( $orderby_params = array() ) { |
|
978 | - EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ ); |
|
979 | - return EEH_Event_Query::posts_join_for_orderby( $orderby_params ); |
|
977 | + public static function posts_join_for_orderby($orderby_params = array()) { |
|
978 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
979 | + return EEH_Event_Query::posts_join_for_orderby($orderby_params); |
|
980 | 980 | } |
981 | 981 | /** |
982 | 982 | * @deprecated |
983 | 983 | * @since 4.4.0 |
984 | 984 | */ |
985 | - public function posts_where( $SQL, WP_Query $wp_query ) { |
|
986 | - EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ ); |
|
987 | - return EEH_Event_Query::posts_where( $SQL, $wp_query ); |
|
985 | + public function posts_where($SQL, WP_Query $wp_query) { |
|
986 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
987 | + return EEH_Event_Query::posts_where($SQL, $wp_query); |
|
988 | 988 | } |
989 | 989 | /** |
990 | 990 | * @deprecated |
991 | 991 | * @since 4.4.0 |
992 | 992 | */ |
993 | - public static function posts_where_sql_for_show_expired( $show_expired = FALSE ) { |
|
994 | - EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ ); |
|
995 | - return EEH_Event_Query::posts_where_sql_for_show_expired( $show_expired ); |
|
993 | + public static function posts_where_sql_for_show_expired($show_expired = FALSE) { |
|
994 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
995 | + return EEH_Event_Query::posts_where_sql_for_show_expired($show_expired); |
|
996 | 996 | } |
997 | 997 | /** |
998 | 998 | * @deprecated |
999 | 999 | * @since 4.4.0 |
1000 | 1000 | */ |
1001 | - public static function posts_where_sql_for_event_category_slug( $event_category_slug = NULL ) { |
|
1002 | - EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ ); |
|
1003 | - return EEH_Event_Query::posts_where_sql_for_event_category_slug( $event_category_slug ); |
|
1001 | + public static function posts_where_sql_for_event_category_slug($event_category_slug = NULL) { |
|
1002 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
1003 | + return EEH_Event_Query::posts_where_sql_for_event_category_slug($event_category_slug); |
|
1004 | 1004 | } |
1005 | 1005 | /** |
1006 | 1006 | * @deprecated |
1007 | 1007 | * @since 4.4.0 |
1008 | 1008 | */ |
1009 | - public static function posts_where_sql_for_event_list_month( $month = NULL ) { |
|
1010 | - EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ ); |
|
1011 | - return EEH_Event_Query::posts_where_sql_for_event_list_month( $month ); |
|
1009 | + public static function posts_where_sql_for_event_list_month($month = NULL) { |
|
1010 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
1011 | + return EEH_Event_Query::posts_where_sql_for_event_list_month($month); |
|
1012 | 1012 | } |
1013 | 1013 | /** |
1014 | 1014 | * @deprecated |
1015 | 1015 | * @since 4.4.0 |
1016 | 1016 | */ |
1017 | - public function posts_orderby( $SQL, WP_Query $wp_query ) { |
|
1018 | - EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ ); |
|
1019 | - return EEH_Event_Query::posts_orderby( $SQL, $wp_query ); |
|
1017 | + public function posts_orderby($SQL, WP_Query $wp_query) { |
|
1018 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
1019 | + return EEH_Event_Query::posts_orderby($SQL, $wp_query); |
|
1020 | 1020 | } |
1021 | 1021 | /** |
1022 | 1022 | * @deprecated |
1023 | 1023 | * @since 4.4.0 |
1024 | 1024 | */ |
1025 | - public static function posts_orderby_sql( $orderby_params = array(), $sort = 'ASC' ) { |
|
1026 | - EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ ); |
|
1027 | - return EEH_Event_Query::posts_orderby_sql( $orderby_params, $sort ); |
|
1025 | + public static function posts_orderby_sql($orderby_params = array(), $sort = 'ASC') { |
|
1026 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
1027 | + return EEH_Event_Query::posts_orderby_sql($orderby_params, $sort); |
|
1028 | 1028 | } |
1029 | 1029 | |
1030 | 1030 | |
@@ -1055,8 +1055,8 @@ discard block |
||
1055 | 1055 | * @param string $extra_class |
1056 | 1056 | * @return string |
1057 | 1057 | */ |
1058 | -function espresso_event_list_css( $extra_class = '' ) { |
|
1059 | - return EED_Events_Archive::event_list_css( $extra_class ); |
|
1058 | +function espresso_event_list_css($extra_class = '') { |
|
1059 | + return EED_Events_Archive::event_list_css($extra_class); |
|
1060 | 1060 | } |
1061 | 1061 | |
1062 | 1062 | /** |
@@ -1070,14 +1070,14 @@ discard block |
||
1070 | 1070 | * @return bool |
1071 | 1071 | */ |
1072 | 1072 | function espresso_display_full_description_in_event_list() { |
1073 | - return EED_Events_Archive::display_description( 2 ); |
|
1073 | + return EED_Events_Archive::display_description(2); |
|
1074 | 1074 | } |
1075 | 1075 | |
1076 | 1076 | /** |
1077 | 1077 | * @return bool |
1078 | 1078 | */ |
1079 | 1079 | function espresso_display_excerpt_in_event_list() { |
1080 | - return EED_Events_Archive::display_description( 1 ); |
|
1080 | + return EED_Events_Archive::display_description(1); |
|
1081 | 1081 | } |
1082 | 1082 | |
1083 | 1083 | /** |
@@ -13,462 +13,462 @@ discard block |
||
13 | 13 | class EED_Event_Single extends EED_Module |
14 | 14 | { |
15 | 15 | |
16 | - const EVENT_DETAILS_PRIORITY = 100; |
|
17 | - const EVENT_DATETIMES_PRIORITY = 110; |
|
18 | - const EVENT_TICKETS_PRIORITY = 120; |
|
19 | - const EVENT_VENUES_PRIORITY = 130; |
|
20 | - |
|
21 | - /** |
|
22 | - * @type bool $using_get_the_excerpt |
|
23 | - */ |
|
24 | - protected static $using_get_the_excerpt = false; |
|
25 | - |
|
26 | - |
|
27 | - /** |
|
28 | - * @type EE_Template_Part_Manager $template_parts |
|
29 | - */ |
|
30 | - protected $template_parts; |
|
31 | - |
|
32 | - |
|
33 | - /** |
|
34 | - * @return EED_Module|EED_Event_Single |
|
35 | - */ |
|
36 | - public static function instance() |
|
37 | - { |
|
38 | - return parent::get_instance(__CLASS__); |
|
39 | - } |
|
40 | - |
|
41 | - |
|
42 | - /** |
|
43 | - * set_hooks - for hooking into EE Core, other modules, etc |
|
44 | - * |
|
45 | - * @return void |
|
46 | - */ |
|
47 | - public static function set_hooks() |
|
48 | - { |
|
49 | - add_filter('FHEE_run_EE_wp', '__return_true'); |
|
50 | - add_action('wp_loaded', array('EED_Event_Single', 'set_definitions'), 2); |
|
51 | - EE_Config::register_route(__('event', 'event_espresso'), 'Event_Single', 'run'); |
|
52 | - } |
|
53 | - |
|
54 | - /** |
|
55 | - * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
56 | - * |
|
57 | - * @return void |
|
58 | - */ |
|
59 | - public static function set_hooks_admin() |
|
60 | - { |
|
61 | - add_action('wp_loaded', array('EED_Event_Single', 'set_definitions'), 2); |
|
62 | - } |
|
63 | - |
|
64 | - |
|
65 | - /** |
|
66 | - * set_definitions |
|
67 | - * |
|
68 | - * @static |
|
69 | - * @return void |
|
70 | - */ |
|
71 | - public static function set_definitions() |
|
72 | - { |
|
73 | - define('EVENT_SINGLE_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets' . DS); |
|
74 | - define('EVENT_SINGLE_TEMPLATES_PATH', plugin_dir_path(__FILE__) . 'templates' . DS); |
|
75 | - } |
|
76 | - |
|
77 | - |
|
78 | - /** |
|
79 | - * set_config |
|
80 | - * |
|
81 | - * @void |
|
82 | - */ |
|
83 | - protected function set_config() |
|
84 | - { |
|
85 | - $this->set_config_section('template_settings'); |
|
86 | - $this->set_config_class('EE_Event_Single_Config'); |
|
87 | - $this->set_config_name('EED_Event_Single'); |
|
88 | - } |
|
89 | - |
|
90 | - |
|
91 | - /** |
|
92 | - * initialize_template_parts |
|
93 | - * |
|
94 | - * @param EE_Config_Base|EE_Event_Single_Config $config |
|
95 | - * @return EE_Template_Part_Manager |
|
96 | - */ |
|
97 | - public function initialize_template_parts(EE_Event_Single_Config $config = null) |
|
98 | - { |
|
99 | - /** @type EE_Event_Single_Config $config */ |
|
100 | - $config = $config instanceof EE_Event_Single_Config ? $config : $this->config(); |
|
101 | - EEH_Autoloader::instance()->register_template_part_autoloaders(); |
|
102 | - $template_parts = new EE_Template_Part_Manager(); |
|
103 | - $template_parts->add_template_part( |
|
104 | - 'tickets', |
|
105 | - __('Ticket Selector', 'event_espresso'), |
|
106 | - 'content-espresso_events-tickets.php', |
|
107 | - $config->display_order_tickets |
|
108 | - ); |
|
109 | - $template_parts->add_template_part( |
|
110 | - 'datetimes', |
|
111 | - __('Dates and Times', 'event_espresso'), |
|
112 | - 'content-espresso_events-datetimes.php', |
|
113 | - $config->display_order_datetimes |
|
114 | - ); |
|
115 | - $template_parts->add_template_part( |
|
116 | - 'event', |
|
117 | - __('Event Description', 'event_espresso'), |
|
118 | - 'content-espresso_events-details.php', |
|
119 | - $config->display_order_event |
|
120 | - ); |
|
121 | - $template_parts->add_template_part( |
|
122 | - 'venue', |
|
123 | - __('Venue Information', 'event_espresso'), |
|
124 | - 'content-espresso_events-venues.php', |
|
125 | - $config->display_order_venue |
|
126 | - ); |
|
127 | - do_action('AHEE__EED_Event_Single__initialize_template_parts', $template_parts); |
|
128 | - return $template_parts; |
|
129 | - } |
|
130 | - |
|
131 | - |
|
132 | - /** |
|
133 | - * run - initial module setup |
|
134 | - * |
|
135 | - * @param WP $WP |
|
136 | - * @return void |
|
137 | - */ |
|
138 | - public function run($WP) |
|
139 | - { |
|
140 | - // ensure valid EE_Events_Single_Config() object exists |
|
141 | - $this->set_config(); |
|
142 | - // check what template is loaded |
|
143 | - add_filter('template_include', array($this, 'template_include'), 999, 1); |
|
144 | - add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true'); |
|
145 | - // load css |
|
146 | - add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10); |
|
147 | - } |
|
148 | - |
|
149 | - |
|
150 | - /** |
|
151 | - * template_include |
|
152 | - * |
|
153 | - * @param string $template |
|
154 | - * @return string |
|
155 | - */ |
|
156 | - public function template_include($template) |
|
157 | - { |
|
158 | - global $post; |
|
159 | - /** @type EE_Event_Single_Config $config */ |
|
160 | - $config = $this->config(); |
|
161 | - if ($config->display_status_banner_single) { |
|
162 | - add_filter('the_title', array('EED_Event_Single', 'the_title'), 100, 2); |
|
163 | - } |
|
164 | - // not a custom template? |
|
165 | - if ( |
|
166 | - !post_password_required($post) |
|
167 | - && ( |
|
168 | - apply_filters('FHEE__EED_Event_Single__template_include__allow_custom_selected_template', false) |
|
169 | - || EE_Registry::instance() |
|
170 | - ->load_core('Front_Controller') |
|
171 | - ->get_selected_template() !== 'single-espresso_events.php' |
|
172 | - ) |
|
173 | - |
|
174 | - ) { |
|
175 | - EEH_Template::load_espresso_theme_functions(); |
|
176 | - // then add extra event data via hooks |
|
177 | - add_action('loop_start', array('EED_Event_Single', 'loop_start')); |
|
178 | - add_filter('get_the_excerpt', array('EED_Event_Single', 'get_the_excerpt'), 1, 1); |
|
179 | - add_filter( |
|
180 | - 'the_content', |
|
181 | - array('EED_Event_Single', 'event_details'), |
|
182 | - EED_Event_Single::EVENT_DETAILS_PRIORITY |
|
183 | - ); |
|
184 | - add_action('loop_end', array('EED_Event_Single', 'loop_end')); |
|
185 | - // don't display entry meta because the existing theme will take car of that |
|
186 | - add_filter('FHEE__content_espresso_events_details_template__display_entry_meta', '__return_false'); |
|
187 | - } |
|
188 | - return $template; |
|
189 | - } |
|
190 | - |
|
191 | - |
|
192 | - /** |
|
193 | - * loop_start |
|
194 | - * |
|
195 | - * @param array $wp_query_array an array containing the WP_Query object |
|
196 | - * @return void |
|
197 | - */ |
|
198 | - public static function loop_start($wp_query_array) |
|
199 | - { |
|
200 | - global $post; |
|
201 | - do_action('AHEE_event_details_before_post', $post, $wp_query_array); |
|
202 | - } |
|
203 | - |
|
204 | - |
|
205 | - /** |
|
206 | - * the_title |
|
207 | - * |
|
208 | - * @param string $title |
|
209 | - * @param int $id |
|
210 | - * @return string |
|
211 | - */ |
|
212 | - public static function the_title($title = '', $id = 0) |
|
213 | - { |
|
214 | - global $post; |
|
215 | - return in_the_loop() && $post->ID === (int)$id |
|
216 | - ? espresso_event_status_banner($post->ID) . $title |
|
217 | - : $title; |
|
218 | - } |
|
219 | - |
|
220 | - |
|
221 | - /** |
|
222 | - * get_the_excerpt |
|
223 | - * kinda hacky, but if a theme is using get_the_excerpt(), |
|
224 | - * then we need to remove our filters on the_content() |
|
225 | - * |
|
226 | - * @param string $excerpt |
|
227 | - * @return string |
|
228 | - */ |
|
229 | - public static function get_the_excerpt($excerpt = '') |
|
230 | - { |
|
231 | - EED_Event_Single::$using_get_the_excerpt = true; |
|
232 | - add_filter('wp_trim_excerpt', array('EED_Event_Single', 'end_get_the_excerpt'), 999, 1); |
|
233 | - return $excerpt; |
|
234 | - } |
|
235 | - |
|
236 | - |
|
237 | - /** |
|
238 | - * end_get_the_excerpt |
|
239 | - * |
|
240 | - * @param string $text |
|
241 | - * @return string |
|
242 | - */ |
|
243 | - public static function end_get_the_excerpt($text = '') |
|
244 | - { |
|
245 | - EED_Event_Single::$using_get_the_excerpt = false; |
|
246 | - return $text; |
|
247 | - } |
|
248 | - |
|
249 | - |
|
250 | - /** |
|
251 | - * event_details |
|
252 | - * |
|
253 | - * @param string $content |
|
254 | - * @return string |
|
255 | - */ |
|
256 | - public static function event_details($content) |
|
257 | - { |
|
258 | - global $post; |
|
259 | - static $current_post_ID = 0; |
|
260 | - if ( |
|
261 | - $current_post_ID !== $post->ID |
|
262 | - && $post->post_type === 'espresso_events' |
|
263 | - && !EED_Event_Single::$using_get_the_excerpt |
|
264 | - && !post_password_required() |
|
265 | - ) { |
|
266 | - // Set current post ID to prevent showing content twice, but only if headers have definitely been sent. |
|
267 | - // Reason being is that some plugins, like Yoast, need to run through a copy of the loop early |
|
268 | - // BEFORE headers are sent in order to examine the post content and generate content for the HTML header. |
|
269 | - // We want to allow those plugins to still do their thing and have access to our content, but depending on |
|
270 | - // how your event content is being displayed (shortcode, CPT route, etc), this filter can get applied twice, |
|
271 | - // so the following allows this filter to be applied multiple times, but only once for real |
|
272 | - $current_post_ID = did_action('loop_start') ? $post->ID : 0; |
|
273 | - if (EE_Registry::instance()->CFG->template_settings->EED_Event_Single->use_sortable_display_order) { |
|
274 | - // we need to first remove this callback from being applied to the_content() |
|
275 | - // (otherwise it will recurse and blow up the interweb) |
|
276 | - remove_filter( |
|
277 | - 'the_content', |
|
278 | - array('EED_Event_Single', 'event_details'), |
|
279 | - EED_Event_Single::EVENT_DETAILS_PRIORITY |
|
280 | - ); |
|
281 | - EED_Event_Single::instance()->template_parts = EED_Event_Single::instance()->initialize_template_parts(); |
|
282 | - $content = EEH_Template::locate_template('content-espresso_events-details.php'); |
|
283 | - $content = EED_Event_Single::instance()->template_parts->apply_template_part_filters($content); |
|
284 | - add_filter( |
|
285 | - 'the_content', |
|
286 | - array('EED_Event_Single', 'event_details'), |
|
287 | - EED_Event_Single::EVENT_DETAILS_PRIORITY |
|
288 | - ); |
|
289 | - } else { |
|
290 | - $content = EED_Event_Single::use_filterable_display_order(); |
|
291 | - } |
|
292 | - } |
|
293 | - return $content; |
|
294 | - } |
|
295 | - |
|
296 | - |
|
297 | - /** |
|
298 | - * use_filterable_display_order |
|
299 | - * |
|
300 | - * @return string |
|
301 | - */ |
|
302 | - protected static function use_filterable_display_order() |
|
303 | - { |
|
304 | - // since the 'content-espresso_events-details.php' template might be used directly from within a theme, |
|
305 | - // it uses the_content() for displaying the $post->post_content |
|
306 | - // so in order to load a template that uses the_content() |
|
307 | - // from within a callback being used to filter the_content(), |
|
308 | - // we need to first remove this callback from being applied to the_content() |
|
309 | - // (otherwise it will recurse and blow up the interweb) |
|
310 | - remove_filter( |
|
311 | - 'the_content', |
|
312 | - array('EED_Event_Single', 'event_details'), |
|
313 | - EED_Event_Single::EVENT_DETAILS_PRIORITY |
|
314 | - ); |
|
315 | - //now add additional content |
|
316 | - add_filter( |
|
317 | - 'the_content', |
|
318 | - array('EED_Event_Single', 'event_datetimes'), |
|
319 | - EED_Event_Single::EVENT_DATETIMES_PRIORITY, |
|
320 | - 1 |
|
321 | - ); |
|
322 | - add_filter( |
|
323 | - 'the_content', |
|
324 | - array('EED_Event_Single', 'event_tickets'), |
|
325 | - EED_Event_Single::EVENT_TICKETS_PRIORITY, |
|
326 | - 1 |
|
327 | - ); |
|
328 | - add_filter( |
|
329 | - 'the_content', |
|
330 | - array('EED_Event_Single', 'event_venues'), |
|
331 | - EED_Event_Single::EVENT_VENUES_PRIORITY, |
|
332 | - 1 |
|
333 | - ); |
|
334 | - do_action('AHEE__EED_Event_Single__use_filterable_display_order__after_add_filters'); |
|
335 | - // now load our template |
|
336 | - $content = EEH_Template::locate_template('content-espresso_events-details.php'); |
|
337 | - //now add our filter back in, plus some others |
|
338 | - add_filter( |
|
339 | - 'the_content', |
|
340 | - array('EED_Event_Single', 'event_details'), |
|
341 | - EED_Event_Single::EVENT_DETAILS_PRIORITY |
|
342 | - ); |
|
343 | - remove_filter( |
|
344 | - 'the_content', |
|
345 | - array('EED_Event_Single', 'event_datetimes'), |
|
346 | - EED_Event_Single::EVENT_DATETIMES_PRIORITY |
|
347 | - ); |
|
348 | - remove_filter( |
|
349 | - 'the_content', |
|
350 | - array('EED_Event_Single', 'event_tickets'), |
|
351 | - EED_Event_Single::EVENT_TICKETS_PRIORITY |
|
352 | - ); |
|
353 | - remove_filter( |
|
354 | - 'the_content', |
|
355 | - array('EED_Event_Single', 'event_venues'), |
|
356 | - EED_Event_Single::EVENT_VENUES_PRIORITY |
|
357 | - ); |
|
358 | - do_action('AHEE__EED_Event_Single__use_filterable_display_order__after_remove_filters'); |
|
359 | - // we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt) |
|
360 | - return $content; |
|
361 | - } |
|
362 | - |
|
363 | - |
|
364 | - /** |
|
365 | - * event_datetimes - adds datetimes ABOVE content |
|
366 | - * |
|
367 | - * @param string $content |
|
368 | - * @return string |
|
369 | - */ |
|
370 | - public static function event_datetimes($content) |
|
371 | - { |
|
372 | - return EEH_Template::locate_template('content-espresso_events-datetimes.php') . $content; |
|
373 | - } |
|
374 | - |
|
375 | - |
|
376 | - /** |
|
377 | - * event_tickets - adds tickets ABOVE content (which includes datetimes) |
|
378 | - * |
|
379 | - * @param string $content |
|
380 | - * @return string |
|
381 | - */ |
|
382 | - public static function event_tickets($content) |
|
383 | - { |
|
384 | - return EEH_Template::locate_template('content-espresso_events-tickets.php') . $content; |
|
385 | - } |
|
386 | - |
|
387 | - |
|
388 | - /** |
|
389 | - * event_venues |
|
390 | - * |
|
391 | - * @param string $content |
|
392 | - * @return string |
|
393 | - */ |
|
394 | - public static function event_venue($content) |
|
395 | - { |
|
396 | - return EED_Event_Single::event_venues($content); |
|
397 | - } |
|
398 | - |
|
399 | - |
|
400 | - /** |
|
401 | - * event_venues - adds venues BELOW content |
|
402 | - * |
|
403 | - * @param string $content |
|
404 | - * @return string |
|
405 | - */ |
|
406 | - public static function event_venues($content) |
|
407 | - { |
|
408 | - return $content . EEH_Template::locate_template('content-espresso_events-venues.php'); |
|
409 | - } |
|
410 | - |
|
411 | - |
|
412 | - /** |
|
413 | - * loop_end |
|
414 | - * |
|
415 | - * @param array $wp_query_array an array containing the WP_Query object |
|
416 | - * @return void |
|
417 | - */ |
|
418 | - public static function loop_end($wp_query_array) |
|
419 | - { |
|
420 | - global $post; |
|
421 | - do_action('AHEE_event_details_after_post', $post, $wp_query_array); |
|
422 | - } |
|
423 | - |
|
424 | - |
|
425 | - /** |
|
426 | - * wp_enqueue_scripts |
|
427 | - * |
|
428 | - * @return void |
|
429 | - */ |
|
430 | - public function wp_enqueue_scripts() |
|
431 | - { |
|
432 | - // get some style |
|
433 | - if ( |
|
434 | - apply_filters('FHEE_enable_default_espresso_css', TRUE) |
|
435 | - && apply_filters('FHEE__EED_Event_Single__wp_enqueue_scripts__enable_css', TRUE) |
|
436 | - ) { |
|
437 | - // first check uploads folder |
|
438 | - if (is_readable(get_stylesheet_directory() . $this->theme . DS . 'style.css')) { |
|
439 | - wp_register_style( |
|
440 | - $this->theme, |
|
441 | - get_stylesheet_directory_uri() . $this->theme . DS . 'style.css', |
|
442 | - array('dashicons', 'espresso_default') |
|
443 | - ); |
|
444 | - } else { |
|
445 | - wp_register_style( |
|
446 | - $this->theme, |
|
447 | - EE_TEMPLATES_URL . $this->theme . DS . 'style.css', |
|
448 | - array('dashicons', 'espresso_default') |
|
449 | - ); |
|
450 | - } |
|
451 | - wp_enqueue_script($this->theme); |
|
452 | - if (EE_Registry::instance()->CFG->map_settings->use_google_maps) { |
|
453 | - add_action('wp_enqueue_scripts', array('EEH_Maps', 'espresso_google_map_js'), 11); |
|
454 | - } |
|
455 | - } |
|
456 | - } |
|
457 | - |
|
458 | - |
|
459 | - /** |
|
460 | - * display_venue |
|
461 | - * |
|
462 | - * @return bool |
|
463 | - */ |
|
464 | - public static function display_venue() |
|
465 | - { |
|
466 | - /** @type EE_Event_Single_Config $config */ |
|
467 | - $config = EED_Event_Single::instance()->config(); |
|
468 | - $display_venue = $config->display_venue === null ? true : $config->display_venue; |
|
469 | - $venue_name = EEH_Venue_View::venue_name(); |
|
470 | - return $display_venue && !empty($venue_name); |
|
471 | - } |
|
16 | + const EVENT_DETAILS_PRIORITY = 100; |
|
17 | + const EVENT_DATETIMES_PRIORITY = 110; |
|
18 | + const EVENT_TICKETS_PRIORITY = 120; |
|
19 | + const EVENT_VENUES_PRIORITY = 130; |
|
20 | + |
|
21 | + /** |
|
22 | + * @type bool $using_get_the_excerpt |
|
23 | + */ |
|
24 | + protected static $using_get_the_excerpt = false; |
|
25 | + |
|
26 | + |
|
27 | + /** |
|
28 | + * @type EE_Template_Part_Manager $template_parts |
|
29 | + */ |
|
30 | + protected $template_parts; |
|
31 | + |
|
32 | + |
|
33 | + /** |
|
34 | + * @return EED_Module|EED_Event_Single |
|
35 | + */ |
|
36 | + public static function instance() |
|
37 | + { |
|
38 | + return parent::get_instance(__CLASS__); |
|
39 | + } |
|
40 | + |
|
41 | + |
|
42 | + /** |
|
43 | + * set_hooks - for hooking into EE Core, other modules, etc |
|
44 | + * |
|
45 | + * @return void |
|
46 | + */ |
|
47 | + public static function set_hooks() |
|
48 | + { |
|
49 | + add_filter('FHEE_run_EE_wp', '__return_true'); |
|
50 | + add_action('wp_loaded', array('EED_Event_Single', 'set_definitions'), 2); |
|
51 | + EE_Config::register_route(__('event', 'event_espresso'), 'Event_Single', 'run'); |
|
52 | + } |
|
53 | + |
|
54 | + /** |
|
55 | + * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
56 | + * |
|
57 | + * @return void |
|
58 | + */ |
|
59 | + public static function set_hooks_admin() |
|
60 | + { |
|
61 | + add_action('wp_loaded', array('EED_Event_Single', 'set_definitions'), 2); |
|
62 | + } |
|
63 | + |
|
64 | + |
|
65 | + /** |
|
66 | + * set_definitions |
|
67 | + * |
|
68 | + * @static |
|
69 | + * @return void |
|
70 | + */ |
|
71 | + public static function set_definitions() |
|
72 | + { |
|
73 | + define('EVENT_SINGLE_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets' . DS); |
|
74 | + define('EVENT_SINGLE_TEMPLATES_PATH', plugin_dir_path(__FILE__) . 'templates' . DS); |
|
75 | + } |
|
76 | + |
|
77 | + |
|
78 | + /** |
|
79 | + * set_config |
|
80 | + * |
|
81 | + * @void |
|
82 | + */ |
|
83 | + protected function set_config() |
|
84 | + { |
|
85 | + $this->set_config_section('template_settings'); |
|
86 | + $this->set_config_class('EE_Event_Single_Config'); |
|
87 | + $this->set_config_name('EED_Event_Single'); |
|
88 | + } |
|
89 | + |
|
90 | + |
|
91 | + /** |
|
92 | + * initialize_template_parts |
|
93 | + * |
|
94 | + * @param EE_Config_Base|EE_Event_Single_Config $config |
|
95 | + * @return EE_Template_Part_Manager |
|
96 | + */ |
|
97 | + public function initialize_template_parts(EE_Event_Single_Config $config = null) |
|
98 | + { |
|
99 | + /** @type EE_Event_Single_Config $config */ |
|
100 | + $config = $config instanceof EE_Event_Single_Config ? $config : $this->config(); |
|
101 | + EEH_Autoloader::instance()->register_template_part_autoloaders(); |
|
102 | + $template_parts = new EE_Template_Part_Manager(); |
|
103 | + $template_parts->add_template_part( |
|
104 | + 'tickets', |
|
105 | + __('Ticket Selector', 'event_espresso'), |
|
106 | + 'content-espresso_events-tickets.php', |
|
107 | + $config->display_order_tickets |
|
108 | + ); |
|
109 | + $template_parts->add_template_part( |
|
110 | + 'datetimes', |
|
111 | + __('Dates and Times', 'event_espresso'), |
|
112 | + 'content-espresso_events-datetimes.php', |
|
113 | + $config->display_order_datetimes |
|
114 | + ); |
|
115 | + $template_parts->add_template_part( |
|
116 | + 'event', |
|
117 | + __('Event Description', 'event_espresso'), |
|
118 | + 'content-espresso_events-details.php', |
|
119 | + $config->display_order_event |
|
120 | + ); |
|
121 | + $template_parts->add_template_part( |
|
122 | + 'venue', |
|
123 | + __('Venue Information', 'event_espresso'), |
|
124 | + 'content-espresso_events-venues.php', |
|
125 | + $config->display_order_venue |
|
126 | + ); |
|
127 | + do_action('AHEE__EED_Event_Single__initialize_template_parts', $template_parts); |
|
128 | + return $template_parts; |
|
129 | + } |
|
130 | + |
|
131 | + |
|
132 | + /** |
|
133 | + * run - initial module setup |
|
134 | + * |
|
135 | + * @param WP $WP |
|
136 | + * @return void |
|
137 | + */ |
|
138 | + public function run($WP) |
|
139 | + { |
|
140 | + // ensure valid EE_Events_Single_Config() object exists |
|
141 | + $this->set_config(); |
|
142 | + // check what template is loaded |
|
143 | + add_filter('template_include', array($this, 'template_include'), 999, 1); |
|
144 | + add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true'); |
|
145 | + // load css |
|
146 | + add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10); |
|
147 | + } |
|
148 | + |
|
149 | + |
|
150 | + /** |
|
151 | + * template_include |
|
152 | + * |
|
153 | + * @param string $template |
|
154 | + * @return string |
|
155 | + */ |
|
156 | + public function template_include($template) |
|
157 | + { |
|
158 | + global $post; |
|
159 | + /** @type EE_Event_Single_Config $config */ |
|
160 | + $config = $this->config(); |
|
161 | + if ($config->display_status_banner_single) { |
|
162 | + add_filter('the_title', array('EED_Event_Single', 'the_title'), 100, 2); |
|
163 | + } |
|
164 | + // not a custom template? |
|
165 | + if ( |
|
166 | + !post_password_required($post) |
|
167 | + && ( |
|
168 | + apply_filters('FHEE__EED_Event_Single__template_include__allow_custom_selected_template', false) |
|
169 | + || EE_Registry::instance() |
|
170 | + ->load_core('Front_Controller') |
|
171 | + ->get_selected_template() !== 'single-espresso_events.php' |
|
172 | + ) |
|
173 | + |
|
174 | + ) { |
|
175 | + EEH_Template::load_espresso_theme_functions(); |
|
176 | + // then add extra event data via hooks |
|
177 | + add_action('loop_start', array('EED_Event_Single', 'loop_start')); |
|
178 | + add_filter('get_the_excerpt', array('EED_Event_Single', 'get_the_excerpt'), 1, 1); |
|
179 | + add_filter( |
|
180 | + 'the_content', |
|
181 | + array('EED_Event_Single', 'event_details'), |
|
182 | + EED_Event_Single::EVENT_DETAILS_PRIORITY |
|
183 | + ); |
|
184 | + add_action('loop_end', array('EED_Event_Single', 'loop_end')); |
|
185 | + // don't display entry meta because the existing theme will take car of that |
|
186 | + add_filter('FHEE__content_espresso_events_details_template__display_entry_meta', '__return_false'); |
|
187 | + } |
|
188 | + return $template; |
|
189 | + } |
|
190 | + |
|
191 | + |
|
192 | + /** |
|
193 | + * loop_start |
|
194 | + * |
|
195 | + * @param array $wp_query_array an array containing the WP_Query object |
|
196 | + * @return void |
|
197 | + */ |
|
198 | + public static function loop_start($wp_query_array) |
|
199 | + { |
|
200 | + global $post; |
|
201 | + do_action('AHEE_event_details_before_post', $post, $wp_query_array); |
|
202 | + } |
|
203 | + |
|
204 | + |
|
205 | + /** |
|
206 | + * the_title |
|
207 | + * |
|
208 | + * @param string $title |
|
209 | + * @param int $id |
|
210 | + * @return string |
|
211 | + */ |
|
212 | + public static function the_title($title = '', $id = 0) |
|
213 | + { |
|
214 | + global $post; |
|
215 | + return in_the_loop() && $post->ID === (int)$id |
|
216 | + ? espresso_event_status_banner($post->ID) . $title |
|
217 | + : $title; |
|
218 | + } |
|
219 | + |
|
220 | + |
|
221 | + /** |
|
222 | + * get_the_excerpt |
|
223 | + * kinda hacky, but if a theme is using get_the_excerpt(), |
|
224 | + * then we need to remove our filters on the_content() |
|
225 | + * |
|
226 | + * @param string $excerpt |
|
227 | + * @return string |
|
228 | + */ |
|
229 | + public static function get_the_excerpt($excerpt = '') |
|
230 | + { |
|
231 | + EED_Event_Single::$using_get_the_excerpt = true; |
|
232 | + add_filter('wp_trim_excerpt', array('EED_Event_Single', 'end_get_the_excerpt'), 999, 1); |
|
233 | + return $excerpt; |
|
234 | + } |
|
235 | + |
|
236 | + |
|
237 | + /** |
|
238 | + * end_get_the_excerpt |
|
239 | + * |
|
240 | + * @param string $text |
|
241 | + * @return string |
|
242 | + */ |
|
243 | + public static function end_get_the_excerpt($text = '') |
|
244 | + { |
|
245 | + EED_Event_Single::$using_get_the_excerpt = false; |
|
246 | + return $text; |
|
247 | + } |
|
248 | + |
|
249 | + |
|
250 | + /** |
|
251 | + * event_details |
|
252 | + * |
|
253 | + * @param string $content |
|
254 | + * @return string |
|
255 | + */ |
|
256 | + public static function event_details($content) |
|
257 | + { |
|
258 | + global $post; |
|
259 | + static $current_post_ID = 0; |
|
260 | + if ( |
|
261 | + $current_post_ID !== $post->ID |
|
262 | + && $post->post_type === 'espresso_events' |
|
263 | + && !EED_Event_Single::$using_get_the_excerpt |
|
264 | + && !post_password_required() |
|
265 | + ) { |
|
266 | + // Set current post ID to prevent showing content twice, but only if headers have definitely been sent. |
|
267 | + // Reason being is that some plugins, like Yoast, need to run through a copy of the loop early |
|
268 | + // BEFORE headers are sent in order to examine the post content and generate content for the HTML header. |
|
269 | + // We want to allow those plugins to still do their thing and have access to our content, but depending on |
|
270 | + // how your event content is being displayed (shortcode, CPT route, etc), this filter can get applied twice, |
|
271 | + // so the following allows this filter to be applied multiple times, but only once for real |
|
272 | + $current_post_ID = did_action('loop_start') ? $post->ID : 0; |
|
273 | + if (EE_Registry::instance()->CFG->template_settings->EED_Event_Single->use_sortable_display_order) { |
|
274 | + // we need to first remove this callback from being applied to the_content() |
|
275 | + // (otherwise it will recurse and blow up the interweb) |
|
276 | + remove_filter( |
|
277 | + 'the_content', |
|
278 | + array('EED_Event_Single', 'event_details'), |
|
279 | + EED_Event_Single::EVENT_DETAILS_PRIORITY |
|
280 | + ); |
|
281 | + EED_Event_Single::instance()->template_parts = EED_Event_Single::instance()->initialize_template_parts(); |
|
282 | + $content = EEH_Template::locate_template('content-espresso_events-details.php'); |
|
283 | + $content = EED_Event_Single::instance()->template_parts->apply_template_part_filters($content); |
|
284 | + add_filter( |
|
285 | + 'the_content', |
|
286 | + array('EED_Event_Single', 'event_details'), |
|
287 | + EED_Event_Single::EVENT_DETAILS_PRIORITY |
|
288 | + ); |
|
289 | + } else { |
|
290 | + $content = EED_Event_Single::use_filterable_display_order(); |
|
291 | + } |
|
292 | + } |
|
293 | + return $content; |
|
294 | + } |
|
295 | + |
|
296 | + |
|
297 | + /** |
|
298 | + * use_filterable_display_order |
|
299 | + * |
|
300 | + * @return string |
|
301 | + */ |
|
302 | + protected static function use_filterable_display_order() |
|
303 | + { |
|
304 | + // since the 'content-espresso_events-details.php' template might be used directly from within a theme, |
|
305 | + // it uses the_content() for displaying the $post->post_content |
|
306 | + // so in order to load a template that uses the_content() |
|
307 | + // from within a callback being used to filter the_content(), |
|
308 | + // we need to first remove this callback from being applied to the_content() |
|
309 | + // (otherwise it will recurse and blow up the interweb) |
|
310 | + remove_filter( |
|
311 | + 'the_content', |
|
312 | + array('EED_Event_Single', 'event_details'), |
|
313 | + EED_Event_Single::EVENT_DETAILS_PRIORITY |
|
314 | + ); |
|
315 | + //now add additional content |
|
316 | + add_filter( |
|
317 | + 'the_content', |
|
318 | + array('EED_Event_Single', 'event_datetimes'), |
|
319 | + EED_Event_Single::EVENT_DATETIMES_PRIORITY, |
|
320 | + 1 |
|
321 | + ); |
|
322 | + add_filter( |
|
323 | + 'the_content', |
|
324 | + array('EED_Event_Single', 'event_tickets'), |
|
325 | + EED_Event_Single::EVENT_TICKETS_PRIORITY, |
|
326 | + 1 |
|
327 | + ); |
|
328 | + add_filter( |
|
329 | + 'the_content', |
|
330 | + array('EED_Event_Single', 'event_venues'), |
|
331 | + EED_Event_Single::EVENT_VENUES_PRIORITY, |
|
332 | + 1 |
|
333 | + ); |
|
334 | + do_action('AHEE__EED_Event_Single__use_filterable_display_order__after_add_filters'); |
|
335 | + // now load our template |
|
336 | + $content = EEH_Template::locate_template('content-espresso_events-details.php'); |
|
337 | + //now add our filter back in, plus some others |
|
338 | + add_filter( |
|
339 | + 'the_content', |
|
340 | + array('EED_Event_Single', 'event_details'), |
|
341 | + EED_Event_Single::EVENT_DETAILS_PRIORITY |
|
342 | + ); |
|
343 | + remove_filter( |
|
344 | + 'the_content', |
|
345 | + array('EED_Event_Single', 'event_datetimes'), |
|
346 | + EED_Event_Single::EVENT_DATETIMES_PRIORITY |
|
347 | + ); |
|
348 | + remove_filter( |
|
349 | + 'the_content', |
|
350 | + array('EED_Event_Single', 'event_tickets'), |
|
351 | + EED_Event_Single::EVENT_TICKETS_PRIORITY |
|
352 | + ); |
|
353 | + remove_filter( |
|
354 | + 'the_content', |
|
355 | + array('EED_Event_Single', 'event_venues'), |
|
356 | + EED_Event_Single::EVENT_VENUES_PRIORITY |
|
357 | + ); |
|
358 | + do_action('AHEE__EED_Event_Single__use_filterable_display_order__after_remove_filters'); |
|
359 | + // we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt) |
|
360 | + return $content; |
|
361 | + } |
|
362 | + |
|
363 | + |
|
364 | + /** |
|
365 | + * event_datetimes - adds datetimes ABOVE content |
|
366 | + * |
|
367 | + * @param string $content |
|
368 | + * @return string |
|
369 | + */ |
|
370 | + public static function event_datetimes($content) |
|
371 | + { |
|
372 | + return EEH_Template::locate_template('content-espresso_events-datetimes.php') . $content; |
|
373 | + } |
|
374 | + |
|
375 | + |
|
376 | + /** |
|
377 | + * event_tickets - adds tickets ABOVE content (which includes datetimes) |
|
378 | + * |
|
379 | + * @param string $content |
|
380 | + * @return string |
|
381 | + */ |
|
382 | + public static function event_tickets($content) |
|
383 | + { |
|
384 | + return EEH_Template::locate_template('content-espresso_events-tickets.php') . $content; |
|
385 | + } |
|
386 | + |
|
387 | + |
|
388 | + /** |
|
389 | + * event_venues |
|
390 | + * |
|
391 | + * @param string $content |
|
392 | + * @return string |
|
393 | + */ |
|
394 | + public static function event_venue($content) |
|
395 | + { |
|
396 | + return EED_Event_Single::event_venues($content); |
|
397 | + } |
|
398 | + |
|
399 | + |
|
400 | + /** |
|
401 | + * event_venues - adds venues BELOW content |
|
402 | + * |
|
403 | + * @param string $content |
|
404 | + * @return string |
|
405 | + */ |
|
406 | + public static function event_venues($content) |
|
407 | + { |
|
408 | + return $content . EEH_Template::locate_template('content-espresso_events-venues.php'); |
|
409 | + } |
|
410 | + |
|
411 | + |
|
412 | + /** |
|
413 | + * loop_end |
|
414 | + * |
|
415 | + * @param array $wp_query_array an array containing the WP_Query object |
|
416 | + * @return void |
|
417 | + */ |
|
418 | + public static function loop_end($wp_query_array) |
|
419 | + { |
|
420 | + global $post; |
|
421 | + do_action('AHEE_event_details_after_post', $post, $wp_query_array); |
|
422 | + } |
|
423 | + |
|
424 | + |
|
425 | + /** |
|
426 | + * wp_enqueue_scripts |
|
427 | + * |
|
428 | + * @return void |
|
429 | + */ |
|
430 | + public function wp_enqueue_scripts() |
|
431 | + { |
|
432 | + // get some style |
|
433 | + if ( |
|
434 | + apply_filters('FHEE_enable_default_espresso_css', TRUE) |
|
435 | + && apply_filters('FHEE__EED_Event_Single__wp_enqueue_scripts__enable_css', TRUE) |
|
436 | + ) { |
|
437 | + // first check uploads folder |
|
438 | + if (is_readable(get_stylesheet_directory() . $this->theme . DS . 'style.css')) { |
|
439 | + wp_register_style( |
|
440 | + $this->theme, |
|
441 | + get_stylesheet_directory_uri() . $this->theme . DS . 'style.css', |
|
442 | + array('dashicons', 'espresso_default') |
|
443 | + ); |
|
444 | + } else { |
|
445 | + wp_register_style( |
|
446 | + $this->theme, |
|
447 | + EE_TEMPLATES_URL . $this->theme . DS . 'style.css', |
|
448 | + array('dashicons', 'espresso_default') |
|
449 | + ); |
|
450 | + } |
|
451 | + wp_enqueue_script($this->theme); |
|
452 | + if (EE_Registry::instance()->CFG->map_settings->use_google_maps) { |
|
453 | + add_action('wp_enqueue_scripts', array('EEH_Maps', 'espresso_google_map_js'), 11); |
|
454 | + } |
|
455 | + } |
|
456 | + } |
|
457 | + |
|
458 | + |
|
459 | + /** |
|
460 | + * display_venue |
|
461 | + * |
|
462 | + * @return bool |
|
463 | + */ |
|
464 | + public static function display_venue() |
|
465 | + { |
|
466 | + /** @type EE_Event_Single_Config $config */ |
|
467 | + $config = EED_Event_Single::instance()->config(); |
|
468 | + $display_venue = $config->display_venue === null ? true : $config->display_venue; |
|
469 | + $venue_name = EEH_Venue_View::venue_name(); |
|
470 | + return $display_venue && !empty($venue_name); |
|
471 | + } |
|
472 | 472 | |
473 | 473 | |
474 | 474 | } |
@@ -482,7 +482,7 @@ discard block |
||
482 | 482 | */ |
483 | 483 | function espresso_display_venue_in_event_details() |
484 | 484 | { |
485 | - return EED_Event_Single::display_venue(); |
|
485 | + return EED_Event_Single::display_venue(); |
|
486 | 486 | } |
487 | 487 | |
488 | 488 |
@@ -70,8 +70,8 @@ discard block |
||
70 | 70 | */ |
71 | 71 | public static function set_definitions() |
72 | 72 | { |
73 | - define('EVENT_SINGLE_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets' . DS); |
|
74 | - define('EVENT_SINGLE_TEMPLATES_PATH', plugin_dir_path(__FILE__) . 'templates' . DS); |
|
73 | + define('EVENT_SINGLE_ASSETS_URL', plugin_dir_url(__FILE__).'assets'.DS); |
|
74 | + define('EVENT_SINGLE_TEMPLATES_PATH', plugin_dir_path(__FILE__).'templates'.DS); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | } |
164 | 164 | // not a custom template? |
165 | 165 | if ( |
166 | - !post_password_required($post) |
|
166 | + ! post_password_required($post) |
|
167 | 167 | && ( |
168 | 168 | apply_filters('FHEE__EED_Event_Single__template_include__allow_custom_selected_template', false) |
169 | 169 | || EE_Registry::instance() |
@@ -212,8 +212,8 @@ discard block |
||
212 | 212 | public static function the_title($title = '', $id = 0) |
213 | 213 | { |
214 | 214 | global $post; |
215 | - return in_the_loop() && $post->ID === (int)$id |
|
216 | - ? espresso_event_status_banner($post->ID) . $title |
|
215 | + return in_the_loop() && $post->ID === (int) $id |
|
216 | + ? espresso_event_status_banner($post->ID).$title |
|
217 | 217 | : $title; |
218 | 218 | } |
219 | 219 | |
@@ -260,8 +260,8 @@ discard block |
||
260 | 260 | if ( |
261 | 261 | $current_post_ID !== $post->ID |
262 | 262 | && $post->post_type === 'espresso_events' |
263 | - && !EED_Event_Single::$using_get_the_excerpt |
|
264 | - && !post_password_required() |
|
263 | + && ! EED_Event_Single::$using_get_the_excerpt |
|
264 | + && ! post_password_required() |
|
265 | 265 | ) { |
266 | 266 | // Set current post ID to prevent showing content twice, but only if headers have definitely been sent. |
267 | 267 | // Reason being is that some plugins, like Yoast, need to run through a copy of the loop early |
@@ -369,7 +369,7 @@ discard block |
||
369 | 369 | */ |
370 | 370 | public static function event_datetimes($content) |
371 | 371 | { |
372 | - return EEH_Template::locate_template('content-espresso_events-datetimes.php') . $content; |
|
372 | + return EEH_Template::locate_template('content-espresso_events-datetimes.php').$content; |
|
373 | 373 | } |
374 | 374 | |
375 | 375 | |
@@ -381,7 +381,7 @@ discard block |
||
381 | 381 | */ |
382 | 382 | public static function event_tickets($content) |
383 | 383 | { |
384 | - return EEH_Template::locate_template('content-espresso_events-tickets.php') . $content; |
|
384 | + return EEH_Template::locate_template('content-espresso_events-tickets.php').$content; |
|
385 | 385 | } |
386 | 386 | |
387 | 387 | |
@@ -405,7 +405,7 @@ discard block |
||
405 | 405 | */ |
406 | 406 | public static function event_venues($content) |
407 | 407 | { |
408 | - return $content . EEH_Template::locate_template('content-espresso_events-venues.php'); |
|
408 | + return $content.EEH_Template::locate_template('content-espresso_events-venues.php'); |
|
409 | 409 | } |
410 | 410 | |
411 | 411 | |
@@ -435,16 +435,16 @@ discard block |
||
435 | 435 | && apply_filters('FHEE__EED_Event_Single__wp_enqueue_scripts__enable_css', TRUE) |
436 | 436 | ) { |
437 | 437 | // first check uploads folder |
438 | - if (is_readable(get_stylesheet_directory() . $this->theme . DS . 'style.css')) { |
|
438 | + if (is_readable(get_stylesheet_directory().$this->theme.DS.'style.css')) { |
|
439 | 439 | wp_register_style( |
440 | 440 | $this->theme, |
441 | - get_stylesheet_directory_uri() . $this->theme . DS . 'style.css', |
|
441 | + get_stylesheet_directory_uri().$this->theme.DS.'style.css', |
|
442 | 442 | array('dashicons', 'espresso_default') |
443 | 443 | ); |
444 | 444 | } else { |
445 | 445 | wp_register_style( |
446 | 446 | $this->theme, |
447 | - EE_TEMPLATES_URL . $this->theme . DS . 'style.css', |
|
447 | + EE_TEMPLATES_URL.$this->theme.DS.'style.css', |
|
448 | 448 | array('dashicons', 'espresso_default') |
449 | 449 | ); |
450 | 450 | } |
@@ -467,7 +467,7 @@ discard block |
||
467 | 467 | $config = EED_Event_Single::instance()->config(); |
468 | 468 | $display_venue = $config->display_venue === null ? true : $config->display_venue; |
469 | 469 | $venue_name = EEH_Venue_View::venue_name(); |
470 | - return $display_venue && !empty($venue_name); |
|
470 | + return $display_venue && ! empty($venue_name); |
|
471 | 471 | } |
472 | 472 | |
473 | 473 |