@@ -814,7 +814,7 @@ discard block |
||
814 | 814 | * |
815 | 815 | * @since 4.5.0 |
816 | 816 | * @param string $meta_cap What meta capability is this mapping. |
817 | - * @param array $map_values array { |
|
817 | + * @param string[] $map_values array { |
|
818 | 818 | * //array of values that MUST match a count of 4. It's okay to send an empty string |
819 | 819 | * for capabilities that don't get mapped to. |
820 | 820 | * @type $map_values [0] string A string representing the model name. Required. String's |
@@ -885,8 +885,8 @@ discard block |
||
885 | 885 | * @see EE_Meta_Capability_Map::_map_meta_caps() for docs on params. |
886 | 886 | * @since 4.6.x |
887 | 887 | * @param $caps |
888 | - * @param $cap |
|
889 | - * @param $user_id |
|
888 | + * @param string $cap |
|
889 | + * @param integer $user_id |
|
890 | 890 | * @param $args |
891 | 891 | * @return array |
892 | 892 | */ |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * @subpackage core, capabilities |
9 | 9 | */ |
10 | 10 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
11 | - exit('No direct script access allowed'); |
|
11 | + exit('No direct script access allowed'); |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | |
@@ -26,762 +26,762 @@ discard block |
||
26 | 26 | { |
27 | 27 | |
28 | 28 | |
29 | - /** |
|
30 | - * instance of EE_Capabilities object |
|
31 | - * |
|
32 | - * @var EE_Capabilities |
|
33 | - */ |
|
34 | - private static $_instance = null; |
|
35 | - |
|
36 | - |
|
37 | - /** |
|
38 | - * This is a map of caps that correspond to a default WP_Role. |
|
39 | - * Array is indexed by Role and values are ee capabilities. |
|
40 | - * |
|
41 | - * @since 4.5.0 |
|
42 | - * @var array |
|
43 | - */ |
|
44 | - private $_caps_map = array(); |
|
45 | - |
|
46 | - |
|
47 | - /** |
|
48 | - * This used to hold an array of EE_Meta_Capability_Map objects that define the granular capabilities mapped to for |
|
49 | - * a user depending on context. |
|
50 | - * |
|
51 | - * @var EE_Meta_Capability_Map[] |
|
52 | - */ |
|
53 | - private $_meta_caps = array(); |
|
54 | - |
|
55 | - /** |
|
56 | - * the name of the wp option used to store caps previously initialized |
|
57 | - */ |
|
58 | - const option_name = 'ee_caps_initialized'; |
|
59 | - |
|
60 | - |
|
61 | - /** |
|
62 | - * singleton method used to instantiate class object |
|
63 | - * |
|
64 | - * @since 4.5.0 |
|
65 | - * @return EE_Capabilities |
|
66 | - */ |
|
67 | - public static function instance() |
|
68 | - { |
|
69 | - //check if instantiated, and if not do so. |
|
70 | - if ( ! self::$_instance instanceof EE_Capabilities) { |
|
71 | - self::$_instance = new self(); |
|
72 | - } |
|
73 | - |
|
74 | - return self::$_instance; |
|
75 | - } |
|
76 | - |
|
77 | - |
|
78 | - /** |
|
79 | - * private constructor |
|
80 | - * |
|
81 | - * @since 4.5.0 |
|
82 | - * @return \EE_Capabilities |
|
83 | - */ |
|
84 | - private function __construct() |
|
85 | - { |
|
86 | - if (is_admin()) { |
|
87 | - add_filter( |
|
88 | - 'FHEE__EE_Capabilities__init_caps_map__caps', |
|
89 | - array($this, 'register_additional_capabilities'), |
|
90 | - 10 |
|
91 | - ); |
|
92 | - } |
|
93 | - } |
|
94 | - |
|
95 | - |
|
96 | - /** |
|
97 | - * This delays the initialization of the capabilities class until EE_System core is loaded and ready. |
|
98 | - * |
|
99 | - * @param bool $reset allows for resetting the default capabilities saved on roles. Note that this doesn't |
|
100 | - * actually REMOVE any capabilities from existing roles, it just resaves defaults roles and |
|
101 | - * ensures that they are up to date. |
|
102 | - * @since 4.5.0 |
|
103 | - * @return void |
|
104 | - */ |
|
105 | - public function init_caps($reset = false) |
|
106 | - { |
|
107 | - /** |
|
108 | - * Note, this means that caps can only initialized on the default roles when: |
|
109 | - * - models are queryable |
|
110 | - * - All addons have been registered (which happens at plugins_loaded priority 1) |
|
111 | - * In practice, currently this method is usually called around `init`. |
|
112 | - */ |
|
113 | - if ( |
|
114 | - did_action('AHEE__EE_System__load_espresso_addons__complete') |
|
115 | - && EE_Maintenance_Mode::instance()->models_can_query() |
|
116 | - ) { |
|
117 | - $this->_caps_map = $this->_init_caps_map(); |
|
118 | - $this->init_role_caps($reset); |
|
119 | - $this->_set_meta_caps(); |
|
120 | - } |
|
121 | - } |
|
122 | - |
|
123 | - |
|
124 | - /** |
|
125 | - * This sets the meta caps property. |
|
126 | - * |
|
127 | - * @since 4.5.0 |
|
128 | - * @return void |
|
129 | - */ |
|
130 | - private function _set_meta_caps() |
|
131 | - { |
|
132 | - //make sure we're only ever initializing the default _meta_caps array once if it's empty. |
|
133 | - $this->_meta_caps = $this->_get_default_meta_caps_array(); |
|
134 | - |
|
135 | - $this->_meta_caps = apply_filters('FHEE__EE_Capabilities___set_meta_caps__meta_caps', $this->_meta_caps); |
|
136 | - |
|
137 | - //add filter for map_meta_caps but only if models can query. |
|
138 | - if (EE_Maintenance_Mode::instance()->models_can_query() && ! has_filter('map_meta_cap', |
|
139 | - array($this, 'map_meta_caps')) |
|
140 | - ) { |
|
141 | - add_filter('map_meta_cap', array($this, 'map_meta_caps'), 10, 4); |
|
142 | - } |
|
143 | - } |
|
144 | - |
|
145 | - |
|
146 | - /** |
|
147 | - * This builds and returns the default meta_caps array only once. |
|
148 | - * |
|
149 | - * @since 4.8.28.rc.012 |
|
150 | - * @return array |
|
151 | - */ |
|
152 | - private function _get_default_meta_caps_array() |
|
153 | - { |
|
154 | - static $default_meta_caps = array(); |
|
155 | - if (empty($default_meta_caps)) { |
|
156 | - $default_meta_caps = array( |
|
157 | - //edits |
|
158 | - new EE_Meta_Capability_Map_Edit('ee_edit_event', |
|
159 | - array('Event', 'ee_edit_published_events', 'ee_edit_others_events', 'ee_edit_private_events')), |
|
160 | - new EE_Meta_Capability_Map_Edit('ee_edit_venue', |
|
161 | - array('Venue', 'ee_edit_published_venues', 'ee_edit_others_venues', 'ee_edit_private_venues')), |
|
162 | - new EE_Meta_Capability_Map_Edit('ee_edit_registration', |
|
163 | - array('Registration', '', 'ee_edit_others_registrations', '')), |
|
164 | - new EE_Meta_Capability_Map_Edit('ee_edit_checkin', |
|
165 | - array('Registration', '', 'ee_edit_others_checkins', '')), |
|
166 | - new EE_Meta_Capability_Map_Messages_Cap('ee_edit_message', |
|
167 | - array('Message_Template_Group', '', 'ee_edit_others_messages', 'ee_edit_global_messages')), |
|
168 | - new EE_Meta_Capability_Map_Edit('ee_edit_default_ticket', |
|
169 | - array('Ticket', '', 'ee_edit_others_default_tickets', '')), |
|
170 | - new EE_Meta_Capability_Map_Registration_Form_Cap('ee_edit_question', |
|
171 | - array('Question', '', '', 'ee_edit_system_questions')), |
|
172 | - new EE_Meta_Capability_Map_Registration_Form_Cap('ee_edit_question_group', |
|
173 | - array('Question_Group', '', '', 'ee_edit_system_question_groups')), |
|
174 | - new EE_Meta_Capability_Map_Edit('ee_edit_payment_method', |
|
175 | - array('Payment_Method', '', 'ee_edit_others_payment_methods', '')), |
|
176 | - //reads |
|
177 | - new EE_Meta_Capability_Map_Read('ee_read_event', |
|
178 | - array('Event', '', 'ee_read_others_events', 'ee_read_private_events')), |
|
179 | - new EE_Meta_Capability_Map_Read('ee_read_venue', |
|
180 | - array('Venue', '', 'ee_read_others_venues', 'ee_read_private_venues')), |
|
181 | - new EE_Meta_Capability_Map_Read('ee_read_registration', |
|
182 | - array('Registration', '', '', 'ee_edit_others_registrations')), |
|
183 | - new EE_Meta_Capability_Map_Read('ee_read_checkin', |
|
184 | - array('Registration', '', '', 'ee_read_others_checkins')), |
|
185 | - new EE_Meta_Capability_Map_Messages_Cap('ee_read_message', |
|
186 | - array('Message_Template_Group', '', 'ee_read_others_messages', 'ee_read_global_messages')), |
|
187 | - new EE_Meta_Capability_Map_Read('ee_read_default_ticket', |
|
188 | - array('Ticket', '', '', 'ee_read_others_default_tickets')), |
|
189 | - new EE_Meta_Capability_Map_Read('ee_read_payment_method', |
|
190 | - array('Payment_Method', '', '', 'ee_read_others_payment_methods')), |
|
191 | - |
|
192 | - //deletes |
|
193 | - new EE_Meta_Capability_Map_Delete('ee_delete_event', array( |
|
194 | - 'Event', |
|
195 | - 'ee_delete_published_events', |
|
196 | - 'ee_delete_others_events', |
|
197 | - 'ee_delete_private_events', |
|
198 | - )), |
|
199 | - new EE_Meta_Capability_Map_Delete('ee_delete_venue', array( |
|
200 | - 'Venue', |
|
201 | - 'ee_delete_published_venues', |
|
202 | - 'ee_delete_others_venues', |
|
203 | - 'ee_delete_private_venues', |
|
204 | - )), |
|
205 | - new EE_Meta_Capability_Map_Delete('ee_delete_registration', |
|
206 | - array('Registration', '', 'ee_delete_others_registrations', '')), |
|
207 | - new EE_Meta_Capability_Map_Delete('ee_delete_checkin', |
|
208 | - array('Registration', '', 'ee_delete_others_checkins', '')), |
|
209 | - new EE_Meta_Capability_Map_Messages_Cap('ee_delete_message', |
|
210 | - array('Message_Template_Group', '', 'ee_delete_others_messages', 'ee_delete_global_messages')), |
|
211 | - new EE_Meta_Capability_Map_Delete('ee_delete_default_ticket', |
|
212 | - array('Ticket', '', 'ee_delete_others_default_tickets', '')), |
|
213 | - new EE_Meta_Capability_Map_Registration_Form_Cap('ee_delete_question', |
|
214 | - array('Question', '', '', 'delete_system_questions')), |
|
215 | - new EE_Meta_Capability_Map_Registration_Form_Cap('ee_delete_question_group', |
|
216 | - array('Question_Group', '', '', 'delete_system_question_groups')), |
|
217 | - new EE_Meta_Capability_Map_Delete('ee_delete_payment_method', |
|
218 | - array('Payment_Method', '', 'ee_delete_others_payment_methods', '')), |
|
219 | - ); |
|
220 | - } |
|
221 | - |
|
222 | - return $default_meta_caps; |
|
223 | - } |
|
224 | - |
|
225 | - |
|
226 | - /** |
|
227 | - * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
228 | - * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
229 | - * The actual logic is carried out by implementer classes in their definition of _map_meta_caps. |
|
230 | - * |
|
231 | - * @since 4.5.0 |
|
232 | - * @see wp-includes/capabilities.php |
|
233 | - * @param array $caps actual users capabilities |
|
234 | - * @param string $cap initial capability name that is being checked (the "map" key) |
|
235 | - * @param int $user_id The user id |
|
236 | - * @param array $args Adds context to the cap. Typically the object ID. |
|
237 | - * @return array actual users capabilities |
|
238 | - */ |
|
239 | - public function map_meta_caps($caps, $cap, $user_id, $args) |
|
240 | - { |
|
241 | - if (did_action('AHEE__EE_System__load_espresso_addons__complete')) { |
|
242 | - //loop through our _meta_caps array |
|
243 | - foreach ($this->_meta_caps as $meta_map) { |
|
244 | - if ( ! $meta_map instanceof EE_Meta_Capability_Map) { |
|
245 | - continue; |
|
246 | - } |
|
247 | - $meta_map->ensure_is_model(); |
|
248 | - |
|
249 | - $caps = $meta_map->map_meta_caps($caps, $cap, $user_id, $args); |
|
250 | - } |
|
251 | - } |
|
252 | - |
|
253 | - return $caps; |
|
254 | - } |
|
255 | - |
|
256 | - |
|
257 | - /** |
|
258 | - * This sets up and returns the initial capabilities map for Event Espresso |
|
259 | - * |
|
260 | - * @since 4.5.0 |
|
261 | - * @return array |
|
262 | - */ |
|
263 | - private function _init_caps_map() |
|
264 | - { |
|
265 | - $caps = array( |
|
266 | - 'administrator' => array( |
|
267 | - //basic access |
|
268 | - 'ee_read_ee', |
|
269 | - //gateways |
|
270 | - /** |
|
271 | - * note that with payment method capabilities, although we've implemented |
|
272 | - * capability mapping which will be used for accessing payment methods owned by |
|
273 | - * other users. This is not fully implemented yet in the payment method ui. |
|
274 | - * Currently only the "plural" caps are in active use. (Specific payment method caps are in use as well). |
|
275 | - **/ |
|
276 | - 'ee_manage_gateways', |
|
277 | - 'ee_read_payment_method', |
|
278 | - 'ee_read_payment_methods', |
|
279 | - 'ee_read_others_payment_methods', |
|
280 | - 'ee_edit_payment_method', |
|
281 | - 'ee_edit_payment_methods', |
|
282 | - 'ee_edit_others_payment_methods', |
|
283 | - 'ee_delete_payment_method', |
|
284 | - 'ee_delete_payment_methods', |
|
285 | - //events |
|
286 | - 'ee_publish_events', |
|
287 | - 'ee_read_private_events', |
|
288 | - 'ee_read_others_events', |
|
289 | - 'ee_read_event', |
|
290 | - 'ee_read_events', |
|
291 | - 'ee_edit_event', |
|
292 | - 'ee_edit_events', |
|
293 | - 'ee_edit_published_events', |
|
294 | - 'ee_edit_others_events', |
|
295 | - 'ee_edit_private_events', |
|
296 | - 'ee_delete_published_events', |
|
297 | - 'ee_delete_private_events', |
|
298 | - 'ee_delete_event', |
|
299 | - 'ee_delete_events', |
|
300 | - 'ee_delete_others_events', |
|
301 | - //event categories |
|
302 | - 'ee_manage_event_categories', |
|
303 | - 'ee_edit_event_category', |
|
304 | - 'ee_delete_event_category', |
|
305 | - 'ee_assign_event_category', |
|
306 | - //venues |
|
307 | - 'ee_publish_venues', |
|
308 | - 'ee_read_venue', |
|
309 | - 'ee_read_venues', |
|
310 | - 'ee_read_others_venues', |
|
311 | - 'ee_read_private_venues', |
|
312 | - 'ee_edit_venue', |
|
313 | - 'ee_edit_venues', |
|
314 | - 'ee_edit_others_venues', |
|
315 | - 'ee_edit_published_venues', |
|
316 | - 'ee_edit_private_venues', |
|
317 | - 'ee_delete_venue', |
|
318 | - 'ee_delete_venues', |
|
319 | - 'ee_delete_others_venues', |
|
320 | - 'ee_delete_private_venues', |
|
321 | - 'ee_delete_published_venues', |
|
322 | - //venue categories |
|
323 | - 'ee_manage_venue_categories', |
|
324 | - 'ee_edit_venue_category', |
|
325 | - 'ee_delete_venue_category', |
|
326 | - 'ee_assign_venue_category', |
|
327 | - //contacts |
|
328 | - 'ee_read_contact', |
|
329 | - 'ee_read_contacts', |
|
330 | - 'ee_edit_contact', |
|
331 | - 'ee_edit_contacts', |
|
332 | - 'ee_delete_contact', |
|
333 | - 'ee_delete_contacts', |
|
334 | - //registrations |
|
335 | - 'ee_read_registration', |
|
336 | - 'ee_read_registrations', |
|
337 | - 'ee_read_others_registrations', |
|
338 | - 'ee_edit_registration', |
|
339 | - 'ee_edit_registrations', |
|
340 | - 'ee_edit_others_registrations', |
|
341 | - 'ee_delete_registration', |
|
342 | - 'ee_delete_registrations', |
|
343 | - //checkins |
|
344 | - 'ee_read_checkin', |
|
345 | - 'ee_read_others_checkins', |
|
346 | - 'ee_read_checkins', |
|
347 | - 'ee_edit_checkin', |
|
348 | - 'ee_edit_checkins', |
|
349 | - 'ee_edit_others_checkins', |
|
350 | - 'ee_delete_checkin', |
|
351 | - 'ee_delete_checkins', |
|
352 | - 'ee_delete_others_checkins', |
|
353 | - //transactions && payments |
|
354 | - 'ee_read_transaction', |
|
355 | - 'ee_read_transactions', |
|
356 | - 'ee_edit_payments', |
|
357 | - 'ee_delete_payments', |
|
358 | - //messages |
|
359 | - 'ee_read_message', |
|
360 | - 'ee_read_messages', |
|
361 | - 'ee_read_others_messages', |
|
362 | - 'ee_read_global_messages', |
|
363 | - 'ee_edit_global_messages', |
|
364 | - 'ee_edit_message', |
|
365 | - 'ee_edit_messages', |
|
366 | - 'ee_edit_others_messages', |
|
367 | - 'ee_delete_message', |
|
368 | - 'ee_delete_messages', |
|
369 | - 'ee_delete_others_messages', |
|
370 | - 'ee_delete_global_messages', |
|
371 | - 'ee_send_message', |
|
372 | - //tickets |
|
373 | - 'ee_read_default_ticket', |
|
374 | - 'ee_read_default_tickets', |
|
375 | - 'ee_read_others_default_tickets', |
|
376 | - 'ee_edit_default_ticket', |
|
377 | - 'ee_edit_default_tickets', |
|
378 | - 'ee_edit_others_default_tickets', |
|
379 | - 'ee_delete_default_ticket', |
|
380 | - 'ee_delete_default_tickets', |
|
381 | - 'ee_delete_others_default_tickets', |
|
382 | - //prices |
|
383 | - 'ee_edit_default_price', |
|
384 | - 'ee_edit_default_prices', |
|
385 | - 'ee_delete_default_price', |
|
386 | - 'ee_delete_default_prices', |
|
387 | - 'ee_edit_default_price_type', |
|
388 | - 'ee_edit_default_price_types', |
|
389 | - 'ee_delete_default_price_type', |
|
390 | - 'ee_delete_default_price_types', |
|
391 | - 'ee_read_default_prices', |
|
392 | - 'ee_read_default_price_types', |
|
393 | - //registration form |
|
394 | - 'ee_edit_question', |
|
395 | - 'ee_edit_questions', |
|
396 | - 'ee_edit_system_questions', |
|
397 | - 'ee_read_questions', |
|
398 | - 'ee_delete_question', |
|
399 | - 'ee_delete_questions', |
|
400 | - 'ee_edit_question_group', |
|
401 | - 'ee_edit_question_groups', |
|
402 | - 'ee_read_question_groups', |
|
403 | - 'ee_edit_system_question_groups', |
|
404 | - 'ee_delete_question_group', |
|
405 | - 'ee_delete_question_groups', |
|
406 | - //event_type taxonomy |
|
407 | - 'ee_assign_event_type', |
|
408 | - 'ee_manage_event_types', |
|
409 | - 'ee_edit_event_type', |
|
410 | - 'ee_delete_event_type', |
|
411 | - ), |
|
412 | - 'ee_events_administrator' => array( |
|
413 | - //core wp caps |
|
414 | - 'read', |
|
415 | - 'read_private_pages', |
|
416 | - 'read_private_posts', |
|
417 | - 'edit_users', |
|
418 | - 'edit_posts', |
|
419 | - 'edit_pages', |
|
420 | - 'edit_published_posts', |
|
421 | - 'edit_published_pages', |
|
422 | - 'edit_private_pages', |
|
423 | - 'edit_private_posts', |
|
424 | - 'edit_others_posts', |
|
425 | - 'edit_others_pages', |
|
426 | - 'publish_posts', |
|
427 | - 'publish_pages', |
|
428 | - 'delete_posts', |
|
429 | - 'delete_pages', |
|
430 | - 'delete_private_pages', |
|
431 | - 'delete_private_posts', |
|
432 | - 'delete_published_pages', |
|
433 | - 'delete_published_posts', |
|
434 | - 'delete_others_posts', |
|
435 | - 'delete_others_pages', |
|
436 | - 'manage_categories', |
|
437 | - 'manage_links', |
|
438 | - 'moderate_comments', |
|
439 | - 'unfiltered_html', |
|
440 | - 'upload_files', |
|
441 | - 'export', |
|
442 | - 'import', |
|
443 | - 'list_users', |
|
444 | - 'level_1', //required if user with this role shows up in author dropdowns |
|
445 | - //basic ee access |
|
446 | - 'ee_read_ee', |
|
447 | - //events |
|
448 | - 'ee_publish_events', |
|
449 | - 'ee_read_private_events', |
|
450 | - 'ee_read_others_events', |
|
451 | - 'ee_read_event', |
|
452 | - 'ee_read_events', |
|
453 | - 'ee_edit_event', |
|
454 | - 'ee_edit_events', |
|
455 | - 'ee_edit_published_events', |
|
456 | - 'ee_edit_others_events', |
|
457 | - 'ee_edit_private_events', |
|
458 | - 'ee_delete_published_events', |
|
459 | - 'ee_delete_private_events', |
|
460 | - 'ee_delete_event', |
|
461 | - 'ee_delete_events', |
|
462 | - 'ee_delete_others_events', |
|
463 | - //event categories |
|
464 | - 'ee_manage_event_categories', |
|
465 | - 'ee_edit_event_category', |
|
466 | - 'ee_delete_event_category', |
|
467 | - 'ee_assign_event_category', |
|
468 | - //venues |
|
469 | - 'ee_publish_venues', |
|
470 | - 'ee_read_venue', |
|
471 | - 'ee_read_venues', |
|
472 | - 'ee_read_others_venues', |
|
473 | - 'ee_read_private_venues', |
|
474 | - 'ee_edit_venue', |
|
475 | - 'ee_edit_venues', |
|
476 | - 'ee_edit_others_venues', |
|
477 | - 'ee_edit_published_venues', |
|
478 | - 'ee_edit_private_venues', |
|
479 | - 'ee_delete_venue', |
|
480 | - 'ee_delete_venues', |
|
481 | - 'ee_delete_others_venues', |
|
482 | - 'ee_delete_private_venues', |
|
483 | - 'ee_delete_published_venues', |
|
484 | - //venue categories |
|
485 | - 'ee_manage_venue_categories', |
|
486 | - 'ee_edit_venue_category', |
|
487 | - 'ee_delete_venue_category', |
|
488 | - 'ee_assign_venue_category', |
|
489 | - //contacts |
|
490 | - 'ee_read_contact', |
|
491 | - 'ee_read_contacts', |
|
492 | - 'ee_edit_contact', |
|
493 | - 'ee_edit_contacts', |
|
494 | - 'ee_delete_contact', |
|
495 | - 'ee_delete_contacts', |
|
496 | - //registrations |
|
497 | - 'ee_read_registration', |
|
498 | - 'ee_read_registrations', |
|
499 | - 'ee_read_others_registrations', |
|
500 | - 'ee_edit_registration', |
|
501 | - 'ee_edit_registrations', |
|
502 | - 'ee_edit_others_registrations', |
|
503 | - 'ee_delete_registration', |
|
504 | - 'ee_delete_registrations', |
|
505 | - //checkins |
|
506 | - 'ee_read_checkin', |
|
507 | - 'ee_read_others_checkins', |
|
508 | - 'ee_read_checkins', |
|
509 | - 'ee_edit_checkin', |
|
510 | - 'ee_edit_checkins', |
|
511 | - 'ee_edit_others_checkins', |
|
512 | - 'ee_delete_checkin', |
|
513 | - 'ee_delete_checkins', |
|
514 | - 'ee_delete_others_checkins', |
|
515 | - //transactions && payments |
|
516 | - 'ee_read_transaction', |
|
517 | - 'ee_read_transactions', |
|
518 | - 'ee_edit_payments', |
|
519 | - 'ee_delete_payments', |
|
520 | - //messages |
|
521 | - 'ee_read_message', |
|
522 | - 'ee_read_messages', |
|
523 | - 'ee_read_others_messages', |
|
524 | - 'ee_read_global_messages', |
|
525 | - 'ee_edit_global_messages', |
|
526 | - 'ee_edit_message', |
|
527 | - 'ee_edit_messages', |
|
528 | - 'ee_edit_others_messages', |
|
529 | - 'ee_delete_message', |
|
530 | - 'ee_delete_messages', |
|
531 | - 'ee_delete_others_messages', |
|
532 | - 'ee_delete_global_messages', |
|
533 | - 'ee_send_message', |
|
534 | - //tickets |
|
535 | - 'ee_read_default_ticket', |
|
536 | - 'ee_read_default_tickets', |
|
537 | - 'ee_read_others_default_tickets', |
|
538 | - 'ee_edit_default_ticket', |
|
539 | - 'ee_edit_default_tickets', |
|
540 | - 'ee_edit_others_default_tickets', |
|
541 | - 'ee_delete_default_ticket', |
|
542 | - 'ee_delete_default_tickets', |
|
543 | - 'ee_delete_others_default_tickets', |
|
544 | - //prices |
|
545 | - 'ee_edit_default_price', |
|
546 | - 'ee_edit_default_prices', |
|
547 | - 'ee_delete_default_price', |
|
548 | - 'ee_delete_default_prices', |
|
549 | - 'ee_edit_default_price_type', |
|
550 | - 'ee_edit_default_price_types', |
|
551 | - 'ee_delete_default_price_type', |
|
552 | - 'ee_delete_default_price_types', |
|
553 | - 'ee_read_default_prices', |
|
554 | - 'ee_read_default_price_types', |
|
555 | - //registration form |
|
556 | - 'ee_edit_question', |
|
557 | - 'ee_edit_questions', |
|
558 | - 'ee_edit_system_questions', |
|
559 | - 'ee_read_questions', |
|
560 | - 'ee_delete_question', |
|
561 | - 'ee_delete_questions', |
|
562 | - 'ee_edit_question_group', |
|
563 | - 'ee_edit_question_groups', |
|
564 | - 'ee_read_question_groups', |
|
565 | - 'ee_edit_system_question_groups', |
|
566 | - 'ee_delete_question_group', |
|
567 | - 'ee_delete_question_groups', |
|
568 | - //event_type taxonomy |
|
569 | - 'ee_assign_event_type', |
|
570 | - 'ee_manage_event_types', |
|
571 | - 'ee_edit_event_type', |
|
572 | - 'ee_delete_event_type', |
|
573 | - ), |
|
574 | - ); |
|
575 | - |
|
576 | - $caps = apply_filters('FHEE__EE_Capabilities__init_caps_map__caps', $caps); |
|
577 | - |
|
578 | - return $caps; |
|
579 | - } |
|
580 | - |
|
581 | - |
|
582 | - /** |
|
583 | - * Callback for FHEE__EE_Capabilities__init_caps_map__caps that is used for registering additional core |
|
584 | - * capabilities that get added. |
|
585 | - * This is typically done for more dynamic cap additions such as what is registered via the |
|
586 | - * `EE_Payment_Method_Manager` |
|
587 | - * |
|
588 | - * @param array $caps The existing $role=>$capability array. |
|
589 | - * @return array. |
|
590 | - */ |
|
591 | - public function register_additional_capabilities($caps) |
|
592 | - { |
|
593 | - //take care of dynamic capabilities for payment methods |
|
594 | - EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
595 | - $caps = EE_Payment_Method_Manager::instance()->add_payment_method_caps($caps); |
|
596 | - return $caps; |
|
597 | - } |
|
598 | - |
|
599 | - |
|
600 | - /** |
|
601 | - * This adds all the default caps to roles as registered in the _caps_map property. |
|
602 | - * |
|
603 | - * @since 4.5.0 |
|
604 | - * @param bool $reset allows for resetting the default capabilities saved on roles. Note that this doesn't |
|
605 | - * actually REMOVE any capabilities from existing roles, it just resaves defaults roles |
|
606 | - * and ensures that they are up to date. |
|
607 | - * @param array $custom_map Optional. Can be used to send a custom map of roles and capabilities for setting them |
|
608 | - * up. Note that this should ONLY be called on activation hook or some other one-time |
|
609 | - * task otherwise the caps will be added on every request. |
|
610 | - * @return void |
|
611 | - */ |
|
612 | - public function init_role_caps($reset = false, $custom_map = array()) |
|
613 | - { |
|
614 | - |
|
615 | - $caps_map = empty($custom_map) ? $this->_caps_map : $custom_map; |
|
616 | - |
|
617 | - //first let's determine if these caps have already been set. |
|
618 | - $caps_set_before = get_option(self::option_name, array()); |
|
619 | - //if not reset, see what caps are new for each role. if they're new, add them. |
|
620 | - foreach ($caps_map as $role => $caps_for_role) { |
|
621 | - foreach ($caps_for_role as $cap) { |
|
622 | - //first check we haven't already added this cap before, or it's a reset |
|
623 | - if ($reset || ! isset($caps_set_before[$role]) || ! in_array($cap, $caps_set_before[$role])) { |
|
624 | - if ($this->add_cap_to_role($role, $cap)) { |
|
625 | - $caps_set_before[$role][] = $cap; |
|
626 | - } |
|
627 | - } |
|
628 | - } |
|
629 | - } |
|
630 | - |
|
631 | - //now let's just save the cap that has been set. |
|
632 | - update_option(self::option_name, $caps_set_before); |
|
633 | - do_action('AHEE__EE_Capabilities__init_role_caps__complete', $caps_set_before); |
|
634 | - } |
|
635 | - |
|
636 | - |
|
637 | - /** |
|
638 | - * This method sets a capability on a role. Note this should only be done on activation, or if you have something |
|
639 | - * specific to prevent the cap from being added on every page load (adding caps are persistent to the db). Note. |
|
640 | - * this is a wrapper for $wp_role->add_cap() |
|
641 | - * |
|
642 | - * @see wp-includes/capabilities.php |
|
643 | - * @since 4.5.0 |
|
644 | - * @param string $role A WordPress role the capability is being added to |
|
645 | - * @param string $cap The capability being added to the role |
|
646 | - * @param bool $grant Whether to grant access to this cap on this role. |
|
647 | - * @return bool |
|
648 | - */ |
|
649 | - public function add_cap_to_role($role, $cap, $grant = true) |
|
650 | - { |
|
651 | - $role_object = get_role($role); |
|
652 | - //if the role isn't available then we create it. |
|
653 | - if ( ! $role_object instanceof WP_Role) { |
|
654 | - //if a plugin wants to create a specific role name then they should create the role before |
|
655 | - //EE_Capabilities does. Otherwise this function will create the role name from the slug: |
|
656 | - // - removes any `ee_` namespacing from the start of the slug. |
|
657 | - // - replaces `_` with ` ` (empty space). |
|
658 | - // - sentence case on the resulting string. |
|
659 | - $role_label = ucwords(str_replace('_', ' ', str_replace('ee_', '', $role))); |
|
660 | - $role_object = add_role($role, $role_label); |
|
661 | - } |
|
662 | - if ($role_object instanceof WP_Role) { |
|
663 | - $role_object->add_cap($cap, $grant); |
|
664 | - |
|
665 | - return true; |
|
666 | - } |
|
667 | - |
|
668 | - return false; |
|
669 | - } |
|
670 | - |
|
671 | - |
|
672 | - /** |
|
673 | - * Functions similarly to add_cap_to_role except removes cap from given role. |
|
674 | - * Wrapper for $wp_role->remove_cap() |
|
675 | - * |
|
676 | - * @see wp-includes/capabilities.php |
|
677 | - * @since 4.5.0 |
|
678 | - * @param string $role A WordPress role the capability is being removed from. |
|
679 | - * @param string $cap The capability being removed |
|
680 | - * @return void |
|
681 | - */ |
|
682 | - public function remove_cap_from_role($role, $cap) |
|
683 | - { |
|
684 | - $role = get_role($role); |
|
685 | - if ($role instanceof WP_Role) { |
|
686 | - $role->remove_cap($cap); |
|
687 | - } |
|
688 | - } |
|
689 | - |
|
690 | - |
|
691 | - /** |
|
692 | - * Wrapper for the native WP current_user_can() method. |
|
693 | - * This is provided as a handy method for a couple things: |
|
694 | - * 1. Using the context string it allows for targeted filtering by addons for a specific check (without having to |
|
695 | - * write those filters wherever current_user_can is called). |
|
696 | - * 2. Explicit passing of $id from a given context ( useful in the cases of map_meta_cap filters ) |
|
697 | - * |
|
698 | - * @since 4.5.0 |
|
699 | - * @param string $cap The cap being checked. |
|
700 | - * @param string $context The context where the current_user_can is being called from. |
|
701 | - * @param int $id Optional. Id for item where current_user_can is being called from (used in map_meta_cap() |
|
702 | - * filters. |
|
703 | - * @return bool Whether user can or not. |
|
704 | - */ |
|
705 | - public function current_user_can($cap, $context, $id = 0) |
|
706 | - { |
|
707 | - //apply filters (both a global on just the cap, and context specific. Global overrides context specific) |
|
708 | - $filtered_cap = apply_filters('FHEE__EE_Capabilities__current_user_can__cap__' . $context, $cap, $id); |
|
709 | - $filtered_cap = apply_filters('FHEE__EE_Capabilities__current_user_can__cap', $filtered_cap, $context, $cap, |
|
710 | - $id); |
|
711 | - |
|
712 | - return ! empty($id) ? current_user_can($filtered_cap, $id) : current_user_can($filtered_cap); |
|
713 | - } |
|
714 | - |
|
715 | - |
|
716 | - /** |
|
717 | - * This is a wrapper for the WP user_can() function and follows the same style as the other wrappers in this class. |
|
718 | - * |
|
719 | - * @param int|WP_User $user Either the user_id or a WP_User object |
|
720 | - * @param string $cap The capability string being checked |
|
721 | - * @param string $context The context where the user_can is being called from (used in filters). |
|
722 | - * @param int $id Optional. Id for item where user_can is being called from ( used in map_meta_cap() |
|
723 | - * filters) |
|
724 | - * @return bool Whether user can or not. |
|
725 | - */ |
|
726 | - public function user_can($user, $cap, $context, $id = 0) |
|
727 | - { |
|
728 | - //apply filters (both a global on just the cap, and context specific. Global overrides context specific) |
|
729 | - $filtered_cap = apply_filters('FHEE__EE_Capabilities__user_can__cap__' . $context, $cap, $user, $id); |
|
730 | - $filtered_cap = apply_filters('FHEE__EE_Capabilities__user_can__cap', $filtered_cap, $context, $cap, $user, |
|
731 | - $id); |
|
732 | - |
|
733 | - return ! empty($id) ? user_can($user, $filtered_cap, $id) : user_can($user, $filtered_cap); |
|
734 | - } |
|
735 | - |
|
736 | - |
|
737 | - /** |
|
738 | - * Wrapper for the native WP current_user_can_for_blog() method. |
|
739 | - * This is provided as a handy method for a couple things: |
|
740 | - * 1. Using the context string it allows for targeted filtering by addons for a specific check (without having to |
|
741 | - * write those filters wherever current_user_can is called). |
|
742 | - * 2. Explicit passing of $id from a given context ( useful in the cases of map_meta_cap filters ) |
|
743 | - * |
|
744 | - * @since 4.5.0 |
|
745 | - * @param int $blog_id The blog id that is being checked for. |
|
746 | - * @param string $cap The cap being checked. |
|
747 | - * @param string $context The context where the current_user_can is being called from. |
|
748 | - * @param int $id Optional. Id for item where current_user_can is being called from (used in map_meta_cap() |
|
749 | - * filters. |
|
750 | - * @return bool Whether user can or not. |
|
751 | - */ |
|
752 | - public function current_user_can_for_blog($blog_id, $cap, $context, $id = 0) |
|
753 | - { |
|
754 | - $user_can = ! empty($id) ? current_user_can_for_blog($blog_id, $cap, $id) : current_user_can($blog_id, $cap); |
|
755 | - |
|
756 | - //apply filters (both a global on just the cap, and context specific. Global overrides context specific) |
|
757 | - $user_can = apply_filters('FHEE__EE_Capabilities__current_user_can_for_blog__user_can__' . $context, $user_can, |
|
758 | - $blog_id, $cap, $id); |
|
759 | - $user_can = apply_filters('FHEE__EE_Capabilities__current_user_can_for_blog__user_can', $user_can, $context, |
|
760 | - $blog_id, $cap, $id); |
|
761 | - |
|
762 | - return $user_can; |
|
763 | - } |
|
764 | - |
|
765 | - |
|
766 | - /** |
|
767 | - * This helper method just returns an array of registered EE capabilities. |
|
768 | - * Note this array is filtered. It is assumed that all available EE capabilities are assigned to the administrator |
|
769 | - * role. |
|
770 | - * |
|
771 | - * @since 4.5.0 |
|
772 | - * @param string $role If empty then the entire role/capability map is returned. Otherwise just the capabilities |
|
773 | - * for the given role are returned. |
|
774 | - * @return array |
|
775 | - */ |
|
776 | - public function get_ee_capabilities($role = 'administrator') |
|
777 | - { |
|
778 | - $capabilities = $this->_init_caps_map(); |
|
779 | - if (empty($role)) { |
|
780 | - return $capabilities; |
|
781 | - } |
|
782 | - |
|
783 | - return isset($capabilities[$role]) ? $capabilities[$role] : array(); |
|
784 | - } |
|
29 | + /** |
|
30 | + * instance of EE_Capabilities object |
|
31 | + * |
|
32 | + * @var EE_Capabilities |
|
33 | + */ |
|
34 | + private static $_instance = null; |
|
35 | + |
|
36 | + |
|
37 | + /** |
|
38 | + * This is a map of caps that correspond to a default WP_Role. |
|
39 | + * Array is indexed by Role and values are ee capabilities. |
|
40 | + * |
|
41 | + * @since 4.5.0 |
|
42 | + * @var array |
|
43 | + */ |
|
44 | + private $_caps_map = array(); |
|
45 | + |
|
46 | + |
|
47 | + /** |
|
48 | + * This used to hold an array of EE_Meta_Capability_Map objects that define the granular capabilities mapped to for |
|
49 | + * a user depending on context. |
|
50 | + * |
|
51 | + * @var EE_Meta_Capability_Map[] |
|
52 | + */ |
|
53 | + private $_meta_caps = array(); |
|
54 | + |
|
55 | + /** |
|
56 | + * the name of the wp option used to store caps previously initialized |
|
57 | + */ |
|
58 | + const option_name = 'ee_caps_initialized'; |
|
59 | + |
|
60 | + |
|
61 | + /** |
|
62 | + * singleton method used to instantiate class object |
|
63 | + * |
|
64 | + * @since 4.5.0 |
|
65 | + * @return EE_Capabilities |
|
66 | + */ |
|
67 | + public static function instance() |
|
68 | + { |
|
69 | + //check if instantiated, and if not do so. |
|
70 | + if ( ! self::$_instance instanceof EE_Capabilities) { |
|
71 | + self::$_instance = new self(); |
|
72 | + } |
|
73 | + |
|
74 | + return self::$_instance; |
|
75 | + } |
|
76 | + |
|
77 | + |
|
78 | + /** |
|
79 | + * private constructor |
|
80 | + * |
|
81 | + * @since 4.5.0 |
|
82 | + * @return \EE_Capabilities |
|
83 | + */ |
|
84 | + private function __construct() |
|
85 | + { |
|
86 | + if (is_admin()) { |
|
87 | + add_filter( |
|
88 | + 'FHEE__EE_Capabilities__init_caps_map__caps', |
|
89 | + array($this, 'register_additional_capabilities'), |
|
90 | + 10 |
|
91 | + ); |
|
92 | + } |
|
93 | + } |
|
94 | + |
|
95 | + |
|
96 | + /** |
|
97 | + * This delays the initialization of the capabilities class until EE_System core is loaded and ready. |
|
98 | + * |
|
99 | + * @param bool $reset allows for resetting the default capabilities saved on roles. Note that this doesn't |
|
100 | + * actually REMOVE any capabilities from existing roles, it just resaves defaults roles and |
|
101 | + * ensures that they are up to date. |
|
102 | + * @since 4.5.0 |
|
103 | + * @return void |
|
104 | + */ |
|
105 | + public function init_caps($reset = false) |
|
106 | + { |
|
107 | + /** |
|
108 | + * Note, this means that caps can only initialized on the default roles when: |
|
109 | + * - models are queryable |
|
110 | + * - All addons have been registered (which happens at plugins_loaded priority 1) |
|
111 | + * In practice, currently this method is usually called around `init`. |
|
112 | + */ |
|
113 | + if ( |
|
114 | + did_action('AHEE__EE_System__load_espresso_addons__complete') |
|
115 | + && EE_Maintenance_Mode::instance()->models_can_query() |
|
116 | + ) { |
|
117 | + $this->_caps_map = $this->_init_caps_map(); |
|
118 | + $this->init_role_caps($reset); |
|
119 | + $this->_set_meta_caps(); |
|
120 | + } |
|
121 | + } |
|
122 | + |
|
123 | + |
|
124 | + /** |
|
125 | + * This sets the meta caps property. |
|
126 | + * |
|
127 | + * @since 4.5.0 |
|
128 | + * @return void |
|
129 | + */ |
|
130 | + private function _set_meta_caps() |
|
131 | + { |
|
132 | + //make sure we're only ever initializing the default _meta_caps array once if it's empty. |
|
133 | + $this->_meta_caps = $this->_get_default_meta_caps_array(); |
|
134 | + |
|
135 | + $this->_meta_caps = apply_filters('FHEE__EE_Capabilities___set_meta_caps__meta_caps', $this->_meta_caps); |
|
136 | + |
|
137 | + //add filter for map_meta_caps but only if models can query. |
|
138 | + if (EE_Maintenance_Mode::instance()->models_can_query() && ! has_filter('map_meta_cap', |
|
139 | + array($this, 'map_meta_caps')) |
|
140 | + ) { |
|
141 | + add_filter('map_meta_cap', array($this, 'map_meta_caps'), 10, 4); |
|
142 | + } |
|
143 | + } |
|
144 | + |
|
145 | + |
|
146 | + /** |
|
147 | + * This builds and returns the default meta_caps array only once. |
|
148 | + * |
|
149 | + * @since 4.8.28.rc.012 |
|
150 | + * @return array |
|
151 | + */ |
|
152 | + private function _get_default_meta_caps_array() |
|
153 | + { |
|
154 | + static $default_meta_caps = array(); |
|
155 | + if (empty($default_meta_caps)) { |
|
156 | + $default_meta_caps = array( |
|
157 | + //edits |
|
158 | + new EE_Meta_Capability_Map_Edit('ee_edit_event', |
|
159 | + array('Event', 'ee_edit_published_events', 'ee_edit_others_events', 'ee_edit_private_events')), |
|
160 | + new EE_Meta_Capability_Map_Edit('ee_edit_venue', |
|
161 | + array('Venue', 'ee_edit_published_venues', 'ee_edit_others_venues', 'ee_edit_private_venues')), |
|
162 | + new EE_Meta_Capability_Map_Edit('ee_edit_registration', |
|
163 | + array('Registration', '', 'ee_edit_others_registrations', '')), |
|
164 | + new EE_Meta_Capability_Map_Edit('ee_edit_checkin', |
|
165 | + array('Registration', '', 'ee_edit_others_checkins', '')), |
|
166 | + new EE_Meta_Capability_Map_Messages_Cap('ee_edit_message', |
|
167 | + array('Message_Template_Group', '', 'ee_edit_others_messages', 'ee_edit_global_messages')), |
|
168 | + new EE_Meta_Capability_Map_Edit('ee_edit_default_ticket', |
|
169 | + array('Ticket', '', 'ee_edit_others_default_tickets', '')), |
|
170 | + new EE_Meta_Capability_Map_Registration_Form_Cap('ee_edit_question', |
|
171 | + array('Question', '', '', 'ee_edit_system_questions')), |
|
172 | + new EE_Meta_Capability_Map_Registration_Form_Cap('ee_edit_question_group', |
|
173 | + array('Question_Group', '', '', 'ee_edit_system_question_groups')), |
|
174 | + new EE_Meta_Capability_Map_Edit('ee_edit_payment_method', |
|
175 | + array('Payment_Method', '', 'ee_edit_others_payment_methods', '')), |
|
176 | + //reads |
|
177 | + new EE_Meta_Capability_Map_Read('ee_read_event', |
|
178 | + array('Event', '', 'ee_read_others_events', 'ee_read_private_events')), |
|
179 | + new EE_Meta_Capability_Map_Read('ee_read_venue', |
|
180 | + array('Venue', '', 'ee_read_others_venues', 'ee_read_private_venues')), |
|
181 | + new EE_Meta_Capability_Map_Read('ee_read_registration', |
|
182 | + array('Registration', '', '', 'ee_edit_others_registrations')), |
|
183 | + new EE_Meta_Capability_Map_Read('ee_read_checkin', |
|
184 | + array('Registration', '', '', 'ee_read_others_checkins')), |
|
185 | + new EE_Meta_Capability_Map_Messages_Cap('ee_read_message', |
|
186 | + array('Message_Template_Group', '', 'ee_read_others_messages', 'ee_read_global_messages')), |
|
187 | + new EE_Meta_Capability_Map_Read('ee_read_default_ticket', |
|
188 | + array('Ticket', '', '', 'ee_read_others_default_tickets')), |
|
189 | + new EE_Meta_Capability_Map_Read('ee_read_payment_method', |
|
190 | + array('Payment_Method', '', '', 'ee_read_others_payment_methods')), |
|
191 | + |
|
192 | + //deletes |
|
193 | + new EE_Meta_Capability_Map_Delete('ee_delete_event', array( |
|
194 | + 'Event', |
|
195 | + 'ee_delete_published_events', |
|
196 | + 'ee_delete_others_events', |
|
197 | + 'ee_delete_private_events', |
|
198 | + )), |
|
199 | + new EE_Meta_Capability_Map_Delete('ee_delete_venue', array( |
|
200 | + 'Venue', |
|
201 | + 'ee_delete_published_venues', |
|
202 | + 'ee_delete_others_venues', |
|
203 | + 'ee_delete_private_venues', |
|
204 | + )), |
|
205 | + new EE_Meta_Capability_Map_Delete('ee_delete_registration', |
|
206 | + array('Registration', '', 'ee_delete_others_registrations', '')), |
|
207 | + new EE_Meta_Capability_Map_Delete('ee_delete_checkin', |
|
208 | + array('Registration', '', 'ee_delete_others_checkins', '')), |
|
209 | + new EE_Meta_Capability_Map_Messages_Cap('ee_delete_message', |
|
210 | + array('Message_Template_Group', '', 'ee_delete_others_messages', 'ee_delete_global_messages')), |
|
211 | + new EE_Meta_Capability_Map_Delete('ee_delete_default_ticket', |
|
212 | + array('Ticket', '', 'ee_delete_others_default_tickets', '')), |
|
213 | + new EE_Meta_Capability_Map_Registration_Form_Cap('ee_delete_question', |
|
214 | + array('Question', '', '', 'delete_system_questions')), |
|
215 | + new EE_Meta_Capability_Map_Registration_Form_Cap('ee_delete_question_group', |
|
216 | + array('Question_Group', '', '', 'delete_system_question_groups')), |
|
217 | + new EE_Meta_Capability_Map_Delete('ee_delete_payment_method', |
|
218 | + array('Payment_Method', '', 'ee_delete_others_payment_methods', '')), |
|
219 | + ); |
|
220 | + } |
|
221 | + |
|
222 | + return $default_meta_caps; |
|
223 | + } |
|
224 | + |
|
225 | + |
|
226 | + /** |
|
227 | + * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
228 | + * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
229 | + * The actual logic is carried out by implementer classes in their definition of _map_meta_caps. |
|
230 | + * |
|
231 | + * @since 4.5.0 |
|
232 | + * @see wp-includes/capabilities.php |
|
233 | + * @param array $caps actual users capabilities |
|
234 | + * @param string $cap initial capability name that is being checked (the "map" key) |
|
235 | + * @param int $user_id The user id |
|
236 | + * @param array $args Adds context to the cap. Typically the object ID. |
|
237 | + * @return array actual users capabilities |
|
238 | + */ |
|
239 | + public function map_meta_caps($caps, $cap, $user_id, $args) |
|
240 | + { |
|
241 | + if (did_action('AHEE__EE_System__load_espresso_addons__complete')) { |
|
242 | + //loop through our _meta_caps array |
|
243 | + foreach ($this->_meta_caps as $meta_map) { |
|
244 | + if ( ! $meta_map instanceof EE_Meta_Capability_Map) { |
|
245 | + continue; |
|
246 | + } |
|
247 | + $meta_map->ensure_is_model(); |
|
248 | + |
|
249 | + $caps = $meta_map->map_meta_caps($caps, $cap, $user_id, $args); |
|
250 | + } |
|
251 | + } |
|
252 | + |
|
253 | + return $caps; |
|
254 | + } |
|
255 | + |
|
256 | + |
|
257 | + /** |
|
258 | + * This sets up and returns the initial capabilities map for Event Espresso |
|
259 | + * |
|
260 | + * @since 4.5.0 |
|
261 | + * @return array |
|
262 | + */ |
|
263 | + private function _init_caps_map() |
|
264 | + { |
|
265 | + $caps = array( |
|
266 | + 'administrator' => array( |
|
267 | + //basic access |
|
268 | + 'ee_read_ee', |
|
269 | + //gateways |
|
270 | + /** |
|
271 | + * note that with payment method capabilities, although we've implemented |
|
272 | + * capability mapping which will be used for accessing payment methods owned by |
|
273 | + * other users. This is not fully implemented yet in the payment method ui. |
|
274 | + * Currently only the "plural" caps are in active use. (Specific payment method caps are in use as well). |
|
275 | + **/ |
|
276 | + 'ee_manage_gateways', |
|
277 | + 'ee_read_payment_method', |
|
278 | + 'ee_read_payment_methods', |
|
279 | + 'ee_read_others_payment_methods', |
|
280 | + 'ee_edit_payment_method', |
|
281 | + 'ee_edit_payment_methods', |
|
282 | + 'ee_edit_others_payment_methods', |
|
283 | + 'ee_delete_payment_method', |
|
284 | + 'ee_delete_payment_methods', |
|
285 | + //events |
|
286 | + 'ee_publish_events', |
|
287 | + 'ee_read_private_events', |
|
288 | + 'ee_read_others_events', |
|
289 | + 'ee_read_event', |
|
290 | + 'ee_read_events', |
|
291 | + 'ee_edit_event', |
|
292 | + 'ee_edit_events', |
|
293 | + 'ee_edit_published_events', |
|
294 | + 'ee_edit_others_events', |
|
295 | + 'ee_edit_private_events', |
|
296 | + 'ee_delete_published_events', |
|
297 | + 'ee_delete_private_events', |
|
298 | + 'ee_delete_event', |
|
299 | + 'ee_delete_events', |
|
300 | + 'ee_delete_others_events', |
|
301 | + //event categories |
|
302 | + 'ee_manage_event_categories', |
|
303 | + 'ee_edit_event_category', |
|
304 | + 'ee_delete_event_category', |
|
305 | + 'ee_assign_event_category', |
|
306 | + //venues |
|
307 | + 'ee_publish_venues', |
|
308 | + 'ee_read_venue', |
|
309 | + 'ee_read_venues', |
|
310 | + 'ee_read_others_venues', |
|
311 | + 'ee_read_private_venues', |
|
312 | + 'ee_edit_venue', |
|
313 | + 'ee_edit_venues', |
|
314 | + 'ee_edit_others_venues', |
|
315 | + 'ee_edit_published_venues', |
|
316 | + 'ee_edit_private_venues', |
|
317 | + 'ee_delete_venue', |
|
318 | + 'ee_delete_venues', |
|
319 | + 'ee_delete_others_venues', |
|
320 | + 'ee_delete_private_venues', |
|
321 | + 'ee_delete_published_venues', |
|
322 | + //venue categories |
|
323 | + 'ee_manage_venue_categories', |
|
324 | + 'ee_edit_venue_category', |
|
325 | + 'ee_delete_venue_category', |
|
326 | + 'ee_assign_venue_category', |
|
327 | + //contacts |
|
328 | + 'ee_read_contact', |
|
329 | + 'ee_read_contacts', |
|
330 | + 'ee_edit_contact', |
|
331 | + 'ee_edit_contacts', |
|
332 | + 'ee_delete_contact', |
|
333 | + 'ee_delete_contacts', |
|
334 | + //registrations |
|
335 | + 'ee_read_registration', |
|
336 | + 'ee_read_registrations', |
|
337 | + 'ee_read_others_registrations', |
|
338 | + 'ee_edit_registration', |
|
339 | + 'ee_edit_registrations', |
|
340 | + 'ee_edit_others_registrations', |
|
341 | + 'ee_delete_registration', |
|
342 | + 'ee_delete_registrations', |
|
343 | + //checkins |
|
344 | + 'ee_read_checkin', |
|
345 | + 'ee_read_others_checkins', |
|
346 | + 'ee_read_checkins', |
|
347 | + 'ee_edit_checkin', |
|
348 | + 'ee_edit_checkins', |
|
349 | + 'ee_edit_others_checkins', |
|
350 | + 'ee_delete_checkin', |
|
351 | + 'ee_delete_checkins', |
|
352 | + 'ee_delete_others_checkins', |
|
353 | + //transactions && payments |
|
354 | + 'ee_read_transaction', |
|
355 | + 'ee_read_transactions', |
|
356 | + 'ee_edit_payments', |
|
357 | + 'ee_delete_payments', |
|
358 | + //messages |
|
359 | + 'ee_read_message', |
|
360 | + 'ee_read_messages', |
|
361 | + 'ee_read_others_messages', |
|
362 | + 'ee_read_global_messages', |
|
363 | + 'ee_edit_global_messages', |
|
364 | + 'ee_edit_message', |
|
365 | + 'ee_edit_messages', |
|
366 | + 'ee_edit_others_messages', |
|
367 | + 'ee_delete_message', |
|
368 | + 'ee_delete_messages', |
|
369 | + 'ee_delete_others_messages', |
|
370 | + 'ee_delete_global_messages', |
|
371 | + 'ee_send_message', |
|
372 | + //tickets |
|
373 | + 'ee_read_default_ticket', |
|
374 | + 'ee_read_default_tickets', |
|
375 | + 'ee_read_others_default_tickets', |
|
376 | + 'ee_edit_default_ticket', |
|
377 | + 'ee_edit_default_tickets', |
|
378 | + 'ee_edit_others_default_tickets', |
|
379 | + 'ee_delete_default_ticket', |
|
380 | + 'ee_delete_default_tickets', |
|
381 | + 'ee_delete_others_default_tickets', |
|
382 | + //prices |
|
383 | + 'ee_edit_default_price', |
|
384 | + 'ee_edit_default_prices', |
|
385 | + 'ee_delete_default_price', |
|
386 | + 'ee_delete_default_prices', |
|
387 | + 'ee_edit_default_price_type', |
|
388 | + 'ee_edit_default_price_types', |
|
389 | + 'ee_delete_default_price_type', |
|
390 | + 'ee_delete_default_price_types', |
|
391 | + 'ee_read_default_prices', |
|
392 | + 'ee_read_default_price_types', |
|
393 | + //registration form |
|
394 | + 'ee_edit_question', |
|
395 | + 'ee_edit_questions', |
|
396 | + 'ee_edit_system_questions', |
|
397 | + 'ee_read_questions', |
|
398 | + 'ee_delete_question', |
|
399 | + 'ee_delete_questions', |
|
400 | + 'ee_edit_question_group', |
|
401 | + 'ee_edit_question_groups', |
|
402 | + 'ee_read_question_groups', |
|
403 | + 'ee_edit_system_question_groups', |
|
404 | + 'ee_delete_question_group', |
|
405 | + 'ee_delete_question_groups', |
|
406 | + //event_type taxonomy |
|
407 | + 'ee_assign_event_type', |
|
408 | + 'ee_manage_event_types', |
|
409 | + 'ee_edit_event_type', |
|
410 | + 'ee_delete_event_type', |
|
411 | + ), |
|
412 | + 'ee_events_administrator' => array( |
|
413 | + //core wp caps |
|
414 | + 'read', |
|
415 | + 'read_private_pages', |
|
416 | + 'read_private_posts', |
|
417 | + 'edit_users', |
|
418 | + 'edit_posts', |
|
419 | + 'edit_pages', |
|
420 | + 'edit_published_posts', |
|
421 | + 'edit_published_pages', |
|
422 | + 'edit_private_pages', |
|
423 | + 'edit_private_posts', |
|
424 | + 'edit_others_posts', |
|
425 | + 'edit_others_pages', |
|
426 | + 'publish_posts', |
|
427 | + 'publish_pages', |
|
428 | + 'delete_posts', |
|
429 | + 'delete_pages', |
|
430 | + 'delete_private_pages', |
|
431 | + 'delete_private_posts', |
|
432 | + 'delete_published_pages', |
|
433 | + 'delete_published_posts', |
|
434 | + 'delete_others_posts', |
|
435 | + 'delete_others_pages', |
|
436 | + 'manage_categories', |
|
437 | + 'manage_links', |
|
438 | + 'moderate_comments', |
|
439 | + 'unfiltered_html', |
|
440 | + 'upload_files', |
|
441 | + 'export', |
|
442 | + 'import', |
|
443 | + 'list_users', |
|
444 | + 'level_1', //required if user with this role shows up in author dropdowns |
|
445 | + //basic ee access |
|
446 | + 'ee_read_ee', |
|
447 | + //events |
|
448 | + 'ee_publish_events', |
|
449 | + 'ee_read_private_events', |
|
450 | + 'ee_read_others_events', |
|
451 | + 'ee_read_event', |
|
452 | + 'ee_read_events', |
|
453 | + 'ee_edit_event', |
|
454 | + 'ee_edit_events', |
|
455 | + 'ee_edit_published_events', |
|
456 | + 'ee_edit_others_events', |
|
457 | + 'ee_edit_private_events', |
|
458 | + 'ee_delete_published_events', |
|
459 | + 'ee_delete_private_events', |
|
460 | + 'ee_delete_event', |
|
461 | + 'ee_delete_events', |
|
462 | + 'ee_delete_others_events', |
|
463 | + //event categories |
|
464 | + 'ee_manage_event_categories', |
|
465 | + 'ee_edit_event_category', |
|
466 | + 'ee_delete_event_category', |
|
467 | + 'ee_assign_event_category', |
|
468 | + //venues |
|
469 | + 'ee_publish_venues', |
|
470 | + 'ee_read_venue', |
|
471 | + 'ee_read_venues', |
|
472 | + 'ee_read_others_venues', |
|
473 | + 'ee_read_private_venues', |
|
474 | + 'ee_edit_venue', |
|
475 | + 'ee_edit_venues', |
|
476 | + 'ee_edit_others_venues', |
|
477 | + 'ee_edit_published_venues', |
|
478 | + 'ee_edit_private_venues', |
|
479 | + 'ee_delete_venue', |
|
480 | + 'ee_delete_venues', |
|
481 | + 'ee_delete_others_venues', |
|
482 | + 'ee_delete_private_venues', |
|
483 | + 'ee_delete_published_venues', |
|
484 | + //venue categories |
|
485 | + 'ee_manage_venue_categories', |
|
486 | + 'ee_edit_venue_category', |
|
487 | + 'ee_delete_venue_category', |
|
488 | + 'ee_assign_venue_category', |
|
489 | + //contacts |
|
490 | + 'ee_read_contact', |
|
491 | + 'ee_read_contacts', |
|
492 | + 'ee_edit_contact', |
|
493 | + 'ee_edit_contacts', |
|
494 | + 'ee_delete_contact', |
|
495 | + 'ee_delete_contacts', |
|
496 | + //registrations |
|
497 | + 'ee_read_registration', |
|
498 | + 'ee_read_registrations', |
|
499 | + 'ee_read_others_registrations', |
|
500 | + 'ee_edit_registration', |
|
501 | + 'ee_edit_registrations', |
|
502 | + 'ee_edit_others_registrations', |
|
503 | + 'ee_delete_registration', |
|
504 | + 'ee_delete_registrations', |
|
505 | + //checkins |
|
506 | + 'ee_read_checkin', |
|
507 | + 'ee_read_others_checkins', |
|
508 | + 'ee_read_checkins', |
|
509 | + 'ee_edit_checkin', |
|
510 | + 'ee_edit_checkins', |
|
511 | + 'ee_edit_others_checkins', |
|
512 | + 'ee_delete_checkin', |
|
513 | + 'ee_delete_checkins', |
|
514 | + 'ee_delete_others_checkins', |
|
515 | + //transactions && payments |
|
516 | + 'ee_read_transaction', |
|
517 | + 'ee_read_transactions', |
|
518 | + 'ee_edit_payments', |
|
519 | + 'ee_delete_payments', |
|
520 | + //messages |
|
521 | + 'ee_read_message', |
|
522 | + 'ee_read_messages', |
|
523 | + 'ee_read_others_messages', |
|
524 | + 'ee_read_global_messages', |
|
525 | + 'ee_edit_global_messages', |
|
526 | + 'ee_edit_message', |
|
527 | + 'ee_edit_messages', |
|
528 | + 'ee_edit_others_messages', |
|
529 | + 'ee_delete_message', |
|
530 | + 'ee_delete_messages', |
|
531 | + 'ee_delete_others_messages', |
|
532 | + 'ee_delete_global_messages', |
|
533 | + 'ee_send_message', |
|
534 | + //tickets |
|
535 | + 'ee_read_default_ticket', |
|
536 | + 'ee_read_default_tickets', |
|
537 | + 'ee_read_others_default_tickets', |
|
538 | + 'ee_edit_default_ticket', |
|
539 | + 'ee_edit_default_tickets', |
|
540 | + 'ee_edit_others_default_tickets', |
|
541 | + 'ee_delete_default_ticket', |
|
542 | + 'ee_delete_default_tickets', |
|
543 | + 'ee_delete_others_default_tickets', |
|
544 | + //prices |
|
545 | + 'ee_edit_default_price', |
|
546 | + 'ee_edit_default_prices', |
|
547 | + 'ee_delete_default_price', |
|
548 | + 'ee_delete_default_prices', |
|
549 | + 'ee_edit_default_price_type', |
|
550 | + 'ee_edit_default_price_types', |
|
551 | + 'ee_delete_default_price_type', |
|
552 | + 'ee_delete_default_price_types', |
|
553 | + 'ee_read_default_prices', |
|
554 | + 'ee_read_default_price_types', |
|
555 | + //registration form |
|
556 | + 'ee_edit_question', |
|
557 | + 'ee_edit_questions', |
|
558 | + 'ee_edit_system_questions', |
|
559 | + 'ee_read_questions', |
|
560 | + 'ee_delete_question', |
|
561 | + 'ee_delete_questions', |
|
562 | + 'ee_edit_question_group', |
|
563 | + 'ee_edit_question_groups', |
|
564 | + 'ee_read_question_groups', |
|
565 | + 'ee_edit_system_question_groups', |
|
566 | + 'ee_delete_question_group', |
|
567 | + 'ee_delete_question_groups', |
|
568 | + //event_type taxonomy |
|
569 | + 'ee_assign_event_type', |
|
570 | + 'ee_manage_event_types', |
|
571 | + 'ee_edit_event_type', |
|
572 | + 'ee_delete_event_type', |
|
573 | + ), |
|
574 | + ); |
|
575 | + |
|
576 | + $caps = apply_filters('FHEE__EE_Capabilities__init_caps_map__caps', $caps); |
|
577 | + |
|
578 | + return $caps; |
|
579 | + } |
|
580 | + |
|
581 | + |
|
582 | + /** |
|
583 | + * Callback for FHEE__EE_Capabilities__init_caps_map__caps that is used for registering additional core |
|
584 | + * capabilities that get added. |
|
585 | + * This is typically done for more dynamic cap additions such as what is registered via the |
|
586 | + * `EE_Payment_Method_Manager` |
|
587 | + * |
|
588 | + * @param array $caps The existing $role=>$capability array. |
|
589 | + * @return array. |
|
590 | + */ |
|
591 | + public function register_additional_capabilities($caps) |
|
592 | + { |
|
593 | + //take care of dynamic capabilities for payment methods |
|
594 | + EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
595 | + $caps = EE_Payment_Method_Manager::instance()->add_payment_method_caps($caps); |
|
596 | + return $caps; |
|
597 | + } |
|
598 | + |
|
599 | + |
|
600 | + /** |
|
601 | + * This adds all the default caps to roles as registered in the _caps_map property. |
|
602 | + * |
|
603 | + * @since 4.5.0 |
|
604 | + * @param bool $reset allows for resetting the default capabilities saved on roles. Note that this doesn't |
|
605 | + * actually REMOVE any capabilities from existing roles, it just resaves defaults roles |
|
606 | + * and ensures that they are up to date. |
|
607 | + * @param array $custom_map Optional. Can be used to send a custom map of roles and capabilities for setting them |
|
608 | + * up. Note that this should ONLY be called on activation hook or some other one-time |
|
609 | + * task otherwise the caps will be added on every request. |
|
610 | + * @return void |
|
611 | + */ |
|
612 | + public function init_role_caps($reset = false, $custom_map = array()) |
|
613 | + { |
|
614 | + |
|
615 | + $caps_map = empty($custom_map) ? $this->_caps_map : $custom_map; |
|
616 | + |
|
617 | + //first let's determine if these caps have already been set. |
|
618 | + $caps_set_before = get_option(self::option_name, array()); |
|
619 | + //if not reset, see what caps are new for each role. if they're new, add them. |
|
620 | + foreach ($caps_map as $role => $caps_for_role) { |
|
621 | + foreach ($caps_for_role as $cap) { |
|
622 | + //first check we haven't already added this cap before, or it's a reset |
|
623 | + if ($reset || ! isset($caps_set_before[$role]) || ! in_array($cap, $caps_set_before[$role])) { |
|
624 | + if ($this->add_cap_to_role($role, $cap)) { |
|
625 | + $caps_set_before[$role][] = $cap; |
|
626 | + } |
|
627 | + } |
|
628 | + } |
|
629 | + } |
|
630 | + |
|
631 | + //now let's just save the cap that has been set. |
|
632 | + update_option(self::option_name, $caps_set_before); |
|
633 | + do_action('AHEE__EE_Capabilities__init_role_caps__complete', $caps_set_before); |
|
634 | + } |
|
635 | + |
|
636 | + |
|
637 | + /** |
|
638 | + * This method sets a capability on a role. Note this should only be done on activation, or if you have something |
|
639 | + * specific to prevent the cap from being added on every page load (adding caps are persistent to the db). Note. |
|
640 | + * this is a wrapper for $wp_role->add_cap() |
|
641 | + * |
|
642 | + * @see wp-includes/capabilities.php |
|
643 | + * @since 4.5.0 |
|
644 | + * @param string $role A WordPress role the capability is being added to |
|
645 | + * @param string $cap The capability being added to the role |
|
646 | + * @param bool $grant Whether to grant access to this cap on this role. |
|
647 | + * @return bool |
|
648 | + */ |
|
649 | + public function add_cap_to_role($role, $cap, $grant = true) |
|
650 | + { |
|
651 | + $role_object = get_role($role); |
|
652 | + //if the role isn't available then we create it. |
|
653 | + if ( ! $role_object instanceof WP_Role) { |
|
654 | + //if a plugin wants to create a specific role name then they should create the role before |
|
655 | + //EE_Capabilities does. Otherwise this function will create the role name from the slug: |
|
656 | + // - removes any `ee_` namespacing from the start of the slug. |
|
657 | + // - replaces `_` with ` ` (empty space). |
|
658 | + // - sentence case on the resulting string. |
|
659 | + $role_label = ucwords(str_replace('_', ' ', str_replace('ee_', '', $role))); |
|
660 | + $role_object = add_role($role, $role_label); |
|
661 | + } |
|
662 | + if ($role_object instanceof WP_Role) { |
|
663 | + $role_object->add_cap($cap, $grant); |
|
664 | + |
|
665 | + return true; |
|
666 | + } |
|
667 | + |
|
668 | + return false; |
|
669 | + } |
|
670 | + |
|
671 | + |
|
672 | + /** |
|
673 | + * Functions similarly to add_cap_to_role except removes cap from given role. |
|
674 | + * Wrapper for $wp_role->remove_cap() |
|
675 | + * |
|
676 | + * @see wp-includes/capabilities.php |
|
677 | + * @since 4.5.0 |
|
678 | + * @param string $role A WordPress role the capability is being removed from. |
|
679 | + * @param string $cap The capability being removed |
|
680 | + * @return void |
|
681 | + */ |
|
682 | + public function remove_cap_from_role($role, $cap) |
|
683 | + { |
|
684 | + $role = get_role($role); |
|
685 | + if ($role instanceof WP_Role) { |
|
686 | + $role->remove_cap($cap); |
|
687 | + } |
|
688 | + } |
|
689 | + |
|
690 | + |
|
691 | + /** |
|
692 | + * Wrapper for the native WP current_user_can() method. |
|
693 | + * This is provided as a handy method for a couple things: |
|
694 | + * 1. Using the context string it allows for targeted filtering by addons for a specific check (without having to |
|
695 | + * write those filters wherever current_user_can is called). |
|
696 | + * 2. Explicit passing of $id from a given context ( useful in the cases of map_meta_cap filters ) |
|
697 | + * |
|
698 | + * @since 4.5.0 |
|
699 | + * @param string $cap The cap being checked. |
|
700 | + * @param string $context The context where the current_user_can is being called from. |
|
701 | + * @param int $id Optional. Id for item where current_user_can is being called from (used in map_meta_cap() |
|
702 | + * filters. |
|
703 | + * @return bool Whether user can or not. |
|
704 | + */ |
|
705 | + public function current_user_can($cap, $context, $id = 0) |
|
706 | + { |
|
707 | + //apply filters (both a global on just the cap, and context specific. Global overrides context specific) |
|
708 | + $filtered_cap = apply_filters('FHEE__EE_Capabilities__current_user_can__cap__' . $context, $cap, $id); |
|
709 | + $filtered_cap = apply_filters('FHEE__EE_Capabilities__current_user_can__cap', $filtered_cap, $context, $cap, |
|
710 | + $id); |
|
711 | + |
|
712 | + return ! empty($id) ? current_user_can($filtered_cap, $id) : current_user_can($filtered_cap); |
|
713 | + } |
|
714 | + |
|
715 | + |
|
716 | + /** |
|
717 | + * This is a wrapper for the WP user_can() function and follows the same style as the other wrappers in this class. |
|
718 | + * |
|
719 | + * @param int|WP_User $user Either the user_id or a WP_User object |
|
720 | + * @param string $cap The capability string being checked |
|
721 | + * @param string $context The context where the user_can is being called from (used in filters). |
|
722 | + * @param int $id Optional. Id for item where user_can is being called from ( used in map_meta_cap() |
|
723 | + * filters) |
|
724 | + * @return bool Whether user can or not. |
|
725 | + */ |
|
726 | + public function user_can($user, $cap, $context, $id = 0) |
|
727 | + { |
|
728 | + //apply filters (both a global on just the cap, and context specific. Global overrides context specific) |
|
729 | + $filtered_cap = apply_filters('FHEE__EE_Capabilities__user_can__cap__' . $context, $cap, $user, $id); |
|
730 | + $filtered_cap = apply_filters('FHEE__EE_Capabilities__user_can__cap', $filtered_cap, $context, $cap, $user, |
|
731 | + $id); |
|
732 | + |
|
733 | + return ! empty($id) ? user_can($user, $filtered_cap, $id) : user_can($user, $filtered_cap); |
|
734 | + } |
|
735 | + |
|
736 | + |
|
737 | + /** |
|
738 | + * Wrapper for the native WP current_user_can_for_blog() method. |
|
739 | + * This is provided as a handy method for a couple things: |
|
740 | + * 1. Using the context string it allows for targeted filtering by addons for a specific check (without having to |
|
741 | + * write those filters wherever current_user_can is called). |
|
742 | + * 2. Explicit passing of $id from a given context ( useful in the cases of map_meta_cap filters ) |
|
743 | + * |
|
744 | + * @since 4.5.0 |
|
745 | + * @param int $blog_id The blog id that is being checked for. |
|
746 | + * @param string $cap The cap being checked. |
|
747 | + * @param string $context The context where the current_user_can is being called from. |
|
748 | + * @param int $id Optional. Id for item where current_user_can is being called from (used in map_meta_cap() |
|
749 | + * filters. |
|
750 | + * @return bool Whether user can or not. |
|
751 | + */ |
|
752 | + public function current_user_can_for_blog($blog_id, $cap, $context, $id = 0) |
|
753 | + { |
|
754 | + $user_can = ! empty($id) ? current_user_can_for_blog($blog_id, $cap, $id) : current_user_can($blog_id, $cap); |
|
755 | + |
|
756 | + //apply filters (both a global on just the cap, and context specific. Global overrides context specific) |
|
757 | + $user_can = apply_filters('FHEE__EE_Capabilities__current_user_can_for_blog__user_can__' . $context, $user_can, |
|
758 | + $blog_id, $cap, $id); |
|
759 | + $user_can = apply_filters('FHEE__EE_Capabilities__current_user_can_for_blog__user_can', $user_can, $context, |
|
760 | + $blog_id, $cap, $id); |
|
761 | + |
|
762 | + return $user_can; |
|
763 | + } |
|
764 | + |
|
765 | + |
|
766 | + /** |
|
767 | + * This helper method just returns an array of registered EE capabilities. |
|
768 | + * Note this array is filtered. It is assumed that all available EE capabilities are assigned to the administrator |
|
769 | + * role. |
|
770 | + * |
|
771 | + * @since 4.5.0 |
|
772 | + * @param string $role If empty then the entire role/capability map is returned. Otherwise just the capabilities |
|
773 | + * for the given role are returned. |
|
774 | + * @return array |
|
775 | + */ |
|
776 | + public function get_ee_capabilities($role = 'administrator') |
|
777 | + { |
|
778 | + $capabilities = $this->_init_caps_map(); |
|
779 | + if (empty($role)) { |
|
780 | + return $capabilities; |
|
781 | + } |
|
782 | + |
|
783 | + return isset($capabilities[$role]) ? $capabilities[$role] : array(); |
|
784 | + } |
|
785 | 785 | } |
786 | 786 | |
787 | 787 | |
@@ -797,118 +797,118 @@ discard block |
||
797 | 797 | */ |
798 | 798 | abstract class EE_Meta_Capability_Map |
799 | 799 | { |
800 | - public $meta_cap; |
|
801 | - /** |
|
802 | - * @var EEM_Base |
|
803 | - */ |
|
804 | - protected $_model; |
|
805 | - protected $_model_name; |
|
806 | - public $published_cap = ''; |
|
807 | - public $others_cap = ''; |
|
808 | - public $private_cap = ''; |
|
809 | - |
|
810 | - |
|
811 | - /** |
|
812 | - * constructor. |
|
813 | - * Receives the setup arguments for the map. |
|
814 | - * |
|
815 | - * @since 4.5.0 |
|
816 | - * @param string $meta_cap What meta capability is this mapping. |
|
817 | - * @param array $map_values array { |
|
818 | - * //array of values that MUST match a count of 4. It's okay to send an empty string |
|
819 | - * for capabilities that don't get mapped to. |
|
820 | - * @type $map_values [0] string A string representing the model name. Required. String's |
|
821 | - * should always be used when Menu Maps are registered via the |
|
822 | - * plugin API as models are not allowed to be instantiated when |
|
823 | - * in maintenance mode 2 (migrations). |
|
824 | - * @type $map_values [1] string represents the capability used for published. Optional. |
|
825 | - * @type $map_values [2] string represents the capability used for "others". Optional. |
|
826 | - * @type $map_values [3] string represents the capability used for private. Optional. |
|
827 | - * } |
|
828 | - * @throws EE_Error |
|
829 | - */ |
|
830 | - public function __construct($meta_cap, $map_values) |
|
831 | - { |
|
832 | - $this->meta_cap = $meta_cap; |
|
833 | - //verify there are four args in the $map_values array; |
|
834 | - if (count($map_values) !== 4) { |
|
835 | - throw new EE_Error(sprintf(__('Incoming $map_values array should have a count of four values in it. This is what was given: %s', |
|
836 | - 'event_espresso'), '<br>' . print_r($map_values, true))); |
|
837 | - } |
|
838 | - |
|
839 | - //set properties |
|
840 | - $this->_model = null; |
|
841 | - $this->_model_name = $map_values[0]; |
|
842 | - $this->published_cap = (string)$map_values[1]; |
|
843 | - $this->others_cap = (string)$map_values[2]; |
|
844 | - $this->private_cap = (string)$map_values[3]; |
|
845 | - } |
|
846 | - |
|
847 | - /** |
|
848 | - * Makes it so this object stops filtering caps |
|
849 | - */ |
|
850 | - public function remove_filters() |
|
851 | - { |
|
852 | - remove_filter('map_meta_cap', array($this, 'map_meta_caps'), 10); |
|
853 | - } |
|
854 | - |
|
855 | - |
|
856 | - /** |
|
857 | - * This method ensures that the $model property is converted from the model name string to a proper EEM_Base class |
|
858 | - * |
|
859 | - * @since 4.5.0 |
|
860 | - * @throws EE_Error |
|
861 | - * @return void |
|
862 | - */ |
|
863 | - public function ensure_is_model() |
|
864 | - { |
|
865 | - //is it already instantiated? |
|
866 | - if ($this->_model instanceof EEM_Base) { |
|
867 | - return; |
|
868 | - } |
|
869 | - |
|
870 | - //ensure model name is string |
|
871 | - $this->_model_name = (string)$this->_model_name; |
|
872 | - //error proof if the name has EEM in it |
|
873 | - $this->_model_name = str_replace('EEM', '', $this->_model_name); |
|
874 | - |
|
875 | - $this->_model = EE_Registry::instance()->load_model($this->_model_name); |
|
876 | - |
|
877 | - if ( ! $this->_model instanceof EEM_Base) { |
|
878 | - throw new EE_Error(sprintf(__('This string passed in to %s to represent a EEM_Base model class was not able to be used to instantiate the class. Please ensure that the string is a match for the EEM_Base model name (not including the EEM_ part). This was given: %s', |
|
879 | - 'event_espresso'), get_class($this), $this->_model)); |
|
880 | - } |
|
881 | - } |
|
882 | - |
|
883 | - |
|
884 | - /** |
|
885 | - * @see EE_Meta_Capability_Map::_map_meta_caps() for docs on params. |
|
886 | - * @since 4.6.x |
|
887 | - * @param $caps |
|
888 | - * @param $cap |
|
889 | - * @param $user_id |
|
890 | - * @param $args |
|
891 | - * @return array |
|
892 | - */ |
|
893 | - public function map_meta_caps($caps, $cap, $user_id, $args) |
|
894 | - { |
|
895 | - return $this->_map_meta_caps($caps, $cap, $user_id, $args); |
|
896 | - } |
|
897 | - |
|
898 | - |
|
899 | - /** |
|
900 | - * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
901 | - * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
902 | - * |
|
903 | - * @since 4.5.0 |
|
904 | - * @see wp-includes/capabilities.php |
|
905 | - * @param array $caps actual users capabilities |
|
906 | - * @param string $cap initial capability name that is being checked (the "map" key) |
|
907 | - * @param int $user_id The user id |
|
908 | - * @param array $args Adds context to the cap. Typically the object ID. |
|
909 | - * @return array actual users capabilities |
|
910 | - */ |
|
911 | - abstract protected function _map_meta_caps($caps, $cap, $user_id, $args); |
|
800 | + public $meta_cap; |
|
801 | + /** |
|
802 | + * @var EEM_Base |
|
803 | + */ |
|
804 | + protected $_model; |
|
805 | + protected $_model_name; |
|
806 | + public $published_cap = ''; |
|
807 | + public $others_cap = ''; |
|
808 | + public $private_cap = ''; |
|
809 | + |
|
810 | + |
|
811 | + /** |
|
812 | + * constructor. |
|
813 | + * Receives the setup arguments for the map. |
|
814 | + * |
|
815 | + * @since 4.5.0 |
|
816 | + * @param string $meta_cap What meta capability is this mapping. |
|
817 | + * @param array $map_values array { |
|
818 | + * //array of values that MUST match a count of 4. It's okay to send an empty string |
|
819 | + * for capabilities that don't get mapped to. |
|
820 | + * @type $map_values [0] string A string representing the model name. Required. String's |
|
821 | + * should always be used when Menu Maps are registered via the |
|
822 | + * plugin API as models are not allowed to be instantiated when |
|
823 | + * in maintenance mode 2 (migrations). |
|
824 | + * @type $map_values [1] string represents the capability used for published. Optional. |
|
825 | + * @type $map_values [2] string represents the capability used for "others". Optional. |
|
826 | + * @type $map_values [3] string represents the capability used for private. Optional. |
|
827 | + * } |
|
828 | + * @throws EE_Error |
|
829 | + */ |
|
830 | + public function __construct($meta_cap, $map_values) |
|
831 | + { |
|
832 | + $this->meta_cap = $meta_cap; |
|
833 | + //verify there are four args in the $map_values array; |
|
834 | + if (count($map_values) !== 4) { |
|
835 | + throw new EE_Error(sprintf(__('Incoming $map_values array should have a count of four values in it. This is what was given: %s', |
|
836 | + 'event_espresso'), '<br>' . print_r($map_values, true))); |
|
837 | + } |
|
838 | + |
|
839 | + //set properties |
|
840 | + $this->_model = null; |
|
841 | + $this->_model_name = $map_values[0]; |
|
842 | + $this->published_cap = (string)$map_values[1]; |
|
843 | + $this->others_cap = (string)$map_values[2]; |
|
844 | + $this->private_cap = (string)$map_values[3]; |
|
845 | + } |
|
846 | + |
|
847 | + /** |
|
848 | + * Makes it so this object stops filtering caps |
|
849 | + */ |
|
850 | + public function remove_filters() |
|
851 | + { |
|
852 | + remove_filter('map_meta_cap', array($this, 'map_meta_caps'), 10); |
|
853 | + } |
|
854 | + |
|
855 | + |
|
856 | + /** |
|
857 | + * This method ensures that the $model property is converted from the model name string to a proper EEM_Base class |
|
858 | + * |
|
859 | + * @since 4.5.0 |
|
860 | + * @throws EE_Error |
|
861 | + * @return void |
|
862 | + */ |
|
863 | + public function ensure_is_model() |
|
864 | + { |
|
865 | + //is it already instantiated? |
|
866 | + if ($this->_model instanceof EEM_Base) { |
|
867 | + return; |
|
868 | + } |
|
869 | + |
|
870 | + //ensure model name is string |
|
871 | + $this->_model_name = (string)$this->_model_name; |
|
872 | + //error proof if the name has EEM in it |
|
873 | + $this->_model_name = str_replace('EEM', '', $this->_model_name); |
|
874 | + |
|
875 | + $this->_model = EE_Registry::instance()->load_model($this->_model_name); |
|
876 | + |
|
877 | + if ( ! $this->_model instanceof EEM_Base) { |
|
878 | + throw new EE_Error(sprintf(__('This string passed in to %s to represent a EEM_Base model class was not able to be used to instantiate the class. Please ensure that the string is a match for the EEM_Base model name (not including the EEM_ part). This was given: %s', |
|
879 | + 'event_espresso'), get_class($this), $this->_model)); |
|
880 | + } |
|
881 | + } |
|
882 | + |
|
883 | + |
|
884 | + /** |
|
885 | + * @see EE_Meta_Capability_Map::_map_meta_caps() for docs on params. |
|
886 | + * @since 4.6.x |
|
887 | + * @param $caps |
|
888 | + * @param $cap |
|
889 | + * @param $user_id |
|
890 | + * @param $args |
|
891 | + * @return array |
|
892 | + */ |
|
893 | + public function map_meta_caps($caps, $cap, $user_id, $args) |
|
894 | + { |
|
895 | + return $this->_map_meta_caps($caps, $cap, $user_id, $args); |
|
896 | + } |
|
897 | + |
|
898 | + |
|
899 | + /** |
|
900 | + * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
901 | + * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
902 | + * |
|
903 | + * @since 4.5.0 |
|
904 | + * @see wp-includes/capabilities.php |
|
905 | + * @param array $caps actual users capabilities |
|
906 | + * @param string $cap initial capability name that is being checked (the "map" key) |
|
907 | + * @param int $user_id The user id |
|
908 | + * @param array $args Adds context to the cap. Typically the object ID. |
|
909 | + * @return array actual users capabilities |
|
910 | + */ |
|
911 | + abstract protected function _map_meta_caps($caps, $cap, $user_id, $args); |
|
912 | 912 | } |
913 | 913 | |
914 | 914 | |
@@ -924,79 +924,79 @@ discard block |
||
924 | 924 | class EE_Meta_Capability_Map_Edit extends EE_Meta_Capability_Map |
925 | 925 | { |
926 | 926 | |
927 | - /** |
|
928 | - * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
929 | - * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
930 | - * |
|
931 | - * @since 4.5.0 |
|
932 | - * @see wp-includes/capabilities.php |
|
933 | - * @param array $caps actual users capabilities |
|
934 | - * @param string $cap initial capability name that is being checked (the "map" key) |
|
935 | - * @param int $user_id The user id |
|
936 | - * @param array $args Adds context to the cap. Typically the object ID. |
|
937 | - * @return array actual users capabilities |
|
938 | - */ |
|
939 | - protected function _map_meta_caps($caps, $cap, $user_id, $args) |
|
940 | - { |
|
941 | - //only process if we're checking our mapped_cap |
|
942 | - if ($cap !== $this->meta_cap) { |
|
943 | - return $caps; |
|
944 | - } |
|
945 | - |
|
946 | - $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
|
947 | - |
|
948 | - //if no obj then let's just do cap |
|
949 | - if ( ! $obj instanceof EE_Base_Class) { |
|
950 | - $caps[] = $cap; |
|
951 | - |
|
952 | - return $caps; |
|
953 | - } |
|
954 | - |
|
955 | - if ($obj instanceof EE_CPT_Base) { |
|
956 | - //if the item author is set and the user is the author... |
|
957 | - if ($obj->wp_user() && $user_id == $obj->wp_user()) { |
|
958 | - if (empty($this->published_cap)) { |
|
959 | - $caps[] = $cap; |
|
960 | - } else { |
|
961 | - //if obj is published... |
|
962 | - if ($obj->status() == 'publish') { |
|
963 | - $caps[] = $this->published_cap; |
|
964 | - } else { |
|
965 | - $caps[] = $cap; |
|
966 | - } |
|
967 | - } |
|
968 | - } else { |
|
969 | - //the user is trying to edit someone else's obj |
|
970 | - if ( ! empty($this->others_cap)) { |
|
971 | - $caps[] = $this->others_cap; |
|
972 | - } |
|
973 | - if ( ! empty($this->published_cap) && $obj->status() == 'publish') { |
|
974 | - $caps[] = $this->published_cap; |
|
975 | - } elseif ( ! empty($this->private_cap) && $obj->status() == 'private') { |
|
976 | - $caps[] = $this->private_cap; |
|
977 | - } |
|
978 | - } |
|
979 | - } else { |
|
980 | - //not a cpt object so handled differently |
|
981 | - $has_cap = false; |
|
982 | - try { |
|
983 | - $has_cap = method_exists($obj, 'wp_user') && $obj->wp_user() && $user_id == $obj->wp_user(); |
|
984 | - } catch (Exception $e) { |
|
985 | - if (WP_DEBUG) { |
|
986 | - EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
987 | - } |
|
988 | - } |
|
989 | - if ($has_cap) { |
|
990 | - $caps[] = $cap; |
|
991 | - } else { |
|
992 | - if ( ! empty($this->others_cap)) { |
|
993 | - $caps[] = $this->others_cap; |
|
994 | - } |
|
995 | - } |
|
996 | - } |
|
997 | - |
|
998 | - return $caps; |
|
999 | - } |
|
927 | + /** |
|
928 | + * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
929 | + * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
930 | + * |
|
931 | + * @since 4.5.0 |
|
932 | + * @see wp-includes/capabilities.php |
|
933 | + * @param array $caps actual users capabilities |
|
934 | + * @param string $cap initial capability name that is being checked (the "map" key) |
|
935 | + * @param int $user_id The user id |
|
936 | + * @param array $args Adds context to the cap. Typically the object ID. |
|
937 | + * @return array actual users capabilities |
|
938 | + */ |
|
939 | + protected function _map_meta_caps($caps, $cap, $user_id, $args) |
|
940 | + { |
|
941 | + //only process if we're checking our mapped_cap |
|
942 | + if ($cap !== $this->meta_cap) { |
|
943 | + return $caps; |
|
944 | + } |
|
945 | + |
|
946 | + $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
|
947 | + |
|
948 | + //if no obj then let's just do cap |
|
949 | + if ( ! $obj instanceof EE_Base_Class) { |
|
950 | + $caps[] = $cap; |
|
951 | + |
|
952 | + return $caps; |
|
953 | + } |
|
954 | + |
|
955 | + if ($obj instanceof EE_CPT_Base) { |
|
956 | + //if the item author is set and the user is the author... |
|
957 | + if ($obj->wp_user() && $user_id == $obj->wp_user()) { |
|
958 | + if (empty($this->published_cap)) { |
|
959 | + $caps[] = $cap; |
|
960 | + } else { |
|
961 | + //if obj is published... |
|
962 | + if ($obj->status() == 'publish') { |
|
963 | + $caps[] = $this->published_cap; |
|
964 | + } else { |
|
965 | + $caps[] = $cap; |
|
966 | + } |
|
967 | + } |
|
968 | + } else { |
|
969 | + //the user is trying to edit someone else's obj |
|
970 | + if ( ! empty($this->others_cap)) { |
|
971 | + $caps[] = $this->others_cap; |
|
972 | + } |
|
973 | + if ( ! empty($this->published_cap) && $obj->status() == 'publish') { |
|
974 | + $caps[] = $this->published_cap; |
|
975 | + } elseif ( ! empty($this->private_cap) && $obj->status() == 'private') { |
|
976 | + $caps[] = $this->private_cap; |
|
977 | + } |
|
978 | + } |
|
979 | + } else { |
|
980 | + //not a cpt object so handled differently |
|
981 | + $has_cap = false; |
|
982 | + try { |
|
983 | + $has_cap = method_exists($obj, 'wp_user') && $obj->wp_user() && $user_id == $obj->wp_user(); |
|
984 | + } catch (Exception $e) { |
|
985 | + if (WP_DEBUG) { |
|
986 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
987 | + } |
|
988 | + } |
|
989 | + if ($has_cap) { |
|
990 | + $caps[] = $cap; |
|
991 | + } else { |
|
992 | + if ( ! empty($this->others_cap)) { |
|
993 | + $caps[] = $this->others_cap; |
|
994 | + } |
|
995 | + } |
|
996 | + } |
|
997 | + |
|
998 | + return $caps; |
|
999 | + } |
|
1000 | 1000 | } |
1001 | 1001 | |
1002 | 1002 | |
@@ -1013,22 +1013,22 @@ discard block |
||
1013 | 1013 | class EE_Meta_Capability_Map_Delete extends EE_Meta_Capability_Map_Edit |
1014 | 1014 | { |
1015 | 1015 | |
1016 | - /** |
|
1017 | - * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
1018 | - * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
1019 | - * |
|
1020 | - * @since 4.5.0 |
|
1021 | - * @see wp-includes/capabilities.php |
|
1022 | - * @param array $caps actual users capabilities |
|
1023 | - * @param string $cap initial capability name that is being checked (the "map" key) |
|
1024 | - * @param int $user_id The user id |
|
1025 | - * @param array $args Adds context to the cap. Typically the object ID. |
|
1026 | - * @return array actual users capabilities |
|
1027 | - */ |
|
1028 | - protected function _map_meta_caps($caps, $cap, $user_id, $args) |
|
1029 | - { |
|
1030 | - return parent::_map_meta_caps($caps, $cap, $user_id, $args); |
|
1031 | - } |
|
1016 | + /** |
|
1017 | + * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
1018 | + * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
1019 | + * |
|
1020 | + * @since 4.5.0 |
|
1021 | + * @see wp-includes/capabilities.php |
|
1022 | + * @param array $caps actual users capabilities |
|
1023 | + * @param string $cap initial capability name that is being checked (the "map" key) |
|
1024 | + * @param int $user_id The user id |
|
1025 | + * @param array $args Adds context to the cap. Typically the object ID. |
|
1026 | + * @return array actual users capabilities |
|
1027 | + */ |
|
1028 | + protected function _map_meta_caps($caps, $cap, $user_id, $args) |
|
1029 | + { |
|
1030 | + return parent::_map_meta_caps($caps, $cap, $user_id, $args); |
|
1031 | + } |
|
1032 | 1032 | } |
1033 | 1033 | |
1034 | 1034 | |
@@ -1044,76 +1044,76 @@ discard block |
||
1044 | 1044 | class EE_Meta_Capability_Map_Read extends EE_Meta_Capability_Map |
1045 | 1045 | { |
1046 | 1046 | |
1047 | - /** |
|
1048 | - * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
1049 | - * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
1050 | - * |
|
1051 | - * @since 4.5.0 |
|
1052 | - * @see wp-includes/capabilities.php |
|
1053 | - * @param array $caps actual users capabilities |
|
1054 | - * @param string $cap initial capability name that is being checked (the "map" key) |
|
1055 | - * @param int $user_id The user id |
|
1056 | - * @param array $args Adds context to the cap. Typically the object ID. |
|
1057 | - * @return array actual users capabilities |
|
1058 | - */ |
|
1059 | - protected function _map_meta_caps($caps, $cap, $user_id, $args) |
|
1060 | - { |
|
1061 | - //only process if we're checking our mapped cap; |
|
1062 | - if ($cap !== $this->meta_cap) { |
|
1063 | - return $caps; |
|
1064 | - } |
|
1065 | - |
|
1066 | - $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
|
1067 | - |
|
1068 | - //if no obj then let's just do cap |
|
1069 | - if ( ! $obj instanceof EE_Base_Class) { |
|
1070 | - $caps[] = $cap; |
|
1071 | - |
|
1072 | - return $caps; |
|
1073 | - } |
|
1074 | - |
|
1075 | - if ($obj instanceof EE_CPT_Base) { |
|
1076 | - $status_obj = get_post_status_object($obj->status()); |
|
1077 | - if ($status_obj->public) { |
|
1078 | - $caps[] = $cap; |
|
1079 | - |
|
1080 | - return $caps; |
|
1081 | - } |
|
1082 | - |
|
1083 | - //if the item author is set and the user is the author... |
|
1084 | - if ($obj->wp_user() && $user_id == $obj->wp_user()) { |
|
1085 | - $caps[] = $cap; |
|
1086 | - } elseif ($status_obj->private && ! empty($this->private_cap)) { |
|
1087 | - //the user is trying to view someone else's obj |
|
1088 | - $caps[] = $this->private_cap; |
|
1089 | - } elseif ( ! empty($this->others_cap)) { |
|
1090 | - $caps[] = $this->others_cap; |
|
1091 | - } else { |
|
1092 | - $caps[] = $cap; |
|
1093 | - } |
|
1094 | - } else { |
|
1095 | - //not a cpt object so handled differently |
|
1096 | - $has_cap = false; |
|
1097 | - try { |
|
1098 | - $has_cap = method_exists($obj, 'wp_user') && $obj->wp_user() && $user_id == $obj->wp_user(); |
|
1099 | - } catch (Exception $e) { |
|
1100 | - if (WP_DEBUG) { |
|
1101 | - EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
1102 | - } |
|
1103 | - } |
|
1104 | - if ($has_cap) { |
|
1105 | - $caps[] = $cap; |
|
1106 | - } elseif ( ! empty($this->private_cap)) { |
|
1107 | - $caps[] = $this->private_cap; |
|
1108 | - } elseif ( ! empty($this->others_cap)) { |
|
1109 | - $caps[] = $this->others_cap; |
|
1110 | - } else { |
|
1111 | - $caps[] = $cap; |
|
1112 | - } |
|
1113 | - } |
|
1114 | - |
|
1115 | - return $caps; |
|
1116 | - } |
|
1047 | + /** |
|
1048 | + * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
1049 | + * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
1050 | + * |
|
1051 | + * @since 4.5.0 |
|
1052 | + * @see wp-includes/capabilities.php |
|
1053 | + * @param array $caps actual users capabilities |
|
1054 | + * @param string $cap initial capability name that is being checked (the "map" key) |
|
1055 | + * @param int $user_id The user id |
|
1056 | + * @param array $args Adds context to the cap. Typically the object ID. |
|
1057 | + * @return array actual users capabilities |
|
1058 | + */ |
|
1059 | + protected function _map_meta_caps($caps, $cap, $user_id, $args) |
|
1060 | + { |
|
1061 | + //only process if we're checking our mapped cap; |
|
1062 | + if ($cap !== $this->meta_cap) { |
|
1063 | + return $caps; |
|
1064 | + } |
|
1065 | + |
|
1066 | + $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
|
1067 | + |
|
1068 | + //if no obj then let's just do cap |
|
1069 | + if ( ! $obj instanceof EE_Base_Class) { |
|
1070 | + $caps[] = $cap; |
|
1071 | + |
|
1072 | + return $caps; |
|
1073 | + } |
|
1074 | + |
|
1075 | + if ($obj instanceof EE_CPT_Base) { |
|
1076 | + $status_obj = get_post_status_object($obj->status()); |
|
1077 | + if ($status_obj->public) { |
|
1078 | + $caps[] = $cap; |
|
1079 | + |
|
1080 | + return $caps; |
|
1081 | + } |
|
1082 | + |
|
1083 | + //if the item author is set and the user is the author... |
|
1084 | + if ($obj->wp_user() && $user_id == $obj->wp_user()) { |
|
1085 | + $caps[] = $cap; |
|
1086 | + } elseif ($status_obj->private && ! empty($this->private_cap)) { |
|
1087 | + //the user is trying to view someone else's obj |
|
1088 | + $caps[] = $this->private_cap; |
|
1089 | + } elseif ( ! empty($this->others_cap)) { |
|
1090 | + $caps[] = $this->others_cap; |
|
1091 | + } else { |
|
1092 | + $caps[] = $cap; |
|
1093 | + } |
|
1094 | + } else { |
|
1095 | + //not a cpt object so handled differently |
|
1096 | + $has_cap = false; |
|
1097 | + try { |
|
1098 | + $has_cap = method_exists($obj, 'wp_user') && $obj->wp_user() && $user_id == $obj->wp_user(); |
|
1099 | + } catch (Exception $e) { |
|
1100 | + if (WP_DEBUG) { |
|
1101 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
1102 | + } |
|
1103 | + } |
|
1104 | + if ($has_cap) { |
|
1105 | + $caps[] = $cap; |
|
1106 | + } elseif ( ! empty($this->private_cap)) { |
|
1107 | + $caps[] = $this->private_cap; |
|
1108 | + } elseif ( ! empty($this->others_cap)) { |
|
1109 | + $caps[] = $this->others_cap; |
|
1110 | + } else { |
|
1111 | + $caps[] = $cap; |
|
1112 | + } |
|
1113 | + } |
|
1114 | + |
|
1115 | + return $caps; |
|
1116 | + } |
|
1117 | 1117 | } |
1118 | 1118 | |
1119 | 1119 | |
@@ -1130,52 +1130,52 @@ discard block |
||
1130 | 1130 | class EE_Meta_Capability_Map_Messages_Cap extends EE_Meta_Capability_Map |
1131 | 1131 | { |
1132 | 1132 | |
1133 | - /** |
|
1134 | - * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
1135 | - * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
1136 | - * |
|
1137 | - * @since 4.5.0 |
|
1138 | - * @see wp-includes/capabilities.php |
|
1139 | - * @param array $caps actual users capabilities |
|
1140 | - * @param string $cap initial capability name that is being checked (the "map" key) |
|
1141 | - * @param int $user_id The user id |
|
1142 | - * @param array $args Adds context to the cap. Typically the object ID. |
|
1143 | - * @return array actual users capabilities |
|
1144 | - */ |
|
1145 | - protected function _map_meta_caps($caps, $cap, $user_id, $args) |
|
1146 | - { |
|
1147 | - //only process if we're checking our mapped_cap |
|
1148 | - if ($cap !== $this->meta_cap) { |
|
1149 | - return $caps; |
|
1150 | - } |
|
1151 | - |
|
1152 | - $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
|
1153 | - |
|
1154 | - //if no obj then let's just do cap |
|
1155 | - if ( ! $obj instanceof EE_Message_Template_Group) { |
|
1156 | - $caps[] = $cap; |
|
1157 | - |
|
1158 | - return $caps; |
|
1159 | - } |
|
1160 | - |
|
1161 | - $is_global = $obj->is_global(); |
|
1162 | - |
|
1163 | - if ($obj->wp_user() && $user_id == $obj->wp_user()) { |
|
1164 | - if ($is_global) { |
|
1165 | - $caps[] = $this->private_cap; |
|
1166 | - } else { |
|
1167 | - $caps[] = $cap; |
|
1168 | - } |
|
1169 | - } else { |
|
1170 | - if ($is_global) { |
|
1171 | - $caps[] = $this->private_cap; |
|
1172 | - } else { |
|
1173 | - $caps[] = $this->others_cap; |
|
1174 | - } |
|
1175 | - } |
|
1176 | - |
|
1177 | - return $caps; |
|
1178 | - } |
|
1133 | + /** |
|
1134 | + * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
1135 | + * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
1136 | + * |
|
1137 | + * @since 4.5.0 |
|
1138 | + * @see wp-includes/capabilities.php |
|
1139 | + * @param array $caps actual users capabilities |
|
1140 | + * @param string $cap initial capability name that is being checked (the "map" key) |
|
1141 | + * @param int $user_id The user id |
|
1142 | + * @param array $args Adds context to the cap. Typically the object ID. |
|
1143 | + * @return array actual users capabilities |
|
1144 | + */ |
|
1145 | + protected function _map_meta_caps($caps, $cap, $user_id, $args) |
|
1146 | + { |
|
1147 | + //only process if we're checking our mapped_cap |
|
1148 | + if ($cap !== $this->meta_cap) { |
|
1149 | + return $caps; |
|
1150 | + } |
|
1151 | + |
|
1152 | + $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
|
1153 | + |
|
1154 | + //if no obj then let's just do cap |
|
1155 | + if ( ! $obj instanceof EE_Message_Template_Group) { |
|
1156 | + $caps[] = $cap; |
|
1157 | + |
|
1158 | + return $caps; |
|
1159 | + } |
|
1160 | + |
|
1161 | + $is_global = $obj->is_global(); |
|
1162 | + |
|
1163 | + if ($obj->wp_user() && $user_id == $obj->wp_user()) { |
|
1164 | + if ($is_global) { |
|
1165 | + $caps[] = $this->private_cap; |
|
1166 | + } else { |
|
1167 | + $caps[] = $cap; |
|
1168 | + } |
|
1169 | + } else { |
|
1170 | + if ($is_global) { |
|
1171 | + $caps[] = $this->private_cap; |
|
1172 | + } else { |
|
1173 | + $caps[] = $this->others_cap; |
|
1174 | + } |
|
1175 | + } |
|
1176 | + |
|
1177 | + return $caps; |
|
1178 | + } |
|
1179 | 1179 | } |
1180 | 1180 | |
1181 | 1181 | |
@@ -1192,43 +1192,43 @@ discard block |
||
1192 | 1192 | class EE_Meta_Capability_Map_Registration_Form_Cap extends EE_Meta_Capability_Map |
1193 | 1193 | { |
1194 | 1194 | |
1195 | - /** |
|
1196 | - * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
1197 | - * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
1198 | - * |
|
1199 | - * @since 4.5.0 |
|
1200 | - * @see wp-includes/capabilities.php |
|
1201 | - * @param array $caps actual users capabilities |
|
1202 | - * @param string $cap initial capability name that is being checked (the "map" key) |
|
1203 | - * @param int $user_id The user id |
|
1204 | - * @param array $args Adds context to the cap. Typically the object ID. |
|
1205 | - * @return array actual users capabilities |
|
1206 | - */ |
|
1207 | - protected function _map_meta_caps($caps, $cap, $user_id, $args) |
|
1208 | - { |
|
1209 | - //only process if we're checking our mapped_cap |
|
1210 | - if ($cap !== $this->meta_cap) { |
|
1211 | - return $caps; |
|
1212 | - } |
|
1213 | - |
|
1214 | - $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
|
1215 | - |
|
1216 | - //if no obj then let's just do cap |
|
1217 | - if ( ! $obj instanceof EE_Base_Class) { |
|
1218 | - $caps[] = $cap; |
|
1219 | - |
|
1220 | - return $caps; |
|
1221 | - } |
|
1222 | - |
|
1223 | - $is_system = $obj instanceof EE_Question_Group ? $obj->system_group() : false; |
|
1224 | - $is_system = $obj instanceof EE_Question ? $obj->is_system_question() : $is_system; |
|
1225 | - |
|
1226 | - if ($is_system) { |
|
1227 | - $caps[] = $this->private_cap; |
|
1228 | - } else { |
|
1229 | - $caps[] = $cap; |
|
1230 | - } |
|
1231 | - |
|
1232 | - return $caps; |
|
1233 | - } |
|
1195 | + /** |
|
1196 | + * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
1197 | + * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
1198 | + * |
|
1199 | + * @since 4.5.0 |
|
1200 | + * @see wp-includes/capabilities.php |
|
1201 | + * @param array $caps actual users capabilities |
|
1202 | + * @param string $cap initial capability name that is being checked (the "map" key) |
|
1203 | + * @param int $user_id The user id |
|
1204 | + * @param array $args Adds context to the cap. Typically the object ID. |
|
1205 | + * @return array actual users capabilities |
|
1206 | + */ |
|
1207 | + protected function _map_meta_caps($caps, $cap, $user_id, $args) |
|
1208 | + { |
|
1209 | + //only process if we're checking our mapped_cap |
|
1210 | + if ($cap !== $this->meta_cap) { |
|
1211 | + return $caps; |
|
1212 | + } |
|
1213 | + |
|
1214 | + $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
|
1215 | + |
|
1216 | + //if no obj then let's just do cap |
|
1217 | + if ( ! $obj instanceof EE_Base_Class) { |
|
1218 | + $caps[] = $cap; |
|
1219 | + |
|
1220 | + return $caps; |
|
1221 | + } |
|
1222 | + |
|
1223 | + $is_system = $obj instanceof EE_Question_Group ? $obj->system_group() : false; |
|
1224 | + $is_system = $obj instanceof EE_Question ? $obj->is_system_question() : $is_system; |
|
1225 | + |
|
1226 | + if ($is_system) { |
|
1227 | + $caps[] = $this->private_cap; |
|
1228 | + } else { |
|
1229 | + $caps[] = $cap; |
|
1230 | + } |
|
1231 | + |
|
1232 | + return $caps; |
|
1233 | + } |
|
1234 | 1234 | } |
@@ -705,7 +705,7 @@ discard block |
||
705 | 705 | public function current_user_can($cap, $context, $id = 0) |
706 | 706 | { |
707 | 707 | //apply filters (both a global on just the cap, and context specific. Global overrides context specific) |
708 | - $filtered_cap = apply_filters('FHEE__EE_Capabilities__current_user_can__cap__' . $context, $cap, $id); |
|
708 | + $filtered_cap = apply_filters('FHEE__EE_Capabilities__current_user_can__cap__'.$context, $cap, $id); |
|
709 | 709 | $filtered_cap = apply_filters('FHEE__EE_Capabilities__current_user_can__cap', $filtered_cap, $context, $cap, |
710 | 710 | $id); |
711 | 711 | |
@@ -726,7 +726,7 @@ discard block |
||
726 | 726 | public function user_can($user, $cap, $context, $id = 0) |
727 | 727 | { |
728 | 728 | //apply filters (both a global on just the cap, and context specific. Global overrides context specific) |
729 | - $filtered_cap = apply_filters('FHEE__EE_Capabilities__user_can__cap__' . $context, $cap, $user, $id); |
|
729 | + $filtered_cap = apply_filters('FHEE__EE_Capabilities__user_can__cap__'.$context, $cap, $user, $id); |
|
730 | 730 | $filtered_cap = apply_filters('FHEE__EE_Capabilities__user_can__cap', $filtered_cap, $context, $cap, $user, |
731 | 731 | $id); |
732 | 732 | |
@@ -754,7 +754,7 @@ discard block |
||
754 | 754 | $user_can = ! empty($id) ? current_user_can_for_blog($blog_id, $cap, $id) : current_user_can($blog_id, $cap); |
755 | 755 | |
756 | 756 | //apply filters (both a global on just the cap, and context specific. Global overrides context specific) |
757 | - $user_can = apply_filters('FHEE__EE_Capabilities__current_user_can_for_blog__user_can__' . $context, $user_can, |
|
757 | + $user_can = apply_filters('FHEE__EE_Capabilities__current_user_can_for_blog__user_can__'.$context, $user_can, |
|
758 | 758 | $blog_id, $cap, $id); |
759 | 759 | $user_can = apply_filters('FHEE__EE_Capabilities__current_user_can_for_blog__user_can', $user_can, $context, |
760 | 760 | $blog_id, $cap, $id); |
@@ -833,15 +833,15 @@ discard block |
||
833 | 833 | //verify there are four args in the $map_values array; |
834 | 834 | if (count($map_values) !== 4) { |
835 | 835 | throw new EE_Error(sprintf(__('Incoming $map_values array should have a count of four values in it. This is what was given: %s', |
836 | - 'event_espresso'), '<br>' . print_r($map_values, true))); |
|
836 | + 'event_espresso'), '<br>'.print_r($map_values, true))); |
|
837 | 837 | } |
838 | 838 | |
839 | 839 | //set properties |
840 | 840 | $this->_model = null; |
841 | 841 | $this->_model_name = $map_values[0]; |
842 | - $this->published_cap = (string)$map_values[1]; |
|
843 | - $this->others_cap = (string)$map_values[2]; |
|
844 | - $this->private_cap = (string)$map_values[3]; |
|
842 | + $this->published_cap = (string) $map_values[1]; |
|
843 | + $this->others_cap = (string) $map_values[2]; |
|
844 | + $this->private_cap = (string) $map_values[3]; |
|
845 | 845 | } |
846 | 846 | |
847 | 847 | /** |
@@ -868,7 +868,7 @@ discard block |
||
868 | 868 | } |
869 | 869 | |
870 | 870 | //ensure model name is string |
871 | - $this->_model_name = (string)$this->_model_name; |
|
871 | + $this->_model_name = (string) $this->_model_name; |
|
872 | 872 | //error proof if the name has EEM in it |
873 | 873 | $this->_model_name = str_replace('EEM', '', $this->_model_name); |
874 | 874 |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | use EventEspresso\core\services\database\TableAnalysis; |
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 | * the purpose of this file is to simply contain any action/filter hook callbacks etc for specific aspects of EE |
@@ -27,277 +27,277 @@ discard block |
||
27 | 27 | class EE_Brewing_Regular extends EE_BASE |
28 | 28 | { |
29 | 29 | |
30 | - /** |
|
31 | - * @var \EventEspresso\core\services\database\TableAnalysis $table_analysis |
|
32 | - */ |
|
33 | - protected $_table_analysis; |
|
34 | - |
|
35 | - |
|
36 | - |
|
37 | - /** |
|
38 | - * EE_Brewing_Regular constructor. |
|
39 | - */ |
|
40 | - public function __construct(TableAnalysis $table_analysis) |
|
41 | - { |
|
42 | - $this->_table_analysis = $table_analysis; |
|
43 | - if (defined('EE_CAFF_PATH')) { |
|
44 | - // activation |
|
45 | - add_action('AHEE__EEH_Activation__initialize_db_content', array($this, 'initialize_caf_db_content')); |
|
46 | - // load caff init |
|
47 | - add_action('AHEE__EE_System__set_hooks_for_core', array($this, 'caffeinated_init')); |
|
48 | - // remove the "powered by" credit link from receipts and invoices |
|
49 | - add_filter('FHEE_EE_Html_messenger__add_powered_by_credit_link_to_receipt_and_invoice', '__return_false'); |
|
50 | - // add caffeinated modules |
|
51 | - add_filter( |
|
52 | - 'FHEE__EE_Config__register_modules__modules_to_register', |
|
53 | - array($this, 'caffeinated_modules_to_register') |
|
54 | - ); |
|
55 | - // load caff scripts |
|
56 | - add_action('wp_enqueue_scripts', array($this, 'enqueue_caffeinated_scripts'), 10); |
|
57 | - add_filter('FHEE__EE_Registry__load_helper__helper_paths', array($this, 'caf_helper_paths'), 10); |
|
58 | - add_filter( |
|
59 | - 'FHEE__EE_Payment_Method_Manager__register_payment_methods__payment_methods_to_register', |
|
60 | - array($this, 'caf_payment_methods') |
|
61 | - ); |
|
62 | - // caffeinated constructed |
|
63 | - do_action('AHEE__EE_Brewing_Regular__construct__finished'); |
|
64 | - //seeing how this is caf, which isn't put on WordPress.org, we can have affiliate links without a disclaimer |
|
65 | - add_filter('FHEE__ee_show_affiliate_links', '__return_false'); |
|
66 | - } |
|
67 | - } |
|
68 | - |
|
69 | - |
|
70 | - |
|
71 | - /** |
|
72 | - * callback for the FHEE__EE_Registry__load_helper__helper_paths filter to add the caffeinated paths |
|
73 | - * |
|
74 | - * @param array $paths original helper paths array |
|
75 | - * @return array new array of paths |
|
76 | - */ |
|
77 | - public function caf_helper_paths($paths) |
|
78 | - { |
|
79 | - $paths[] = EE_CAF_CORE . 'helpers' . DS; |
|
80 | - return $paths; |
|
81 | - } |
|
82 | - |
|
83 | - |
|
84 | - |
|
85 | - /** |
|
86 | - * Upon brand-new activation, if this is a new activation of CAF, we want to add |
|
87 | - * some global prices that will show off EE4's capabilities. However, if they're upgrading |
|
88 | - * from 3.1, or simply EE4.x decaf, we assume they don't want us to suddenly introduce these extra prices. |
|
89 | - * This action should only be called when EE 4.x.0.P is initially activated. |
|
90 | - * Right now the only CAF content are these global prices. If there's more in the future, then |
|
91 | - * we should probably create a caf file to contain it all instead just a function like this. |
|
92 | - * Right now, we ASSUME the only price types in the system are default ones |
|
93 | - * |
|
94 | - * @global wpdb $wpdb |
|
95 | - */ |
|
96 | - public function initialize_caf_db_content() |
|
97 | - { |
|
98 | - global $wpdb; |
|
99 | - //use same method of getting creator id as the version introducing the change |
|
100 | - $default_creator_id = apply_filters('FHEE__EE_DMS_Core_4_5_0__get_default_creator_id', get_current_user_id()); |
|
101 | - $price_type_table = $wpdb->prefix . "esp_price_type"; |
|
102 | - $price_table = $wpdb->prefix . "esp_price"; |
|
103 | - if ($this->_get_table_analysis()->tableExists($price_type_table)) { |
|
104 | - $SQL = 'SELECT COUNT(PRT_ID) FROM ' . $price_type_table . ' WHERE PBT_ID=4';//include trashed price types |
|
105 | - $tax_price_type_count = $wpdb->get_var($SQL); |
|
106 | - if ($tax_price_type_count <= 1) { |
|
107 | - $wpdb->insert( |
|
108 | - $price_type_table, |
|
109 | - array( |
|
110 | - 'PRT_name' => __("Regional Tax", "event_espresso"), |
|
111 | - 'PBT_ID' => 4, |
|
112 | - 'PRT_is_percent' => true, |
|
113 | - 'PRT_order' => 60, |
|
114 | - 'PRT_deleted' => false, |
|
115 | - 'PRT_wp_user' => $default_creator_id, |
|
116 | - ), |
|
117 | - array( |
|
118 | - '%s',//PRT_name |
|
119 | - '%d',//PBT_id |
|
120 | - '%d',//PRT_is_percent |
|
121 | - '%d',//PRT_order |
|
122 | - '%d',//PRT_deleted |
|
123 | - '%d', //PRT_wp_user |
|
124 | - ) |
|
125 | - ); |
|
126 | - //federal tax |
|
127 | - $result = $wpdb->insert( |
|
128 | - $price_type_table, |
|
129 | - array( |
|
130 | - 'PRT_name' => __("Federal Tax", "event_espresso"), |
|
131 | - 'PBT_ID' => 4, |
|
132 | - 'PRT_is_percent' => true, |
|
133 | - 'PRT_order' => 70, |
|
134 | - 'PRT_deleted' => false, |
|
135 | - 'PRT_wp_user' => $default_creator_id, |
|
136 | - ), |
|
137 | - array( |
|
138 | - '%s',//PRT_name |
|
139 | - '%d',//PBT_id |
|
140 | - '%d',//PRT_is_percent |
|
141 | - '%d',//PRT_order |
|
142 | - '%d',//PRT_deleted |
|
143 | - '%d' //PRT_wp_user |
|
144 | - ) |
|
145 | - ); |
|
146 | - if ($result) { |
|
147 | - $wpdb->insert( |
|
148 | - $price_table, |
|
149 | - array( |
|
150 | - 'PRT_ID' => $wpdb->insert_id, |
|
151 | - 'PRC_amount' => 15.00, |
|
152 | - 'PRC_name' => __("Sales Tax", "event_espresso"), |
|
153 | - 'PRC_desc' => '', |
|
154 | - 'PRC_is_default' => true, |
|
155 | - 'PRC_overrides' => null, |
|
156 | - 'PRC_deleted' => false, |
|
157 | - 'PRC_order' => 50, |
|
158 | - 'PRC_parent' => null, |
|
159 | - 'PRC_wp_user' => $default_creator_id, |
|
160 | - ), |
|
161 | - array( |
|
162 | - '%d',//PRT_id |
|
163 | - '%f',//PRC_amount |
|
164 | - '%s',//PRC_name |
|
165 | - '%s',//PRC_desc |
|
166 | - '%d',//PRC_is_default |
|
167 | - '%d',//PRC_overrides |
|
168 | - '%d',//PRC_deleted |
|
169 | - '%d',//PRC_order |
|
170 | - '%d',//PRC_parent |
|
171 | - '%d' //PRC_wp_user |
|
172 | - ) |
|
173 | - ); |
|
174 | - } |
|
175 | - } |
|
176 | - } |
|
177 | - } |
|
178 | - |
|
179 | - |
|
180 | - |
|
181 | - /** |
|
182 | - * caffeinated_modules_to_register |
|
183 | - * |
|
184 | - * @access public |
|
185 | - * @param array $modules_to_register |
|
186 | - * @return array |
|
187 | - */ |
|
188 | - public function caffeinated_modules_to_register($modules_to_register = array()) |
|
189 | - { |
|
190 | - if (is_readable(EE_CAFF_PATH . 'modules')) { |
|
191 | - $caffeinated_modules_to_register = glob(EE_CAFF_PATH . 'modules' . DS . '*', GLOB_ONLYDIR); |
|
192 | - if (is_array($caffeinated_modules_to_register) && ! empty($caffeinated_modules_to_register)) { |
|
193 | - $modules_to_register = array_merge($modules_to_register, $caffeinated_modules_to_register); |
|
194 | - } |
|
195 | - } |
|
196 | - return $modules_to_register; |
|
197 | - } |
|
198 | - |
|
199 | - |
|
200 | - |
|
201 | - public function caffeinated_init() |
|
202 | - { |
|
203 | - // EE_Register_CPTs hooks |
|
204 | - add_filter('FHEE__EE_Register_CPTs__get_taxonomies__taxonomies', array($this, 'filter_taxonomies'), 10); |
|
205 | - add_filter('FHEE__EE_Register_CPTs__get_CPTs__cpts', array($this, 'filter_cpts'), 10); |
|
206 | - add_filter('FHEE__EE_Admin__get_extra_nav_menu_pages_items', array($this, 'nav_metabox_items'), 10); |
|
207 | - EE_Registry::instance()->load_file(EE_CAFF_PATH, 'EE_Caf_Messages', 'class', array(), false); |
|
208 | - // caffeinated_init__complete hook |
|
209 | - do_action('AHEE__EE_Brewing_Regular__caffeinated_init__complete'); |
|
210 | - } |
|
211 | - |
|
212 | - |
|
213 | - |
|
214 | - public function enqueue_caffeinated_scripts() |
|
215 | - { |
|
216 | - // sound of crickets... |
|
217 | - } |
|
218 | - |
|
219 | - |
|
220 | - |
|
221 | - /** |
|
222 | - * callbacks below here |
|
223 | - * |
|
224 | - * @param array $taxonomy_array |
|
225 | - * @return array |
|
226 | - */ |
|
227 | - public function filter_taxonomies(array $taxonomy_array) |
|
228 | - { |
|
229 | - $taxonomy_array['espresso_venue_categories']['args']['show_in_nav_menus'] = true; |
|
230 | - return $taxonomy_array; |
|
231 | - } |
|
232 | - |
|
233 | - |
|
234 | - |
|
235 | - /** |
|
236 | - * @param array $cpt_array |
|
237 | - * @return mixed |
|
238 | - */ |
|
239 | - public function filter_cpts(array $cpt_array) |
|
240 | - { |
|
241 | - $cpt_array['espresso_venues']['args']['show_in_nav_menus'] = true; |
|
242 | - return $cpt_array; |
|
243 | - } |
|
244 | - |
|
245 | - |
|
246 | - |
|
247 | - /** |
|
248 | - * @param array $menuitems |
|
249 | - * @return array |
|
250 | - */ |
|
251 | - public function nav_metabox_items(array $menuitems) |
|
252 | - { |
|
253 | - $menuitems[] = array( |
|
254 | - 'title' => __('Venue List', 'event_espresso'), |
|
255 | - 'url' => get_post_type_archive_link('espresso_venues'), |
|
256 | - 'description' => __('Archive page for all venues.', 'event_espresso'), |
|
257 | - ); |
|
258 | - return $menuitems; |
|
259 | - } |
|
260 | - |
|
261 | - |
|
262 | - |
|
263 | - /** |
|
264 | - * Adds the payment methods in {event-espresso-core}/caffeinated/payment_methods |
|
265 | - * |
|
266 | - * @param array $payment_method_paths |
|
267 | - * @return array values are folder paths to payment method folders |
|
268 | - */ |
|
269 | - public function caf_payment_methods($payment_method_paths) |
|
270 | - { |
|
271 | - $caf_payment_methods_paths = glob(EE_CAF_PAYMENT_METHODS . '*', GLOB_ONLYDIR); |
|
272 | - $payment_method_paths = array_merge($payment_method_paths, $caf_payment_methods_paths); |
|
273 | - return $payment_method_paths; |
|
274 | - } |
|
275 | - |
|
276 | - |
|
277 | - |
|
278 | - /** |
|
279 | - * Gets the injected table analyzer, or throws an exception |
|
280 | - * |
|
281 | - * @return TableAnalysis |
|
282 | - * @throws \EE_Error |
|
283 | - */ |
|
284 | - protected function _get_table_analysis() |
|
285 | - { |
|
286 | - if ($this->_table_analysis instanceof TableAnalysis) { |
|
287 | - return $this->_table_analysis; |
|
288 | - } else { |
|
289 | - throw new \EE_Error( |
|
290 | - sprintf( |
|
291 | - __('Table analysis class on class %1$s is not set properly.', 'event_espresso'), |
|
292 | - get_class($this) |
|
293 | - ) |
|
294 | - ); |
|
295 | - } |
|
296 | - } |
|
30 | + /** |
|
31 | + * @var \EventEspresso\core\services\database\TableAnalysis $table_analysis |
|
32 | + */ |
|
33 | + protected $_table_analysis; |
|
34 | + |
|
35 | + |
|
36 | + |
|
37 | + /** |
|
38 | + * EE_Brewing_Regular constructor. |
|
39 | + */ |
|
40 | + public function __construct(TableAnalysis $table_analysis) |
|
41 | + { |
|
42 | + $this->_table_analysis = $table_analysis; |
|
43 | + if (defined('EE_CAFF_PATH')) { |
|
44 | + // activation |
|
45 | + add_action('AHEE__EEH_Activation__initialize_db_content', array($this, 'initialize_caf_db_content')); |
|
46 | + // load caff init |
|
47 | + add_action('AHEE__EE_System__set_hooks_for_core', array($this, 'caffeinated_init')); |
|
48 | + // remove the "powered by" credit link from receipts and invoices |
|
49 | + add_filter('FHEE_EE_Html_messenger__add_powered_by_credit_link_to_receipt_and_invoice', '__return_false'); |
|
50 | + // add caffeinated modules |
|
51 | + add_filter( |
|
52 | + 'FHEE__EE_Config__register_modules__modules_to_register', |
|
53 | + array($this, 'caffeinated_modules_to_register') |
|
54 | + ); |
|
55 | + // load caff scripts |
|
56 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_caffeinated_scripts'), 10); |
|
57 | + add_filter('FHEE__EE_Registry__load_helper__helper_paths', array($this, 'caf_helper_paths'), 10); |
|
58 | + add_filter( |
|
59 | + 'FHEE__EE_Payment_Method_Manager__register_payment_methods__payment_methods_to_register', |
|
60 | + array($this, 'caf_payment_methods') |
|
61 | + ); |
|
62 | + // caffeinated constructed |
|
63 | + do_action('AHEE__EE_Brewing_Regular__construct__finished'); |
|
64 | + //seeing how this is caf, which isn't put on WordPress.org, we can have affiliate links without a disclaimer |
|
65 | + add_filter('FHEE__ee_show_affiliate_links', '__return_false'); |
|
66 | + } |
|
67 | + } |
|
68 | + |
|
69 | + |
|
70 | + |
|
71 | + /** |
|
72 | + * callback for the FHEE__EE_Registry__load_helper__helper_paths filter to add the caffeinated paths |
|
73 | + * |
|
74 | + * @param array $paths original helper paths array |
|
75 | + * @return array new array of paths |
|
76 | + */ |
|
77 | + public function caf_helper_paths($paths) |
|
78 | + { |
|
79 | + $paths[] = EE_CAF_CORE . 'helpers' . DS; |
|
80 | + return $paths; |
|
81 | + } |
|
82 | + |
|
83 | + |
|
84 | + |
|
85 | + /** |
|
86 | + * Upon brand-new activation, if this is a new activation of CAF, we want to add |
|
87 | + * some global prices that will show off EE4's capabilities. However, if they're upgrading |
|
88 | + * from 3.1, or simply EE4.x decaf, we assume they don't want us to suddenly introduce these extra prices. |
|
89 | + * This action should only be called when EE 4.x.0.P is initially activated. |
|
90 | + * Right now the only CAF content are these global prices. If there's more in the future, then |
|
91 | + * we should probably create a caf file to contain it all instead just a function like this. |
|
92 | + * Right now, we ASSUME the only price types in the system are default ones |
|
93 | + * |
|
94 | + * @global wpdb $wpdb |
|
95 | + */ |
|
96 | + public function initialize_caf_db_content() |
|
97 | + { |
|
98 | + global $wpdb; |
|
99 | + //use same method of getting creator id as the version introducing the change |
|
100 | + $default_creator_id = apply_filters('FHEE__EE_DMS_Core_4_5_0__get_default_creator_id', get_current_user_id()); |
|
101 | + $price_type_table = $wpdb->prefix . "esp_price_type"; |
|
102 | + $price_table = $wpdb->prefix . "esp_price"; |
|
103 | + if ($this->_get_table_analysis()->tableExists($price_type_table)) { |
|
104 | + $SQL = 'SELECT COUNT(PRT_ID) FROM ' . $price_type_table . ' WHERE PBT_ID=4';//include trashed price types |
|
105 | + $tax_price_type_count = $wpdb->get_var($SQL); |
|
106 | + if ($tax_price_type_count <= 1) { |
|
107 | + $wpdb->insert( |
|
108 | + $price_type_table, |
|
109 | + array( |
|
110 | + 'PRT_name' => __("Regional Tax", "event_espresso"), |
|
111 | + 'PBT_ID' => 4, |
|
112 | + 'PRT_is_percent' => true, |
|
113 | + 'PRT_order' => 60, |
|
114 | + 'PRT_deleted' => false, |
|
115 | + 'PRT_wp_user' => $default_creator_id, |
|
116 | + ), |
|
117 | + array( |
|
118 | + '%s',//PRT_name |
|
119 | + '%d',//PBT_id |
|
120 | + '%d',//PRT_is_percent |
|
121 | + '%d',//PRT_order |
|
122 | + '%d',//PRT_deleted |
|
123 | + '%d', //PRT_wp_user |
|
124 | + ) |
|
125 | + ); |
|
126 | + //federal tax |
|
127 | + $result = $wpdb->insert( |
|
128 | + $price_type_table, |
|
129 | + array( |
|
130 | + 'PRT_name' => __("Federal Tax", "event_espresso"), |
|
131 | + 'PBT_ID' => 4, |
|
132 | + 'PRT_is_percent' => true, |
|
133 | + 'PRT_order' => 70, |
|
134 | + 'PRT_deleted' => false, |
|
135 | + 'PRT_wp_user' => $default_creator_id, |
|
136 | + ), |
|
137 | + array( |
|
138 | + '%s',//PRT_name |
|
139 | + '%d',//PBT_id |
|
140 | + '%d',//PRT_is_percent |
|
141 | + '%d',//PRT_order |
|
142 | + '%d',//PRT_deleted |
|
143 | + '%d' //PRT_wp_user |
|
144 | + ) |
|
145 | + ); |
|
146 | + if ($result) { |
|
147 | + $wpdb->insert( |
|
148 | + $price_table, |
|
149 | + array( |
|
150 | + 'PRT_ID' => $wpdb->insert_id, |
|
151 | + 'PRC_amount' => 15.00, |
|
152 | + 'PRC_name' => __("Sales Tax", "event_espresso"), |
|
153 | + 'PRC_desc' => '', |
|
154 | + 'PRC_is_default' => true, |
|
155 | + 'PRC_overrides' => null, |
|
156 | + 'PRC_deleted' => false, |
|
157 | + 'PRC_order' => 50, |
|
158 | + 'PRC_parent' => null, |
|
159 | + 'PRC_wp_user' => $default_creator_id, |
|
160 | + ), |
|
161 | + array( |
|
162 | + '%d',//PRT_id |
|
163 | + '%f',//PRC_amount |
|
164 | + '%s',//PRC_name |
|
165 | + '%s',//PRC_desc |
|
166 | + '%d',//PRC_is_default |
|
167 | + '%d',//PRC_overrides |
|
168 | + '%d',//PRC_deleted |
|
169 | + '%d',//PRC_order |
|
170 | + '%d',//PRC_parent |
|
171 | + '%d' //PRC_wp_user |
|
172 | + ) |
|
173 | + ); |
|
174 | + } |
|
175 | + } |
|
176 | + } |
|
177 | + } |
|
178 | + |
|
179 | + |
|
180 | + |
|
181 | + /** |
|
182 | + * caffeinated_modules_to_register |
|
183 | + * |
|
184 | + * @access public |
|
185 | + * @param array $modules_to_register |
|
186 | + * @return array |
|
187 | + */ |
|
188 | + public function caffeinated_modules_to_register($modules_to_register = array()) |
|
189 | + { |
|
190 | + if (is_readable(EE_CAFF_PATH . 'modules')) { |
|
191 | + $caffeinated_modules_to_register = glob(EE_CAFF_PATH . 'modules' . DS . '*', GLOB_ONLYDIR); |
|
192 | + if (is_array($caffeinated_modules_to_register) && ! empty($caffeinated_modules_to_register)) { |
|
193 | + $modules_to_register = array_merge($modules_to_register, $caffeinated_modules_to_register); |
|
194 | + } |
|
195 | + } |
|
196 | + return $modules_to_register; |
|
197 | + } |
|
198 | + |
|
199 | + |
|
200 | + |
|
201 | + public function caffeinated_init() |
|
202 | + { |
|
203 | + // EE_Register_CPTs hooks |
|
204 | + add_filter('FHEE__EE_Register_CPTs__get_taxonomies__taxonomies', array($this, 'filter_taxonomies'), 10); |
|
205 | + add_filter('FHEE__EE_Register_CPTs__get_CPTs__cpts', array($this, 'filter_cpts'), 10); |
|
206 | + add_filter('FHEE__EE_Admin__get_extra_nav_menu_pages_items', array($this, 'nav_metabox_items'), 10); |
|
207 | + EE_Registry::instance()->load_file(EE_CAFF_PATH, 'EE_Caf_Messages', 'class', array(), false); |
|
208 | + // caffeinated_init__complete hook |
|
209 | + do_action('AHEE__EE_Brewing_Regular__caffeinated_init__complete'); |
|
210 | + } |
|
211 | + |
|
212 | + |
|
213 | + |
|
214 | + public function enqueue_caffeinated_scripts() |
|
215 | + { |
|
216 | + // sound of crickets... |
|
217 | + } |
|
218 | + |
|
219 | + |
|
220 | + |
|
221 | + /** |
|
222 | + * callbacks below here |
|
223 | + * |
|
224 | + * @param array $taxonomy_array |
|
225 | + * @return array |
|
226 | + */ |
|
227 | + public function filter_taxonomies(array $taxonomy_array) |
|
228 | + { |
|
229 | + $taxonomy_array['espresso_venue_categories']['args']['show_in_nav_menus'] = true; |
|
230 | + return $taxonomy_array; |
|
231 | + } |
|
232 | + |
|
233 | + |
|
234 | + |
|
235 | + /** |
|
236 | + * @param array $cpt_array |
|
237 | + * @return mixed |
|
238 | + */ |
|
239 | + public function filter_cpts(array $cpt_array) |
|
240 | + { |
|
241 | + $cpt_array['espresso_venues']['args']['show_in_nav_menus'] = true; |
|
242 | + return $cpt_array; |
|
243 | + } |
|
244 | + |
|
245 | + |
|
246 | + |
|
247 | + /** |
|
248 | + * @param array $menuitems |
|
249 | + * @return array |
|
250 | + */ |
|
251 | + public function nav_metabox_items(array $menuitems) |
|
252 | + { |
|
253 | + $menuitems[] = array( |
|
254 | + 'title' => __('Venue List', 'event_espresso'), |
|
255 | + 'url' => get_post_type_archive_link('espresso_venues'), |
|
256 | + 'description' => __('Archive page for all venues.', 'event_espresso'), |
|
257 | + ); |
|
258 | + return $menuitems; |
|
259 | + } |
|
260 | + |
|
261 | + |
|
262 | + |
|
263 | + /** |
|
264 | + * Adds the payment methods in {event-espresso-core}/caffeinated/payment_methods |
|
265 | + * |
|
266 | + * @param array $payment_method_paths |
|
267 | + * @return array values are folder paths to payment method folders |
|
268 | + */ |
|
269 | + public function caf_payment_methods($payment_method_paths) |
|
270 | + { |
|
271 | + $caf_payment_methods_paths = glob(EE_CAF_PAYMENT_METHODS . '*', GLOB_ONLYDIR); |
|
272 | + $payment_method_paths = array_merge($payment_method_paths, $caf_payment_methods_paths); |
|
273 | + return $payment_method_paths; |
|
274 | + } |
|
275 | + |
|
276 | + |
|
277 | + |
|
278 | + /** |
|
279 | + * Gets the injected table analyzer, or throws an exception |
|
280 | + * |
|
281 | + * @return TableAnalysis |
|
282 | + * @throws \EE_Error |
|
283 | + */ |
|
284 | + protected function _get_table_analysis() |
|
285 | + { |
|
286 | + if ($this->_table_analysis instanceof TableAnalysis) { |
|
287 | + return $this->_table_analysis; |
|
288 | + } else { |
|
289 | + throw new \EE_Error( |
|
290 | + sprintf( |
|
291 | + __('Table analysis class on class %1$s is not set properly.', 'event_espresso'), |
|
292 | + get_class($this) |
|
293 | + ) |
|
294 | + ); |
|
295 | + } |
|
296 | + } |
|
297 | 297 | } |
298 | 298 | |
299 | 299 | |
300 | 300 | |
301 | 301 | $brewing = new EE_Brewing_Regular( |
302 | - EE_Registry::instance()->create('TableAnalysis', array(), true) |
|
302 | + EE_Registry::instance()->create('TableAnalysis', array(), true) |
|
303 | 303 | ); |
@@ -955,17 +955,17 @@ |
||
955 | 955 | |
956 | 956 | |
957 | 957 | function ee_deprecate_AHEE__EE_Brewing_Regular__construct__complete() { |
958 | - if (has_action('AHEE__EE_Brewing_Regular__construct__complete')) { |
|
959 | - EE_Error::doing_it_wrong( |
|
960 | - 'Action Hook: AHEE__EE_Brewing_Regular__construct__complete', |
|
961 | - esc_html__( |
|
962 | - 'This action has been replaced by `AHEE__EE_Brewing_Regular__construct_finished` which executes at plugins_loaded priority 1. Your callback hooking into this action is still being executed at plugins_loaded priority level 5 but no longer immediately at the end of the EE_Brewing_Regular::construct.', |
|
963 | - 'event_espresso' |
|
964 | - ), |
|
965 | - '4.9.22.p' |
|
966 | - ); |
|
967 | - } |
|
968 | - do_action( 'AHEE__EE_Brewing_Regular__construct__complete' ); |
|
958 | + if (has_action('AHEE__EE_Brewing_Regular__construct__complete')) { |
|
959 | + EE_Error::doing_it_wrong( |
|
960 | + 'Action Hook: AHEE__EE_Brewing_Regular__construct__complete', |
|
961 | + esc_html__( |
|
962 | + 'This action has been replaced by `AHEE__EE_Brewing_Regular__construct_finished` which executes at plugins_loaded priority 1. Your callback hooking into this action is still being executed at plugins_loaded priority level 5 but no longer immediately at the end of the EE_Brewing_Regular::construct.', |
|
963 | + 'event_espresso' |
|
964 | + ), |
|
965 | + '4.9.22.p' |
|
966 | + ); |
|
967 | + } |
|
968 | + do_action( 'AHEE__EE_Brewing_Regular__construct__complete' ); |
|
969 | 969 | } |
970 | 970 | add_action( 'AHEE__EE_System__load_core_configuration__complete', 'ee_deprecate_AHEE__EE_Brewing_Regular__construct__complete' ); |
971 | 971 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'No direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('No direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | /** |
6 | 6 | * ************************************************************************ |
@@ -43,8 +43,8 @@ discard block |
||
43 | 43 | $action_or_filter = 'action' |
44 | 44 | ) { |
45 | 45 | $action_or_filter = $action_or_filter === 'action' |
46 | - ? esc_html__( 'action', 'event_espresso' ) |
|
47 | - : esc_html__( 'filter', 'event_espresso' ); |
|
46 | + ? esc_html__('action', 'event_espresso') |
|
47 | + : esc_html__('filter', 'event_espresso'); |
|
48 | 48 | EE_Error::doing_it_wrong( |
49 | 49 | $deprecated_filter, |
50 | 50 | sprintf( |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | * @param \EE_Checkout $checkout |
69 | 69 | * @return string |
70 | 70 | */ |
71 | -function ee_deprecated__registration_checkout__button_text( $submit_button_text, EE_Checkout $checkout ) { |
|
71 | +function ee_deprecated__registration_checkout__button_text($submit_button_text, EE_Checkout $checkout) { |
|
72 | 72 | // list of old filters |
73 | 73 | $deprecated_filters = array( |
74 | 74 | 'update_registration_details' => true, |
@@ -78,16 +78,16 @@ discard block |
||
78 | 78 | 'proceed_to' => true, |
79 | 79 | ); |
80 | 80 | // loop thru and call doing_it_wrong() or remove any that aren't being used |
81 | - foreach ( $deprecated_filters as $deprecated_filter => $on ) { |
|
81 | + foreach ($deprecated_filters as $deprecated_filter => $on) { |
|
82 | 82 | // was this filter called ? |
83 | - if ( has_action( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter )) { |
|
83 | + if (has_action('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__'.$deprecated_filter)) { |
|
84 | 84 | // only display doing_it_wrong() notice to Event Admins during non-AJAX requests |
85 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_ee', 'hide_doing_it_wrong_for_deprecated_SPCO_filter' ) && ! defined( 'DOING_AJAX' ) ) { |
|
85 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_ee', 'hide_doing_it_wrong_for_deprecated_SPCO_filter') && ! defined('DOING_AJAX')) { |
|
86 | 86 | EE_Error::doing_it_wrong( |
87 | - 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter, |
|
87 | + 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__'.$deprecated_filter, |
|
88 | 88 | sprintf( |
89 | - __( 'The %1$s filter is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use the following new filter: %2$s"%3$s" found in "%4$s"', 'event_espresso' ), |
|
90 | - 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter, |
|
89 | + __('The %1$s filter is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use the following new filter: %2$s"%3$s" found in "%4$s"', 'event_espresso'), |
|
90 | + 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__'.$deprecated_filter, |
|
91 | 91 | '<br />', |
92 | 92 | 'FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text', |
93 | 93 | '/modules/single_page_checkout/inc/EE_SPCO_Reg_Step.class.php' |
@@ -96,24 +96,24 @@ discard block |
||
96 | 96 | ); |
97 | 97 | } |
98 | 98 | } else { |
99 | - unset( $deprecated_filters[ $deprecated_filter ] ); |
|
99 | + unset($deprecated_filters[$deprecated_filter]); |
|
100 | 100 | } |
101 | 101 | } |
102 | - if ( ! empty( $deprecated_filters )) { |
|
103 | - |
|
104 | - if ( $checkout->current_step->slug() == 'attendee_information' && $checkout->revisit && isset( $deprecated_filters[ 'update_registration_details' ] )) { |
|
105 | - $submit_button_text = apply_filters( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__update_registration_details', $submit_button_text ); |
|
106 | - } else if ( $checkout->current_step->slug() == 'payment_options' && $checkout->revisit && isset( $deprecated_filters[ 'process_payment' ] ) ) { |
|
107 | - $submit_button_text = apply_filters( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__process_payment', $submit_button_text ); |
|
108 | - } else if ( $checkout->next_step instanceof EE_SPCO_Reg_Step && $checkout->next_step->slug() == 'finalize_registration' && isset( $deprecated_filters[ 'finalize_registration' ] ) ) { |
|
109 | - $submit_button_text = apply_filters( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__finalize_registration', $submit_button_text ); |
|
102 | + if ( ! empty($deprecated_filters)) { |
|
103 | + |
|
104 | + if ($checkout->current_step->slug() == 'attendee_information' && $checkout->revisit && isset($deprecated_filters['update_registration_details'])) { |
|
105 | + $submit_button_text = apply_filters('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__update_registration_details', $submit_button_text); |
|
106 | + } else if ($checkout->current_step->slug() == 'payment_options' && $checkout->revisit && isset($deprecated_filters['process_payment'])) { |
|
107 | + $submit_button_text = apply_filters('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__process_payment', $submit_button_text); |
|
108 | + } else if ($checkout->next_step instanceof EE_SPCO_Reg_Step && $checkout->next_step->slug() == 'finalize_registration' && isset($deprecated_filters['finalize_registration'])) { |
|
109 | + $submit_button_text = apply_filters('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__finalize_registration', $submit_button_text); |
|
110 | 110 | } |
111 | - if ( $checkout->next_step instanceof EE_SPCO_Reg_Step ) { |
|
112 | - if ( $checkout->payment_required() && $checkout->next_step->slug() == 'payment_options' && isset( $deprecated_filters[ 'and_proceed_to_payment' ] ) ) { |
|
113 | - $submit_button_text .= apply_filters( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__and_proceed_to_payment', $submit_button_text ); |
|
111 | + if ($checkout->next_step instanceof EE_SPCO_Reg_Step) { |
|
112 | + if ($checkout->payment_required() && $checkout->next_step->slug() == 'payment_options' && isset($deprecated_filters['and_proceed_to_payment'])) { |
|
113 | + $submit_button_text .= apply_filters('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__and_proceed_to_payment', $submit_button_text); |
|
114 | 114 | } |
115 | - if ( $checkout->next_step->slug() != 'finalize_registration' && ! $checkout->revisit && isset( $deprecated_filters[ 'proceed_to' ] ) ) { |
|
116 | - $submit_button_text = apply_filters( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__proceed_to', $submit_button_text ) . $checkout->next_step->name(); |
|
115 | + if ($checkout->next_step->slug() != 'finalize_registration' && ! $checkout->revisit && isset($deprecated_filters['proceed_to'])) { |
|
116 | + $submit_button_text = apply_filters('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__proceed_to', $submit_button_text).$checkout->next_step->name(); |
|
117 | 117 | } |
118 | 118 | } |
119 | 119 | |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | return $submit_button_text; |
122 | 122 | |
123 | 123 | } |
124 | -add_filter( 'FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text', 'ee_deprecated__registration_checkout__button_text', 10, 2 ); |
|
124 | +add_filter('FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text', 'ee_deprecated__registration_checkout__button_text', 10, 2); |
|
125 | 125 | |
126 | 126 | |
127 | 127 | |
@@ -132,16 +132,16 @@ discard block |
||
132 | 132 | * @param \EE_Checkout $checkout |
133 | 133 | * @param boolean $status_updates |
134 | 134 | */ |
135 | -function ee_deprecated_finalize_transaction( EE_Checkout $checkout, $status_updates ) { |
|
135 | +function ee_deprecated_finalize_transaction(EE_Checkout $checkout, $status_updates) { |
|
136 | 136 | $action_ref = NULL; |
137 | - $action_ref = has_action( 'AHEE__EE_Transaction__finalize__new_transaction' ) ? 'AHEE__EE_Transaction__finalize__new_transaction' : $action_ref; |
|
138 | - $action_ref = has_action( 'AHEE__EE_Transaction__finalize__all_transaction' ) ? 'AHEE__EE_Transaction__finalize__all_transaction' : $action_ref; |
|
139 | - if ( $action_ref ) { |
|
137 | + $action_ref = has_action('AHEE__EE_Transaction__finalize__new_transaction') ? 'AHEE__EE_Transaction__finalize__new_transaction' : $action_ref; |
|
138 | + $action_ref = has_action('AHEE__EE_Transaction__finalize__all_transaction') ? 'AHEE__EE_Transaction__finalize__all_transaction' : $action_ref; |
|
139 | + if ($action_ref) { |
|
140 | 140 | |
141 | 141 | EE_Error::doing_it_wrong( |
142 | 142 | $action_ref, |
143 | 143 | sprintf( |
144 | - __( 'This action is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use one of the following new actions: %1$s"%3$s" found in "%2$s" %1$s"%4$s" found in "%2$s" %1$s"%5$s" found in "%2$s" %1$s"%6$s" found in "%2$s"', 'event_espresso' ), |
|
144 | + __('This action is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use one of the following new actions: %1$s"%3$s" found in "%2$s" %1$s"%4$s" found in "%2$s" %1$s"%5$s" found in "%2$s" %1$s"%6$s" found in "%2$s"', 'event_espresso'), |
|
145 | 145 | '<br />', |
146 | 146 | '/core/business/EE_Transaction_Processor.class.php', |
147 | 147 | 'AHEE__EE_Transaction_Processor__finalize', |
@@ -151,39 +151,39 @@ discard block |
||
151 | 151 | ), |
152 | 152 | '4.6.0' |
153 | 153 | ); |
154 | - switch ( $action_ref ) { |
|
154 | + switch ($action_ref) { |
|
155 | 155 | case 'AHEE__EE_Transaction__finalize__new_transaction' : |
156 | - do_action( 'AHEE__EE_Transaction__finalize__new_transaction', $checkout->transaction, $checkout->admin_request ); |
|
156 | + do_action('AHEE__EE_Transaction__finalize__new_transaction', $checkout->transaction, $checkout->admin_request); |
|
157 | 157 | break; |
158 | 158 | case 'AHEE__EE_Transaction__finalize__all_transaction' : |
159 | - do_action( 'AHEE__EE_Transaction__finalize__new_transaction', $checkout->transaction, array( 'new_reg' => ! $checkout->revisit, 'to_approved' => $status_updates ), $checkout->admin_request ); |
|
159 | + do_action('AHEE__EE_Transaction__finalize__new_transaction', $checkout->transaction, array('new_reg' => ! $checkout->revisit, 'to_approved' => $status_updates), $checkout->admin_request); |
|
160 | 160 | break; |
161 | 161 | } |
162 | 162 | } |
163 | 163 | } |
164 | -add_action( 'AHEE__EE_SPCO_Reg_Step_Finalize_Registration__process_reg_step__completed', 'ee_deprecated_finalize_transaction', 10, 2 ); |
|
164 | +add_action('AHEE__EE_SPCO_Reg_Step_Finalize_Registration__process_reg_step__completed', 'ee_deprecated_finalize_transaction', 10, 2); |
|
165 | 165 | /** |
166 | 166 | * ee_deprecated_finalize_registration |
167 | 167 | * |
168 | 168 | * @param EE_Registration $registration |
169 | 169 | */ |
170 | -function ee_deprecated_finalize_registration( EE_Registration $registration ) { |
|
171 | - $action_ref = has_action( 'AHEE__EE_Registration__finalize__update_and_new_reg' ) ? 'AHEE__EE_Registration__finalize__update_and_new_reg' : NULL; |
|
172 | - if ( $action_ref ) { |
|
170 | +function ee_deprecated_finalize_registration(EE_Registration $registration) { |
|
171 | + $action_ref = has_action('AHEE__EE_Registration__finalize__update_and_new_reg') ? 'AHEE__EE_Registration__finalize__update_and_new_reg' : NULL; |
|
172 | + if ($action_ref) { |
|
173 | 173 | EE_Error::doing_it_wrong( |
174 | 174 | $action_ref, |
175 | 175 | sprintf( |
176 | - __( 'This action is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use the following new action: %1$s"%3$s" found in "%2$s"', 'event_espresso' ), |
|
176 | + __('This action is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use the following new action: %1$s"%3$s" found in "%2$s"', 'event_espresso'), |
|
177 | 177 | '<br />', |
178 | 178 | '/core/business/EE_Registration_Processor.class.php', |
179 | 179 | 'AHEE__EE_Registration_Processor__trigger_registration_status_changed_hook' |
180 | 180 | ), |
181 | 181 | '4.6.0' |
182 | 182 | ); |
183 | - do_action( 'AHEE__EE_Registration__finalize__update_and_new_reg', $registration, ( is_admin() && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ))); |
|
183 | + do_action('AHEE__EE_Registration__finalize__update_and_new_reg', $registration, (is_admin() && ! (defined('DOING_AJAX') && DOING_AJAX))); |
|
184 | 184 | } |
185 | 185 | } |
186 | -add_action( 'AHEE__EE_Registration_Processor__trigger_registration_update_notifications', 'ee_deprecated_finalize_registration', 10, 1 ); |
|
186 | +add_action('AHEE__EE_Registration_Processor__trigger_registration_update_notifications', 'ee_deprecated_finalize_registration', 10, 1); |
|
187 | 187 | |
188 | 188 | |
189 | 189 | |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | * Called after EED_Module::set_hooks() and EED_Module::set_admin_hooks() was called. |
192 | 192 | * Checks if any deprecated hooks were hooked-into and provide doing_it_wrong messages appropriately. |
193 | 193 | */ |
194 | -function ee_deprecated_hooks(){ |
|
194 | +function ee_deprecated_hooks() { |
|
195 | 195 | /** |
196 | 196 | * @var $hooks array where keys are hook names, and their values are array{ |
197 | 197 | * @type string $version when deprecated |
@@ -202,25 +202,25 @@ discard block |
||
202 | 202 | $hooks = array( |
203 | 203 | 'AHEE__EE_System___do_setup_validations' => array( |
204 | 204 | 'version' => '4.6.0', |
205 | - 'alternative' => __( 'Instead use "AHEE__EEH_Activation__validate_messages_system" which is called after validating messages (done on every new install, upgrade, reactivation, and downgrade)', 'event_espresso' ), |
|
205 | + 'alternative' => __('Instead use "AHEE__EEH_Activation__validate_messages_system" which is called after validating messages (done on every new install, upgrade, reactivation, and downgrade)', 'event_espresso'), |
|
206 | 206 | 'still_works' => FALSE |
207 | 207 | ) |
208 | 208 | ); |
209 | - foreach( $hooks as $name => $deprecation_info ){ |
|
210 | - if( has_action( $name ) ){ |
|
209 | + foreach ($hooks as $name => $deprecation_info) { |
|
210 | + if (has_action($name)) { |
|
211 | 211 | EE_Error::doing_it_wrong( |
212 | 212 | $name, |
213 | 213 | sprintf( |
214 | - __('This filter is deprecated. %1$s%2$s','event_espresso'), |
|
215 | - $deprecation_info[ 'still_works' ] ? __('It *may* work as an attempt to build in backwards compatibility.', 'event_espresso') : __( 'It has been completely removed.', 'event_espresso' ), |
|
216 | - isset( $deprecation_info[ 'alternative' ] ) ? $deprecation_info[ 'alternative' ] : __( 'Please read the current EE4 documentation further or contact Support.', 'event_espresso' ) |
|
214 | + __('This filter is deprecated. %1$s%2$s', 'event_espresso'), |
|
215 | + $deprecation_info['still_works'] ? __('It *may* work as an attempt to build in backwards compatibility.', 'event_espresso') : __('It has been completely removed.', 'event_espresso'), |
|
216 | + isset($deprecation_info['alternative']) ? $deprecation_info['alternative'] : __('Please read the current EE4 documentation further or contact Support.', 'event_espresso') |
|
217 | 217 | ), |
218 | - isset( $deprecation_info[ 'version' ] ) ? $deprecation_info[ 'version' ] : __( 'recently', 'event_espresso' ) |
|
218 | + isset($deprecation_info['version']) ? $deprecation_info['version'] : __('recently', 'event_espresso') |
|
219 | 219 | ); |
220 | 220 | } |
221 | 221 | } |
222 | 222 | } |
223 | -add_action( 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', 'ee_deprecated_hooks' ); |
|
223 | +add_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', 'ee_deprecated_hooks'); |
|
224 | 224 | |
225 | 225 | |
226 | 226 | |
@@ -231,9 +231,9 @@ discard block |
||
231 | 231 | * @return boolean |
232 | 232 | */ |
233 | 233 | function ee_deprecated_using_old_registration_admin_custom_questions_form_hooks() { |
234 | - $in_use = has_filter( 'FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns' ) |
|
235 | - || has_action( 'AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save' ); |
|
236 | - if( $in_use ) { |
|
234 | + $in_use = has_filter('FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns') |
|
235 | + || has_action('AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save'); |
|
236 | + if ($in_use) { |
|
237 | 237 | $msg = __( |
238 | 238 | 'We detected you are using the filter FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns or AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save.' |
239 | 239 | . 'Both of these have been deprecated and should not be used anymore. You should instead use FHEE__EE_Form_Section_Proper___construct__options_array to customize the contents of the form,' |
@@ -242,18 +242,18 @@ discard block |
||
242 | 242 | 'event_espresso' ) |
243 | 243 | ; |
244 | 244 | EE_Error::doing_it_wrong( |
245 | - __CLASS__ . '::' . __FUNCTION__, |
|
245 | + __CLASS__.'::'.__FUNCTION__, |
|
246 | 246 | $msg, |
247 | 247 | '4.8.32.rc.000' |
248 | 248 | ); |
249 | 249 | //it seems the doing_it_wrong messages get output during some hidden html tags, so add an error to make sure this gets noticed |
250 | - if ( is_admin() && ! defined( 'DOING_AJAX' ) ) { |
|
251 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
250 | + if (is_admin() && ! defined('DOING_AJAX')) { |
|
251 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
252 | 252 | } |
253 | 253 | } |
254 | 254 | return $in_use; |
255 | 255 | } |
256 | -add_action( 'AHEE__Registrations_Admin_Page___registration_details_metabox__start', 'ee_deprecated_using_old_registration_admin_custom_questions_form_hooks' ); |
|
256 | +add_action('AHEE__Registrations_Admin_Page___registration_details_metabox__start', 'ee_deprecated_using_old_registration_admin_custom_questions_form_hooks'); |
|
257 | 257 | |
258 | 258 | /** |
259 | 259 | * @deprecated since 4.8.32.rc.000 because it has issues on https://events.codebasehq.com/projects/event-espresso/tickets/9165 |
@@ -262,34 +262,34 @@ discard block |
||
262 | 262 | * @param EE_Admin_Page $admin_page |
263 | 263 | * @return void |
264 | 264 | */ |
265 | -function ee_deprecated_update_attendee_registration_form_old( $admin_page ) { |
|
265 | +function ee_deprecated_update_attendee_registration_form_old($admin_page) { |
|
266 | 266 | //check if the old hooks are in use. If not, do the default |
267 | - if( ! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks() |
|
268 | - || ! $admin_page instanceof EE_Admin_Page ) { |
|
267 | + if ( ! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks() |
|
268 | + || ! $admin_page instanceof EE_Admin_Page) { |
|
269 | 269 | return; |
270 | 270 | } |
271 | 271 | $req_data = $admin_page->get_request_data(); |
272 | - $qstns = isset( $req_data['qstn'] ) ? $req_data['qstn'] : FALSE; |
|
273 | - $REG_ID = isset( $req_data['_REG_ID'] ) ? absint( $req_data['_REG_ID'] ) : FALSE; |
|
274 | - $qstns = apply_filters( 'FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns', $qstns ); |
|
275 | - if ( ! $REG_ID || ! $qstns ) { |
|
276 | - EE_Error::add_error( __('An error occurred. No registration ID and/or registration questions were received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
272 | + $qstns = isset($req_data['qstn']) ? $req_data['qstn'] : FALSE; |
|
273 | + $REG_ID = isset($req_data['_REG_ID']) ? absint($req_data['_REG_ID']) : FALSE; |
|
274 | + $qstns = apply_filters('FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns', $qstns); |
|
275 | + if ( ! $REG_ID || ! $qstns) { |
|
276 | + EE_Error::add_error(__('An error occurred. No registration ID and/or registration questions were received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
277 | 277 | } |
278 | 278 | $success = TRUE; |
279 | 279 | |
280 | 280 | // allow others to get in on this awesome fun :D |
281 | - do_action( 'AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save', $REG_ID, $qstns ); |
|
281 | + do_action('AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save', $REG_ID, $qstns); |
|
282 | 282 | // loop thru questions... FINALLY!!! |
283 | 283 | |
284 | - foreach ( $qstns as $QST_ID => $qstn ) { |
|
284 | + foreach ($qstns as $QST_ID => $qstn) { |
|
285 | 285 | //if $qstn isn't an array then it doesn't already have an answer, so let's create the answer |
286 | - if ( !is_array($qstn) ) { |
|
287 | - $success = $this->_save_new_answer( $REG_ID, $QST_ID, $qstn); |
|
286 | + if ( ! is_array($qstn)) { |
|
287 | + $success = $this->_save_new_answer($REG_ID, $QST_ID, $qstn); |
|
288 | 288 | continue; |
289 | 289 | } |
290 | 290 | |
291 | 291 | |
292 | - foreach ( $qstn as $ANS_ID => $ANS_value ) { |
|
292 | + foreach ($qstn as $ANS_ID => $ANS_value) { |
|
293 | 293 | //get answer |
294 | 294 | $query_params = array( |
295 | 295 | 0 => array( |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | ); |
301 | 301 | $answer = EEM_Answer::instance()->get_one($query_params); |
302 | 302 | //this MAY be an array but NOT have an answer because its multi select. If so then we need to create the answer |
303 | - if ( ! $answer instanceof EE_Answer ) { |
|
303 | + if ( ! $answer instanceof EE_Answer) { |
|
304 | 304 | $set_values = array( |
305 | 305 | 'QST_ID' => $QST_ID, |
306 | 306 | 'REG_ID' => $REG_ID, |
@@ -315,11 +315,11 @@ discard block |
||
315 | 315 | } |
316 | 316 | } |
317 | 317 | $what = __('Registration Form', 'event_espresso'); |
318 | - $route = $REG_ID ? array( 'action' => 'view_registration', '_REG_ID' => $REG_ID ) : array( 'action' => 'default' ); |
|
319 | - $admin_page->redirect_after_action( $success, $what, __('updated', 'event_espresso'), $route ); |
|
318 | + $route = $REG_ID ? array('action' => 'view_registration', '_REG_ID' => $REG_ID) : array('action' => 'default'); |
|
319 | + $admin_page->redirect_after_action($success, $what, __('updated', 'event_espresso'), $route); |
|
320 | 320 | exit; |
321 | 321 | } |
322 | -add_action( 'AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', 'ee_deprecated_update_attendee_registration_form_old', 10, 1 ); |
|
322 | +add_action('AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', 'ee_deprecated_update_attendee_registration_form_old', 10, 1); |
|
323 | 323 | /** |
324 | 324 | * Render the registration admin page's custom questions area in the old fashion |
325 | 325 | * and firing the old hooks. When this method is removed, we can probably also |
@@ -332,31 +332,31 @@ discard block |
||
332 | 332 | * @return bool |
333 | 333 | * @throws \EE_Error |
334 | 334 | */ |
335 | -function ee_deprecated_reg_questions_meta_box_old( $do_default_action, $admin_page, $registration ) { |
|
335 | +function ee_deprecated_reg_questions_meta_box_old($do_default_action, $admin_page, $registration) { |
|
336 | 336 | //check if the old hooks are in use. If not, do the default |
337 | - if( ! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks() |
|
338 | - || ! $admin_page instanceof EE_Admin_Page ) { |
|
337 | + if ( ! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks() |
|
338 | + || ! $admin_page instanceof EE_Admin_Page) { |
|
339 | 339 | return $do_default_action; |
340 | 340 | } |
341 | - add_filter( 'FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', array( $admin_page, 'form_before_question_group' ), 10, 1 ); |
|
342 | - add_filter( 'FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', array( $admin_page, 'form_after_question_group' ), 10, 1 ); |
|
343 | - add_filter( 'FHEE__EEH_Form_Fields__label_html', array( $admin_page, 'form_form_field_label_wrap' ), 10, 1 ); |
|
344 | - add_filter( 'FHEE__EEH_Form_Fields__input_html', array( $admin_page, 'form_form_field_input__wrap' ), 10, 1 ); |
|
341 | + add_filter('FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', array($admin_page, 'form_before_question_group'), 10, 1); |
|
342 | + add_filter('FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', array($admin_page, 'form_after_question_group'), 10, 1); |
|
343 | + add_filter('FHEE__EEH_Form_Fields__label_html', array($admin_page, 'form_form_field_label_wrap'), 10, 1); |
|
344 | + add_filter('FHEE__EEH_Form_Fields__input_html', array($admin_page, 'form_form_field_input__wrap'), 10, 1); |
|
345 | 345 | |
346 | - $question_groups = EEM_Event::instance()->assemble_array_of_groups_questions_and_options( $registration, $registration->get('EVT_ID') ); |
|
346 | + $question_groups = EEM_Event::instance()->assemble_array_of_groups_questions_and_options($registration, $registration->get('EVT_ID')); |
|
347 | 347 | |
348 | - EE_Registry::instance()->load_helper( 'Form_Fields' ); |
|
348 | + EE_Registry::instance()->load_helper('Form_Fields'); |
|
349 | 349 | $template_args = array( |
350 | - 'att_questions' => EEH_Form_Fields::generate_question_groups_html( $question_groups ), |
|
350 | + 'att_questions' => EEH_Form_Fields::generate_question_groups_html($question_groups), |
|
351 | 351 | 'reg_questions_form_action' => 'edit_registration', |
352 | 352 | 'REG_ID' => $registration->ID() |
353 | 353 | ); |
354 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php'; |
|
355 | - echo EEH_Template::display_template( $template_path, $template_args, TRUE ); |
|
354 | + $template_path = REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_reg_questions.template.php'; |
|
355 | + echo EEH_Template::display_template($template_path, $template_args, TRUE); |
|
356 | 356 | //indicate that we should not do the default admin page code |
357 | 357 | return false; |
358 | 358 | } |
359 | -add_action( 'FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default', 'ee_deprecated_reg_questions_meta_box_old', 10, 3 ); |
|
359 | +add_action('FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default', 'ee_deprecated_reg_questions_meta_box_old', 10, 3); |
|
360 | 360 | |
361 | 361 | |
362 | 362 | |
@@ -397,9 +397,9 @@ discard block |
||
397 | 397 | '4.9.0' |
398 | 398 | ); |
399 | 399 | /** @var EE_Message_Resource_Manager $message_resource_manager */ |
400 | - $message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
401 | - $messenger = $message_resource_manager->get_messenger( $messenger_name ); |
|
402 | - $message_type = $message_resource_manager->get_message_type( $message_type_name ); |
|
400 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
401 | + $messenger = $message_resource_manager->get_messenger($messenger_name); |
|
402 | + $message_type = $message_resource_manager->get_message_type($message_type_name); |
|
403 | 403 | return EE_Registry::instance()->load_lib( |
404 | 404 | 'Messages_Template_Defaults', |
405 | 405 | array( |
@@ -464,15 +464,15 @@ discard block |
||
464 | 464 | /** |
465 | 465 | * @param string $method |
466 | 466 | */ |
467 | - public function _class_is_deprecated( $method ) { |
|
467 | + public function _class_is_deprecated($method) { |
|
468 | 468 | EE_Error::doing_it_wrong( |
469 | - 'EE_messages::' . $method, |
|
470 | - __( 'EE_messages has been deprecated. Please use EE_Message_Resource_Manager instead.' ), |
|
469 | + 'EE_messages::'.$method, |
|
470 | + __('EE_messages has been deprecated. Please use EE_Message_Resource_Manager instead.'), |
|
471 | 471 | '4.9.0', |
472 | 472 | '4.10.0.p' |
473 | 473 | ); |
474 | 474 | // Please use EE_Message_Resource_Manager instead |
475 | - $this->_message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
475 | + $this->_message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
476 | 476 | } |
477 | 477 | |
478 | 478 | |
@@ -482,10 +482,10 @@ discard block |
||
482 | 482 | * @param string $messenger_name |
483 | 483 | * @return boolean TRUE if it was PREVIOUSLY active, and FALSE if it was previously inactive |
484 | 484 | */ |
485 | - public function ensure_messenger_is_active( $messenger_name ) { |
|
485 | + public function ensure_messenger_is_active($messenger_name) { |
|
486 | 486 | // EE_messages has been deprecated |
487 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
488 | - return $this->_message_resource_manager->ensure_messenger_is_active( $messenger_name ); |
|
487 | + $this->_class_is_deprecated(__FUNCTION__); |
|
488 | + return $this->_message_resource_manager->ensure_messenger_is_active($messenger_name); |
|
489 | 489 | } |
490 | 490 | |
491 | 491 | |
@@ -497,10 +497,10 @@ discard block |
||
497 | 497 | * @return bool true if it got activated (or was active) and false if not. |
498 | 498 | * @throws \EE_Error |
499 | 499 | */ |
500 | - public function ensure_message_type_is_active( $message_type, $messenger ) { |
|
500 | + public function ensure_message_type_is_active($message_type, $messenger) { |
|
501 | 501 | // EE_messages has been deprecated |
502 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
503 | - return $this->_message_resource_manager->ensure_message_type_is_active( $message_type, $messenger ); |
|
502 | + $this->_class_is_deprecated(__FUNCTION__); |
|
503 | + return $this->_message_resource_manager->ensure_message_type_is_active($message_type, $messenger); |
|
504 | 504 | } |
505 | 505 | |
506 | 506 | |
@@ -513,10 +513,10 @@ discard block |
||
513 | 513 | * they are already setup.) |
514 | 514 | * @return boolean an array of generated templates or false if nothing generated/activated. |
515 | 515 | */ |
516 | - public function activate_messenger( $messenger_name, $mts_to_activate = array() ) { |
|
516 | + public function activate_messenger($messenger_name, $mts_to_activate = array()) { |
|
517 | 517 | // EE_messages has been deprecated |
518 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
519 | - return $this->_message_resource_manager->activate_messenger( $messenger_name, $mts_to_activate ); |
|
518 | + $this->_class_is_deprecated(__FUNCTION__); |
|
519 | + return $this->_message_resource_manager->activate_messenger($messenger_name, $mts_to_activate); |
|
520 | 520 | } |
521 | 521 | |
522 | 522 | |
@@ -528,10 +528,10 @@ discard block |
||
528 | 528 | * |
529 | 529 | * @return bool true is a generating messenger and can be sent OR FALSE meaning cannot send. |
530 | 530 | */ |
531 | - public function is_generating_messenger_and_active( EE_messenger $messenger, EE_message_type $message_type ) { |
|
531 | + public function is_generating_messenger_and_active(EE_messenger $messenger, EE_message_type $message_type) { |
|
532 | 532 | // EE_messages has been deprecated |
533 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
534 | - return $this->_message_resource_manager->is_generating_messenger_and_active( $messenger, $message_type ); |
|
533 | + $this->_class_is_deprecated(__FUNCTION__); |
|
534 | + return $this->_message_resource_manager->is_generating_messenger_and_active($messenger, $message_type); |
|
535 | 535 | } |
536 | 536 | |
537 | 537 | |
@@ -541,10 +541,10 @@ discard block |
||
541 | 541 | * @param string $messenger |
542 | 542 | * @return EE_messenger | null |
543 | 543 | */ |
544 | - public function get_messenger_if_active( $messenger ) { |
|
544 | + public function get_messenger_if_active($messenger) { |
|
545 | 545 | // EE_messages has been deprecated |
546 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
547 | - return $this->_message_resource_manager->get_active_messenger( $messenger ); |
|
546 | + $this->_class_is_deprecated(__FUNCTION__); |
|
547 | + return $this->_message_resource_manager->get_active_messenger($messenger); |
|
548 | 548 | } |
549 | 549 | |
550 | 550 | |
@@ -565,9 +565,9 @@ discard block |
||
565 | 565 | * 'message_type' => null |
566 | 566 | * ) |
567 | 567 | */ |
568 | - public function validate_for_use( EE_Message $message ) { |
|
568 | + public function validate_for_use(EE_Message $message) { |
|
569 | 569 | // EE_messages has been deprecated |
570 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
570 | + $this->_class_is_deprecated(__FUNCTION__); |
|
571 | 571 | return array( |
572 | 572 | 'messenger' => $message->messenger_object(), |
573 | 573 | 'message_type' => $message->message_type_object(), |
@@ -595,41 +595,41 @@ discard block |
||
595 | 595 | $send = true |
596 | 596 | ) { |
597 | 597 | // EE_messages has been deprecated |
598 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
598 | + $this->_class_is_deprecated(__FUNCTION__); |
|
599 | 599 | /** @type EE_Messages_Processor $processor */ |
600 | - $processor = EE_Registry::instance()->load_lib( 'Messages_Processor' ); |
|
600 | + $processor = EE_Registry::instance()->load_lib('Messages_Processor'); |
|
601 | 601 | $error = false; |
602 | 602 | //try to intelligently determine what method we'll call based on the incoming data. |
603 | 603 | //if generating and sending are different then generate and send immediately. |
604 | - if ( ! empty( $sending_messenger ) && $sending_messenger != $generating_messenger && $send ) { |
|
604 | + if ( ! empty($sending_messenger) && $sending_messenger != $generating_messenger && $send) { |
|
605 | 605 | //in the legacy system, when generating and sending were different, that means all the |
606 | 606 | //vars are already in the request object. So let's just use that. |
607 | 607 | try { |
608 | 608 | /** @type EE_Message_To_Generate_From_Request $mtg */ |
609 | - $mtg = EE_Registry::instance()->load_lib( 'Message_To_Generate_From_Request' ); |
|
610 | - $processor->generate_and_send_now( $mtg ); |
|
611 | - } catch ( EE_Error $e ) { |
|
609 | + $mtg = EE_Registry::instance()->load_lib('Message_To_Generate_From_Request'); |
|
610 | + $processor->generate_and_send_now($mtg); |
|
611 | + } catch (EE_Error $e) { |
|
612 | 612 | $error_msg = __( |
613 | 613 | 'Please note that a system message failed to send due to a technical issue.', |
614 | 614 | 'event_espresso' |
615 | 615 | ); |
616 | 616 | // add specific message for developers if WP_DEBUG in on |
617 | - $error_msg .= '||' . $e->getMessage(); |
|
618 | - EE_Error::add_error( $error_msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
617 | + $error_msg .= '||'.$e->getMessage(); |
|
618 | + EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
619 | 619 | $error = true; |
620 | 620 | } |
621 | 621 | } else { |
622 | - $processor->generate_for_all_active_messengers( $type, $vars, $send ); |
|
622 | + $processor->generate_for_all_active_messengers($type, $vars, $send); |
|
623 | 623 | //let's find out if there were any errors and how many successfully were queued. |
624 | 624 | $count_errors = $processor->get_queue()->count_STS_in_queue( |
625 | - array( EEM_Message::status_failed, EEM_Message::status_debug_only ) |
|
625 | + array(EEM_Message::status_failed, EEM_Message::status_debug_only) |
|
626 | 626 | ); |
627 | - $count_queued = $processor->get_queue()->count_STS_in_queue( EEM_Message::status_incomplete ); |
|
628 | - $count_retry = $processor->get_queue()->count_STS_in_queue( EEM_Message::status_retry ); |
|
627 | + $count_queued = $processor->get_queue()->count_STS_in_queue(EEM_Message::status_incomplete); |
|
628 | + $count_retry = $processor->get_queue()->count_STS_in_queue(EEM_Message::status_retry); |
|
629 | 629 | $count_errors = $count_errors + $count_retry; |
630 | - if ( $count_errors > 0 ) { |
|
630 | + if ($count_errors > 0) { |
|
631 | 631 | $error = true; |
632 | - if ( $count_errors > 1 && $count_retry > 1 && $count_queued > 1 ) { |
|
632 | + if ($count_errors > 1 && $count_retry > 1 && $count_queued > 1) { |
|
633 | 633 | $message = sprintf( |
634 | 634 | __( |
635 | 635 | 'There were %d errors and %d messages successfully queued for generation and sending', |
@@ -638,7 +638,7 @@ discard block |
||
638 | 638 | $count_errors, |
639 | 639 | $count_queued |
640 | 640 | ); |
641 | - } elseif ( $count_errors > 1 && $count_queued === 1 ) { |
|
641 | + } elseif ($count_errors > 1 && $count_queued === 1) { |
|
642 | 642 | $message = sprintf( |
643 | 643 | __( |
644 | 644 | 'There were %d errors and %d message successfully queued for generation.', |
@@ -647,7 +647,7 @@ discard block |
||
647 | 647 | $count_errors, |
648 | 648 | $count_queued |
649 | 649 | ); |
650 | - } elseif ( $count_errors === 1 && $count_queued > 1 ) { |
|
650 | + } elseif ($count_errors === 1 && $count_queued > 1) { |
|
651 | 651 | $message = sprintf( |
652 | 652 | __( |
653 | 653 | 'There was %d error and %d messages successfully queued for generation.', |
@@ -665,9 +665,9 @@ discard block |
||
665 | 665 | $count_errors |
666 | 666 | ); |
667 | 667 | } |
668 | - EE_Error::add_error( $message, __FILE__, __FUNCTION__, __LINE__ ); |
|
668 | + EE_Error::add_error($message, __FILE__, __FUNCTION__, __LINE__); |
|
669 | 669 | } else { |
670 | - if ( $count_queued === 1 ) { |
|
670 | + if ($count_queued === 1) { |
|
671 | 671 | $message = sprintf( |
672 | 672 | __( |
673 | 673 | '%d message successfully queued for generation.', |
@@ -684,18 +684,18 @@ discard block |
||
684 | 684 | $count_queued |
685 | 685 | ); |
686 | 686 | } |
687 | - EE_Error::add_success( $message ); |
|
687 | + EE_Error::add_success($message); |
|
688 | 688 | } |
689 | 689 | } |
690 | 690 | //if no error then return the generated message(s). |
691 | - if ( ! $error && ! $send ) { |
|
692 | - $generated_queue = $processor->generate_queue( false ); |
|
691 | + if ( ! $error && ! $send) { |
|
692 | + $generated_queue = $processor->generate_queue(false); |
|
693 | 693 | //get message and return. |
694 | 694 | $generated_queue->get_message_repository()->rewind(); |
695 | 695 | $messages = array(); |
696 | - while ( $generated_queue->get_message_repository()->valid() ) { |
|
696 | + while ($generated_queue->get_message_repository()->valid()) { |
|
697 | 697 | $message = $generated_queue->get_message_repository()->current(); |
698 | - if ( $message instanceof EE_Message ) { |
|
698 | + if ($message instanceof EE_Message) { |
|
699 | 699 | //set properties that might be expected by add-ons (backward compat) |
700 | 700 | $message->content = $message->content(); |
701 | 701 | $message->template_pack = $message->get_template_pack(); |
@@ -720,10 +720,10 @@ discard block |
||
720 | 720 | * @param bool $send true we will do a test send using the messenger delivery, false we just do a regular preview |
721 | 721 | * @return string The body of the message. |
722 | 722 | */ |
723 | - public function preview_message( $type, $context, $messenger, $send = false ) { |
|
723 | + public function preview_message($type, $context, $messenger, $send = false) { |
|
724 | 724 | // EE_messages has been deprecated |
725 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
726 | - return EED_Messages::preview_message( $type, $context, $messenger, $send ); |
|
725 | + $this->_class_is_deprecated(__FUNCTION__); |
|
726 | + return EED_Messages::preview_message($type, $context, $messenger, $send); |
|
727 | 727 | } |
728 | 728 | |
729 | 729 | |
@@ -737,14 +737,14 @@ discard block |
||
737 | 737 | * |
738 | 738 | * @return bool success or fail. |
739 | 739 | */ |
740 | - public function send_message_with_messenger_only( $messenger, $message_type, $message ) { |
|
740 | + public function send_message_with_messenger_only($messenger, $message_type, $message) { |
|
741 | 741 | // EE_messages has been deprecated |
742 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
742 | + $this->_class_is_deprecated(__FUNCTION__); |
|
743 | 743 | //setup for sending to new method. |
744 | 744 | /** @type EE_Messages_Queue $queue */ |
745 | - $queue = EE_Registry::instance()->load_lib( 'Messages_Queue' ); |
|
745 | + $queue = EE_Registry::instance()->load_lib('Messages_Queue'); |
|
746 | 746 | //make sure we have a proper message object |
747 | - if ( ! $message instanceof EE_Message && is_object( $message ) && isset( $message->content ) ) { |
|
747 | + if ( ! $message instanceof EE_Message && is_object($message) && isset($message->content)) { |
|
748 | 748 | $msg = EE_Message_Factory::create( |
749 | 749 | array( |
750 | 750 | 'MSG_messenger' => $messenger, |
@@ -756,15 +756,15 @@ discard block |
||
756 | 756 | } else { |
757 | 757 | $msg = $message; |
758 | 758 | } |
759 | - if ( ! $msg instanceof EE_Message ) { |
|
759 | + if ( ! $msg instanceof EE_Message) { |
|
760 | 760 | return false; |
761 | 761 | } |
762 | 762 | //make sure any content in a content property (if not empty) is set on the MSG_content. |
763 | - if ( ! empty( $msg->content ) ) { |
|
764 | - $msg->set( 'MSG_content', $msg->content ); |
|
763 | + if ( ! empty($msg->content)) { |
|
764 | + $msg->set('MSG_content', $msg->content); |
|
765 | 765 | } |
766 | - $queue->add( $msg ); |
|
767 | - return EED_Messages::send_message_with_messenger_only( $messenger, $message_type, $queue ); |
|
766 | + $queue->add($msg); |
|
767 | + return EED_Messages::send_message_with_messenger_only($messenger, $message_type, $queue); |
|
768 | 768 | } |
769 | 769 | |
770 | 770 | |
@@ -778,11 +778,11 @@ discard block |
||
778 | 778 | * @return array|object if creation is successful then we return an array of info, otherwise an error_object is returned. |
779 | 779 | * @throws \EE_Error |
780 | 780 | */ |
781 | - public function create_new_templates( $messenger, $message_type, $GRP_ID = 0, $is_global = false ) { |
|
781 | + public function create_new_templates($messenger, $message_type, $GRP_ID = 0, $is_global = false) { |
|
782 | 782 | // EE_messages has been deprecated |
783 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
784 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
785 | - return EEH_MSG_Template::create_new_templates( $messenger, $message_type, $GRP_ID, $is_global ); |
|
783 | + $this->_class_is_deprecated(__FUNCTION__); |
|
784 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
785 | + return EEH_MSG_Template::create_new_templates($messenger, $message_type, $GRP_ID, $is_global); |
|
786 | 786 | } |
787 | 787 | |
788 | 788 | |
@@ -793,11 +793,11 @@ discard block |
||
793 | 793 | * @param string $message_type_name name of EE_message_type |
794 | 794 | * @return array |
795 | 795 | */ |
796 | - public function get_fields( $messenger_name, $message_type_name ) { |
|
796 | + public function get_fields($messenger_name, $message_type_name) { |
|
797 | 797 | // EE_messages has been deprecated |
798 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
799 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
800 | - return EEH_MSG_Template::get_fields( $messenger_name, $message_type_name ); |
|
798 | + $this->_class_is_deprecated(__FUNCTION__); |
|
799 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
800 | + return EEH_MSG_Template::get_fields($messenger_name, $message_type_name); |
|
801 | 801 | } |
802 | 802 | |
803 | 803 | |
@@ -811,13 +811,13 @@ discard block |
||
811 | 811 | * @return array multidimensional array of messenger and message_type objects |
812 | 812 | * (messengers index, and message_type index); |
813 | 813 | */ |
814 | - public function get_installed( $type = 'all', $skip_cache = false ) { |
|
814 | + public function get_installed($type = 'all', $skip_cache = false) { |
|
815 | 815 | // EE_messages has been deprecated |
816 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
817 | - if ( $skip_cache ) { |
|
816 | + $this->_class_is_deprecated(__FUNCTION__); |
|
817 | + if ($skip_cache) { |
|
818 | 818 | $this->_message_resource_manager->reset_active_messengers_and_message_types(); |
819 | 819 | } |
820 | - switch ( $type ) { |
|
820 | + switch ($type) { |
|
821 | 821 | case 'messengers' : |
822 | 822 | return array( |
823 | 823 | 'messenger' => $this->_message_resource_manager->installed_messengers(), |
@@ -846,7 +846,7 @@ discard block |
||
846 | 846 | */ |
847 | 847 | public function get_active_messengers() { |
848 | 848 | // EE_messages has been deprecated |
849 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
849 | + $this->_class_is_deprecated(__FUNCTION__); |
|
850 | 850 | return $this->_message_resource_manager->active_messengers(); |
851 | 851 | } |
852 | 852 | |
@@ -858,7 +858,7 @@ discard block |
||
858 | 858 | */ |
859 | 859 | public function get_active_message_types() { |
860 | 860 | // EE_messages has been deprecated |
861 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
861 | + $this->_class_is_deprecated(__FUNCTION__); |
|
862 | 862 | return $this->_message_resource_manager->list_of_active_message_types(); |
863 | 863 | } |
864 | 864 | |
@@ -870,7 +870,7 @@ discard block |
||
870 | 870 | */ |
871 | 871 | public function get_active_message_type_objects() { |
872 | 872 | // EE_messages has been deprecated |
873 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
873 | + $this->_class_is_deprecated(__FUNCTION__); |
|
874 | 874 | return $this->_message_resource_manager->get_active_message_type_objects(); |
875 | 875 | } |
876 | 876 | |
@@ -882,10 +882,10 @@ discard block |
||
882 | 882 | * @param string $messenger The messenger being checked |
883 | 883 | * @return EE_message_type[] (or empty array if none present) |
884 | 884 | */ |
885 | - public function get_active_message_types_per_messenger( $messenger ) { |
|
885 | + public function get_active_message_types_per_messenger($messenger) { |
|
886 | 886 | // EE_messages has been deprecated |
887 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
888 | - return $this->_message_resource_manager->get_active_message_types_for_messenger( $messenger ); |
|
887 | + $this->_class_is_deprecated(__FUNCTION__); |
|
888 | + return $this->_message_resource_manager->get_active_message_types_for_messenger($messenger); |
|
889 | 889 | } |
890 | 890 | |
891 | 891 | |
@@ -896,10 +896,10 @@ discard block |
||
896 | 896 | * @param string $message_type The string should correspond to a message type. |
897 | 897 | * @return EE_message_type|null |
898 | 898 | */ |
899 | - public function get_active_message_type( $messenger, $message_type ) { |
|
899 | + public function get_active_message_type($messenger, $message_type) { |
|
900 | 900 | // EE_messages has been deprecated |
901 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
902 | - return $this->_message_resource_manager->get_active_message_type_for_messenger( $messenger, $message_type ); |
|
901 | + $this->_class_is_deprecated(__FUNCTION__); |
|
902 | + return $this->_message_resource_manager->get_active_message_type_for_messenger($messenger, $message_type); |
|
903 | 903 | } |
904 | 904 | |
905 | 905 | |
@@ -910,7 +910,7 @@ discard block |
||
910 | 910 | */ |
911 | 911 | public function get_installed_message_types() { |
912 | 912 | // EE_messages has been deprecated |
913 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
913 | + $this->_class_is_deprecated(__FUNCTION__); |
|
914 | 914 | return $this->_message_resource_manager->installed_message_types(); |
915 | 915 | } |
916 | 916 | |
@@ -922,7 +922,7 @@ discard block |
||
922 | 922 | */ |
923 | 923 | public function get_installed_messengers() { |
924 | 924 | // EE_messages has been deprecated |
925 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
925 | + $this->_class_is_deprecated(__FUNCTION__); |
|
926 | 926 | return $this->_message_resource_manager->installed_messengers(); |
927 | 927 | } |
928 | 928 | |
@@ -933,10 +933,10 @@ discard block |
||
933 | 933 | * @param bool $slugs_only Whether to return an array of just slugs and labels (true) or all contexts indexed by message type. |
934 | 934 | * @return array |
935 | 935 | */ |
936 | - public function get_all_contexts( $slugs_only = true ) { |
|
936 | + public function get_all_contexts($slugs_only = true) { |
|
937 | 937 | // EE_messages has been deprecated |
938 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
939 | - return $this->_message_resource_manager->get_all_contexts( $slugs_only ); |
|
938 | + $this->_class_is_deprecated(__FUNCTION__); |
|
939 | + return $this->_message_resource_manager->get_all_contexts($slugs_only); |
|
940 | 940 | } |
941 | 941 | |
942 | 942 | |
@@ -1002,15 +1002,15 @@ discard block |
||
1002 | 1002 | '4.9.22.p' |
1003 | 1003 | ); |
1004 | 1004 | } |
1005 | - do_action( 'AHEE__EE_Brewing_Regular__construct__complete' ); |
|
1005 | + do_action('AHEE__EE_Brewing_Regular__construct__complete'); |
|
1006 | 1006 | } |
1007 | -add_action( 'AHEE__EE_System__load_core_configuration__complete', 'ee_deprecate_AHEE__EE_Brewing_Regular__construct__complete' ); |
|
1007 | +add_action('AHEE__EE_System__load_core_configuration__complete', 'ee_deprecate_AHEE__EE_Brewing_Regular__construct__complete'); |
|
1008 | 1008 | |
1009 | 1009 | |
1010 | 1010 | add_filter( |
1011 | 1011 | 'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css', |
1012 | 1012 | function($event_list_iframe_css) { |
1013 | - if ( ! has_filter( 'FHEE__EventsArchiveIframe__event_list_iframe__css' )) { |
|
1013 | + if ( ! has_filter('FHEE__EventsArchiveIframe__event_list_iframe__css')) { |
|
1014 | 1014 | return $event_list_iframe_css; |
1015 | 1015 | } |
1016 | 1016 | deprecated_espresso_action_or_filter_doing_it_wrong( |
@@ -1030,7 +1030,7 @@ discard block |
||
1030 | 1030 | add_filter( |
1031 | 1031 | 'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js', |
1032 | 1032 | function($event_list_iframe_js) { |
1033 | - if ( ! has_filter( 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js' )) { |
|
1033 | + if ( ! has_filter('FHEE__EED_Ticket_Selector__ticket_selector_iframe__js')) { |
|
1034 | 1034 | return $event_list_iframe_js; |
1035 | 1035 | } |
1036 | 1036 | deprecated_espresso_action_or_filter_doing_it_wrong( |
@@ -47,30 +47,30 @@ discard block |
||
47 | 47 | * @throws EE_Error |
48 | 48 | * @return void |
49 | 49 | */ |
50 | - public static function register( $cap_reference = NULL, $setup_args = array() ) { |
|
50 | + public static function register($cap_reference = NULL, $setup_args = array()) { |
|
51 | 51 | //required fields MUST be present, so let's make sure they are. |
52 | - if ( ! isset( $cap_reference ) || ! is_array( $setup_args ) || empty( $setup_args['capabilities'] ) ) { |
|
52 | + if ( ! isset($cap_reference) || ! is_array($setup_args) || empty($setup_args['capabilities'])) { |
|
53 | 53 | throw new EE_Error( |
54 | - __( 'In order to register capabilities with EE_Register_Capabilities::register, you must include a unique name to reference the capabilities being registered, plus an array containing the following keys: "capabilities".', 'event_espresso' ) |
|
54 | + __('In order to register capabilities with EE_Register_Capabilities::register, you must include a unique name to reference the capabilities being registered, plus an array containing the following keys: "capabilities".', 'event_espresso') |
|
55 | 55 | ); |
56 | 56 | } |
57 | 57 | //make sure we don't register twice |
58 | - if( isset( self::$_registry[ $cap_reference ] ) ){ |
|
58 | + if (isset(self::$_registry[$cap_reference])) { |
|
59 | 59 | return; |
60 | 60 | } |
61 | 61 | //make sure this is not registered too late or too early. |
62 | - if ( ! did_action( 'AHEE__EE_System__load_espresso_addons' ) || did_action( 'AHEE__EE_System___detect_if_activation_or_upgrade__begin' ) ) { |
|
63 | - EE_Error::doing_it_wrong( __METHOD__, sprintf( __('%s has been registered too late. Please ensure that EE_Register_Capabilities::register has been called at some point before the "AHEE__EE_System___detect_if_activation_or_upgrade__begin" action hook has been called.', 'event_espresso'), $cap_reference ), '4.5.0' ); |
|
62 | + if ( ! did_action('AHEE__EE_System__load_espresso_addons') || did_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin')) { |
|
63 | + EE_Error::doing_it_wrong(__METHOD__, sprintf(__('%s has been registered too late. Please ensure that EE_Register_Capabilities::register has been called at some point before the "AHEE__EE_System___detect_if_activation_or_upgrade__begin" action hook has been called.', 'event_espresso'), $cap_reference), '4.5.0'); |
|
64 | 64 | } |
65 | 65 | //some preliminary sanitization and setting to the $_registry property |
66 | 66 | self::$_registry[$cap_reference] = array( |
67 | - 'caps' => isset( $setup_args['capabilities'] ) && is_array( $setup_args['capabilities'] ) ? $setup_args['capabilities'] : array(), |
|
68 | - 'cap_maps' => isset( $setup_args['capability_maps'] ) ? $setup_args['capability_maps'] : array() |
|
67 | + 'caps' => isset($setup_args['capabilities']) && is_array($setup_args['capabilities']) ? $setup_args['capabilities'] : array(), |
|
68 | + 'cap_maps' => isset($setup_args['capability_maps']) ? $setup_args['capability_maps'] : array() |
|
69 | 69 | ); |
70 | 70 | //set initial caps (note that EE_Capabilities takes care of making sure that the caps get added only once) |
71 | - add_filter( 'FHEE__EE_Capabilities__init_caps_map__caps', array( 'EE_Register_Capabilities', 'register_capabilities' ), 10 ); |
|
71 | + add_filter('FHEE__EE_Capabilities__init_caps_map__caps', array('EE_Register_Capabilities', 'register_capabilities'), 10); |
|
72 | 72 | //add filter for cap maps |
73 | - add_filter( 'FHEE__EE_Capabilities___set_meta_caps__meta_caps', array( 'EE_Register_Capabilities', 'register_cap_maps' ), 10 ); |
|
73 | + add_filter('FHEE__EE_Capabilities___set_meta_caps__meta_caps', array('EE_Register_Capabilities', 'register_cap_maps'), 10); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | |
@@ -83,9 +83,9 @@ discard block |
||
83 | 83 | * |
84 | 84 | * @return array merged in new caps. |
85 | 85 | */ |
86 | - public static function register_capabilities( $incoming_caps ) { |
|
87 | - foreach ( self::$_registry as $ref => $caps_and_cap_map ) { |
|
88 | - $incoming_caps = array_merge_recursive( $incoming_caps, $caps_and_cap_map[ 'caps' ] ); |
|
86 | + public static function register_capabilities($incoming_caps) { |
|
87 | + foreach (self::$_registry as $ref => $caps_and_cap_map) { |
|
88 | + $incoming_caps = array_merge_recursive($incoming_caps, $caps_and_cap_map['caps']); |
|
89 | 89 | } |
90 | 90 | return $incoming_caps; |
91 | 91 | } |
@@ -100,13 +100,13 @@ discard block |
||
100 | 100 | * @return EE_Meta_Capability_Map[] |
101 | 101 | * @throws EE_Error |
102 | 102 | */ |
103 | - public static function register_cap_maps( $cap_maps ) { |
|
103 | + public static function register_cap_maps($cap_maps) { |
|
104 | 104 | //loop through and instantiate cap maps. |
105 | - foreach ( self::$_registry as $cap_reference => $setup ) { |
|
106 | - if ( ! isset( $setup['cap_maps'] ) ) { |
|
105 | + foreach (self::$_registry as $cap_reference => $setup) { |
|
106 | + if ( ! isset($setup['cap_maps'])) { |
|
107 | 107 | continue; |
108 | 108 | } |
109 | - foreach ( $setup['cap_maps'] as $cap_class => $args ) { |
|
109 | + foreach ($setup['cap_maps'] as $cap_class => $args) { |
|
110 | 110 | |
111 | 111 | /** |
112 | 112 | * account for cases where capability maps may be indexed |
@@ -133,19 +133,19 @@ discard block |
||
133 | 133 | * ... |
134 | 134 | * ) |
135 | 135 | */ |
136 | - if ( is_numeric( $cap_class ) ) { |
|
137 | - $cap_class = key( $args ); |
|
136 | + if (is_numeric($cap_class)) { |
|
137 | + $cap_class = key($args); |
|
138 | 138 | $args = $args[$cap_class]; |
139 | 139 | } |
140 | 140 | |
141 | - if ( ! class_exists( $cap_class ) ) { |
|
142 | - throw new EE_Error( sprintf( __( 'An addon (%s) has tried to register a capability map improperly. Capability map arrays must be indexed by capability map classname, and an array for the class arguments', 'event_espresso' ), $cap_reference ) ); |
|
141 | + if ( ! class_exists($cap_class)) { |
|
142 | + throw new EE_Error(sprintf(__('An addon (%s) has tried to register a capability map improperly. Capability map arrays must be indexed by capability map classname, and an array for the class arguments', 'event_espresso'), $cap_reference)); |
|
143 | 143 | } |
144 | 144 | |
145 | - if ( count( $args ) !== 2 ) { |
|
146 | - throw new EE_Error( sprintf( __('An addon (%s) has tried to register a capability map improperly. Capability map arrays must be indexed by capability map classname, and an array for the class arguments. The array should have two values the first being a string and the second an array.', 'event_espresso' ), $cap_reference ) ); |
|
145 | + if (count($args) !== 2) { |
|
146 | + throw new EE_Error(sprintf(__('An addon (%s) has tried to register a capability map improperly. Capability map arrays must be indexed by capability map classname, and an array for the class arguments. The array should have two values the first being a string and the second an array.', 'event_espresso'), $cap_reference)); |
|
147 | 147 | } |
148 | - $cap_maps[] = new $cap_class( $args[0], $args[1] ); |
|
148 | + $cap_maps[] = new $cap_class($args[0], $args[1]); |
|
149 | 149 | } |
150 | 150 | } |
151 | 151 | return $cap_maps; |
@@ -154,9 +154,9 @@ discard block |
||
154 | 154 | |
155 | 155 | |
156 | 156 | |
157 | - public static function deregister( $cap_reference = NULL ) { |
|
158 | - if ( !empty( self::$_registry[$cap_reference] ) ) { |
|
159 | - unset( self::$_registry[ $cap_reference ] ); |
|
157 | + public static function deregister($cap_reference = NULL) { |
|
158 | + if ( ! empty(self::$_registry[$cap_reference])) { |
|
159 | + unset(self::$_registry[$cap_reference]); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | //re init caps to grab the changes due to removed caps. |
@@ -27,12 +27,12 @@ discard block |
||
27 | 27 | * @param int | \EE_Event $event |
28 | 28 | * @return bool |
29 | 29 | */ |
30 | -function is_espresso_event( $event = NULL ) { |
|
31 | - if ( can_use_espresso_conditionals( __FUNCTION__ )) { |
|
30 | +function is_espresso_event($event = NULL) { |
|
31 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
32 | 32 | // extract EE_Event object from passed param regardless of what it is (within reason of course) |
33 | - $event = EEH_Event_View::get_event( $event ); |
|
33 | + $event = EEH_Event_View::get_event($event); |
|
34 | 34 | // do we have a valid event ? |
35 | - return $event instanceof EE_Event ? TRUE : FALSE; |
|
35 | + return $event instanceof EE_Event ? TRUE : FALSE; |
|
36 | 36 | } |
37 | 37 | return FALSE; |
38 | 38 | } |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | * @return bool |
45 | 45 | */ |
46 | 46 | function is_espresso_event_single() { |
47 | - if ( can_use_espresso_conditionals( __FUNCTION__ )) { |
|
47 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
48 | 48 | global $wp_query; |
49 | 49 | // return conditionals set by CPTs |
50 | 50 | return $wp_query instanceof WP_Query ? $wp_query->is_espresso_event_single : FALSE; |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | * @return bool |
60 | 60 | */ |
61 | 61 | function is_espresso_event_archive() { |
62 | - if ( can_use_espresso_conditionals( __FUNCTION__ )) { |
|
62 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
63 | 63 | global $wp_query; |
64 | 64 | return $wp_query instanceof WP_Query ? $wp_query->is_espresso_event_archive : FALSE; |
65 | 65 | } |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | * @return bool |
74 | 74 | */ |
75 | 75 | function is_espresso_event_taxonomy() { |
76 | - if ( can_use_espresso_conditionals( __FUNCTION__ )) { |
|
76 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
77 | 77 | global $wp_query; |
78 | 78 | return $wp_query instanceof WP_Query ? $wp_query->is_espresso_event_taxonomy : FALSE; |
79 | 79 | } |
@@ -87,10 +87,10 @@ discard block |
||
87 | 87 | * @param int | \EE_Venue $venue |
88 | 88 | * @return bool |
89 | 89 | */ |
90 | -function is_espresso_venue( $venue = NULL ) { |
|
91 | - if ( can_use_espresso_conditionals( __FUNCTION__ )) { |
|
90 | +function is_espresso_venue($venue = NULL) { |
|
91 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
92 | 92 | // extract EE_Venue object from passed param regardless of what it is (within reason of course) |
93 | - $venue = EEH_Venue_View::get_venue( $venue, FALSE ); |
|
93 | + $venue = EEH_Venue_View::get_venue($venue, FALSE); |
|
94 | 94 | // do we have a valid event ? |
95 | 95 | return $venue instanceof EE_Venue ? TRUE : FALSE; |
96 | 96 | } |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | * @return bool |
105 | 105 | */ |
106 | 106 | function is_espresso_venue_single() { |
107 | - if ( can_use_espresso_conditionals( __FUNCTION__ )) { |
|
107 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
108 | 108 | global $wp_query; |
109 | 109 | return $wp_query instanceof WP_Query ? $wp_query->is_espresso_venue_single : FALSE; |
110 | 110 | } |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | * @return bool |
119 | 119 | */ |
120 | 120 | function is_espresso_venue_archive() { |
121 | - if ( can_use_espresso_conditionals( __FUNCTION__ )) { |
|
121 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
122 | 122 | global $wp_query; |
123 | 123 | return $wp_query instanceof WP_Query ? $wp_query->is_espresso_venue_archive : FALSE; |
124 | 124 | } |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | * @return bool |
133 | 133 | */ |
134 | 134 | function is_espresso_venue_taxonomy() { |
135 | - if ( can_use_espresso_conditionals( __FUNCTION__ )) { |
|
135 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
136 | 136 | global $wp_query; |
137 | 137 | return $wp_query instanceof WP_Query ? $wp_query->is_espresso_venue_taxonomy : FALSE; |
138 | 138 | } |
@@ -146,12 +146,12 @@ discard block |
||
146 | 146 | * @param $conditional_tag |
147 | 147 | * @return bool |
148 | 148 | */ |
149 | -function can_use_espresso_conditionals( $conditional_tag ) { |
|
150 | - if ( ! did_action( 'AHEE__EE_System__initialize' )) { |
|
149 | +function can_use_espresso_conditionals($conditional_tag) { |
|
150 | + if ( ! did_action('AHEE__EE_System__initialize')) { |
|
151 | 151 | EE_Error::doing_it_wrong( |
152 | 152 | __FUNCTION__, |
153 | 153 | sprintf( |
154 | - __( 'The "%s" conditional tag can not be used until after the "init" hook has run, but works best when used within a theme\'s template files.','event_espresso'), |
|
154 | + __('The "%s" conditional tag can not be used until after the "init" hook has run, but works best when used within a theme\'s template files.', 'event_espresso'), |
|
155 | 155 | $conditional_tag |
156 | 156 | ), |
157 | 157 | '4.4.0' |
@@ -166,13 +166,13 @@ discard block |
||
166 | 166 | |
167 | 167 | /*************************** Event Queries ***************************/ |
168 | 168 | |
169 | -if ( ! function_exists( 'espresso_get_events' )) { |
|
169 | +if ( ! function_exists('espresso_get_events')) { |
|
170 | 170 | /** |
171 | 171 | * espresso_get_events |
172 | 172 | * @param array $params |
173 | 173 | * @return array |
174 | 174 | */ |
175 | - function espresso_get_events( $params = array() ) { |
|
175 | + function espresso_get_events($params = array()) { |
|
176 | 176 | //set default params |
177 | 177 | $default_espresso_events_params = array( |
178 | 178 | 'limit' => 10, |
@@ -183,18 +183,18 @@ discard block |
||
183 | 183 | 'sort' => 'ASC' |
184 | 184 | ); |
185 | 185 | // allow the defaults to be filtered |
186 | - $default_espresso_events_params = apply_filters( 'espresso_get_events__default_espresso_events_params', $default_espresso_events_params ); |
|
186 | + $default_espresso_events_params = apply_filters('espresso_get_events__default_espresso_events_params', $default_espresso_events_params); |
|
187 | 187 | // grab params and merge with defaults, then extract |
188 | - $params = array_merge( $default_espresso_events_params, $params ); |
|
188 | + $params = array_merge($default_espresso_events_params, $params); |
|
189 | 189 | // run the query |
190 | - $events_query = new EE_Event_List_Query( $params ); |
|
190 | + $events_query = new EE_Event_List_Query($params); |
|
191 | 191 | // assign results to a variable so we can return it |
192 | 192 | $events = $events_query->have_posts() ? $events_query->posts : array(); |
193 | 193 | // but first reset the query and postdata |
194 | 194 | wp_reset_query(); |
195 | 195 | wp_reset_postdata(); |
196 | 196 | EED_Events_Archive::remove_all_events_archive_filters(); |
197 | - unset( $events_query ); |
|
197 | + unset($events_query); |
|
198 | 198 | return $events; |
199 | 199 | } |
200 | 200 | } |
@@ -208,32 +208,32 @@ discard block |
||
208 | 208 | * espresso_load_ticket_selector |
209 | 209 | */ |
210 | 210 | function espresso_load_ticket_selector() { |
211 | - EE_Registry::instance()->load_file( EE_MODULES . 'ticket_selector', 'EED_Ticket_Selector', 'module' ); |
|
211 | + EE_Registry::instance()->load_file(EE_MODULES.'ticket_selector', 'EED_Ticket_Selector', 'module'); |
|
212 | 212 | } |
213 | 213 | |
214 | -if ( ! function_exists( 'espresso_ticket_selector' )) { |
|
214 | +if ( ! function_exists('espresso_ticket_selector')) { |
|
215 | 215 | /** |
216 | 216 | * espresso_ticket_selector |
217 | 217 | * @param null $event |
218 | 218 | */ |
219 | - function espresso_ticket_selector( $event = NULL ) { |
|
220 | - if ( ! apply_filters( 'FHEE_disable_espresso_ticket_selector', FALSE ) ) { |
|
219 | + function espresso_ticket_selector($event = NULL) { |
|
220 | + if ( ! apply_filters('FHEE_disable_espresso_ticket_selector', FALSE)) { |
|
221 | 221 | espresso_load_ticket_selector(); |
222 | - echo EED_Ticket_Selector::display_ticket_selector( $event ); |
|
222 | + echo EED_Ticket_Selector::display_ticket_selector($event); |
|
223 | 223 | } |
224 | 224 | } |
225 | 225 | } |
226 | 226 | |
227 | 227 | |
228 | - if ( ! function_exists( 'espresso_view_details_btn' )) { |
|
228 | + if ( ! function_exists('espresso_view_details_btn')) { |
|
229 | 229 | /** |
230 | 230 | * espresso_view_details_btn |
231 | 231 | * @param null $event |
232 | 232 | */ |
233 | - function espresso_view_details_btn( $event = NULL ) { |
|
234 | - if ( ! apply_filters( 'FHEE_disable_espresso_view_details_btn', FALSE ) ) { |
|
233 | + function espresso_view_details_btn($event = NULL) { |
|
234 | + if ( ! apply_filters('FHEE_disable_espresso_view_details_btn', FALSE)) { |
|
235 | 235 | espresso_load_ticket_selector(); |
236 | - echo EED_Ticket_Selector::display_ticket_selector( $event, TRUE ); |
|
236 | + echo EED_Ticket_Selector::display_ticket_selector($event, TRUE); |
|
237 | 237 | } |
238 | 238 | } |
239 | 239 | } |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | |
244 | 244 | /*************************** EEH_Event_View ***************************/ |
245 | 245 | |
246 | -if ( ! function_exists( 'espresso_load_event_list_assets' )) { |
|
246 | +if ( ! function_exists('espresso_load_event_list_assets')) { |
|
247 | 247 | /** |
248 | 248 | * espresso_load_event_list_assets |
249 | 249 | * ensures that event list styles and scripts are loaded |
@@ -252,13 +252,13 @@ discard block |
||
252 | 252 | */ |
253 | 253 | function espresso_load_event_list_assets() { |
254 | 254 | $event_list = EED_Events_Archive::instance(); |
255 | - add_action( 'AHEE__EE_System__initialize_last', array( $event_list, 'load_event_list_assets' ), 10 ); |
|
256 | - add_filter( 'FHEE_enable_default_espresso_css', '__return_true' ); |
|
255 | + add_action('AHEE__EE_System__initialize_last', array($event_list, 'load_event_list_assets'), 10); |
|
256 | + add_filter('FHEE_enable_default_espresso_css', '__return_true'); |
|
257 | 257 | } |
258 | 258 | } |
259 | 259 | |
260 | 260 | |
261 | -if ( ! function_exists( 'espresso_event_reg_button' )) { |
|
261 | +if ( ! function_exists('espresso_event_reg_button')) { |
|
262 | 262 | /** |
263 | 263 | * espresso_event_reg_button |
264 | 264 | * returns the "Register Now" button if event is active, |
@@ -270,9 +270,9 @@ discard block |
||
270 | 270 | * @param bool $EVT_ID |
271 | 271 | * @return string |
272 | 272 | */ |
273 | - function espresso_event_reg_button( $btn_text_if_active = NULL, $btn_text_if_inactive = FALSE, $EVT_ID = FALSE ) { |
|
274 | - $event_status = EEH_Event_View::event_active_status( $EVT_ID ); |
|
275 | - switch ( $event_status ) { |
|
273 | + function espresso_event_reg_button($btn_text_if_active = NULL, $btn_text_if_inactive = FALSE, $EVT_ID = FALSE) { |
|
274 | + $event_status = EEH_Event_View::event_active_status($EVT_ID); |
|
275 | + switch ($event_status) { |
|
276 | 276 | case EE_Datetime::sold_out : |
277 | 277 | $btn_text = __('Sold Out', 'event_espresso'); |
278 | 278 | $class = 'ee-pink'; |
@@ -288,10 +288,10 @@ discard block |
||
288 | 288 | case EE_Datetime::upcoming : |
289 | 289 | case EE_Datetime::active : |
290 | 290 | default : |
291 | - $btn_text =! empty( $btn_text_if_active ) ? $btn_text_if_active : __( 'Register Now', 'event_espresso' ); |
|
291 | + $btn_text = ! empty($btn_text_if_active) ? $btn_text_if_active : __('Register Now', 'event_espresso'); |
|
292 | 292 | $class = 'ee-green'; |
293 | 293 | } |
294 | - if ( $event_status < 1 && ! empty( $btn_text_if_inactive )) { |
|
294 | + if ($event_status < 1 && ! empty($btn_text_if_inactive)) { |
|
295 | 295 | $btn_text = $btn_text_if_inactive; |
296 | 296 | $class = 'ee-grey'; |
297 | 297 | } |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | |
306 | 306 | |
307 | 307 | |
308 | -if ( ! function_exists( 'espresso_display_ticket_selector' )) { |
|
308 | +if ( ! function_exists('espresso_display_ticket_selector')) { |
|
309 | 309 | /** |
310 | 310 | * espresso_display_ticket_selector |
311 | 311 | * whether or not to display the Ticket Selector for an event |
@@ -313,14 +313,14 @@ discard block |
||
313 | 313 | * @param bool $EVT_ID |
314 | 314 | * @return boolean |
315 | 315 | */ |
316 | - function espresso_display_ticket_selector( $EVT_ID = FALSE ) { |
|
317 | - return EEH_Event_View::display_ticket_selector( $EVT_ID ); |
|
316 | + function espresso_display_ticket_selector($EVT_ID = FALSE) { |
|
317 | + return EEH_Event_View::display_ticket_selector($EVT_ID); |
|
318 | 318 | } |
319 | 319 | } |
320 | 320 | |
321 | 321 | |
322 | 322 | |
323 | -if ( ! function_exists( 'espresso_event_status_banner' )) { |
|
323 | +if ( ! function_exists('espresso_event_status_banner')) { |
|
324 | 324 | /** |
325 | 325 | * espresso_event_status |
326 | 326 | * returns a banner showing the event status if it is sold out, expired, or inactive |
@@ -328,13 +328,13 @@ discard block |
||
328 | 328 | * @param bool $EVT_ID |
329 | 329 | * @return string |
330 | 330 | */ |
331 | - function espresso_event_status_banner( $EVT_ID = FALSE ) { |
|
332 | - return EEH_Event_View::event_status( $EVT_ID ); |
|
331 | + function espresso_event_status_banner($EVT_ID = FALSE) { |
|
332 | + return EEH_Event_View::event_status($EVT_ID); |
|
333 | 333 | } |
334 | 334 | } |
335 | 335 | |
336 | 336 | |
337 | -if ( ! function_exists( 'espresso_event_status' )) { |
|
337 | +if ( ! function_exists('espresso_event_status')) { |
|
338 | 338 | /** |
339 | 339 | * espresso_event_status |
340 | 340 | * returns the event status if it is sold out, expired, or inactive |
@@ -343,17 +343,17 @@ discard block |
||
343 | 343 | * @param bool $echo |
344 | 344 | * @return string |
345 | 345 | */ |
346 | - function espresso_event_status( $EVT_ID = 0, $echo = TRUE ) { |
|
347 | - if ( $echo ) { |
|
348 | - echo EEH_Event_View::event_active_status( $EVT_ID ); |
|
346 | + function espresso_event_status($EVT_ID = 0, $echo = TRUE) { |
|
347 | + if ($echo) { |
|
348 | + echo EEH_Event_View::event_active_status($EVT_ID); |
|
349 | 349 | return ''; |
350 | 350 | } |
351 | - return EEH_Event_View::event_active_status( $EVT_ID ); |
|
351 | + return EEH_Event_View::event_active_status($EVT_ID); |
|
352 | 352 | } |
353 | 353 | } |
354 | 354 | |
355 | 355 | |
356 | -if ( ! function_exists( 'espresso_event_categories' )) { |
|
356 | +if ( ! function_exists('espresso_event_categories')) { |
|
357 | 357 | /** |
358 | 358 | * espresso_event_categories |
359 | 359 | * returns the terms associated with an event |
@@ -363,17 +363,17 @@ discard block |
||
363 | 363 | * @param bool $echo |
364 | 364 | * @return string |
365 | 365 | */ |
366 | - function espresso_event_categories( $EVT_ID = 0, $hide_uncategorized = TRUE, $echo = TRUE ) { |
|
367 | - if ( $echo ) { |
|
368 | - echo EEH_Event_View::event_categories( $EVT_ID, $hide_uncategorized ); |
|
366 | + function espresso_event_categories($EVT_ID = 0, $hide_uncategorized = TRUE, $echo = TRUE) { |
|
367 | + if ($echo) { |
|
368 | + echo EEH_Event_View::event_categories($EVT_ID, $hide_uncategorized); |
|
369 | 369 | return ''; |
370 | 370 | } |
371 | - return EEH_Event_View::event_categories( $EVT_ID, $hide_uncategorized ); |
|
371 | + return EEH_Event_View::event_categories($EVT_ID, $hide_uncategorized); |
|
372 | 372 | } |
373 | 373 | } |
374 | 374 | |
375 | 375 | |
376 | -if ( ! function_exists( 'espresso_event_tickets_available' )) { |
|
376 | +if ( ! function_exists('espresso_event_tickets_available')) { |
|
377 | 377 | /** |
378 | 378 | * espresso_event_tickets_available |
379 | 379 | * returns the ticket types available for purchase for an event |
@@ -383,26 +383,26 @@ discard block |
||
383 | 383 | * @param bool $format |
384 | 384 | * @return string |
385 | 385 | */ |
386 | - function espresso_event_tickets_available( $EVT_ID = 0, $echo = TRUE, $format = TRUE ) { |
|
387 | - $tickets = EEH_Event_View::event_tickets_available( $EVT_ID ); |
|
388 | - if ( is_array( $tickets ) && ! empty( $tickets )) { |
|
386 | + function espresso_event_tickets_available($EVT_ID = 0, $echo = TRUE, $format = TRUE) { |
|
387 | + $tickets = EEH_Event_View::event_tickets_available($EVT_ID); |
|
388 | + if (is_array($tickets) && ! empty($tickets)) { |
|
389 | 389 | // if formatting then $html will be a string, else it will be an array of ticket objects |
390 | - $html = $format ? '<ul id="ee-event-tickets-ul-' . $EVT_ID . '" class="ee-event-tickets-ul">' : array(); |
|
391 | - foreach ( $tickets as $ticket ) { |
|
392 | - if ( $ticket instanceof EE_Ticket ) { |
|
393 | - if ( $format ) { |
|
394 | - $html .= '<li id="ee-event-tickets-li-' . $ticket->ID() . '" class="ee-event-tickets-li">'; |
|
395 | - $html .= $ticket->name() . ' ' . EEH_Template::format_currency( $ticket->get_ticket_total_with_taxes() ); |
|
390 | + $html = $format ? '<ul id="ee-event-tickets-ul-'.$EVT_ID.'" class="ee-event-tickets-ul">' : array(); |
|
391 | + foreach ($tickets as $ticket) { |
|
392 | + if ($ticket instanceof EE_Ticket) { |
|
393 | + if ($format) { |
|
394 | + $html .= '<li id="ee-event-tickets-li-'.$ticket->ID().'" class="ee-event-tickets-li">'; |
|
395 | + $html .= $ticket->name().' '.EEH_Template::format_currency($ticket->get_ticket_total_with_taxes()); |
|
396 | 396 | $html .= '</li>'; |
397 | 397 | } else { |
398 | 398 | $html[] = $ticket; |
399 | 399 | } |
400 | 400 | } |
401 | 401 | } |
402 | - if ( $format ) { |
|
402 | + if ($format) { |
|
403 | 403 | $html .= '</ul>'; |
404 | 404 | } |
405 | - if ( $echo && ! $format ) { |
|
405 | + if ($echo && ! $format) { |
|
406 | 406 | echo $html; |
407 | 407 | return ''; |
408 | 408 | } |
@@ -412,7 +412,7 @@ discard block |
||
412 | 412 | } |
413 | 413 | } |
414 | 414 | |
415 | -if ( ! function_exists( 'espresso_event_date_obj' )) { |
|
415 | +if ( ! function_exists('espresso_event_date_obj')) { |
|
416 | 416 | /** |
417 | 417 | * espresso_event_date_obj |
418 | 418 | * returns the primary date object for an event |
@@ -420,13 +420,13 @@ discard block |
||
420 | 420 | * @param bool $EVT_ID |
421 | 421 | * @return object |
422 | 422 | */ |
423 | - function espresso_event_date_obj( $EVT_ID = FALSE ) { |
|
424 | - return EEH_Event_View::get_primary_date_obj( $EVT_ID ); |
|
423 | + function espresso_event_date_obj($EVT_ID = FALSE) { |
|
424 | + return EEH_Event_View::get_primary_date_obj($EVT_ID); |
|
425 | 425 | } |
426 | 426 | } |
427 | 427 | |
428 | 428 | |
429 | -if ( ! function_exists( 'espresso_event_date' )) { |
|
429 | +if ( ! function_exists('espresso_event_date')) { |
|
430 | 430 | /** |
431 | 431 | * espresso_event_date |
432 | 432 | * returns the primary date for an event |
@@ -437,22 +437,22 @@ discard block |
||
437 | 437 | * @param bool $echo |
438 | 438 | * @return string |
439 | 439 | */ |
440 | - function espresso_event_date( $date_format = '', $time_format = '', $EVT_ID = FALSE, $echo = TRUE ) { |
|
441 | - $date_format = ! empty( $date_format ) ? $date_format : get_option( 'date_format' ); |
|
442 | - $time_format = ! empty( $time_format ) ? $time_format : get_option( 'time_format' ); |
|
443 | - $date_format = apply_filters( 'FHEE__espresso_event_date__date_format', $date_format ); |
|
444 | - $time_format = apply_filters( 'FHEE__espresso_event_date__time_format', $time_format ); |
|
445 | - if($echo){ |
|
446 | - echo EEH_Event_View::the_event_date( $date_format, $time_format, $EVT_ID ); |
|
440 | + function espresso_event_date($date_format = '', $time_format = '', $EVT_ID = FALSE, $echo = TRUE) { |
|
441 | + $date_format = ! empty($date_format) ? $date_format : get_option('date_format'); |
|
442 | + $time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
|
443 | + $date_format = apply_filters('FHEE__espresso_event_date__date_format', $date_format); |
|
444 | + $time_format = apply_filters('FHEE__espresso_event_date__time_format', $time_format); |
|
445 | + if ($echo) { |
|
446 | + echo EEH_Event_View::the_event_date($date_format, $time_format, $EVT_ID); |
|
447 | 447 | return ''; |
448 | 448 | } |
449 | - return EEH_Event_View::the_event_date( $date_format, $time_format, $EVT_ID ); |
|
449 | + return EEH_Event_View::the_event_date($date_format, $time_format, $EVT_ID); |
|
450 | 450 | |
451 | 451 | } |
452 | 452 | } |
453 | 453 | |
454 | 454 | |
455 | -if ( ! function_exists( 'espresso_list_of_event_dates' )) { |
|
455 | +if ( ! function_exists('espresso_list_of_event_dates')) { |
|
456 | 456 | /** |
457 | 457 | * espresso_list_of_event_dates |
458 | 458 | * returns a unordered list of dates for an event |
@@ -467,40 +467,40 @@ discard block |
||
467 | 467 | * @param null $limit |
468 | 468 | * @return string |
469 | 469 | */ |
470 | - function espresso_list_of_event_dates( $EVT_ID = 0, $date_format = '', $time_format = '', $echo = TRUE, $show_expired = NULL, $format = TRUE, $add_breaks = TRUE, $limit = NULL ) { |
|
471 | - $date_format = ! empty( $date_format ) ? $date_format : get_option( 'date_format' ); |
|
472 | - $time_format = ! empty( $time_format ) ? $time_format : get_option( 'time_format' ); |
|
473 | - $date_format = apply_filters( 'FHEE__espresso_list_of_event_dates__date_format', $date_format ); |
|
474 | - $time_format = apply_filters( 'FHEE__espresso_list_of_event_dates__time_format', $time_format ); |
|
475 | - $datetimes = EEH_Event_View::get_all_date_obj( $EVT_ID, $show_expired, FALSE, $limit ); |
|
476 | - if ( ! $format ) { |
|
477 | - return apply_filters( 'FHEE__espresso_list_of_event_dates__datetimes', $datetimes ); |
|
470 | + function espresso_list_of_event_dates($EVT_ID = 0, $date_format = '', $time_format = '', $echo = TRUE, $show_expired = NULL, $format = TRUE, $add_breaks = TRUE, $limit = NULL) { |
|
471 | + $date_format = ! empty($date_format) ? $date_format : get_option('date_format'); |
|
472 | + $time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
|
473 | + $date_format = apply_filters('FHEE__espresso_list_of_event_dates__date_format', $date_format); |
|
474 | + $time_format = apply_filters('FHEE__espresso_list_of_event_dates__time_format', $time_format); |
|
475 | + $datetimes = EEH_Event_View::get_all_date_obj($EVT_ID, $show_expired, FALSE, $limit); |
|
476 | + if ( ! $format) { |
|
477 | + return apply_filters('FHEE__espresso_list_of_event_dates__datetimes', $datetimes); |
|
478 | 478 | } |
479 | 479 | //d( $datetimes ); |
480 | - if ( is_array( $datetimes ) && ! empty( $datetimes )) { |
|
480 | + if (is_array($datetimes) && ! empty($datetimes)) { |
|
481 | 481 | global $post; |
482 | - $html = $format ? '<ul id="ee-event-datetimes-ul-' . $post->ID . '" class="ee-event-datetimes-ul ee-clearfix">' : ''; |
|
483 | - foreach ( $datetimes as $datetime ) { |
|
484 | - if ( $datetime instanceof EE_Datetime ) { |
|
485 | - $html .= '<li id="ee-event-datetimes-li-' . $datetime->ID(); |
|
486 | - $html .= '" class="ee-event-datetimes-li ee-event-datetimes-li-' . $datetime->get_active_status() . '">'; |
|
482 | + $html = $format ? '<ul id="ee-event-datetimes-ul-'.$post->ID.'" class="ee-event-datetimes-ul ee-clearfix">' : ''; |
|
483 | + foreach ($datetimes as $datetime) { |
|
484 | + if ($datetime instanceof EE_Datetime) { |
|
485 | + $html .= '<li id="ee-event-datetimes-li-'.$datetime->ID(); |
|
486 | + $html .= '" class="ee-event-datetimes-li ee-event-datetimes-li-'.$datetime->get_active_status().'">'; |
|
487 | 487 | $datetime_name = $datetime->name(); |
488 | - $html .= ! empty( $datetime_name ) ? '<strong>' . $datetime_name . '</strong>' : ''; |
|
489 | - $html .= ! empty( $datetime_name ) && $add_breaks ? '<br />' : ''; |
|
490 | - $html .= '<span class="dashicons dashicons-calendar"></span><span class="ee-event-datetimes-li-daterange">' . $datetime->date_range( $date_format ) . '</span><br/>'; |
|
491 | - $html .= '<span class="dashicons dashicons-clock"></span><span class="ee-event-datetimes-li-timerange">' . $datetime->time_range( $time_format ) . '</span>'; |
|
488 | + $html .= ! empty($datetime_name) ? '<strong>'.$datetime_name.'</strong>' : ''; |
|
489 | + $html .= ! empty($datetime_name) && $add_breaks ? '<br />' : ''; |
|
490 | + $html .= '<span class="dashicons dashicons-calendar"></span><span class="ee-event-datetimes-li-daterange">'.$datetime->date_range($date_format).'</span><br/>'; |
|
491 | + $html .= '<span class="dashicons dashicons-clock"></span><span class="ee-event-datetimes-li-timerange">'.$datetime->time_range($time_format).'</span>'; |
|
492 | 492 | $datetime_description = $datetime->description(); |
493 | - $html .= ! empty( $datetime_description ) && $add_breaks ? '<br />' : ''; |
|
494 | - $html .= ! empty( $datetime_description ) ? ' - ' . $datetime_description : ''; |
|
495 | - $html = apply_filters( 'FHEE__espresso_list_of_event_dates__datetime_html', $html, $datetime ); |
|
493 | + $html .= ! empty($datetime_description) && $add_breaks ? '<br />' : ''; |
|
494 | + $html .= ! empty($datetime_description) ? ' - '.$datetime_description : ''; |
|
495 | + $html = apply_filters('FHEE__espresso_list_of_event_dates__datetime_html', $html, $datetime); |
|
496 | 496 | $html .= '</li>'; |
497 | 497 | } |
498 | 498 | } |
499 | 499 | $html .= $format ? '</ul>' : ''; |
500 | 500 | } else { |
501 | - $html = $format ? '<p><span class="dashicons dashicons-marker pink-text"></span>' . __( 'There are no upcoming dates for this event.', 'event_espresso' ) . '</p><br/>' : ''; |
|
501 | + $html = $format ? '<p><span class="dashicons dashicons-marker pink-text"></span>'.__('There are no upcoming dates for this event.', 'event_espresso').'</p><br/>' : ''; |
|
502 | 502 | } |
503 | - if ( $echo ) { |
|
503 | + if ($echo) { |
|
504 | 504 | echo $html; |
505 | 505 | return ''; |
506 | 506 | } |
@@ -509,7 +509,7 @@ discard block |
||
509 | 509 | } |
510 | 510 | |
511 | 511 | |
512 | -if ( ! function_exists( 'espresso_event_end_date' )) { |
|
512 | +if ( ! function_exists('espresso_event_end_date')) { |
|
513 | 513 | /** |
514 | 514 | * espresso_event_end_date |
515 | 515 | * returns the last date for an event |
@@ -520,20 +520,20 @@ discard block |
||
520 | 520 | * @param bool $echo |
521 | 521 | * @return string |
522 | 522 | */ |
523 | - function espresso_event_end_date( $date_format = '', $time_format = '', $EVT_ID = FALSE, $echo = TRUE ) { |
|
524 | - $date_format = ! empty( $date_format ) ? $date_format : get_option( 'date_format' ); |
|
525 | - $time_format = ! empty( $time_format ) ? $time_format : get_option( 'time_format' ); |
|
526 | - $date_format = apply_filters( 'FHEE__espresso_event_end_date__date_format', $date_format ); |
|
527 | - $time_format = apply_filters( 'FHEE__espresso_event_end_date__time_format', $time_format ); |
|
528 | - if($echo){ |
|
529 | - echo EEH_Event_View::the_event_end_date( $date_format, $time_format, $EVT_ID ); |
|
523 | + function espresso_event_end_date($date_format = '', $time_format = '', $EVT_ID = FALSE, $echo = TRUE) { |
|
524 | + $date_format = ! empty($date_format) ? $date_format : get_option('date_format'); |
|
525 | + $time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
|
526 | + $date_format = apply_filters('FHEE__espresso_event_end_date__date_format', $date_format); |
|
527 | + $time_format = apply_filters('FHEE__espresso_event_end_date__time_format', $time_format); |
|
528 | + if ($echo) { |
|
529 | + echo EEH_Event_View::the_event_end_date($date_format, $time_format, $EVT_ID); |
|
530 | 530 | return ''; |
531 | 531 | } |
532 | - return EEH_Event_View::the_event_end_date( $date_format, $time_format, $EVT_ID ); |
|
532 | + return EEH_Event_View::the_event_end_date($date_format, $time_format, $EVT_ID); |
|
533 | 533 | } |
534 | 534 | } |
535 | 535 | |
536 | -if ( ! function_exists( 'espresso_event_date_range' )) { |
|
536 | +if ( ! function_exists('espresso_event_date_range')) { |
|
537 | 537 | /** |
538 | 538 | * espresso_event_date_range |
539 | 539 | * returns the first and last chronologically ordered dates for an event (if different) |
@@ -546,31 +546,31 @@ discard block |
||
546 | 546 | * @param bool $echo |
547 | 547 | * @return string |
548 | 548 | */ |
549 | - function espresso_event_date_range( $date_format = '', $time_format = '', $single_date_format = '', $single_time_format = '', $EVT_ID = FALSE, $echo = TRUE ) { |
|
549 | + function espresso_event_date_range($date_format = '', $time_format = '', $single_date_format = '', $single_time_format = '', $EVT_ID = FALSE, $echo = TRUE) { |
|
550 | 550 | // set and filter date and time formats when a range is returned |
551 | - $date_format = ! empty( $date_format ) ? $date_format : get_option( 'date_format' ); |
|
552 | - $date_format = apply_filters( 'FHEE__espresso_event_date_range__date_format', $date_format ); |
|
551 | + $date_format = ! empty($date_format) ? $date_format : get_option('date_format'); |
|
552 | + $date_format = apply_filters('FHEE__espresso_event_date_range__date_format', $date_format); |
|
553 | 553 | // get the start and end date with NO time portion |
554 | - $the_event_date = EEH_Event_View::the_earliest_event_date( $date_format, '', $EVT_ID ); |
|
555 | - $the_event_end_date = EEH_Event_View::the_latest_event_date( $date_format, '', $EVT_ID ); |
|
554 | + $the_event_date = EEH_Event_View::the_earliest_event_date($date_format, '', $EVT_ID); |
|
555 | + $the_event_end_date = EEH_Event_View::the_latest_event_date($date_format, '', $EVT_ID); |
|
556 | 556 | // now we can determine if date range spans more than one day |
557 | - if ( $the_event_date != $the_event_end_date ) { |
|
558 | - $time_format = ! empty( $time_format ) ? $time_format : get_option( 'time_format' ); |
|
559 | - $time_format = apply_filters( 'FHEE__espresso_event_date_range__time_format', $time_format ); |
|
557 | + if ($the_event_date != $the_event_end_date) { |
|
558 | + $time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
|
559 | + $time_format = apply_filters('FHEE__espresso_event_date_range__time_format', $time_format); |
|
560 | 560 | $html = sprintf( |
561 | - __( '%1$s - %2$s', 'event_espresso' ), |
|
562 | - EEH_Event_View::the_earliest_event_date( $date_format, $time_format, $EVT_ID ), |
|
563 | - EEH_Event_View::the_latest_event_date( $date_format, $time_format, $EVT_ID ) |
|
561 | + __('%1$s - %2$s', 'event_espresso'), |
|
562 | + EEH_Event_View::the_earliest_event_date($date_format, $time_format, $EVT_ID), |
|
563 | + EEH_Event_View::the_latest_event_date($date_format, $time_format, $EVT_ID) |
|
564 | 564 | ); |
565 | 565 | } else { |
566 | 566 | // set and filter date and time formats when only a single datetime is returned |
567 | - $single_date_format = ! empty( $single_date_format ) ? $single_date_format : get_option( 'date_format' ); |
|
568 | - $single_time_format = ! empty( $single_time_format ) ? $single_time_format : get_option( 'time_format' ); |
|
569 | - $single_date_format = apply_filters( 'FHEE__espresso_event_date_range__single_date_format', $single_date_format ); |
|
570 | - $single_time_format = apply_filters( 'FHEE__espresso_event_date_range__single_time_format', $single_time_format ); |
|
571 | - $html = EEH_Event_View::the_earliest_event_date( $single_date_format, $single_time_format, $EVT_ID ); |
|
567 | + $single_date_format = ! empty($single_date_format) ? $single_date_format : get_option('date_format'); |
|
568 | + $single_time_format = ! empty($single_time_format) ? $single_time_format : get_option('time_format'); |
|
569 | + $single_date_format = apply_filters('FHEE__espresso_event_date_range__single_date_format', $single_date_format); |
|
570 | + $single_time_format = apply_filters('FHEE__espresso_event_date_range__single_time_format', $single_time_format); |
|
571 | + $html = EEH_Event_View::the_earliest_event_date($single_date_format, $single_time_format, $EVT_ID); |
|
572 | 572 | } |
573 | - if ( $echo ) { |
|
573 | + if ($echo) { |
|
574 | 574 | echo $html; |
575 | 575 | return ''; |
576 | 576 | } |
@@ -579,7 +579,7 @@ discard block |
||
579 | 579 | } |
580 | 580 | |
581 | 581 | |
582 | -if ( ! function_exists( 'espresso_event_date_as_calendar_page' )) { |
|
582 | +if ( ! function_exists('espresso_event_date_as_calendar_page')) { |
|
583 | 583 | /** |
584 | 584 | * espresso_event_date_as_calendar_page |
585 | 585 | * returns the primary date for an event, stylized to appear as the page of a calendar |
@@ -587,15 +587,15 @@ discard block |
||
587 | 587 | * @param bool $EVT_ID |
588 | 588 | * @return string |
589 | 589 | */ |
590 | - function espresso_event_date_as_calendar_page( $EVT_ID = FALSE ) { |
|
591 | - EEH_Event_View::event_date_as_calendar_page( $EVT_ID ); |
|
590 | + function espresso_event_date_as_calendar_page($EVT_ID = FALSE) { |
|
591 | + EEH_Event_View::event_date_as_calendar_page($EVT_ID); |
|
592 | 592 | } |
593 | 593 | } |
594 | 594 | |
595 | 595 | |
596 | 596 | |
597 | 597 | |
598 | -if ( ! function_exists( 'espresso_event_link_url' )) { |
|
598 | +if ( ! function_exists('espresso_event_link_url')) { |
|
599 | 599 | /** |
600 | 600 | * espresso_event_link_url |
601 | 601 | * |
@@ -603,18 +603,18 @@ discard block |
||
603 | 603 | * @param bool $echo |
604 | 604 | * @return string |
605 | 605 | */ |
606 | - function espresso_event_link_url( $EVT_ID = 0, $echo = TRUE ) { |
|
607 | - if ( $echo ) { |
|
608 | - echo EEH_Event_View::event_link_url( $EVT_ID ); |
|
606 | + function espresso_event_link_url($EVT_ID = 0, $echo = TRUE) { |
|
607 | + if ($echo) { |
|
608 | + echo EEH_Event_View::event_link_url($EVT_ID); |
|
609 | 609 | return ''; |
610 | 610 | } |
611 | - return EEH_Event_View::event_link_url( $EVT_ID ); |
|
611 | + return EEH_Event_View::event_link_url($EVT_ID); |
|
612 | 612 | } |
613 | 613 | } |
614 | 614 | |
615 | 615 | |
616 | 616 | |
617 | -if ( ! function_exists( 'espresso_event_has_content_or_excerpt' )) { |
|
617 | +if ( ! function_exists('espresso_event_has_content_or_excerpt')) { |
|
618 | 618 | /** |
619 | 619 | * espresso_event_has_content_or_excerpt |
620 | 620 | * |
@@ -622,15 +622,15 @@ discard block |
||
622 | 622 | * @param bool $EVT_ID |
623 | 623 | * @return boolean |
624 | 624 | */ |
625 | - function espresso_event_has_content_or_excerpt( $EVT_ID = FALSE ) { |
|
626 | - return EEH_Event_View::event_has_content_or_excerpt( $EVT_ID ); |
|
625 | + function espresso_event_has_content_or_excerpt($EVT_ID = FALSE) { |
|
626 | + return EEH_Event_View::event_has_content_or_excerpt($EVT_ID); |
|
627 | 627 | } |
628 | 628 | } |
629 | 629 | |
630 | 630 | |
631 | 631 | |
632 | 632 | |
633 | -if ( ! function_exists( 'espresso_event_content_or_excerpt' )) { |
|
633 | +if ( ! function_exists('espresso_event_content_or_excerpt')) { |
|
634 | 634 | /** |
635 | 635 | * espresso_event_content_or_excerpt |
636 | 636 | * |
@@ -639,18 +639,18 @@ discard block |
||
639 | 639 | * @param bool $echo |
640 | 640 | * @return string |
641 | 641 | */ |
642 | - function espresso_event_content_or_excerpt( $num_words = 55, $more = NULL, $echo = TRUE ) { |
|
643 | - if ( $echo ) { |
|
644 | - echo EEH_Event_View::event_content_or_excerpt( $num_words, $more ); |
|
642 | + function espresso_event_content_or_excerpt($num_words = 55, $more = NULL, $echo = TRUE) { |
|
643 | + if ($echo) { |
|
644 | + echo EEH_Event_View::event_content_or_excerpt($num_words, $more); |
|
645 | 645 | return ''; |
646 | 646 | } |
647 | - return EEH_Event_View::event_content_or_excerpt( $num_words, $more ); |
|
647 | + return EEH_Event_View::event_content_or_excerpt($num_words, $more); |
|
648 | 648 | } |
649 | 649 | } |
650 | 650 | |
651 | 651 | |
652 | 652 | |
653 | -if ( ! function_exists( 'espresso_event_phone' )) { |
|
653 | +if ( ! function_exists('espresso_event_phone')) { |
|
654 | 654 | /** |
655 | 655 | * espresso_event_phone |
656 | 656 | * |
@@ -658,18 +658,18 @@ discard block |
||
658 | 658 | * @param bool $echo |
659 | 659 | * @return string |
660 | 660 | */ |
661 | - function espresso_event_phone( $EVT_ID = 0, $echo = TRUE ) { |
|
662 | - if ( $echo ) { |
|
663 | - echo EEH_Event_View::event_phone( $EVT_ID ); |
|
661 | + function espresso_event_phone($EVT_ID = 0, $echo = TRUE) { |
|
662 | + if ($echo) { |
|
663 | + echo EEH_Event_View::event_phone($EVT_ID); |
|
664 | 664 | return ''; |
665 | 665 | } |
666 | - return EEH_Event_View::event_phone( $EVT_ID ); |
|
666 | + return EEH_Event_View::event_phone($EVT_ID); |
|
667 | 667 | } |
668 | 668 | } |
669 | 669 | |
670 | 670 | |
671 | 671 | |
672 | -if ( ! function_exists( 'espresso_edit_event_link' )) { |
|
672 | +if ( ! function_exists('espresso_edit_event_link')) { |
|
673 | 673 | /** |
674 | 674 | * espresso_edit_event_link |
675 | 675 | * returns a link to edit an event |
@@ -678,39 +678,39 @@ discard block |
||
678 | 678 | * @param bool $echo |
679 | 679 | * @return string |
680 | 680 | */ |
681 | - function espresso_edit_event_link( $EVT_ID = 0, $echo = TRUE ) { |
|
682 | - if ( $echo ) { |
|
683 | - echo EEH_Event_View::edit_event_link( $EVT_ID ); |
|
681 | + function espresso_edit_event_link($EVT_ID = 0, $echo = TRUE) { |
|
682 | + if ($echo) { |
|
683 | + echo EEH_Event_View::edit_event_link($EVT_ID); |
|
684 | 684 | return ''; |
685 | 685 | } |
686 | - return EEH_Event_View::edit_event_link( $EVT_ID ); |
|
686 | + return EEH_Event_View::edit_event_link($EVT_ID); |
|
687 | 687 | } |
688 | 688 | } |
689 | 689 | |
690 | 690 | |
691 | -if ( ! function_exists( 'espresso_organization_name' )) { |
|
691 | +if ( ! function_exists('espresso_organization_name')) { |
|
692 | 692 | /** |
693 | 693 | * espresso_organization_name |
694 | 694 | * @param bool $echo |
695 | 695 | * @return string |
696 | 696 | */ |
697 | 697 | function espresso_organization_name($echo = TRUE) { |
698 | - if($echo){ |
|
699 | - echo EE_Registry::instance()->CFG->organization->get_pretty( 'name' ); |
|
698 | + if ($echo) { |
|
699 | + echo EE_Registry::instance()->CFG->organization->get_pretty('name'); |
|
700 | 700 | return ''; |
701 | 701 | } |
702 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'name' ); |
|
702 | + return EE_Registry::instance()->CFG->organization->get_pretty('name'); |
|
703 | 703 | } |
704 | 704 | } |
705 | 705 | |
706 | -if ( ! function_exists( 'espresso_organization_address' )) { |
|
706 | +if ( ! function_exists('espresso_organization_address')) { |
|
707 | 707 | /** |
708 | 708 | * espresso_organization_address |
709 | 709 | * @param string $type |
710 | 710 | * @return string |
711 | 711 | */ |
712 | - function espresso_organization_address( $type = 'inline' ) { |
|
713 | - if ( EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config ) { |
|
712 | + function espresso_organization_address($type = 'inline') { |
|
713 | + if (EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config) { |
|
714 | 714 | $address = new EventEspresso\core\domain\entities\GenericAddress( |
715 | 715 | EE_Registry::instance()->CFG->organization->address_1, |
716 | 716 | EE_Registry::instance()->CFG->organization->address_2, |
@@ -719,129 +719,129 @@ discard block |
||
719 | 719 | EE_Registry::instance()->CFG->organization->zip, |
720 | 720 | EE_Registry::instance()->CFG->organization->CNT_ISO |
721 | 721 | ); |
722 | - return EEH_Address::format( $address, $type ); |
|
722 | + return EEH_Address::format($address, $type); |
|
723 | 723 | } |
724 | 724 | return ''; |
725 | 725 | } |
726 | 726 | } |
727 | 727 | |
728 | -if ( ! function_exists( 'espresso_organization_email' )) { |
|
728 | +if ( ! function_exists('espresso_organization_email')) { |
|
729 | 729 | /** |
730 | 730 | * espresso_organization_email |
731 | 731 | * @param bool $echo |
732 | 732 | * @return string |
733 | 733 | */ |
734 | - function espresso_organization_email( $echo = TRUE ) { |
|
735 | - if($echo){ |
|
736 | - echo EE_Registry::instance()->CFG->organization->get_pretty( 'email' ); |
|
734 | + function espresso_organization_email($echo = TRUE) { |
|
735 | + if ($echo) { |
|
736 | + echo EE_Registry::instance()->CFG->organization->get_pretty('email'); |
|
737 | 737 | return ''; |
738 | 738 | } |
739 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'email' ); |
|
739 | + return EE_Registry::instance()->CFG->organization->get_pretty('email'); |
|
740 | 740 | } |
741 | 741 | } |
742 | 742 | |
743 | -if ( ! function_exists( 'espresso_organization_logo_url' )) { |
|
743 | +if ( ! function_exists('espresso_organization_logo_url')) { |
|
744 | 744 | /** |
745 | 745 | * espresso_organization_logo_url |
746 | 746 | * @param bool $echo |
747 | 747 | * @return string |
748 | 748 | */ |
749 | - function espresso_organization_logo_url( $echo = TRUE ) { |
|
750 | - if($echo){ |
|
751 | - echo EE_Registry::instance()->CFG->organization->get_pretty( 'logo_url' ); |
|
749 | + function espresso_organization_logo_url($echo = TRUE) { |
|
750 | + if ($echo) { |
|
751 | + echo EE_Registry::instance()->CFG->organization->get_pretty('logo_url'); |
|
752 | 752 | return ''; |
753 | 753 | } |
754 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'logo_url' ); |
|
754 | + return EE_Registry::instance()->CFG->organization->get_pretty('logo_url'); |
|
755 | 755 | } |
756 | 756 | } |
757 | 757 | |
758 | -if ( ! function_exists( 'espresso_organization_facebook' )) { |
|
758 | +if ( ! function_exists('espresso_organization_facebook')) { |
|
759 | 759 | /** |
760 | 760 | * espresso_organization_facebook |
761 | 761 | * @param bool $echo |
762 | 762 | * @return string |
763 | 763 | */ |
764 | - function espresso_organization_facebook( $echo = TRUE ) { |
|
765 | - if($echo){ |
|
766 | - echo EE_Registry::instance()->CFG->organization->get_pretty( 'facebook' ); |
|
764 | + function espresso_organization_facebook($echo = TRUE) { |
|
765 | + if ($echo) { |
|
766 | + echo EE_Registry::instance()->CFG->organization->get_pretty('facebook'); |
|
767 | 767 | return ''; |
768 | 768 | } |
769 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'facebook' ); |
|
769 | + return EE_Registry::instance()->CFG->organization->get_pretty('facebook'); |
|
770 | 770 | } |
771 | 771 | } |
772 | 772 | |
773 | -if ( ! function_exists( 'espresso_organization_twitter' )) { |
|
773 | +if ( ! function_exists('espresso_organization_twitter')) { |
|
774 | 774 | /** |
775 | 775 | * espresso_organization_twitter |
776 | 776 | * @param bool $echo |
777 | 777 | * @return string |
778 | 778 | */ |
779 | - function espresso_organization_twitter( $echo = TRUE ) { |
|
780 | - if($echo){ |
|
781 | - echo EE_Registry::instance()->CFG->organization->get_pretty( 'twitter' ); |
|
779 | + function espresso_organization_twitter($echo = TRUE) { |
|
780 | + if ($echo) { |
|
781 | + echo EE_Registry::instance()->CFG->organization->get_pretty('twitter'); |
|
782 | 782 | return ''; |
783 | 783 | } |
784 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'twitter' ); |
|
784 | + return EE_Registry::instance()->CFG->organization->get_pretty('twitter'); |
|
785 | 785 | } |
786 | 786 | } |
787 | 787 | |
788 | -if ( ! function_exists( 'espresso_organization_linkedin' )) { |
|
788 | +if ( ! function_exists('espresso_organization_linkedin')) { |
|
789 | 789 | /** |
790 | 790 | * espresso_organization_linkedin |
791 | 791 | * @param bool $echo |
792 | 792 | * @return string |
793 | 793 | */ |
794 | - function espresso_organization_linkedin( $echo = TRUE ) { |
|
795 | - if($echo){ |
|
796 | - echo EE_Registry::instance()->CFG->organization->get_pretty( 'linkedin' ); |
|
794 | + function espresso_organization_linkedin($echo = TRUE) { |
|
795 | + if ($echo) { |
|
796 | + echo EE_Registry::instance()->CFG->organization->get_pretty('linkedin'); |
|
797 | 797 | return ''; |
798 | 798 | } |
799 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'linkedin' ); |
|
799 | + return EE_Registry::instance()->CFG->organization->get_pretty('linkedin'); |
|
800 | 800 | } |
801 | 801 | } |
802 | 802 | |
803 | -if ( ! function_exists( 'espresso_organization_pinterest' )) { |
|
803 | +if ( ! function_exists('espresso_organization_pinterest')) { |
|
804 | 804 | /** |
805 | 805 | * espresso_organization_pinterest |
806 | 806 | * @param bool $echo |
807 | 807 | * @return string |
808 | 808 | */ |
809 | - function espresso_organization_pinterest( $echo = TRUE ) { |
|
810 | - if($echo){ |
|
811 | - echo EE_Registry::instance()->CFG->organization->get_pretty( 'pinterest' ); |
|
809 | + function espresso_organization_pinterest($echo = TRUE) { |
|
810 | + if ($echo) { |
|
811 | + echo EE_Registry::instance()->CFG->organization->get_pretty('pinterest'); |
|
812 | 812 | return ''; |
813 | 813 | } |
814 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'pinterest' ); |
|
814 | + return EE_Registry::instance()->CFG->organization->get_pretty('pinterest'); |
|
815 | 815 | } |
816 | 816 | } |
817 | 817 | |
818 | -if ( ! function_exists( 'espresso_organization_google' )) { |
|
818 | +if ( ! function_exists('espresso_organization_google')) { |
|
819 | 819 | /** |
820 | 820 | * espresso_organization_google |
821 | 821 | * @param bool $echo |
822 | 822 | * @return string |
823 | 823 | */ |
824 | - function espresso_organization_google( $echo = TRUE ) { |
|
825 | - if($echo){ |
|
826 | - echo EE_Registry::instance()->CFG->organization->get_pretty( 'google' ); |
|
824 | + function espresso_organization_google($echo = TRUE) { |
|
825 | + if ($echo) { |
|
826 | + echo EE_Registry::instance()->CFG->organization->get_pretty('google'); |
|
827 | 827 | return ''; |
828 | 828 | } |
829 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'google' ); |
|
829 | + return EE_Registry::instance()->CFG->organization->get_pretty('google'); |
|
830 | 830 | } |
831 | 831 | } |
832 | 832 | |
833 | -if ( ! function_exists( 'espresso_organization_instagram' )) { |
|
833 | +if ( ! function_exists('espresso_organization_instagram')) { |
|
834 | 834 | /** |
835 | 835 | * espresso_organization_instagram |
836 | 836 | * @param bool $echo |
837 | 837 | * @return string |
838 | 838 | */ |
839 | - function espresso_organization_instagram( $echo = TRUE ) { |
|
840 | - if($echo){ |
|
841 | - echo EE_Registry::instance()->CFG->organization->get_pretty( 'instagram' ); |
|
839 | + function espresso_organization_instagram($echo = TRUE) { |
|
840 | + if ($echo) { |
|
841 | + echo EE_Registry::instance()->CFG->organization->get_pretty('instagram'); |
|
842 | 842 | return ''; |
843 | 843 | } |
844 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'instagram' ); |
|
844 | + return EE_Registry::instance()->CFG->organization->get_pretty('instagram'); |
|
845 | 845 | } |
846 | 846 | } |
847 | 847 | |
@@ -851,7 +851,7 @@ discard block |
||
851 | 851 | |
852 | 852 | |
853 | 853 | |
854 | -if ( ! function_exists( 'espresso_event_venues' )) { |
|
854 | +if ( ! function_exists('espresso_event_venues')) { |
|
855 | 855 | /** |
856 | 856 | * espresso_event_venues |
857 | 857 | * |
@@ -865,7 +865,7 @@ discard block |
||
865 | 865 | |
866 | 866 | |
867 | 867 | |
868 | -if ( ! function_exists( 'espresso_venue_id' )) { |
|
868 | +if ( ! function_exists('espresso_venue_id')) { |
|
869 | 869 | /** |
870 | 870 | * espresso_venue_name |
871 | 871 | * |
@@ -873,15 +873,15 @@ discard block |
||
873 | 873 | * @param int $EVT_ID |
874 | 874 | * @return string |
875 | 875 | */ |
876 | - function espresso_venue_id( $EVT_ID = 0 ) { |
|
877 | - $venue = EEH_Venue_View::get_venue( $EVT_ID ); |
|
876 | + function espresso_venue_id($EVT_ID = 0) { |
|
877 | + $venue = EEH_Venue_View::get_venue($EVT_ID); |
|
878 | 878 | return $venue instanceof EE_Venue ? $venue->ID() : 0; |
879 | 879 | } |
880 | 880 | } |
881 | 881 | |
882 | 882 | |
883 | 883 | |
884 | -if ( ! function_exists( 'espresso_is_venue_private' ) ) { |
|
884 | +if ( ! function_exists('espresso_is_venue_private')) { |
|
885 | 885 | /** |
886 | 886 | * Return whether a venue is private or not. |
887 | 887 | * @see EEH_Venue_View::get_venue() for more info on expected return results. |
@@ -890,45 +890,45 @@ discard block |
||
890 | 890 | * |
891 | 891 | * @return bool | null |
892 | 892 | */ |
893 | - function espresso_is_venue_private( $VNU_ID = 0 ) { |
|
894 | - return EEH_Venue_View::is_venue_private( $VNU_ID ); |
|
893 | + function espresso_is_venue_private($VNU_ID = 0) { |
|
894 | + return EEH_Venue_View::is_venue_private($VNU_ID); |
|
895 | 895 | } |
896 | 896 | } |
897 | 897 | |
898 | 898 | |
899 | 899 | |
900 | -if ( ! function_exists( 'espresso_venue_is_password_protected' ) ) { |
|
900 | +if ( ! function_exists('espresso_venue_is_password_protected')) { |
|
901 | 901 | /** |
902 | 902 | * returns true or false if a venue is password protected or not |
903 | 903 | * |
904 | 904 | * @param int $VNU_ID optional, the venue id to check. |
905 | 905 | * @return string |
906 | 906 | */ |
907 | - function espresso_venue_is_password_protected( $VNU_ID = 0 ) { |
|
908 | - EE_Registry::instance()->load_helper( 'Venue_View' ); |
|
909 | - return EEH_Venue_View::is_venue_password_protected( $VNU_ID ); |
|
907 | + function espresso_venue_is_password_protected($VNU_ID = 0) { |
|
908 | + EE_Registry::instance()->load_helper('Venue_View'); |
|
909 | + return EEH_Venue_View::is_venue_password_protected($VNU_ID); |
|
910 | 910 | } |
911 | 911 | } |
912 | 912 | |
913 | 913 | |
914 | 914 | |
915 | -if ( ! function_exists( 'espresso_password_protected_venue_form' ) ) { |
|
915 | +if ( ! function_exists('espresso_password_protected_venue_form')) { |
|
916 | 916 | /** |
917 | 917 | * Returns a password form if venue is password protected. |
918 | 918 | * |
919 | 919 | * @param int $VNU_ID optional, the venue id to check. |
920 | 920 | * @return string |
921 | 921 | */ |
922 | - function espresso_password_protected_venue_form( $VNU_ID = 0 ) { |
|
923 | - EE_Registry::instance()->load_helper( 'Venue_View' ); |
|
924 | - return EEH_Venue_View::password_protected_venue_form( $VNU_ID ); |
|
922 | + function espresso_password_protected_venue_form($VNU_ID = 0) { |
|
923 | + EE_Registry::instance()->load_helper('Venue_View'); |
|
924 | + return EEH_Venue_View::password_protected_venue_form($VNU_ID); |
|
925 | 925 | } |
926 | 926 | } |
927 | 927 | |
928 | 928 | |
929 | 929 | |
930 | 930 | |
931 | -if ( ! function_exists( 'espresso_venue_name' )) { |
|
931 | +if ( ! function_exists('espresso_venue_name')) { |
|
932 | 932 | /** |
933 | 933 | * espresso_venue_name |
934 | 934 | * |
@@ -938,19 +938,19 @@ discard block |
||
938 | 938 | * @param bool $echo |
939 | 939 | * @return string |
940 | 940 | */ |
941 | - function espresso_venue_name( $VNU_ID = 0, $link_to = 'details', $echo = TRUE ) { |
|
942 | - if($echo){ |
|
943 | - echo EEH_Venue_View::venue_name( $link_to, $VNU_ID ); |
|
941 | + function espresso_venue_name($VNU_ID = 0, $link_to = 'details', $echo = TRUE) { |
|
942 | + if ($echo) { |
|
943 | + echo EEH_Venue_View::venue_name($link_to, $VNU_ID); |
|
944 | 944 | return ''; |
945 | 945 | } |
946 | - return EEH_Venue_View::venue_name( $link_to, $VNU_ID ); |
|
946 | + return EEH_Venue_View::venue_name($link_to, $VNU_ID); |
|
947 | 947 | } |
948 | 948 | } |
949 | 949 | |
950 | 950 | |
951 | 951 | |
952 | 952 | |
953 | -if ( ! function_exists( 'espresso_venue_link' )) { |
|
953 | +if ( ! function_exists('espresso_venue_link')) { |
|
954 | 954 | /** |
955 | 955 | * espresso_venue_link |
956 | 956 | * |
@@ -959,14 +959,14 @@ discard block |
||
959 | 959 | * @param string $text |
960 | 960 | * @return string |
961 | 961 | */ |
962 | - function espresso_venue_link( $VNU_ID = 0, $text = '' ) { |
|
963 | - return EEH_Venue_View::venue_details_link( $VNU_ID, $text ); |
|
962 | + function espresso_venue_link($VNU_ID = 0, $text = '') { |
|
963 | + return EEH_Venue_View::venue_details_link($VNU_ID, $text); |
|
964 | 964 | } |
965 | 965 | } |
966 | 966 | |
967 | 967 | |
968 | 968 | |
969 | -if ( ! function_exists( 'espresso_venue_description' )) { |
|
969 | +if ( ! function_exists('espresso_venue_description')) { |
|
970 | 970 | /** |
971 | 971 | * espresso_venue_description |
972 | 972 | * |
@@ -975,17 +975,17 @@ discard block |
||
975 | 975 | * @param bool $echo |
976 | 976 | * @return string |
977 | 977 | */ |
978 | - function espresso_venue_description( $VNU_ID = FALSE, $echo = TRUE ) { |
|
979 | - if($echo){ |
|
980 | - echo EEH_Venue_View::venue_description( $VNU_ID ); |
|
978 | + function espresso_venue_description($VNU_ID = FALSE, $echo = TRUE) { |
|
979 | + if ($echo) { |
|
980 | + echo EEH_Venue_View::venue_description($VNU_ID); |
|
981 | 981 | return ''; |
982 | 982 | } |
983 | - return EEH_Venue_View::venue_description( $VNU_ID ); |
|
983 | + return EEH_Venue_View::venue_description($VNU_ID); |
|
984 | 984 | } |
985 | 985 | } |
986 | 986 | |
987 | 987 | |
988 | -if ( ! function_exists( 'espresso_venue_excerpt' )) { |
|
988 | +if ( ! function_exists('espresso_venue_excerpt')) { |
|
989 | 989 | /** |
990 | 990 | * espresso_venue_excerpt |
991 | 991 | * |
@@ -994,18 +994,18 @@ discard block |
||
994 | 994 | * @param bool $echo |
995 | 995 | * @return string |
996 | 996 | */ |
997 | - function espresso_venue_excerpt( $VNU_ID = 0, $echo = TRUE ) { |
|
998 | - if ( $echo ) { |
|
999 | - echo EEH_Venue_View::venue_excerpt( $VNU_ID ); |
|
997 | + function espresso_venue_excerpt($VNU_ID = 0, $echo = TRUE) { |
|
998 | + if ($echo) { |
|
999 | + echo EEH_Venue_View::venue_excerpt($VNU_ID); |
|
1000 | 1000 | return ''; |
1001 | 1001 | } |
1002 | - return EEH_Venue_View::venue_excerpt( $VNU_ID ); |
|
1002 | + return EEH_Venue_View::venue_excerpt($VNU_ID); |
|
1003 | 1003 | } |
1004 | 1004 | } |
1005 | 1005 | |
1006 | 1006 | |
1007 | 1007 | |
1008 | -if ( ! function_exists( 'espresso_venue_categories' )) { |
|
1008 | +if ( ! function_exists('espresso_venue_categories')) { |
|
1009 | 1009 | /** |
1010 | 1010 | * espresso_venue_categories |
1011 | 1011 | * returns the terms associated with a venue |
@@ -1015,17 +1015,17 @@ discard block |
||
1015 | 1015 | * @param bool $echo |
1016 | 1016 | * @return string |
1017 | 1017 | */ |
1018 | - function espresso_venue_categories( $VNU_ID = 0, $hide_uncategorized = TRUE, $echo = TRUE ) { |
|
1019 | - if ( $echo ) { |
|
1020 | - echo EEH_Venue_View::venue_categories( $VNU_ID, $hide_uncategorized ); |
|
1018 | + function espresso_venue_categories($VNU_ID = 0, $hide_uncategorized = TRUE, $echo = TRUE) { |
|
1019 | + if ($echo) { |
|
1020 | + echo EEH_Venue_View::venue_categories($VNU_ID, $hide_uncategorized); |
|
1021 | 1021 | return ''; |
1022 | 1022 | } |
1023 | - return EEH_Venue_View::venue_categories( $VNU_ID, $hide_uncategorized ); |
|
1023 | + return EEH_Venue_View::venue_categories($VNU_ID, $hide_uncategorized); |
|
1024 | 1024 | } |
1025 | 1025 | } |
1026 | 1026 | |
1027 | 1027 | |
1028 | -if ( ! function_exists( 'espresso_venue_address' )) { |
|
1028 | +if ( ! function_exists('espresso_venue_address')) { |
|
1029 | 1029 | /** |
1030 | 1030 | * espresso_venue_address |
1031 | 1031 | * returns a formatted block of html for displaying a venue's address |
@@ -1035,17 +1035,17 @@ discard block |
||
1035 | 1035 | * @param bool $echo |
1036 | 1036 | * @return string |
1037 | 1037 | */ |
1038 | - function espresso_venue_address( $type = 'multiline', $VNU_ID = 0, $echo = TRUE ) { |
|
1039 | - if ( $echo ) { |
|
1040 | - echo EEH_Venue_View::venue_address( $type, $VNU_ID ); |
|
1038 | + function espresso_venue_address($type = 'multiline', $VNU_ID = 0, $echo = TRUE) { |
|
1039 | + if ($echo) { |
|
1040 | + echo EEH_Venue_View::venue_address($type, $VNU_ID); |
|
1041 | 1041 | return ''; |
1042 | 1042 | } |
1043 | - return EEH_Venue_View::venue_address( $type, $VNU_ID ); |
|
1043 | + return EEH_Venue_View::venue_address($type, $VNU_ID); |
|
1044 | 1044 | } |
1045 | 1045 | } |
1046 | 1046 | |
1047 | 1047 | |
1048 | -if ( ! function_exists( 'espresso_venue_raw_address' )) { |
|
1048 | +if ( ! function_exists('espresso_venue_raw_address')) { |
|
1049 | 1049 | /** |
1050 | 1050 | * espresso_venue_address |
1051 | 1051 | * returns an UN-formatted string containing a venue's address |
@@ -1055,17 +1055,17 @@ discard block |
||
1055 | 1055 | * @param bool $echo |
1056 | 1056 | * @return string |
1057 | 1057 | */ |
1058 | - function espresso_venue_raw_address( $type = 'multiline', $VNU_ID = 0, $echo = TRUE ) { |
|
1059 | - if ( $echo ) { |
|
1060 | - echo EEH_Venue_View::venue_address( $type, $VNU_ID, FALSE, FALSE ); |
|
1058 | + function espresso_venue_raw_address($type = 'multiline', $VNU_ID = 0, $echo = TRUE) { |
|
1059 | + if ($echo) { |
|
1060 | + echo EEH_Venue_View::venue_address($type, $VNU_ID, FALSE, FALSE); |
|
1061 | 1061 | return ''; |
1062 | 1062 | } |
1063 | - return EEH_Venue_View::venue_address( $type, $VNU_ID, FALSE, FALSE ); |
|
1063 | + return EEH_Venue_View::venue_address($type, $VNU_ID, FALSE, FALSE); |
|
1064 | 1064 | } |
1065 | 1065 | } |
1066 | 1066 | |
1067 | 1067 | |
1068 | -if ( ! function_exists( 'espresso_venue_has_address' )) { |
|
1068 | +if ( ! function_exists('espresso_venue_has_address')) { |
|
1069 | 1069 | /** |
1070 | 1070 | * espresso_venue_has_address |
1071 | 1071 | * returns TRUE or FALSE if a Venue has address information |
@@ -1073,13 +1073,13 @@ discard block |
||
1073 | 1073 | * @param int $VNU_ID |
1074 | 1074 | * @return bool |
1075 | 1075 | */ |
1076 | - function espresso_venue_has_address( $VNU_ID = 0 ) { |
|
1077 | - return EEH_Venue_View::venue_has_address( $VNU_ID ); |
|
1076 | + function espresso_venue_has_address($VNU_ID = 0) { |
|
1077 | + return EEH_Venue_View::venue_has_address($VNU_ID); |
|
1078 | 1078 | } |
1079 | 1079 | } |
1080 | 1080 | |
1081 | 1081 | |
1082 | -if ( ! function_exists( 'espresso_venue_gmap' )) { |
|
1082 | +if ( ! function_exists('espresso_venue_gmap')) { |
|
1083 | 1083 | /** |
1084 | 1084 | * espresso_venue_gmap |
1085 | 1085 | * returns a google map for the venue address |
@@ -1090,17 +1090,17 @@ discard block |
||
1090 | 1090 | * @param bool $echo |
1091 | 1091 | * @return string |
1092 | 1092 | */ |
1093 | - function espresso_venue_gmap( $VNU_ID = 0, $map_ID = FALSE, $gmap = array(), $echo = TRUE ) { |
|
1094 | - if ( $echo ) { |
|
1095 | - echo EEH_Venue_View::venue_gmap( $VNU_ID, $map_ID, $gmap ); |
|
1093 | + function espresso_venue_gmap($VNU_ID = 0, $map_ID = FALSE, $gmap = array(), $echo = TRUE) { |
|
1094 | + if ($echo) { |
|
1095 | + echo EEH_Venue_View::venue_gmap($VNU_ID, $map_ID, $gmap); |
|
1096 | 1096 | return ''; |
1097 | 1097 | } |
1098 | - return EEH_Venue_View::venue_gmap( $VNU_ID, $map_ID, $gmap ); |
|
1098 | + return EEH_Venue_View::venue_gmap($VNU_ID, $map_ID, $gmap); |
|
1099 | 1099 | } |
1100 | 1100 | } |
1101 | 1101 | |
1102 | 1102 | |
1103 | -if ( ! function_exists( 'espresso_venue_phone' )) { |
|
1103 | +if ( ! function_exists('espresso_venue_phone')) { |
|
1104 | 1104 | /** |
1105 | 1105 | * espresso_venue_phone |
1106 | 1106 | * |
@@ -1108,18 +1108,18 @@ discard block |
||
1108 | 1108 | * @param bool $echo |
1109 | 1109 | * @return string |
1110 | 1110 | */ |
1111 | - function espresso_venue_phone( $VNU_ID = 0, $echo = TRUE ) { |
|
1112 | - if ( $echo ) { |
|
1113 | - echo EEH_Venue_View::venue_phone( $VNU_ID ); |
|
1111 | + function espresso_venue_phone($VNU_ID = 0, $echo = TRUE) { |
|
1112 | + if ($echo) { |
|
1113 | + echo EEH_Venue_View::venue_phone($VNU_ID); |
|
1114 | 1114 | return ''; |
1115 | 1115 | } |
1116 | - return EEH_Venue_View::venue_phone( $VNU_ID ); |
|
1116 | + return EEH_Venue_View::venue_phone($VNU_ID); |
|
1117 | 1117 | } |
1118 | 1118 | } |
1119 | 1119 | |
1120 | 1120 | |
1121 | 1121 | |
1122 | -if ( ! function_exists( 'espresso_venue_website' )) { |
|
1122 | +if ( ! function_exists('espresso_venue_website')) { |
|
1123 | 1123 | /** |
1124 | 1124 | * espresso_venue_website |
1125 | 1125 | * |
@@ -1127,18 +1127,18 @@ discard block |
||
1127 | 1127 | * @param bool $echo |
1128 | 1128 | * @return string |
1129 | 1129 | */ |
1130 | - function espresso_venue_website( $VNU_ID = 0, $echo = TRUE ) { |
|
1131 | - if ( $echo ) { |
|
1132 | - echo EEH_Venue_View::venue_website_link( $VNU_ID ); |
|
1130 | + function espresso_venue_website($VNU_ID = 0, $echo = TRUE) { |
|
1131 | + if ($echo) { |
|
1132 | + echo EEH_Venue_View::venue_website_link($VNU_ID); |
|
1133 | 1133 | return ''; |
1134 | 1134 | } |
1135 | - return EEH_Venue_View::venue_website_link( $VNU_ID ); |
|
1135 | + return EEH_Venue_View::venue_website_link($VNU_ID); |
|
1136 | 1136 | } |
1137 | 1137 | } |
1138 | 1138 | |
1139 | 1139 | |
1140 | 1140 | |
1141 | -if ( ! function_exists( 'espresso_edit_venue_link' )) { |
|
1141 | +if ( ! function_exists('espresso_edit_venue_link')) { |
|
1142 | 1142 | /** |
1143 | 1143 | * espresso_edit_venue_link |
1144 | 1144 | * |
@@ -1146,12 +1146,12 @@ discard block |
||
1146 | 1146 | * @param bool $echo |
1147 | 1147 | * @return string |
1148 | 1148 | */ |
1149 | - function espresso_edit_venue_link( $VNU_ID = 0, $echo = TRUE ) { |
|
1150 | - if($echo){ |
|
1151 | - echo EEH_Venue_View::edit_venue_link( $VNU_ID ); |
|
1149 | + function espresso_edit_venue_link($VNU_ID = 0, $echo = TRUE) { |
|
1150 | + if ($echo) { |
|
1151 | + echo EEH_Venue_View::edit_venue_link($VNU_ID); |
|
1152 | 1152 | return ''; |
1153 | 1153 | } |
1154 | - return EEH_Venue_View::edit_venue_link( $VNU_ID ); |
|
1154 | + return EEH_Venue_View::edit_venue_link($VNU_ID); |
|
1155 | 1155 | } |
1156 | 1156 | } |
1157 | 1157 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | 4 | |
5 | 5 | /** |
@@ -116,42 +116,42 @@ discard block |
||
116 | 116 | |
117 | 117 | |
118 | 118 | protected function _start() { |
119 | - $content = '<h3>' . __('Questions Overview', 'event_espresso') . '</h3>'; |
|
120 | - $content .= '<p>' . __('This tour of the Questions Overview page will go over different areas of the screen to help you understand what they are used for.', 'event_espresso') . '</p>'; |
|
119 | + $content = '<h3>'.__('Questions Overview', 'event_espresso').'</h3>'; |
|
120 | + $content .= '<p>'.__('This tour of the Questions Overview page will go over different areas of the screen to help you understand what they are used for.', 'event_espresso').'</p>'; |
|
121 | 121 | |
122 | 122 | return $content; |
123 | 123 | } |
124 | 124 | |
125 | 125 | protected function _display_text_stop() { |
126 | - return '<p>' . __('View available questions.', 'event_espresso') . '</p>'; |
|
126 | + return '<p>'.__('View available questions.', 'event_espresso').'</p>'; |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | protected function _admin_label_stop() { |
130 | - return '<p>' . __('View the admin label for your questions.', 'event_espresso') . '</p>'; |
|
130 | + return '<p>'.__('View the admin label for your questions.', 'event_espresso').'</p>'; |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | protected function _type_stop() { |
134 | - return '<p>' . __('View the type of question. Available options are Text, Textarea, Checkboxes, Radio Buttons, Dropdown, State/Province Dropdown, Country Dropdown, and Date Picker.', 'event_espresso') . '</p>'; |
|
134 | + return '<p>'.__('View the type of question. Available options are Text, Textarea, Checkboxes, Radio Buttons, Dropdown, State/Province Dropdown, Country Dropdown, and Date Picker.', 'event_espresso').'</p>'; |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | protected function _values_stop() { |
138 | - return '<p>' . __('View stored values for checkboxes, radio buttons, and select boxes.', 'event_espresso') . '</p>'; |
|
138 | + return '<p>'.__('View stored values for checkboxes, radio buttons, and select boxes.', 'event_espresso').'</p>'; |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | protected function _required_stop() { |
142 | - return '<p>' . __('View if a question is required.', 'event_espresso') . '</p>'; |
|
142 | + return '<p>'.__('View if a question is required.', 'event_espresso').'</p>'; |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | protected function _bulk_actions_stop() { |
146 | - return '<p>' . __('Perform bulk actions to multiple questions.', 'event_espresso') . '</p>'; |
|
146 | + return '<p>'.__('Perform bulk actions to multiple questions.', 'event_espresso').'</p>'; |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | protected function _search_stop() { |
150 | - return '<p>' . __('Search through questions. The following sources will be searched: Name of Question (display text).', 'event_espresso') . '</p>'; |
|
150 | + return '<p>'.__('Search through questions. The following sources will be searched: Name of Question (display text).', 'event_espresso').'</p>'; |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | protected function _add_new_question_stop() { |
154 | - return '<p>' . __('Click here to add a new question.', 'event_espresso') . '</p>'; |
|
154 | + return '<p>'.__('Click here to add a new question.', 'event_espresso').'</p>'; |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | } |
158 | 158 | \ No newline at end of file |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
3 | - exit('NO direct script access allowed'); |
|
3 | + exit('NO direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | /** |
@@ -18,64 +18,64 @@ discard block |
||
18 | 18 | class Registration_Form_Questions_Overview_Help_Tour extends EE_Help_Tour |
19 | 19 | { |
20 | 20 | |
21 | - protected function _set_tour_properties() |
|
22 | - { |
|
23 | - $this->_label = __('Questions Overview Tour', 'event_espresso'); |
|
24 | - $this->_slug = $this->_is_caf ? 'questions-overview-caf-joyride' : 'questions-overview-joyride'; |
|
25 | - } |
|
21 | + protected function _set_tour_properties() |
|
22 | + { |
|
23 | + $this->_label = __('Questions Overview Tour', 'event_espresso'); |
|
24 | + $this->_slug = $this->_is_caf ? 'questions-overview-caf-joyride' : 'questions-overview-joyride'; |
|
25 | + } |
|
26 | 26 | |
27 | - protected function _set_tour_stops() |
|
28 | - { |
|
29 | - $this->_stops = array( |
|
30 | - 10 => array( |
|
31 | - 'content' => $this->_start(), |
|
32 | - ), |
|
33 | - 30 => array( |
|
34 | - 'id' => 'display_text', |
|
35 | - 'content' => $this->_display_text_stop(), |
|
36 | - 'options' => array( |
|
37 | - 'tipLocation' => 'top', |
|
38 | - 'tipAdjustmentX' => -5, |
|
39 | - 'tipAdjustmentY' => -25 |
|
40 | - ) |
|
41 | - ), |
|
42 | - 40 => array( |
|
43 | - 'id' => 'admin_label', |
|
44 | - 'content' => $this->_admin_label_stop(), |
|
45 | - 'options' => array( |
|
46 | - 'tipLocation' => 'top', |
|
47 | - 'tipAdjustmentX' => 20, |
|
48 | - 'tipAdjustmentY' => -25 |
|
49 | - ) |
|
50 | - ), |
|
51 | - 50 => array( |
|
52 | - 'id' => 'type', |
|
53 | - 'content' => $this->_type_stop(), |
|
54 | - 'options' => array( |
|
55 | - 'tipLocation' => 'top', |
|
56 | - 'tipAdjustmentX' => -5, |
|
57 | - 'tipAdjustmentY' => -25 |
|
58 | - ) |
|
59 | - ), |
|
60 | - 60 => array( |
|
61 | - 'id' => 'values', |
|
62 | - 'content' => $this->_values_stop(), |
|
63 | - 'options' => array( |
|
64 | - 'tipLocation' => 'top', |
|
65 | - 'tipAdjustmentX' => -5, |
|
66 | - 'tipAdjustmentY' => -25 |
|
67 | - ) |
|
68 | - ), |
|
69 | - 70 => array( |
|
70 | - 'id' => 'required', |
|
71 | - 'content' => $this->_required_stop(), |
|
72 | - 'options' => array( |
|
73 | - 'tipLocation' => 'top', |
|
74 | - 'tipAdjustmentY' => -20, |
|
75 | - 'tipAdjustmentX' => -15 |
|
76 | - ) |
|
77 | - ), |
|
78 | - /*80 => array( |
|
27 | + protected function _set_tour_stops() |
|
28 | + { |
|
29 | + $this->_stops = array( |
|
30 | + 10 => array( |
|
31 | + 'content' => $this->_start(), |
|
32 | + ), |
|
33 | + 30 => array( |
|
34 | + 'id' => 'display_text', |
|
35 | + 'content' => $this->_display_text_stop(), |
|
36 | + 'options' => array( |
|
37 | + 'tipLocation' => 'top', |
|
38 | + 'tipAdjustmentX' => -5, |
|
39 | + 'tipAdjustmentY' => -25 |
|
40 | + ) |
|
41 | + ), |
|
42 | + 40 => array( |
|
43 | + 'id' => 'admin_label', |
|
44 | + 'content' => $this->_admin_label_stop(), |
|
45 | + 'options' => array( |
|
46 | + 'tipLocation' => 'top', |
|
47 | + 'tipAdjustmentX' => 20, |
|
48 | + 'tipAdjustmentY' => -25 |
|
49 | + ) |
|
50 | + ), |
|
51 | + 50 => array( |
|
52 | + 'id' => 'type', |
|
53 | + 'content' => $this->_type_stop(), |
|
54 | + 'options' => array( |
|
55 | + 'tipLocation' => 'top', |
|
56 | + 'tipAdjustmentX' => -5, |
|
57 | + 'tipAdjustmentY' => -25 |
|
58 | + ) |
|
59 | + ), |
|
60 | + 60 => array( |
|
61 | + 'id' => 'values', |
|
62 | + 'content' => $this->_values_stop(), |
|
63 | + 'options' => array( |
|
64 | + 'tipLocation' => 'top', |
|
65 | + 'tipAdjustmentX' => -5, |
|
66 | + 'tipAdjustmentY' => -25 |
|
67 | + ) |
|
68 | + ), |
|
69 | + 70 => array( |
|
70 | + 'id' => 'required', |
|
71 | + 'content' => $this->_required_stop(), |
|
72 | + 'options' => array( |
|
73 | + 'tipLocation' => 'top', |
|
74 | + 'tipAdjustmentY' => -20, |
|
75 | + 'tipAdjustmentX' => -15 |
|
76 | + ) |
|
77 | + ), |
|
78 | + /*80 => array( |
|
79 | 79 | 'class' => 'bulkactions', |
80 | 80 | 'content' => $this->_bulk_actions_stop(), |
81 | 81 | 'options' => array( |
@@ -84,77 +84,77 @@ discard block |
||
84 | 84 | 'tipAdjustmentX' => -15 |
85 | 85 | ) |
86 | 86 | ),*/ |
87 | - 90 => array( |
|
88 | - 'id' => 'event-espresso_page_espresso_registration_form-search-input', |
|
89 | - 'content' => $this->_search_stop(), |
|
90 | - 'options' => array( |
|
91 | - 'tipLocation' => 'left', |
|
92 | - 'tipAdjustmentY' => -50, |
|
93 | - 'tipAdjustmentX' => -15 |
|
94 | - ) |
|
95 | - ), |
|
96 | - 100 => array( |
|
97 | - 'id' => 'add-new-question', |
|
98 | - 'content' => $this->_add_new_question_stop(), |
|
99 | - 'options' => array( |
|
100 | - 'tipLocation' => 'right', |
|
101 | - 'tipAdjustmentY' => -50, |
|
102 | - 'tipAdjustmentX' => 15 |
|
103 | - ) |
|
104 | - ), |
|
105 | - ); |
|
106 | - } |
|
87 | + 90 => array( |
|
88 | + 'id' => 'event-espresso_page_espresso_registration_form-search-input', |
|
89 | + 'content' => $this->_search_stop(), |
|
90 | + 'options' => array( |
|
91 | + 'tipLocation' => 'left', |
|
92 | + 'tipAdjustmentY' => -50, |
|
93 | + 'tipAdjustmentX' => -15 |
|
94 | + ) |
|
95 | + ), |
|
96 | + 100 => array( |
|
97 | + 'id' => 'add-new-question', |
|
98 | + 'content' => $this->_add_new_question_stop(), |
|
99 | + 'options' => array( |
|
100 | + 'tipLocation' => 'right', |
|
101 | + 'tipAdjustmentY' => -50, |
|
102 | + 'tipAdjustmentX' => 15 |
|
103 | + ) |
|
104 | + ), |
|
105 | + ); |
|
106 | + } |
|
107 | 107 | |
108 | 108 | |
109 | - protected function _start() |
|
110 | - { |
|
111 | - $content = '<h3>' . __('Questions Overview', 'event_espresso') . '</h3>'; |
|
112 | - $content .= '<p>' . __('This tour of the Questions Overview page will go over different areas of the screen to help you understand what they are used for.', |
|
113 | - 'event_espresso') . '</p>'; |
|
109 | + protected function _start() |
|
110 | + { |
|
111 | + $content = '<h3>' . __('Questions Overview', 'event_espresso') . '</h3>'; |
|
112 | + $content .= '<p>' . __('This tour of the Questions Overview page will go over different areas of the screen to help you understand what they are used for.', |
|
113 | + 'event_espresso') . '</p>'; |
|
114 | 114 | |
115 | - return $content; |
|
116 | - } |
|
115 | + return $content; |
|
116 | + } |
|
117 | 117 | |
118 | - protected function _display_text_stop() |
|
119 | - { |
|
120 | - return '<p>' . __('View available questions.', 'event_espresso') . '</p>'; |
|
121 | - } |
|
118 | + protected function _display_text_stop() |
|
119 | + { |
|
120 | + return '<p>' . __('View available questions.', 'event_espresso') . '</p>'; |
|
121 | + } |
|
122 | 122 | |
123 | - protected function _admin_label_stop() |
|
124 | - { |
|
125 | - return '<p>' . __('View the admin label for your questions.', 'event_espresso') . '</p>'; |
|
126 | - } |
|
123 | + protected function _admin_label_stop() |
|
124 | + { |
|
125 | + return '<p>' . __('View the admin label for your questions.', 'event_espresso') . '</p>'; |
|
126 | + } |
|
127 | 127 | |
128 | - protected function _type_stop() |
|
129 | - { |
|
130 | - return '<p>' . __('View the type of question. Available options are Text, Textarea, Checkboxes, Radio Buttons, Dropdown, State/Province Dropdown, Country Dropdown, and Date Picker.', |
|
131 | - 'event_espresso') . '</p>'; |
|
132 | - } |
|
128 | + protected function _type_stop() |
|
129 | + { |
|
130 | + return '<p>' . __('View the type of question. Available options are Text, Textarea, Checkboxes, Radio Buttons, Dropdown, State/Province Dropdown, Country Dropdown, and Date Picker.', |
|
131 | + 'event_espresso') . '</p>'; |
|
132 | + } |
|
133 | 133 | |
134 | - protected function _values_stop() |
|
135 | - { |
|
136 | - return '<p>' . __('View stored values for checkboxes, radio buttons, and select boxes.', |
|
137 | - 'event_espresso') . '</p>'; |
|
138 | - } |
|
134 | + protected function _values_stop() |
|
135 | + { |
|
136 | + return '<p>' . __('View stored values for checkboxes, radio buttons, and select boxes.', |
|
137 | + 'event_espresso') . '</p>'; |
|
138 | + } |
|
139 | 139 | |
140 | - protected function _required_stop() |
|
141 | - { |
|
142 | - return '<p>' . __('View if a question is required.', 'event_espresso') . '</p>'; |
|
143 | - } |
|
140 | + protected function _required_stop() |
|
141 | + { |
|
142 | + return '<p>' . __('View if a question is required.', 'event_espresso') . '</p>'; |
|
143 | + } |
|
144 | 144 | |
145 | - /* protected function _bulk_actions_stop() { |
|
145 | + /* protected function _bulk_actions_stop() { |
|
146 | 146 | return '<p>' . __('Perform bulk actions to multiple questions.', 'event_espresso') . '</p>'; |
147 | 147 | } */ |
148 | 148 | |
149 | - protected function _search_stop() |
|
150 | - { |
|
151 | - return '<p>' . __('Search through questions. The following sources will be searched: Name of Question (display text).', |
|
152 | - 'event_espresso') . '</p>'; |
|
153 | - } |
|
149 | + protected function _search_stop() |
|
150 | + { |
|
151 | + return '<p>' . __('Search through questions. The following sources will be searched: Name of Question (display text).', |
|
152 | + 'event_espresso') . '</p>'; |
|
153 | + } |
|
154 | 154 | |
155 | - protected function _add_new_question_stop() |
|
156 | - { |
|
157 | - return '<p>' . __('Click here to add a new question.', 'event_espresso') . '</p>'; |
|
158 | - } |
|
155 | + protected function _add_new_question_stop() |
|
156 | + { |
|
157 | + return '<p>' . __('Click here to add a new question.', 'event_espresso') . '</p>'; |
|
158 | + } |
|
159 | 159 | |
160 | 160 | } |
161 | 161 | \ No newline at end of file |
@@ -108,38 +108,38 @@ discard block |
||
108 | 108 | |
109 | 109 | protected function _start() |
110 | 110 | { |
111 | - $content = '<h3>' . __('Questions Overview', 'event_espresso') . '</h3>'; |
|
112 | - $content .= '<p>' . __('This tour of the Questions Overview page will go over different areas of the screen to help you understand what they are used for.', |
|
113 | - 'event_espresso') . '</p>'; |
|
111 | + $content = '<h3>'.__('Questions Overview', 'event_espresso').'</h3>'; |
|
112 | + $content .= '<p>'.__('This tour of the Questions Overview page will go over different areas of the screen to help you understand what they are used for.', |
|
113 | + 'event_espresso').'</p>'; |
|
114 | 114 | |
115 | 115 | return $content; |
116 | 116 | } |
117 | 117 | |
118 | 118 | protected function _display_text_stop() |
119 | 119 | { |
120 | - return '<p>' . __('View available questions.', 'event_espresso') . '</p>'; |
|
120 | + return '<p>'.__('View available questions.', 'event_espresso').'</p>'; |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | protected function _admin_label_stop() |
124 | 124 | { |
125 | - return '<p>' . __('View the admin label for your questions.', 'event_espresso') . '</p>'; |
|
125 | + return '<p>'.__('View the admin label for your questions.', 'event_espresso').'</p>'; |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | protected function _type_stop() |
129 | 129 | { |
130 | - return '<p>' . __('View the type of question. Available options are Text, Textarea, Checkboxes, Radio Buttons, Dropdown, State/Province Dropdown, Country Dropdown, and Date Picker.', |
|
131 | - 'event_espresso') . '</p>'; |
|
130 | + return '<p>'.__('View the type of question. Available options are Text, Textarea, Checkboxes, Radio Buttons, Dropdown, State/Province Dropdown, Country Dropdown, and Date Picker.', |
|
131 | + 'event_espresso').'</p>'; |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | protected function _values_stop() |
135 | 135 | { |
136 | - return '<p>' . __('View stored values for checkboxes, radio buttons, and select boxes.', |
|
137 | - 'event_espresso') . '</p>'; |
|
136 | + return '<p>'.__('View stored values for checkboxes, radio buttons, and select boxes.', |
|
137 | + 'event_espresso').'</p>'; |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | protected function _required_stop() |
141 | 141 | { |
142 | - return '<p>' . __('View if a question is required.', 'event_espresso') . '</p>'; |
|
142 | + return '<p>'.__('View if a question is required.', 'event_espresso').'</p>'; |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | /* protected function _bulk_actions_stop() { |
@@ -148,13 +148,13 @@ discard block |
||
148 | 148 | |
149 | 149 | protected function _search_stop() |
150 | 150 | { |
151 | - return '<p>' . __('Search through questions. The following sources will be searched: Name of Question (display text).', |
|
152 | - 'event_espresso') . '</p>'; |
|
151 | + return '<p>'.__('Search through questions. The following sources will be searched: Name of Question (display text).', |
|
152 | + 'event_espresso').'</p>'; |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | protected function _add_new_question_stop() |
156 | 156 | { |
157 | - return '<p>' . __('Click here to add a new question.', 'event_espresso') . '</p>'; |
|
157 | + return '<p>'.__('Click here to add a new question.', 'event_espresso').'</p>'; |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | } |
161 | 161 | \ No newline at end of file |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
2 | 2 | exit('No direct script access allowed'); |
3 | 3 | } |
4 | -require_once(EE_MODELS . 'EEM_Base.model.php'); |
|
4 | +require_once(EE_MODELS.'EEM_Base.model.php'); |
|
5 | 5 | |
6 | 6 | /** |
7 | 7 | * |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | __('Registration Steps', 'event_espresso'), false, array()), |
106 | 106 | ) |
107 | 107 | ); |
108 | - $this->_model_relations = array( |
|
108 | + $this->_model_relations = array( |
|
109 | 109 | 'Registration' => new EE_Has_Many_Relation(), |
110 | 110 | 'Payment' => new EE_Has_Many_Relation(), |
111 | 111 | 'Status' => new EE_Belongs_To_Relation(), |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | ), |
168 | 168 | OBJECT, |
169 | 169 | array( |
170 | - 'txnDate' => array('DATE(' . $query_interval . ')', '%s'), |
|
170 | + 'txnDate' => array('DATE('.$query_interval.')', '%s'), |
|
171 | 171 | 'revenue' => array('SUM(TransactionTable.TXN_paid)', '%d') |
172 | 172 | ) |
173 | 173 | ); |
@@ -187,17 +187,17 @@ discard block |
||
187 | 187 | public function get_revenue_per_event_report($period = '-1 month') |
188 | 188 | { |
189 | 189 | global $wpdb; |
190 | - $transaction_table = $wpdb->prefix . 'esp_transaction'; |
|
191 | - $registration_table = $wpdb->prefix . 'esp_registration'; |
|
192 | - $registration_payment_table = $wpdb->prefix . 'esp_registration_payment'; |
|
190 | + $transaction_table = $wpdb->prefix.'esp_transaction'; |
|
191 | + $registration_table = $wpdb->prefix.'esp_registration'; |
|
192 | + $registration_payment_table = $wpdb->prefix.'esp_registration_payment'; |
|
193 | 193 | $event_table = $wpdb->posts; |
194 | - $payment_table = $wpdb->prefix . 'esp_payment'; |
|
194 | + $payment_table = $wpdb->prefix.'esp_payment'; |
|
195 | 195 | $sql_date = date('Y-m-d H:i:s', strtotime($period)); |
196 | 196 | $approved_payment_status = EEM_Payment::status_id_approved; |
197 | 197 | $extra_event_on_join = ''; |
198 | 198 | //exclude events not authored by user if permissions in effect |
199 | 199 | if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) { |
200 | - $extra_event_on_join = ' AND Event.post_author = ' . get_current_user_id(); |
|
200 | + $extra_event_on_join = ' AND Event.post_author = '.get_current_user_id(); |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | return $wpdb->get_results( |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | public function update_based_on_payments($transaction_obj_or_id, $save_txn = true) |
269 | 269 | { |
270 | 270 | EE_Error::doing_it_wrong( |
271 | - __CLASS__ . '::' . __FUNCTION__, |
|
271 | + __CLASS__.'::'.__FUNCTION__, |
|
272 | 272 | sprintf(__('This method is deprecated. Please use "%s" instead', 'event_espresso'), |
273 | 273 | 'EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment()'), |
274 | 274 | '4.6.0' |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | array( |
317 | 317 | 0 => array( |
318 | 318 | 'STS_ID' => EEM_Transaction::failed_status_code, |
319 | - 'Payment.PAY_ID' => array( 'IS NULL' ), |
|
319 | + 'Payment.PAY_ID' => array('IS NULL'), |
|
320 | 320 | 'TXN_timestamp' => array('<', time() - $time_to_leave_alone) |
321 | 321 | ) |
322 | 322 | ), |
@@ -334,18 +334,18 @@ discard block |
||
334 | 334 | $time_to_leave_alone |
335 | 335 | ); |
336 | 336 | //now that we have the ids to delete |
337 | - if (! empty($txn_ids) && is_array($txn_ids)) { |
|
337 | + if ( ! empty($txn_ids) && is_array($txn_ids)) { |
|
338 | 338 | // first, make sure these TXN's are removed the "ee_locked_transactions" array |
339 | 339 | EEM_Transaction::unset_locked_transactions($txn_ids); |
340 | 340 | // let's get deletin'... |
341 | 341 | // Why no wpdb->prepare? Because the data is trusted. |
342 | 342 | // We got the ids from the original query to get them FROM |
343 | 343 | // the db (which is sanitized) so no need to prepare them again. |
344 | - $query = ' |
|
344 | + $query = ' |
|
345 | 345 | DELETE |
346 | - FROM ' . $this->table() . ' |
|
346 | + FROM ' . $this->table().' |
|
347 | 347 | WHERE |
348 | - TXN_ID IN ( ' . implode(",", $txn_ids) . ')'; |
|
348 | + TXN_ID IN ( ' . implode(",", $txn_ids).')'; |
|
349 | 349 | $deleted = $wpdb->query($query); |
350 | 350 | } |
351 | 351 | if ($deleted) { |
@@ -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 | require_once(EE_MODELS . 'EEM_Base.model.php'); |
5 | 5 | |
@@ -15,193 +15,193 @@ discard block |
||
15 | 15 | class EEM_Transaction extends EEM_Base |
16 | 16 | { |
17 | 17 | |
18 | - // private instance of the Transaction object |
|
19 | - protected static $_instance; |
|
20 | - |
|
21 | - /** |
|
22 | - * Status ID(STS_ID on esp_status table) to indicate the transaction is complete, |
|
23 | - * but payment is pending. This is the state for transactions where payment is promised |
|
24 | - * from an offline gateway. |
|
25 | - */ |
|
26 | - // const open_status_code = 'TPN'; |
|
27 | - |
|
28 | - /** |
|
29 | - * Status ID(STS_ID on esp_status table) to indicate the transaction failed, |
|
30 | - * either due to a technical reason (server or computer crash during registration), |
|
31 | - * or some other reason that prevent the collection of any useful contact information from any of the registrants |
|
32 | - */ |
|
33 | - const failed_status_code = 'TFL'; |
|
34 | - |
|
35 | - /** |
|
36 | - * Status ID(STS_ID on esp_status table) to indicate the transaction was abandoned, |
|
37 | - * either due to a technical reason (server or computer crash during registration), |
|
38 | - * or due to an abandoned cart after registrant chose not to complete the registration process |
|
39 | - * HOWEVER... |
|
40 | - * an abandoned TXN differs from a failed TXN in that it was able to capture contact information for at least one |
|
41 | - * registrant |
|
42 | - */ |
|
43 | - const abandoned_status_code = 'TAB'; |
|
44 | - |
|
45 | - /** |
|
46 | - * Status ID(STS_ID on esp_status table) to indicate an incomplete transaction, |
|
47 | - * meaning that monies are still owing: TXN_paid < TXN_total |
|
48 | - */ |
|
49 | - const incomplete_status_code = 'TIN'; |
|
50 | - |
|
51 | - /** |
|
52 | - * Status ID (STS_ID on esp_status table) to indicate a complete transaction. |
|
53 | - * meaning that NO monies are owing: TXN_paid == TXN_total |
|
54 | - */ |
|
55 | - const complete_status_code = 'TCM'; |
|
56 | - |
|
57 | - /** |
|
58 | - * Status ID(STS_ID on esp_status table) to indicate the transaction is overpaid. |
|
59 | - * This is the same as complete, but site admins actually owe clients the moneys! TXN_paid > TXN_total |
|
60 | - */ |
|
61 | - const overpaid_status_code = 'TOP'; |
|
62 | - |
|
63 | - |
|
64 | - /** |
|
65 | - * private constructor to prevent direct creation |
|
66 | - * |
|
67 | - * @Constructor |
|
68 | - * @access protected |
|
69 | - * |
|
70 | - * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any |
|
71 | - * incoming timezone data that gets saved). Note this just sends the timezone info to the |
|
72 | - * date time model field objects. Default is NULL (and will be assumed using the set |
|
73 | - * timezone in the 'timezone_string' wp option) |
|
74 | - * |
|
75 | - * @return EEM_Transaction |
|
76 | - * @throws \EE_Error |
|
77 | - */ |
|
78 | - protected function __construct($timezone) |
|
79 | - { |
|
80 | - $this->singular_item = __('Transaction', 'event_espresso'); |
|
81 | - $this->plural_item = __('Transactions', 'event_espresso'); |
|
82 | - |
|
83 | - $this->_tables = array( |
|
84 | - 'TransactionTable' => new EE_Primary_Table('esp_transaction', 'TXN_ID') |
|
85 | - ); |
|
86 | - $this->_fields = array( |
|
87 | - 'TransactionTable' => array( |
|
88 | - 'TXN_ID' => new EE_Primary_Key_Int_Field('TXN_ID', __('Transaction ID', 'event_espresso')), |
|
89 | - 'TXN_timestamp' => new EE_Datetime_Field('TXN_timestamp', |
|
90 | - __('date when transaction was created', 'event_espresso'), false, EE_Datetime_Field::now, |
|
91 | - $timezone), |
|
92 | - 'TXN_total' => new EE_Money_Field('TXN_total', |
|
93 | - __('Total value of Transaction', 'event_espresso'), false, 0), |
|
94 | - 'TXN_paid' => new EE_Money_Field('TXN_paid', |
|
95 | - __('Amount paid towards transaction to date', 'event_espresso'), false, 0), |
|
96 | - 'STS_ID' => new EE_Foreign_Key_String_Field('STS_ID', __('Status ID', 'event_espresso'), |
|
97 | - false, EEM_Transaction::failed_status_code, 'Status'), |
|
98 | - 'TXN_session_data' => new EE_Serialized_Text_Field('TXN_session_data', |
|
99 | - __('Serialized session data', 'event_espresso'), true, ''), |
|
100 | - 'TXN_hash_salt' => new EE_Plain_Text_Field('TXN_hash_salt', |
|
101 | - __('Transaction Hash Salt', 'event_espresso'), true, ''), |
|
102 | - 'PMD_ID' => new EE_Foreign_Key_Int_Field('PMD_ID', |
|
103 | - __("Last Used Payment Method", 'event_espresso'), true, null, 'Payment_Method'), |
|
104 | - 'TXN_reg_steps' => new EE_Serialized_Text_Field('TXN_reg_steps', |
|
105 | - __('Registration Steps', 'event_espresso'), false, array()), |
|
106 | - ) |
|
107 | - ); |
|
108 | - $this->_model_relations = array( |
|
109 | - 'Registration' => new EE_Has_Many_Relation(), |
|
110 | - 'Payment' => new EE_Has_Many_Relation(), |
|
111 | - 'Status' => new EE_Belongs_To_Relation(), |
|
112 | - 'Line_Item' => new EE_Has_Many_Relation(false), |
|
113 | - //you can delete a transaction without needing to delete its line items |
|
114 | - 'Payment_Method' => new EE_Belongs_To_Relation(), |
|
115 | - 'Message' => new EE_Has_Many_Relation() |
|
116 | - ); |
|
117 | - $this->_model_chain_to_wp_user = 'Registration.Event'; |
|
118 | - parent::__construct($timezone); |
|
119 | - |
|
120 | - } |
|
121 | - |
|
122 | - |
|
123 | - /** |
|
124 | - * txn_status_array |
|
125 | - * get list of transaction statuses |
|
126 | - * |
|
127 | - * @access public |
|
128 | - * @return array |
|
129 | - */ |
|
130 | - public static function txn_status_array() |
|
131 | - { |
|
132 | - return apply_filters( |
|
133 | - 'FHEE__EEM_Transaction__txn_status_array', |
|
134 | - array( |
|
135 | - EEM_Transaction::overpaid_status_code, |
|
136 | - EEM_Transaction::complete_status_code, |
|
137 | - EEM_Transaction::incomplete_status_code, |
|
138 | - EEM_Transaction::abandoned_status_code, |
|
139 | - EEM_Transaction::failed_status_code, |
|
140 | - ) |
|
141 | - ); |
|
142 | - } |
|
143 | - |
|
144 | - /** |
|
145 | - * get the revenue per day for the Transaction Admin page Reports Tab |
|
146 | - * |
|
147 | - * @access public |
|
148 | - * |
|
149 | - * @param string $period |
|
150 | - * |
|
151 | - * @return \stdClass[] |
|
152 | - */ |
|
153 | - public function get_revenue_per_day_report($period = '-1 month') |
|
154 | - { |
|
155 | - $sql_date = $this->convert_datetime_for_query('TXN_timestamp', date('Y-m-d H:i:s', strtotime($period)), |
|
156 | - 'Y-m-d H:i:s', 'UTC'); |
|
157 | - |
|
158 | - $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset($this->get_timezone(), 'TXN_timestamp'); |
|
159 | - |
|
160 | - return $this->_get_all_wpdb_results( |
|
161 | - array( |
|
162 | - array( |
|
163 | - 'TXN_timestamp' => array('>=', $sql_date) |
|
164 | - ), |
|
165 | - 'group_by' => 'txnDate', |
|
166 | - 'order_by' => array('TXN_timestamp' => 'ASC') |
|
167 | - ), |
|
168 | - OBJECT, |
|
169 | - array( |
|
170 | - 'txnDate' => array('DATE(' . $query_interval . ')', '%s'), |
|
171 | - 'revenue' => array('SUM(TransactionTable.TXN_paid)', '%d') |
|
172 | - ) |
|
173 | - ); |
|
174 | - } |
|
175 | - |
|
176 | - |
|
177 | - /** |
|
178 | - * get the revenue per event for the Transaction Admin page Reports Tab |
|
179 | - * |
|
180 | - * @access public |
|
181 | - * |
|
182 | - * @param string $period |
|
183 | - * |
|
184 | - * @throws \EE_Error |
|
185 | - * @return mixed |
|
186 | - */ |
|
187 | - public function get_revenue_per_event_report($period = '-1 month') |
|
188 | - { |
|
189 | - global $wpdb; |
|
190 | - $transaction_table = $wpdb->prefix . 'esp_transaction'; |
|
191 | - $registration_table = $wpdb->prefix . 'esp_registration'; |
|
192 | - $registration_payment_table = $wpdb->prefix . 'esp_registration_payment'; |
|
193 | - $event_table = $wpdb->posts; |
|
194 | - $payment_table = $wpdb->prefix . 'esp_payment'; |
|
195 | - $sql_date = date('Y-m-d H:i:s', strtotime($period)); |
|
196 | - $approved_payment_status = EEM_Payment::status_id_approved; |
|
197 | - $extra_event_on_join = ''; |
|
198 | - //exclude events not authored by user if permissions in effect |
|
199 | - if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) { |
|
200 | - $extra_event_on_join = ' AND Event.post_author = ' . get_current_user_id(); |
|
201 | - } |
|
202 | - |
|
203 | - return $wpdb->get_results( |
|
204 | - "SELECT |
|
18 | + // private instance of the Transaction object |
|
19 | + protected static $_instance; |
|
20 | + |
|
21 | + /** |
|
22 | + * Status ID(STS_ID on esp_status table) to indicate the transaction is complete, |
|
23 | + * but payment is pending. This is the state for transactions where payment is promised |
|
24 | + * from an offline gateway. |
|
25 | + */ |
|
26 | + // const open_status_code = 'TPN'; |
|
27 | + |
|
28 | + /** |
|
29 | + * Status ID(STS_ID on esp_status table) to indicate the transaction failed, |
|
30 | + * either due to a technical reason (server or computer crash during registration), |
|
31 | + * or some other reason that prevent the collection of any useful contact information from any of the registrants |
|
32 | + */ |
|
33 | + const failed_status_code = 'TFL'; |
|
34 | + |
|
35 | + /** |
|
36 | + * Status ID(STS_ID on esp_status table) to indicate the transaction was abandoned, |
|
37 | + * either due to a technical reason (server or computer crash during registration), |
|
38 | + * or due to an abandoned cart after registrant chose not to complete the registration process |
|
39 | + * HOWEVER... |
|
40 | + * an abandoned TXN differs from a failed TXN in that it was able to capture contact information for at least one |
|
41 | + * registrant |
|
42 | + */ |
|
43 | + const abandoned_status_code = 'TAB'; |
|
44 | + |
|
45 | + /** |
|
46 | + * Status ID(STS_ID on esp_status table) to indicate an incomplete transaction, |
|
47 | + * meaning that monies are still owing: TXN_paid < TXN_total |
|
48 | + */ |
|
49 | + const incomplete_status_code = 'TIN'; |
|
50 | + |
|
51 | + /** |
|
52 | + * Status ID (STS_ID on esp_status table) to indicate a complete transaction. |
|
53 | + * meaning that NO monies are owing: TXN_paid == TXN_total |
|
54 | + */ |
|
55 | + const complete_status_code = 'TCM'; |
|
56 | + |
|
57 | + /** |
|
58 | + * Status ID(STS_ID on esp_status table) to indicate the transaction is overpaid. |
|
59 | + * This is the same as complete, but site admins actually owe clients the moneys! TXN_paid > TXN_total |
|
60 | + */ |
|
61 | + const overpaid_status_code = 'TOP'; |
|
62 | + |
|
63 | + |
|
64 | + /** |
|
65 | + * private constructor to prevent direct creation |
|
66 | + * |
|
67 | + * @Constructor |
|
68 | + * @access protected |
|
69 | + * |
|
70 | + * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any |
|
71 | + * incoming timezone data that gets saved). Note this just sends the timezone info to the |
|
72 | + * date time model field objects. Default is NULL (and will be assumed using the set |
|
73 | + * timezone in the 'timezone_string' wp option) |
|
74 | + * |
|
75 | + * @return EEM_Transaction |
|
76 | + * @throws \EE_Error |
|
77 | + */ |
|
78 | + protected function __construct($timezone) |
|
79 | + { |
|
80 | + $this->singular_item = __('Transaction', 'event_espresso'); |
|
81 | + $this->plural_item = __('Transactions', 'event_espresso'); |
|
82 | + |
|
83 | + $this->_tables = array( |
|
84 | + 'TransactionTable' => new EE_Primary_Table('esp_transaction', 'TXN_ID') |
|
85 | + ); |
|
86 | + $this->_fields = array( |
|
87 | + 'TransactionTable' => array( |
|
88 | + 'TXN_ID' => new EE_Primary_Key_Int_Field('TXN_ID', __('Transaction ID', 'event_espresso')), |
|
89 | + 'TXN_timestamp' => new EE_Datetime_Field('TXN_timestamp', |
|
90 | + __('date when transaction was created', 'event_espresso'), false, EE_Datetime_Field::now, |
|
91 | + $timezone), |
|
92 | + 'TXN_total' => new EE_Money_Field('TXN_total', |
|
93 | + __('Total value of Transaction', 'event_espresso'), false, 0), |
|
94 | + 'TXN_paid' => new EE_Money_Field('TXN_paid', |
|
95 | + __('Amount paid towards transaction to date', 'event_espresso'), false, 0), |
|
96 | + 'STS_ID' => new EE_Foreign_Key_String_Field('STS_ID', __('Status ID', 'event_espresso'), |
|
97 | + false, EEM_Transaction::failed_status_code, 'Status'), |
|
98 | + 'TXN_session_data' => new EE_Serialized_Text_Field('TXN_session_data', |
|
99 | + __('Serialized session data', 'event_espresso'), true, ''), |
|
100 | + 'TXN_hash_salt' => new EE_Plain_Text_Field('TXN_hash_salt', |
|
101 | + __('Transaction Hash Salt', 'event_espresso'), true, ''), |
|
102 | + 'PMD_ID' => new EE_Foreign_Key_Int_Field('PMD_ID', |
|
103 | + __("Last Used Payment Method", 'event_espresso'), true, null, 'Payment_Method'), |
|
104 | + 'TXN_reg_steps' => new EE_Serialized_Text_Field('TXN_reg_steps', |
|
105 | + __('Registration Steps', 'event_espresso'), false, array()), |
|
106 | + ) |
|
107 | + ); |
|
108 | + $this->_model_relations = array( |
|
109 | + 'Registration' => new EE_Has_Many_Relation(), |
|
110 | + 'Payment' => new EE_Has_Many_Relation(), |
|
111 | + 'Status' => new EE_Belongs_To_Relation(), |
|
112 | + 'Line_Item' => new EE_Has_Many_Relation(false), |
|
113 | + //you can delete a transaction without needing to delete its line items |
|
114 | + 'Payment_Method' => new EE_Belongs_To_Relation(), |
|
115 | + 'Message' => new EE_Has_Many_Relation() |
|
116 | + ); |
|
117 | + $this->_model_chain_to_wp_user = 'Registration.Event'; |
|
118 | + parent::__construct($timezone); |
|
119 | + |
|
120 | + } |
|
121 | + |
|
122 | + |
|
123 | + /** |
|
124 | + * txn_status_array |
|
125 | + * get list of transaction statuses |
|
126 | + * |
|
127 | + * @access public |
|
128 | + * @return array |
|
129 | + */ |
|
130 | + public static function txn_status_array() |
|
131 | + { |
|
132 | + return apply_filters( |
|
133 | + 'FHEE__EEM_Transaction__txn_status_array', |
|
134 | + array( |
|
135 | + EEM_Transaction::overpaid_status_code, |
|
136 | + EEM_Transaction::complete_status_code, |
|
137 | + EEM_Transaction::incomplete_status_code, |
|
138 | + EEM_Transaction::abandoned_status_code, |
|
139 | + EEM_Transaction::failed_status_code, |
|
140 | + ) |
|
141 | + ); |
|
142 | + } |
|
143 | + |
|
144 | + /** |
|
145 | + * get the revenue per day for the Transaction Admin page Reports Tab |
|
146 | + * |
|
147 | + * @access public |
|
148 | + * |
|
149 | + * @param string $period |
|
150 | + * |
|
151 | + * @return \stdClass[] |
|
152 | + */ |
|
153 | + public function get_revenue_per_day_report($period = '-1 month') |
|
154 | + { |
|
155 | + $sql_date = $this->convert_datetime_for_query('TXN_timestamp', date('Y-m-d H:i:s', strtotime($period)), |
|
156 | + 'Y-m-d H:i:s', 'UTC'); |
|
157 | + |
|
158 | + $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset($this->get_timezone(), 'TXN_timestamp'); |
|
159 | + |
|
160 | + return $this->_get_all_wpdb_results( |
|
161 | + array( |
|
162 | + array( |
|
163 | + 'TXN_timestamp' => array('>=', $sql_date) |
|
164 | + ), |
|
165 | + 'group_by' => 'txnDate', |
|
166 | + 'order_by' => array('TXN_timestamp' => 'ASC') |
|
167 | + ), |
|
168 | + OBJECT, |
|
169 | + array( |
|
170 | + 'txnDate' => array('DATE(' . $query_interval . ')', '%s'), |
|
171 | + 'revenue' => array('SUM(TransactionTable.TXN_paid)', '%d') |
|
172 | + ) |
|
173 | + ); |
|
174 | + } |
|
175 | + |
|
176 | + |
|
177 | + /** |
|
178 | + * get the revenue per event for the Transaction Admin page Reports Tab |
|
179 | + * |
|
180 | + * @access public |
|
181 | + * |
|
182 | + * @param string $period |
|
183 | + * |
|
184 | + * @throws \EE_Error |
|
185 | + * @return mixed |
|
186 | + */ |
|
187 | + public function get_revenue_per_event_report($period = '-1 month') |
|
188 | + { |
|
189 | + global $wpdb; |
|
190 | + $transaction_table = $wpdb->prefix . 'esp_transaction'; |
|
191 | + $registration_table = $wpdb->prefix . 'esp_registration'; |
|
192 | + $registration_payment_table = $wpdb->prefix . 'esp_registration_payment'; |
|
193 | + $event_table = $wpdb->posts; |
|
194 | + $payment_table = $wpdb->prefix . 'esp_payment'; |
|
195 | + $sql_date = date('Y-m-d H:i:s', strtotime($period)); |
|
196 | + $approved_payment_status = EEM_Payment::status_id_approved; |
|
197 | + $extra_event_on_join = ''; |
|
198 | + //exclude events not authored by user if permissions in effect |
|
199 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) { |
|
200 | + $extra_event_on_join = ' AND Event.post_author = ' . get_current_user_id(); |
|
201 | + } |
|
202 | + |
|
203 | + return $wpdb->get_results( |
|
204 | + "SELECT |
|
205 | 205 | Transaction_Event.event_name AS event_name, |
206 | 206 | SUM(Transaction_Event.paid) AS revenue |
207 | 207 | FROM |
@@ -228,185 +228,185 @@ discard block |
||
228 | 228 | $extra_event_on_join |
229 | 229 | ) AS Transaction_Event |
230 | 230 | GROUP BY event_name", |
231 | - OBJECT |
|
232 | - ); |
|
233 | - } |
|
234 | - |
|
235 | - |
|
236 | - /** |
|
237 | - * Gets the current transaction given the reg_url_link, or assumes the reg_url_link is in the |
|
238 | - * $_REQUEST global variable. Either way, tries to find the current transaction (through |
|
239 | - * the registration pointed to by reg_url_link), if not returns null |
|
240 | - * |
|
241 | - * @param string $reg_url_link |
|
242 | - * |
|
243 | - * @return EE_Transaction |
|
244 | - */ |
|
245 | - public function get_transaction_from_reg_url_link($reg_url_link = '') |
|
246 | - { |
|
247 | - return $this->get_one(array( |
|
248 | - array( |
|
249 | - 'Registration.REG_url_link' => ! empty($reg_url_link) ? $reg_url_link : EE_Registry::instance()->REQ->get('e_reg_url_link', |
|
250 | - '') |
|
251 | - ) |
|
252 | - )); |
|
253 | - } |
|
254 | - |
|
255 | - |
|
256 | - /** |
|
257 | - * Updates the provided EE_Transaction with all the applicable payments |
|
258 | - * (or fetch the EE_Transaction from its ID) |
|
259 | - * |
|
260 | - * @deprecated |
|
261 | - * |
|
262 | - * @param EE_Transaction|int $transaction_obj_or_id |
|
263 | - * @param boolean $save_txn whether or not to save the transaction during this function call |
|
264 | - * |
|
265 | - * @return boolean |
|
266 | - * @throws \EE_Error |
|
267 | - */ |
|
268 | - public function update_based_on_payments($transaction_obj_or_id, $save_txn = true) |
|
269 | - { |
|
270 | - EE_Error::doing_it_wrong( |
|
271 | - __CLASS__ . '::' . __FUNCTION__, |
|
272 | - sprintf(__('This method is deprecated. Please use "%s" instead', 'event_espresso'), |
|
273 | - 'EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment()'), |
|
274 | - '4.6.0' |
|
275 | - ); |
|
276 | - /** @type EE_Transaction_Processor $transaction_processor */ |
|
277 | - $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
278 | - |
|
279 | - return $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment( |
|
280 | - $this->ensure_is_obj($transaction_obj_or_id) |
|
281 | - ); |
|
282 | - } |
|
283 | - |
|
284 | - /** |
|
285 | - * Deletes "junk" transactions that were probably added by bots. There might be TONS |
|
286 | - * of these, so we are very careful to NOT select (which the models do even when deleting), |
|
287 | - * and so we only use wpdb directly and only do minimal joins. |
|
288 | - * Transactions are considered "junk" if they're failed for longer than a week. |
|
289 | - * Also, there is an extra check for payments related to the transaction, because if a transaction has a payment on |
|
290 | - * it, it's probably not junk (regardless of what status it has). |
|
291 | - * The downside to this approach is that is addons are listening for object deletions |
|
292 | - * on EEM_Base::delete() they won't be notified of this. However, there is an action that plugins can hook into |
|
293 | - * to catch these types of deletions. |
|
294 | - * |
|
295 | - * @global WPDB $wpdb |
|
296 | - * @return mixed |
|
297 | - */ |
|
298 | - public function delete_junk_transactions() |
|
299 | - { |
|
300 | - /** @type WPDB $wpdb */ |
|
301 | - global $wpdb; |
|
302 | - $deleted = false; |
|
303 | - $time_to_leave_alone = apply_filters( |
|
304 | - 'FHEE__EEM_Transaction__delete_junk_transactions__time_to_leave_alone' |
|
305 | - , WEEK_IN_SECONDS |
|
306 | - ); |
|
307 | - |
|
308 | - |
|
309 | - /** |
|
310 | - * This allows code to filter the query arguments used for retrieving the transaction IDs to delete. |
|
311 | - * Useful for plugins that want to exclude transactions matching certain query parameters. |
|
312 | - * The query parameters should be in the format accepted by the EEM_Base model queries. |
|
313 | - */ |
|
314 | - $ids_query = apply_filters( |
|
315 | - 'FHEE__EEM_Transaction__delete_junk_transactions__initial_query_args', |
|
316 | - array( |
|
317 | - 0 => array( |
|
318 | - 'STS_ID' => EEM_Transaction::failed_status_code, |
|
319 | - 'Payment.PAY_ID' => array( 'IS NULL' ), |
|
320 | - 'TXN_timestamp' => array('<', time() - $time_to_leave_alone) |
|
321 | - ) |
|
322 | - ), |
|
323 | - $time_to_leave_alone |
|
324 | - ); |
|
325 | - |
|
326 | - |
|
327 | - /** |
|
328 | - * This filter is for when code needs to filter the list of transaction ids that represent transactions |
|
329 | - * about to be deleted based on some other criteria that isn't easily done via the query args filter. |
|
330 | - */ |
|
331 | - $txn_ids = apply_filters( |
|
332 | - 'FHEE__EEM_Transaction__delete_junk_transactions__transaction_ids_to_delete', |
|
333 | - EEM_Transaction::instance()->get_col($ids_query, 'TXN_ID'), |
|
334 | - $time_to_leave_alone |
|
335 | - ); |
|
336 | - //now that we have the ids to delete |
|
337 | - if (! empty($txn_ids) && is_array($txn_ids)) { |
|
338 | - // first, make sure these TXN's are removed the "ee_locked_transactions" array |
|
339 | - EEM_Transaction::unset_locked_transactions($txn_ids); |
|
340 | - // let's get deletin'... |
|
341 | - // Why no wpdb->prepare? Because the data is trusted. |
|
342 | - // We got the ids from the original query to get them FROM |
|
343 | - // the db (which is sanitized) so no need to prepare them again. |
|
344 | - $query = ' |
|
231 | + OBJECT |
|
232 | + ); |
|
233 | + } |
|
234 | + |
|
235 | + |
|
236 | + /** |
|
237 | + * Gets the current transaction given the reg_url_link, or assumes the reg_url_link is in the |
|
238 | + * $_REQUEST global variable. Either way, tries to find the current transaction (through |
|
239 | + * the registration pointed to by reg_url_link), if not returns null |
|
240 | + * |
|
241 | + * @param string $reg_url_link |
|
242 | + * |
|
243 | + * @return EE_Transaction |
|
244 | + */ |
|
245 | + public function get_transaction_from_reg_url_link($reg_url_link = '') |
|
246 | + { |
|
247 | + return $this->get_one(array( |
|
248 | + array( |
|
249 | + 'Registration.REG_url_link' => ! empty($reg_url_link) ? $reg_url_link : EE_Registry::instance()->REQ->get('e_reg_url_link', |
|
250 | + '') |
|
251 | + ) |
|
252 | + )); |
|
253 | + } |
|
254 | + |
|
255 | + |
|
256 | + /** |
|
257 | + * Updates the provided EE_Transaction with all the applicable payments |
|
258 | + * (or fetch the EE_Transaction from its ID) |
|
259 | + * |
|
260 | + * @deprecated |
|
261 | + * |
|
262 | + * @param EE_Transaction|int $transaction_obj_or_id |
|
263 | + * @param boolean $save_txn whether or not to save the transaction during this function call |
|
264 | + * |
|
265 | + * @return boolean |
|
266 | + * @throws \EE_Error |
|
267 | + */ |
|
268 | + public function update_based_on_payments($transaction_obj_or_id, $save_txn = true) |
|
269 | + { |
|
270 | + EE_Error::doing_it_wrong( |
|
271 | + __CLASS__ . '::' . __FUNCTION__, |
|
272 | + sprintf(__('This method is deprecated. Please use "%s" instead', 'event_espresso'), |
|
273 | + 'EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment()'), |
|
274 | + '4.6.0' |
|
275 | + ); |
|
276 | + /** @type EE_Transaction_Processor $transaction_processor */ |
|
277 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
278 | + |
|
279 | + return $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment( |
|
280 | + $this->ensure_is_obj($transaction_obj_or_id) |
|
281 | + ); |
|
282 | + } |
|
283 | + |
|
284 | + /** |
|
285 | + * Deletes "junk" transactions that were probably added by bots. There might be TONS |
|
286 | + * of these, so we are very careful to NOT select (which the models do even when deleting), |
|
287 | + * and so we only use wpdb directly and only do minimal joins. |
|
288 | + * Transactions are considered "junk" if they're failed for longer than a week. |
|
289 | + * Also, there is an extra check for payments related to the transaction, because if a transaction has a payment on |
|
290 | + * it, it's probably not junk (regardless of what status it has). |
|
291 | + * The downside to this approach is that is addons are listening for object deletions |
|
292 | + * on EEM_Base::delete() they won't be notified of this. However, there is an action that plugins can hook into |
|
293 | + * to catch these types of deletions. |
|
294 | + * |
|
295 | + * @global WPDB $wpdb |
|
296 | + * @return mixed |
|
297 | + */ |
|
298 | + public function delete_junk_transactions() |
|
299 | + { |
|
300 | + /** @type WPDB $wpdb */ |
|
301 | + global $wpdb; |
|
302 | + $deleted = false; |
|
303 | + $time_to_leave_alone = apply_filters( |
|
304 | + 'FHEE__EEM_Transaction__delete_junk_transactions__time_to_leave_alone' |
|
305 | + , WEEK_IN_SECONDS |
|
306 | + ); |
|
307 | + |
|
308 | + |
|
309 | + /** |
|
310 | + * This allows code to filter the query arguments used for retrieving the transaction IDs to delete. |
|
311 | + * Useful for plugins that want to exclude transactions matching certain query parameters. |
|
312 | + * The query parameters should be in the format accepted by the EEM_Base model queries. |
|
313 | + */ |
|
314 | + $ids_query = apply_filters( |
|
315 | + 'FHEE__EEM_Transaction__delete_junk_transactions__initial_query_args', |
|
316 | + array( |
|
317 | + 0 => array( |
|
318 | + 'STS_ID' => EEM_Transaction::failed_status_code, |
|
319 | + 'Payment.PAY_ID' => array( 'IS NULL' ), |
|
320 | + 'TXN_timestamp' => array('<', time() - $time_to_leave_alone) |
|
321 | + ) |
|
322 | + ), |
|
323 | + $time_to_leave_alone |
|
324 | + ); |
|
325 | + |
|
326 | + |
|
327 | + /** |
|
328 | + * This filter is for when code needs to filter the list of transaction ids that represent transactions |
|
329 | + * about to be deleted based on some other criteria that isn't easily done via the query args filter. |
|
330 | + */ |
|
331 | + $txn_ids = apply_filters( |
|
332 | + 'FHEE__EEM_Transaction__delete_junk_transactions__transaction_ids_to_delete', |
|
333 | + EEM_Transaction::instance()->get_col($ids_query, 'TXN_ID'), |
|
334 | + $time_to_leave_alone |
|
335 | + ); |
|
336 | + //now that we have the ids to delete |
|
337 | + if (! empty($txn_ids) && is_array($txn_ids)) { |
|
338 | + // first, make sure these TXN's are removed the "ee_locked_transactions" array |
|
339 | + EEM_Transaction::unset_locked_transactions($txn_ids); |
|
340 | + // let's get deletin'... |
|
341 | + // Why no wpdb->prepare? Because the data is trusted. |
|
342 | + // We got the ids from the original query to get them FROM |
|
343 | + // the db (which is sanitized) so no need to prepare them again. |
|
344 | + $query = ' |
|
345 | 345 | DELETE |
346 | 346 | FROM ' . $this->table() . ' |
347 | 347 | WHERE |
348 | 348 | TXN_ID IN ( ' . implode(",", $txn_ids) . ')'; |
349 | - $deleted = $wpdb->query($query); |
|
350 | - } |
|
351 | - if ($deleted) { |
|
352 | - /** |
|
353 | - * Allows code to do something after the transactions have been deleted. |
|
354 | - */ |
|
355 | - do_action('AHEE__EEM_Transaction__delete_junk_transactions__successful_deletion', $txn_ids); |
|
356 | - } |
|
357 | - |
|
358 | - return $deleted; |
|
359 | - } |
|
360 | - |
|
361 | - |
|
362 | - /** |
|
363 | - * @param array $transaction_IDs |
|
364 | - * |
|
365 | - * @return bool |
|
366 | - */ |
|
367 | - public static function unset_locked_transactions(array $transaction_IDs) |
|
368 | - { |
|
369 | - $locked_transactions = get_option('ee_locked_transactions', array()); |
|
370 | - $update = false; |
|
371 | - foreach ($transaction_IDs as $TXN_ID) { |
|
372 | - if (isset($locked_transactions[$TXN_ID])) { |
|
373 | - unset($locked_transactions[$TXN_ID]); |
|
374 | - $update = true; |
|
375 | - } |
|
376 | - } |
|
377 | - if ($update) { |
|
378 | - update_option('ee_locked_transactions', $locked_transactions); |
|
379 | - } |
|
380 | - |
|
381 | - return $update; |
|
382 | - } |
|
383 | - |
|
384 | - |
|
385 | - |
|
386 | - /** |
|
387 | - * returns an array of EE_Transaction objects whose timestamp is less than |
|
388 | - * the current time minus the session lifespan, which defaults to 60 minutes |
|
389 | - * |
|
390 | - * @return EE_Base_Class[]|EE_Transaction[] |
|
391 | - * @throws \EE_Error |
|
392 | - */ |
|
393 | - public function get_transactions_in_progress() |
|
394 | - { |
|
395 | - return $this->get_all( |
|
396 | - array( |
|
397 | - array( |
|
398 | - 'TXN_timestamp' => array( |
|
399 | - '>', |
|
400 | - time() - EE_Registry::instance()->SSN->lifespan() |
|
401 | - ), |
|
402 | - 'STS_ID' => array( |
|
403 | - '!=', |
|
404 | - EEM_Transaction::complete_status_code |
|
405 | - ), |
|
406 | - ) |
|
407 | - ) |
|
408 | - ); |
|
409 | - } |
|
349 | + $deleted = $wpdb->query($query); |
|
350 | + } |
|
351 | + if ($deleted) { |
|
352 | + /** |
|
353 | + * Allows code to do something after the transactions have been deleted. |
|
354 | + */ |
|
355 | + do_action('AHEE__EEM_Transaction__delete_junk_transactions__successful_deletion', $txn_ids); |
|
356 | + } |
|
357 | + |
|
358 | + return $deleted; |
|
359 | + } |
|
360 | + |
|
361 | + |
|
362 | + /** |
|
363 | + * @param array $transaction_IDs |
|
364 | + * |
|
365 | + * @return bool |
|
366 | + */ |
|
367 | + public static function unset_locked_transactions(array $transaction_IDs) |
|
368 | + { |
|
369 | + $locked_transactions = get_option('ee_locked_transactions', array()); |
|
370 | + $update = false; |
|
371 | + foreach ($transaction_IDs as $TXN_ID) { |
|
372 | + if (isset($locked_transactions[$TXN_ID])) { |
|
373 | + unset($locked_transactions[$TXN_ID]); |
|
374 | + $update = true; |
|
375 | + } |
|
376 | + } |
|
377 | + if ($update) { |
|
378 | + update_option('ee_locked_transactions', $locked_transactions); |
|
379 | + } |
|
380 | + |
|
381 | + return $update; |
|
382 | + } |
|
383 | + |
|
384 | + |
|
385 | + |
|
386 | + /** |
|
387 | + * returns an array of EE_Transaction objects whose timestamp is less than |
|
388 | + * the current time minus the session lifespan, which defaults to 60 minutes |
|
389 | + * |
|
390 | + * @return EE_Base_Class[]|EE_Transaction[] |
|
391 | + * @throws \EE_Error |
|
392 | + */ |
|
393 | + public function get_transactions_in_progress() |
|
394 | + { |
|
395 | + return $this->get_all( |
|
396 | + array( |
|
397 | + array( |
|
398 | + 'TXN_timestamp' => array( |
|
399 | + '>', |
|
400 | + time() - EE_Registry::instance()->SSN->lifespan() |
|
401 | + ), |
|
402 | + 'STS_ID' => array( |
|
403 | + '!=', |
|
404 | + EEM_Transaction::complete_status_code |
|
405 | + ), |
|
406 | + ) |
|
407 | + ) |
|
408 | + ); |
|
409 | + } |
|
410 | 410 | |
411 | 411 | |
412 | 412 | } |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | * remove param |
343 | 343 | * |
344 | 344 | * @access public |
345 | - * @param $key |
|
345 | + * @param string $key |
|
346 | 346 | * @return void |
347 | 347 | */ |
348 | 348 | public function un_set( $key ) { |
@@ -382,7 +382,7 @@ discard block |
||
382 | 382 | * add_output |
383 | 383 | * |
384 | 384 | * @access public |
385 | - * @param $string |
|
385 | + * @param string $string |
|
386 | 386 | * @return void |
387 | 387 | */ |
388 | 388 | public function add_output( $string ) { |
@@ -238,8 +238,8 @@ discard block |
||
238 | 238 | if ( ! $this->get( 'post_name' ) ) { |
239 | 239 | // there's no specific post name set, so maybe it's one of our endpoints like www.domain.com/events |
240 | 240 | $post_name = isset( $post_type_CPT_endpoints[ $this->get( 'post_type' ) ] ) |
241 | - ? $post_type_CPT_endpoints[ $this->get( 'post_type' ) ] |
|
242 | - : ''; |
|
241 | + ? $post_type_CPT_endpoints[ $this->get( 'post_type' ) ] |
|
242 | + : ''; |
|
243 | 243 | // if the post type matches on of our then set the endpoint |
244 | 244 | if ( $post_name ) { |
245 | 245 | $this->set( 'post_name', $post_name ); |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | * @return void |
262 | 262 | */ |
263 | 263 | public function set_espresso_page( $value = null ) { |
264 | - $this->_params['is_espresso_page'] = ! empty($value) ? $value : $this->test_for_espresso_page(); |
|
264 | + $this->_params['is_espresso_page'] = ! empty($value) ? $value : $this->test_for_espresso_page(); |
|
265 | 265 | } |
266 | 266 | |
267 | 267 |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed');} |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed'); } |
|
2 | 2 | /** |
3 | 3 | * class EE_Request_Handler |
4 | 4 | * |
@@ -49,13 +49,13 @@ discard block |
||
49 | 49 | * @access public |
50 | 50 | * @param EE_Request $request |
51 | 51 | */ |
52 | - public function __construct( EE_Request $request ) { |
|
52 | + public function __construct(EE_Request $request) { |
|
53 | 53 | // grab request vars |
54 | 54 | $this->_params = $request->params(); |
55 | 55 | // AJAX ??? |
56 | - $this->ajax = defined( 'DOING_AJAX' ) && DOING_AJAX ? true : false; |
|
57 | - $this->front_ajax = defined( 'EE_FRONT_AJAX' ) && EE_FRONT_AJAX ? true : false; |
|
58 | - do_action( 'AHEE__EE_Request_Handler__construct__complete' ); |
|
56 | + $this->ajax = defined('DOING_AJAX') && DOING_AJAX ? true : false; |
|
57 | + $this->front_ajax = defined('EE_FRONT_AJAX') && EE_FRONT_AJAX ? true : false; |
|
58 | + do_action('AHEE__EE_Request_Handler__construct__complete'); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | |
@@ -67,12 +67,12 @@ discard block |
||
67 | 67 | * @param WP $wp |
68 | 68 | * @return void |
69 | 69 | */ |
70 | - public function parse_request( $wp = null ) { |
|
70 | + public function parse_request($wp = null) { |
|
71 | 71 | //if somebody forgot to provide us with WP, that's ok because its global |
72 | - if ( ! $wp instanceof WP ) { |
|
72 | + if ( ! $wp instanceof WP) { |
|
73 | 73 | global $wp; |
74 | 74 | } |
75 | - $this->set_request_vars( $wp ); |
|
75 | + $this->set_request_vars($wp); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | |
@@ -84,14 +84,14 @@ discard block |
||
84 | 84 | * @param WP $wp |
85 | 85 | * @return void |
86 | 86 | */ |
87 | - public function set_request_vars( $wp = null ) { |
|
88 | - if ( ! is_admin() ) { |
|
87 | + public function set_request_vars($wp = null) { |
|
88 | + if ( ! is_admin()) { |
|
89 | 89 | // set request post_id |
90 | - $this->set( 'post_id', $this->get_post_id_from_request( $wp )); |
|
90 | + $this->set('post_id', $this->get_post_id_from_request($wp)); |
|
91 | 91 | // set request post name |
92 | - $this->set( 'post_name', $this->get_post_name_from_request( $wp )); |
|
92 | + $this->set('post_name', $this->get_post_name_from_request($wp)); |
|
93 | 93 | // set request post_type |
94 | - $this->set( 'post_type', $this->get_post_type_from_request( $wp )); |
|
94 | + $this->set('post_type', $this->get_post_type_from_request($wp)); |
|
95 | 95 | // true or false ? is this page being used by EE ? |
96 | 96 | $this->set_espresso_page(); |
97 | 97 | } |
@@ -106,19 +106,19 @@ discard block |
||
106 | 106 | * @param WP $wp |
107 | 107 | * @return int |
108 | 108 | */ |
109 | - public function get_post_id_from_request( $wp = null ) { |
|
110 | - if ( ! $wp instanceof WP ){ |
|
109 | + public function get_post_id_from_request($wp = null) { |
|
110 | + if ( ! $wp instanceof WP) { |
|
111 | 111 | global $wp; |
112 | 112 | } |
113 | 113 | $post_id = null; |
114 | - if ( isset( $wp->query_vars['p'] )) { |
|
114 | + if (isset($wp->query_vars['p'])) { |
|
115 | 115 | $post_id = $wp->query_vars['p']; |
116 | 116 | } |
117 | - if ( ! $post_id && isset( $wp->query_vars['page_id'] )) { |
|
117 | + if ( ! $post_id && isset($wp->query_vars['page_id'])) { |
|
118 | 118 | $post_id = $wp->query_vars['page_id']; |
119 | 119 | } |
120 | - if ( ! $post_id && isset( $wp->request ) && is_numeric( basename( $wp->request ))) { |
|
121 | - $post_id = basename( $wp->request ); |
|
120 | + if ( ! $post_id && isset($wp->request) && is_numeric(basename($wp->request))) { |
|
121 | + $post_id = basename($wp->request); |
|
122 | 122 | } |
123 | 123 | return $post_id; |
124 | 124 | } |
@@ -132,35 +132,35 @@ discard block |
||
132 | 132 | * @param WP $wp |
133 | 133 | * @return string |
134 | 134 | */ |
135 | - public function get_post_name_from_request( $wp = null ) { |
|
136 | - if ( ! $wp instanceof WP ){ |
|
135 | + public function get_post_name_from_request($wp = null) { |
|
136 | + if ( ! $wp instanceof WP) { |
|
137 | 137 | global $wp; |
138 | 138 | } |
139 | 139 | $post_name = null; |
140 | - if ( isset( $wp->query_vars['name'] ) && ! empty( $wp->query_vars['name'] )) { |
|
140 | + if (isset($wp->query_vars['name']) && ! empty($wp->query_vars['name'])) { |
|
141 | 141 | $post_name = $wp->query_vars['name']; |
142 | 142 | } |
143 | - if ( ! $post_name && isset( $wp->query_vars['pagename'] ) && ! empty( $wp->query_vars['pagename'] )) { |
|
143 | + if ( ! $post_name && isset($wp->query_vars['pagename']) && ! empty($wp->query_vars['pagename'])) { |
|
144 | 144 | $post_name = $wp->query_vars['pagename']; |
145 | 145 | } |
146 | - if ( ! $post_name && isset( $wp->request ) && ! empty( $wp->request )) { |
|
147 | - $possible_post_name = basename( $wp->request ); |
|
148 | - if ( ! is_numeric( $possible_post_name )) { |
|
146 | + if ( ! $post_name && isset($wp->request) && ! empty($wp->request)) { |
|
147 | + $possible_post_name = basename($wp->request); |
|
148 | + if ( ! is_numeric($possible_post_name)) { |
|
149 | 149 | /** @type WPDB $wpdb */ |
150 | 150 | global $wpdb; |
151 | 151 | $SQL = "SELECT ID from {$wpdb->posts} WHERE post_status='publish' AND post_name=%s"; |
152 | - $possible_post_name = $wpdb->get_var( $wpdb->prepare( $SQL, $possible_post_name )); |
|
153 | - if ( $possible_post_name ) { |
|
152 | + $possible_post_name = $wpdb->get_var($wpdb->prepare($SQL, $possible_post_name)); |
|
153 | + if ($possible_post_name) { |
|
154 | 154 | $post_name = $possible_post_name; |
155 | 155 | } |
156 | 156 | } |
157 | 157 | } |
158 | - if ( ! $post_name && $this->get( 'post_id' )) { |
|
158 | + if ( ! $post_name && $this->get('post_id')) { |
|
159 | 159 | /** @type WPDB $wpdb */ |
160 | 160 | global $wpdb; |
161 | 161 | $SQL = "SELECT post_name from {$wpdb->posts} WHERE post_status='publish' AND ID=%d"; |
162 | - $possible_post_name = $wpdb->get_var( $wpdb->prepare( $SQL, $this->get( 'post_id' ))); |
|
163 | - if( $possible_post_name ) { |
|
162 | + $possible_post_name = $wpdb->get_var($wpdb->prepare($SQL, $this->get('post_id'))); |
|
163 | + if ($possible_post_name) { |
|
164 | 164 | $post_name = $possible_post_name; |
165 | 165 | } |
166 | 166 | } |
@@ -176,11 +176,11 @@ discard block |
||
176 | 176 | * @param WP $wp |
177 | 177 | * @return mixed |
178 | 178 | */ |
179 | - public function get_post_type_from_request( $wp = null ) { |
|
180 | - if ( ! $wp instanceof WP ){ |
|
179 | + public function get_post_type_from_request($wp = null) { |
|
180 | + if ( ! $wp instanceof WP) { |
|
181 | 181 | global $wp; |
182 | 182 | } |
183 | - return isset( $wp->query_vars['post_type'] ) ? $wp->query_vars['post_type'] : null; |
|
183 | + return isset($wp->query_vars['post_type']) ? $wp->query_vars['post_type'] : null; |
|
184 | 184 | } |
185 | 185 | |
186 | 186 | |
@@ -190,18 +190,18 @@ discard block |
||
190 | 190 | * @param WP $wp |
191 | 191 | * @return string |
192 | 192 | */ |
193 | - public function get_current_page_permalink( $wp = null ) { |
|
194 | - $post_id = $this->get_post_id_from_request( $wp ); |
|
195 | - if ( $post_id ) { |
|
196 | - $current_page_permalink = get_permalink( $post_id ); |
|
193 | + public function get_current_page_permalink($wp = null) { |
|
194 | + $post_id = $this->get_post_id_from_request($wp); |
|
195 | + if ($post_id) { |
|
196 | + $current_page_permalink = get_permalink($post_id); |
|
197 | 197 | } else { |
198 | - if ( ! $wp instanceof WP ) { |
|
198 | + if ( ! $wp instanceof WP) { |
|
199 | 199 | global $wp; |
200 | 200 | } |
201 | - if ( $wp->request ) { |
|
202 | - $current_page_permalink = site_url( $wp->request ); |
|
201 | + if ($wp->request) { |
|
202 | + $current_page_permalink = site_url($wp->request); |
|
203 | 203 | } else { |
204 | - $current_page_permalink = esc_url( site_url( $_SERVER[ 'REQUEST_URI' ] ) ); |
|
204 | + $current_page_permalink = esc_url(site_url($_SERVER['REQUEST_URI'])); |
|
205 | 205 | } |
206 | 206 | } |
207 | 207 | return $current_page_permalink; |
@@ -218,31 +218,31 @@ discard block |
||
218 | 218 | public function test_for_espresso_page() { |
219 | 219 | global $wp; |
220 | 220 | /** @type EE_CPT_Strategy $EE_CPT_Strategy */ |
221 | - $EE_CPT_Strategy = EE_Registry::instance()->load_core( 'CPT_Strategy' ); |
|
221 | + $EE_CPT_Strategy = EE_Registry::instance()->load_core('CPT_Strategy'); |
|
222 | 222 | $espresso_CPT_taxonomies = $EE_CPT_Strategy->get_CPT_taxonomies(); |
223 | - if ( is_array( $espresso_CPT_taxonomies ) ) { |
|
224 | - foreach ( $espresso_CPT_taxonomies as $espresso_CPT_taxonomy =>$details ) { |
|
225 | - if ( isset( $wp->query_vars, $wp->query_vars[ $espresso_CPT_taxonomy ] ) ) { |
|
223 | + if (is_array($espresso_CPT_taxonomies)) { |
|
224 | + foreach ($espresso_CPT_taxonomies as $espresso_CPT_taxonomy =>$details) { |
|
225 | + if (isset($wp->query_vars, $wp->query_vars[$espresso_CPT_taxonomy])) { |
|
226 | 226 | return true; |
227 | 227 | } |
228 | 228 | } |
229 | 229 | } |
230 | 230 | // load espresso CPT endpoints |
231 | 231 | $espresso_CPT_endpoints = $EE_CPT_Strategy->get_CPT_endpoints(); |
232 | - $post_type_CPT_endpoints = array_flip( $espresso_CPT_endpoints ); |
|
233 | - $post_types = (array)$this->get( 'post_type' ); |
|
234 | - foreach ( $post_types as $post_type ) { |
|
232 | + $post_type_CPT_endpoints = array_flip($espresso_CPT_endpoints); |
|
233 | + $post_types = (array) $this->get('post_type'); |
|
234 | + foreach ($post_types as $post_type) { |
|
235 | 235 | // was a post name passed ? |
236 | - if ( isset( $post_type_CPT_endpoints[ $post_type ] ) ) { |
|
236 | + if (isset($post_type_CPT_endpoints[$post_type])) { |
|
237 | 237 | // kk we know this is an espresso page, but is it a specific post ? |
238 | - if ( ! $this->get( 'post_name' ) ) { |
|
238 | + if ( ! $this->get('post_name')) { |
|
239 | 239 | // there's no specific post name set, so maybe it's one of our endpoints like www.domain.com/events |
240 | - $post_name = isset( $post_type_CPT_endpoints[ $this->get( 'post_type' ) ] ) |
|
241 | - ? $post_type_CPT_endpoints[ $this->get( 'post_type' ) ] |
|
240 | + $post_name = isset($post_type_CPT_endpoints[$this->get('post_type')]) |
|
241 | + ? $post_type_CPT_endpoints[$this->get('post_type')] |
|
242 | 242 | : ''; |
243 | 243 | // if the post type matches on of our then set the endpoint |
244 | - if ( $post_name ) { |
|
245 | - $this->set( 'post_name', $post_name ); |
|
244 | + if ($post_name) { |
|
245 | + $this->set('post_name', $post_name); |
|
246 | 246 | } |
247 | 247 | } |
248 | 248 | return true; |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | * @param null|bool $value |
261 | 261 | * @return void |
262 | 262 | */ |
263 | - public function set_espresso_page( $value = null ) { |
|
263 | + public function set_espresso_page($value = null) { |
|
264 | 264 | $this->_params['is_espresso_page'] = ! empty($value) ? $value : $this->test_for_espresso_page(); |
265 | 265 | } |
266 | 266 | |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | * @return mixed |
274 | 274 | */ |
275 | 275 | public function is_espresso_page() { |
276 | - return isset( $this->_params['is_espresso_page'] ) ? $this->_params['is_espresso_page'] : false; |
|
276 | + return isset($this->_params['is_espresso_page']) ? $this->_params['is_espresso_page'] : false; |
|
277 | 277 | } |
278 | 278 | |
279 | 279 | |
@@ -297,14 +297,14 @@ discard block |
||
297 | 297 | * @param bool $override_ee |
298 | 298 | * @return void |
299 | 299 | */ |
300 | - public function set( $key, $value, $override_ee = false ) { |
|
300 | + public function set($key, $value, $override_ee = false) { |
|
301 | 301 | // don't allow "ee" to be overwritten unless explicitly instructed to do so |
302 | 302 | if ( |
303 | 303 | $key !== 'ee' || |
304 | - ( $key === 'ee' && empty( $this->_params['ee'] )) |
|
305 | - || ( $key === 'ee' && ! empty( $this->_params['ee'] ) && $override_ee ) |
|
304 | + ($key === 'ee' && empty($this->_params['ee'])) |
|
305 | + || ($key === 'ee' && ! empty($this->_params['ee']) && $override_ee) |
|
306 | 306 | ) { |
307 | - $this->_params[ $key ] = $value; |
|
307 | + $this->_params[$key] = $value; |
|
308 | 308 | } |
309 | 309 | } |
310 | 310 | |
@@ -318,8 +318,8 @@ discard block |
||
318 | 318 | * @param null $default |
319 | 319 | * @return mixed |
320 | 320 | */ |
321 | - public function get( $key, $default = null ) { |
|
322 | - return isset( $this->_params[ $key ] ) ? $this->_params[ $key ] : $default; |
|
321 | + public function get($key, $default = null) { |
|
322 | + return isset($this->_params[$key]) ? $this->_params[$key] : $default; |
|
323 | 323 | } |
324 | 324 | |
325 | 325 | |
@@ -331,8 +331,8 @@ discard block |
||
331 | 331 | * @param $key |
332 | 332 | * @return boolean |
333 | 333 | */ |
334 | - public function is_set( $key ) { |
|
335 | - return isset( $this->_params[ $key ] ) ? true : false; |
|
334 | + public function is_set($key) { |
|
335 | + return isset($this->_params[$key]) ? true : false; |
|
336 | 336 | } |
337 | 337 | |
338 | 338 | |
@@ -344,8 +344,8 @@ discard block |
||
344 | 344 | * @param $key |
345 | 345 | * @return void |
346 | 346 | */ |
347 | - public function un_set( $key ) { |
|
348 | - unset( $this->_params[ $key ] ); |
|
347 | + public function un_set($key) { |
|
348 | + unset($this->_params[$key]); |
|
349 | 349 | } |
350 | 350 | |
351 | 351 | |
@@ -358,8 +358,8 @@ discard block |
||
358 | 358 | * @param $value |
359 | 359 | * @return void |
360 | 360 | */ |
361 | - public function set_notice( $key, $value ) { |
|
362 | - $this->_notice[ $key ] = $value; |
|
361 | + public function set_notice($key, $value) { |
|
362 | + $this->_notice[$key] = $value; |
|
363 | 363 | } |
364 | 364 | |
365 | 365 | |
@@ -371,8 +371,8 @@ discard block |
||
371 | 371 | * @param $key |
372 | 372 | * @return mixed |
373 | 373 | */ |
374 | - public function get_notice( $key ) { |
|
375 | - return isset( $this->_notice[ $key ] ) ? $this->_notice[ $key ] : null; |
|
374 | + public function get_notice($key) { |
|
375 | + return isset($this->_notice[$key]) ? $this->_notice[$key] : null; |
|
376 | 376 | } |
377 | 377 | |
378 | 378 | |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | * @param $string |
385 | 385 | * @return void |
386 | 386 | */ |
387 | - public function add_output( $string ) { |
|
387 | + public function add_output($string) { |
|
388 | 388 | $this->_output .= $string; |
389 | 389 | } |
390 | 390 | |
@@ -406,8 +406,8 @@ discard block |
||
406 | 406 | * @param $item |
407 | 407 | * @param $key |
408 | 408 | */ |
409 | - public function sanitize_text_field_for_array_walk( &$item, &$key ) { |
|
410 | - $item = strpos( $item, 'email' ) !== false ? sanitize_email( $item ) : sanitize_text_field( $item ); |
|
409 | + public function sanitize_text_field_for_array_walk(&$item, &$key) { |
|
410 | + $item = strpos($item, 'email') !== false ? sanitize_email($item) : sanitize_text_field($item); |
|
411 | 411 | } |
412 | 412 | |
413 | 413 | |
@@ -417,7 +417,7 @@ discard block |
||
417 | 417 | * @param $b |
418 | 418 | * @return bool |
419 | 419 | */ |
420 | - public function __set($a,$b) { return false; } |
|
420 | + public function __set($a, $b) { return false; } |
|
421 | 421 | |
422 | 422 | |
423 | 423 |