@@ -16,181 +16,181 @@ |
||
16 | 16 | */ |
17 | 17 | class RegisterCustomTaxonomyTerms |
18 | 18 | { |
19 | - /** |
|
20 | - * @var array[] $custom_taxonomy_terms |
|
21 | - */ |
|
22 | - public $custom_taxonomy_terms = array(); |
|
19 | + /** |
|
20 | + * @var array[] $custom_taxonomy_terms |
|
21 | + */ |
|
22 | + public $custom_taxonomy_terms = array(); |
|
23 | 23 | |
24 | 24 | |
25 | - /** |
|
26 | - * RegisterCustomTaxonomyTerms constructor. |
|
27 | - */ |
|
28 | - public function __construct() |
|
29 | - { |
|
30 | - // hook into save_post so that we can make sure that the default terms get saved on publish of registered cpts |
|
31 | - // IF they don't have a term for that taxonomy set. |
|
32 | - add_action('save_post', array($this, 'saveDefaultTerm'), 100, 2); |
|
33 | - do_action( |
|
34 | - 'AHEE__EventEspresso_core_domain_services_custom_post_types_RegisterCustomTaxonomyTerms__construct_end', |
|
35 | - $this |
|
36 | - ); |
|
37 | - } |
|
25 | + /** |
|
26 | + * RegisterCustomTaxonomyTerms constructor. |
|
27 | + */ |
|
28 | + public function __construct() |
|
29 | + { |
|
30 | + // hook into save_post so that we can make sure that the default terms get saved on publish of registered cpts |
|
31 | + // IF they don't have a term for that taxonomy set. |
|
32 | + add_action('save_post', array($this, 'saveDefaultTerm'), 100, 2); |
|
33 | + do_action( |
|
34 | + 'AHEE__EventEspresso_core_domain_services_custom_post_types_RegisterCustomTaxonomyTerms__construct_end', |
|
35 | + $this |
|
36 | + ); |
|
37 | + } |
|
38 | 38 | |
39 | 39 | |
40 | - public function registerCustomTaxonomyTerms() |
|
41 | - { |
|
42 | - // setup default terms in any of our taxonomies (but only if we're in admin). |
|
43 | - // Why not added via register_activation_hook? |
|
44 | - // Because it's possible that in future iterations of EE we may add new defaults for specialized taxonomies |
|
45 | - // (think event_types) and register_activation_hook only reliably runs when a user manually activates the plugin. |
|
46 | - // Keep in mind that this will READ these terms if they are deleted by the user. Hence MUST use terms. |
|
47 | - // if ( is_admin() ) { |
|
48 | - // $this->set_must_use_event_types(); |
|
49 | - // } |
|
50 | - // set default terms |
|
51 | - $this->registerCustomTaxonomyTerm( |
|
52 | - 'espresso_event_type', |
|
53 | - 'single-event', |
|
54 | - [EspressoPostType::EVENTS] |
|
55 | - ); |
|
56 | - } |
|
40 | + public function registerCustomTaxonomyTerms() |
|
41 | + { |
|
42 | + // setup default terms in any of our taxonomies (but only if we're in admin). |
|
43 | + // Why not added via register_activation_hook? |
|
44 | + // Because it's possible that in future iterations of EE we may add new defaults for specialized taxonomies |
|
45 | + // (think event_types) and register_activation_hook only reliably runs when a user manually activates the plugin. |
|
46 | + // Keep in mind that this will READ these terms if they are deleted by the user. Hence MUST use terms. |
|
47 | + // if ( is_admin() ) { |
|
48 | + // $this->set_must_use_event_types(); |
|
49 | + // } |
|
50 | + // set default terms |
|
51 | + $this->registerCustomTaxonomyTerm( |
|
52 | + 'espresso_event_type', |
|
53 | + 'single-event', |
|
54 | + [EspressoPostType::EVENTS] |
|
55 | + ); |
|
56 | + } |
|
57 | 57 | |
58 | 58 | |
59 | - /** |
|
60 | - * Allows us to set what the default will be for terms when a cpt is PUBLISHED. |
|
61 | - * |
|
62 | - * @param string $taxonomy The taxonomy we're using for the default term |
|
63 | - * @param string $term_slug The slug of the term that will be the default. |
|
64 | - * @param array $cpt_slugs An array of custom post types we want the default assigned to |
|
65 | - */ |
|
66 | - public function registerCustomTaxonomyTerm($taxonomy, $term_slug, array $cpt_slugs = array()) |
|
67 | - { |
|
68 | - $this->custom_taxonomy_terms[][ $term_slug ] = new CustomTaxonomyTerm( |
|
69 | - $taxonomy, |
|
70 | - $term_slug, |
|
71 | - $cpt_slugs |
|
72 | - ); |
|
73 | - } |
|
59 | + /** |
|
60 | + * Allows us to set what the default will be for terms when a cpt is PUBLISHED. |
|
61 | + * |
|
62 | + * @param string $taxonomy The taxonomy we're using for the default term |
|
63 | + * @param string $term_slug The slug of the term that will be the default. |
|
64 | + * @param array $cpt_slugs An array of custom post types we want the default assigned to |
|
65 | + */ |
|
66 | + public function registerCustomTaxonomyTerm($taxonomy, $term_slug, array $cpt_slugs = array()) |
|
67 | + { |
|
68 | + $this->custom_taxonomy_terms[][ $term_slug ] = new CustomTaxonomyTerm( |
|
69 | + $taxonomy, |
|
70 | + $term_slug, |
|
71 | + $cpt_slugs |
|
72 | + ); |
|
73 | + } |
|
74 | 74 | |
75 | 75 | |
76 | - /** |
|
77 | - * hooked into the wp 'save_post' action hook for setting our default terms found in the $_default_terms property |
|
78 | - * |
|
79 | - * @param int $post_id ID of CPT being saved |
|
80 | - * @param WP_Post|null $post Post object |
|
81 | - * @return void |
|
82 | - */ |
|
83 | - public function saveDefaultTerm(int $post_id, ?WP_Post $post) |
|
84 | - { |
|
85 | - if (! $post || empty($this->custom_taxonomy_terms)) { |
|
86 | - return; |
|
87 | - } |
|
88 | - // no default terms set so lets just exit. |
|
89 | - foreach ($this->custom_taxonomy_terms as $custom_taxonomy_terms) { |
|
90 | - foreach ($custom_taxonomy_terms as $custom_taxonomy_term) { |
|
91 | - if ( |
|
92 | - $post->post_status === 'publish' |
|
93 | - && $custom_taxonomy_term instanceof CustomTaxonomyTerm |
|
94 | - && in_array($post->post_type, $custom_taxonomy_term->customPostTypeSlugs(), true) |
|
95 | - ) { |
|
96 | - // note some error proofing going on here to save unnecessary db queries |
|
97 | - $taxonomies = get_object_taxonomies($post->post_type); |
|
98 | - foreach ($taxonomies as $taxonomy) { |
|
99 | - $terms = wp_get_post_terms($post_id, $taxonomy); |
|
100 | - if (empty($terms) && $taxonomy === $custom_taxonomy_term->taxonomySlug()) { |
|
101 | - wp_set_object_terms( |
|
102 | - $post_id, |
|
103 | - array($custom_taxonomy_term->termSlug()), |
|
104 | - $taxonomy |
|
105 | - ); |
|
106 | - } |
|
107 | - } |
|
108 | - } |
|
109 | - } |
|
110 | - } |
|
111 | - } |
|
76 | + /** |
|
77 | + * hooked into the wp 'save_post' action hook for setting our default terms found in the $_default_terms property |
|
78 | + * |
|
79 | + * @param int $post_id ID of CPT being saved |
|
80 | + * @param WP_Post|null $post Post object |
|
81 | + * @return void |
|
82 | + */ |
|
83 | + public function saveDefaultTerm(int $post_id, ?WP_Post $post) |
|
84 | + { |
|
85 | + if (! $post || empty($this->custom_taxonomy_terms)) { |
|
86 | + return; |
|
87 | + } |
|
88 | + // no default terms set so lets just exit. |
|
89 | + foreach ($this->custom_taxonomy_terms as $custom_taxonomy_terms) { |
|
90 | + foreach ($custom_taxonomy_terms as $custom_taxonomy_term) { |
|
91 | + if ( |
|
92 | + $post->post_status === 'publish' |
|
93 | + && $custom_taxonomy_term instanceof CustomTaxonomyTerm |
|
94 | + && in_array($post->post_type, $custom_taxonomy_term->customPostTypeSlugs(), true) |
|
95 | + ) { |
|
96 | + // note some error proofing going on here to save unnecessary db queries |
|
97 | + $taxonomies = get_object_taxonomies($post->post_type); |
|
98 | + foreach ($taxonomies as $taxonomy) { |
|
99 | + $terms = wp_get_post_terms($post_id, $taxonomy); |
|
100 | + if (empty($terms) && $taxonomy === $custom_taxonomy_term->taxonomySlug()) { |
|
101 | + wp_set_object_terms( |
|
102 | + $post_id, |
|
103 | + array($custom_taxonomy_term->termSlug()), |
|
104 | + $taxonomy |
|
105 | + ); |
|
106 | + } |
|
107 | + } |
|
108 | + } |
|
109 | + } |
|
110 | + } |
|
111 | + } |
|
112 | 112 | |
113 | 113 | |
114 | - /** |
|
115 | - * @return void |
|
116 | - */ |
|
117 | - public function setMustUseEventTypes() |
|
118 | - { |
|
119 | - $term_details = array( |
|
120 | - // Attendee's register for the first date-time only |
|
121 | - 'single-event' => array( |
|
122 | - 'term' => esc_html__('Single Event', 'event_espresso'), |
|
123 | - 'desc' => esc_html__( |
|
124 | - 'A single event that spans one or more consecutive days.', |
|
125 | - 'event_espresso' |
|
126 | - ), |
|
127 | - ), |
|
128 | - // example: a party or two-day long workshop |
|
129 | - // Attendee's can register for any of the date-times |
|
130 | - 'multi-event' => array( |
|
131 | - 'term' => esc_html__('Multi Event', 'event_espresso'), |
|
132 | - 'desc' => esc_html__( |
|
133 | - 'Multiple, separate, but related events that occur on consecutive days.', |
|
134 | - 'event_espresso' |
|
135 | - ), |
|
136 | - ), |
|
137 | - // example: a three day music festival or week long conference |
|
138 | - // Attendee's register for the first date-time only |
|
139 | - 'event-series' => array( |
|
140 | - 'term' => esc_html__('Event Series', 'event_espresso'), |
|
141 | - 'desc' => esc_html__( |
|
142 | - ' Multiple events that occur over multiple non-consecutive days.', |
|
143 | - 'event_espresso' |
|
144 | - ), |
|
145 | - ), |
|
146 | - // example: an 8 week introduction to basket weaving course |
|
147 | - // Attendee's can register for any of the date-times. |
|
148 | - 'recurring-event' => array( |
|
149 | - 'term' => esc_html__('Recurring Event', 'event_espresso'), |
|
150 | - 'desc' => esc_html__( |
|
151 | - 'Multiple events that occur over multiple non-consecutive days.', |
|
152 | - 'event_espresso' |
|
153 | - ), |
|
154 | - ), |
|
155 | - // example: a yoga class |
|
156 | - 'ongoing' => array( |
|
157 | - 'term' => esc_html__('Ongoing Event', 'event_espresso'), |
|
158 | - 'desc' => esc_html__( |
|
159 | - 'An "event" that people can purchase tickets to gain access for anytime for this event regardless of date times on the event', |
|
160 | - 'event_espresso' |
|
161 | - ), |
|
162 | - ) |
|
163 | - // example: access to a museum |
|
164 | - // 'walk-in' => array( esc_html__('Walk In', 'event_espresso'), esc_html__('Single datetime and single entry recurring events. Attendees register for one or multiple datetimes individually.', 'event_espresso') ), |
|
165 | - // 'reservation' => array( esc_html__('Reservation', 'event_espresso'), esc_html__('Reservations are created by specifying available datetimes and quantities. Attendees choose from the available datetimes and specify the quantity available (if the maximum is greater than 1)') ), //@TODO to avoid confusion we'll implement this in a later iteration > EE4.1 |
|
166 | - // 'multiple-session' => array( esc_html__('Multiple Session', 'event_espresso'), esc_html__('Multiple event, multiple datetime, hierarchically organized, custom entry events. Attendees may be required to register for a parent event before being allowed to register for child events. Attendees can register for any combination of child events as long as the datetimes do not conflict. Parent and child events may have additional fees or registration questions.') ), //@TODO to avoid confusion we'll implement this in a later iteration > EE4.1 |
|
167 | - // 'appointment' => array( esc_html__('Appointments', 'event_espresso'), esc_html__('Time slotted events where datetimes are generally in hours or minutes. For example, attendees can register for a single 15 minute or 1 hour time slot and this type of availability frequently reoccurs.', 'event_espresso') ) |
|
168 | - ); |
|
169 | - $this->setMustUseTerms('espresso_event_type', $term_details); |
|
170 | - } |
|
114 | + /** |
|
115 | + * @return void |
|
116 | + */ |
|
117 | + public function setMustUseEventTypes() |
|
118 | + { |
|
119 | + $term_details = array( |
|
120 | + // Attendee's register for the first date-time only |
|
121 | + 'single-event' => array( |
|
122 | + 'term' => esc_html__('Single Event', 'event_espresso'), |
|
123 | + 'desc' => esc_html__( |
|
124 | + 'A single event that spans one or more consecutive days.', |
|
125 | + 'event_espresso' |
|
126 | + ), |
|
127 | + ), |
|
128 | + // example: a party or two-day long workshop |
|
129 | + // Attendee's can register for any of the date-times |
|
130 | + 'multi-event' => array( |
|
131 | + 'term' => esc_html__('Multi Event', 'event_espresso'), |
|
132 | + 'desc' => esc_html__( |
|
133 | + 'Multiple, separate, but related events that occur on consecutive days.', |
|
134 | + 'event_espresso' |
|
135 | + ), |
|
136 | + ), |
|
137 | + // example: a three day music festival or week long conference |
|
138 | + // Attendee's register for the first date-time only |
|
139 | + 'event-series' => array( |
|
140 | + 'term' => esc_html__('Event Series', 'event_espresso'), |
|
141 | + 'desc' => esc_html__( |
|
142 | + ' Multiple events that occur over multiple non-consecutive days.', |
|
143 | + 'event_espresso' |
|
144 | + ), |
|
145 | + ), |
|
146 | + // example: an 8 week introduction to basket weaving course |
|
147 | + // Attendee's can register for any of the date-times. |
|
148 | + 'recurring-event' => array( |
|
149 | + 'term' => esc_html__('Recurring Event', 'event_espresso'), |
|
150 | + 'desc' => esc_html__( |
|
151 | + 'Multiple events that occur over multiple non-consecutive days.', |
|
152 | + 'event_espresso' |
|
153 | + ), |
|
154 | + ), |
|
155 | + // example: a yoga class |
|
156 | + 'ongoing' => array( |
|
157 | + 'term' => esc_html__('Ongoing Event', 'event_espresso'), |
|
158 | + 'desc' => esc_html__( |
|
159 | + 'An "event" that people can purchase tickets to gain access for anytime for this event regardless of date times on the event', |
|
160 | + 'event_espresso' |
|
161 | + ), |
|
162 | + ) |
|
163 | + // example: access to a museum |
|
164 | + // 'walk-in' => array( esc_html__('Walk In', 'event_espresso'), esc_html__('Single datetime and single entry recurring events. Attendees register for one or multiple datetimes individually.', 'event_espresso') ), |
|
165 | + // 'reservation' => array( esc_html__('Reservation', 'event_espresso'), esc_html__('Reservations are created by specifying available datetimes and quantities. Attendees choose from the available datetimes and specify the quantity available (if the maximum is greater than 1)') ), //@TODO to avoid confusion we'll implement this in a later iteration > EE4.1 |
|
166 | + // 'multiple-session' => array( esc_html__('Multiple Session', 'event_espresso'), esc_html__('Multiple event, multiple datetime, hierarchically organized, custom entry events. Attendees may be required to register for a parent event before being allowed to register for child events. Attendees can register for any combination of child events as long as the datetimes do not conflict. Parent and child events may have additional fees or registration questions.') ), //@TODO to avoid confusion we'll implement this in a later iteration > EE4.1 |
|
167 | + // 'appointment' => array( esc_html__('Appointments', 'event_espresso'), esc_html__('Time slotted events where datetimes are generally in hours or minutes. For example, attendees can register for a single 15 minute or 1 hour time slot and this type of availability frequently reoccurs.', 'event_espresso') ) |
|
168 | + ); |
|
169 | + $this->setMustUseTerms('espresso_event_type', $term_details); |
|
170 | + } |
|
171 | 171 | |
172 | 172 | |
173 | - /** |
|
174 | - * wrapper method for handling the setting up of initial terms in the db (if they don't already exist). |
|
175 | - * Note this should ONLY be used for terms that always must be present. Be aware that if an initial term is |
|
176 | - * deleted then it WILL be recreated. |
|
177 | - * |
|
178 | - * @param string $taxonomy The name of the taxonomy |
|
179 | - * @param array $term_details An array of term details indexed by slug and containing Name of term, and |
|
180 | - * description as the elements in the array |
|
181 | - * @return void |
|
182 | - */ |
|
183 | - public function setMustUseTerms($taxonomy, $term_details) |
|
184 | - { |
|
185 | - $term_details = (array) $term_details; |
|
186 | - foreach ($term_details as $slug => $details) { |
|
187 | - if (isset($details['term'], $details['desc']) && ! term_exists($slug, $taxonomy)) { |
|
188 | - $insert_arr = array( |
|
189 | - 'slug' => $slug, |
|
190 | - 'description' => $details['desc'], |
|
191 | - ); |
|
192 | - wp_insert_term($details['term'], $taxonomy, $insert_arr); |
|
193 | - } |
|
194 | - } |
|
195 | - } |
|
173 | + /** |
|
174 | + * wrapper method for handling the setting up of initial terms in the db (if they don't already exist). |
|
175 | + * Note this should ONLY be used for terms that always must be present. Be aware that if an initial term is |
|
176 | + * deleted then it WILL be recreated. |
|
177 | + * |
|
178 | + * @param string $taxonomy The name of the taxonomy |
|
179 | + * @param array $term_details An array of term details indexed by slug and containing Name of term, and |
|
180 | + * description as the elements in the array |
|
181 | + * @return void |
|
182 | + */ |
|
183 | + public function setMustUseTerms($taxonomy, $term_details) |
|
184 | + { |
|
185 | + $term_details = (array) $term_details; |
|
186 | + foreach ($term_details as $slug => $details) { |
|
187 | + if (isset($details['term'], $details['desc']) && ! term_exists($slug, $taxonomy)) { |
|
188 | + $insert_arr = array( |
|
189 | + 'slug' => $slug, |
|
190 | + 'description' => $details['desc'], |
|
191 | + ); |
|
192 | + wp_insert_term($details['term'], $taxonomy, $insert_arr); |
|
193 | + } |
|
194 | + } |
|
195 | + } |
|
196 | 196 | } |
@@ -15,150 +15,150 @@ |
||
15 | 15 | */ |
16 | 16 | class RegistrationsListTableUserCapabilities extends UserCapabilities |
17 | 17 | { |
18 | - /** |
|
19 | - * @throws EE_Error |
|
20 | - * @throws ReflectionException |
|
21 | - */ |
|
22 | - public function userCanReadRegistration(EE_Registration $registration): bool |
|
23 | - { |
|
24 | - return $this->hasEntityCap( |
|
25 | - 'ee_read_registration', |
|
26 | - 'espresso_registrations_view_registration', |
|
27 | - $registration->ID() |
|
28 | - ); |
|
29 | - } |
|
30 | - |
|
31 | - |
|
32 | - /** |
|
33 | - * @throws EE_Error |
|
34 | - * @throws ReflectionException |
|
35 | - */ |
|
36 | - public function userCanEditRegistration(EE_Registration $registration): bool |
|
37 | - { |
|
38 | - return $this->hasEntityCap( |
|
39 | - 'ee_edit_registration', |
|
40 | - 'registration_list_table_checkbox_input', |
|
41 | - $registration->ID() |
|
42 | - ); |
|
43 | - } |
|
44 | - |
|
45 | - |
|
46 | - public function userCanTrashRegistrations(): bool |
|
47 | - { |
|
48 | - return $this->hasGlobalCap('ee_delete_registrations', 'espresso_registrations_trash_registrations'); |
|
49 | - } |
|
50 | - |
|
51 | - |
|
52 | - /** |
|
53 | - * @throws EE_Error |
|
54 | - * @throws ReflectionException |
|
55 | - */ |
|
56 | - public function userCanTrashRegistration(EE_Registration $registration): bool |
|
57 | - { |
|
58 | - return $this->hasEntityCap( |
|
59 | - 'ee_delete_registration', |
|
60 | - 'espresso_registrations_trash_registrations', |
|
61 | - $registration->ID() |
|
62 | - ); |
|
63 | - } |
|
64 | - |
|
65 | - |
|
66 | - /** |
|
67 | - * @throws EE_Error |
|
68 | - * @throws ReflectionException |
|
69 | - */ |
|
70 | - public function userCanDeleteRegistration(EE_Registration $registration): bool |
|
71 | - { |
|
72 | - return $this->hasEntityCap( |
|
73 | - 'ee_delete_registration', |
|
74 | - 'espresso_registrations_ee_delete_registrations', |
|
75 | - $registration->ID() |
|
76 | - ); |
|
77 | - } |
|
78 | - |
|
79 | - |
|
80 | - /** |
|
81 | - * @throws EE_Error |
|
82 | - * @throws ReflectionException |
|
83 | - */ |
|
84 | - public function userCanRestoreRegistration(EE_Registration $registration): bool |
|
85 | - { |
|
86 | - return $this->hasEntityCap( |
|
87 | - 'ee_delete_registration', |
|
88 | - 'espresso_registrations_restore_registrations', |
|
89 | - $registration->ID() |
|
90 | - ); |
|
91 | - } |
|
92 | - |
|
93 | - |
|
94 | - public function userCanViewTransaction(): bool |
|
95 | - { |
|
96 | - return $this->hasGlobalCap('ee_read_transaction', 'espresso_transactions_view_transaction'); |
|
97 | - } |
|
98 | - |
|
99 | - |
|
100 | - public function userCanReadGlobalMessages(): bool |
|
101 | - { |
|
102 | - return $this->hasGlobalCap('ee_read_global_messages', 'view_filtered_messages'); |
|
103 | - } |
|
104 | - |
|
105 | - |
|
106 | - /** |
|
107 | - * @throws EE_Error |
|
108 | - * @throws ReflectionException |
|
109 | - */ |
|
110 | - public function userCanResendMessage(EE_Registration $registration): bool |
|
111 | - { |
|
112 | - return $this->hasEntityCap( |
|
113 | - 'ee_send_message', |
|
114 | - 'espresso_registrations_resend_registration', |
|
115 | - $registration->ID() |
|
116 | - ); |
|
117 | - } |
|
118 | - |
|
119 | - |
|
120 | - public function userCanEditEvent(int $EVT_ID): bool |
|
121 | - { |
|
122 | - return $this->hasEntityCap('ee_edit_event', 'edit_event', $EVT_ID); |
|
123 | - } |
|
124 | - |
|
125 | - |
|
126 | - public function userCanEditContacts(): bool |
|
127 | - { |
|
128 | - return $this->hasGlobalCap('ee_edit_contacts', 'espresso_registrations_edit_attendee'); |
|
129 | - } |
|
130 | - |
|
131 | - |
|
132 | - public function userCanReadRegistrationCheckins(): bool |
|
133 | - { |
|
134 | - return $this->hasGlobalCap('ee_read_checkins', 'espresso_registrations_registration_checkins'); |
|
135 | - } |
|
136 | - |
|
137 | - |
|
138 | - /** |
|
139 | - * @throws EE_Error |
|
140 | - * @throws ReflectionException |
|
141 | - */ |
|
142 | - public function userCanReadRegistrationCheckin(EE_Registration $registration): bool |
|
143 | - { |
|
144 | - return $this->hasEntityCap( |
|
145 | - 'ee_read_checkin', |
|
146 | - 'espresso_registrations_registration_checkins', |
|
147 | - $registration->ID() |
|
148 | - ); |
|
149 | - } |
|
150 | - |
|
151 | - |
|
152 | - /** |
|
153 | - * @throws EE_Error |
|
154 | - * @throws ReflectionException |
|
155 | - */ |
|
156 | - public function userCanEditRegistrationCheckin(EE_Registration $registration): bool |
|
157 | - { |
|
158 | - return $this->hasEntityCap( |
|
159 | - 'ee_edit_checkin', |
|
160 | - 'espresso_registrations_toggle_checkin_status', |
|
161 | - $registration->ID() |
|
162 | - ); |
|
163 | - } |
|
18 | + /** |
|
19 | + * @throws EE_Error |
|
20 | + * @throws ReflectionException |
|
21 | + */ |
|
22 | + public function userCanReadRegistration(EE_Registration $registration): bool |
|
23 | + { |
|
24 | + return $this->hasEntityCap( |
|
25 | + 'ee_read_registration', |
|
26 | + 'espresso_registrations_view_registration', |
|
27 | + $registration->ID() |
|
28 | + ); |
|
29 | + } |
|
30 | + |
|
31 | + |
|
32 | + /** |
|
33 | + * @throws EE_Error |
|
34 | + * @throws ReflectionException |
|
35 | + */ |
|
36 | + public function userCanEditRegistration(EE_Registration $registration): bool |
|
37 | + { |
|
38 | + return $this->hasEntityCap( |
|
39 | + 'ee_edit_registration', |
|
40 | + 'registration_list_table_checkbox_input', |
|
41 | + $registration->ID() |
|
42 | + ); |
|
43 | + } |
|
44 | + |
|
45 | + |
|
46 | + public function userCanTrashRegistrations(): bool |
|
47 | + { |
|
48 | + return $this->hasGlobalCap('ee_delete_registrations', 'espresso_registrations_trash_registrations'); |
|
49 | + } |
|
50 | + |
|
51 | + |
|
52 | + /** |
|
53 | + * @throws EE_Error |
|
54 | + * @throws ReflectionException |
|
55 | + */ |
|
56 | + public function userCanTrashRegistration(EE_Registration $registration): bool |
|
57 | + { |
|
58 | + return $this->hasEntityCap( |
|
59 | + 'ee_delete_registration', |
|
60 | + 'espresso_registrations_trash_registrations', |
|
61 | + $registration->ID() |
|
62 | + ); |
|
63 | + } |
|
64 | + |
|
65 | + |
|
66 | + /** |
|
67 | + * @throws EE_Error |
|
68 | + * @throws ReflectionException |
|
69 | + */ |
|
70 | + public function userCanDeleteRegistration(EE_Registration $registration): bool |
|
71 | + { |
|
72 | + return $this->hasEntityCap( |
|
73 | + 'ee_delete_registration', |
|
74 | + 'espresso_registrations_ee_delete_registrations', |
|
75 | + $registration->ID() |
|
76 | + ); |
|
77 | + } |
|
78 | + |
|
79 | + |
|
80 | + /** |
|
81 | + * @throws EE_Error |
|
82 | + * @throws ReflectionException |
|
83 | + */ |
|
84 | + public function userCanRestoreRegistration(EE_Registration $registration): bool |
|
85 | + { |
|
86 | + return $this->hasEntityCap( |
|
87 | + 'ee_delete_registration', |
|
88 | + 'espresso_registrations_restore_registrations', |
|
89 | + $registration->ID() |
|
90 | + ); |
|
91 | + } |
|
92 | + |
|
93 | + |
|
94 | + public function userCanViewTransaction(): bool |
|
95 | + { |
|
96 | + return $this->hasGlobalCap('ee_read_transaction', 'espresso_transactions_view_transaction'); |
|
97 | + } |
|
98 | + |
|
99 | + |
|
100 | + public function userCanReadGlobalMessages(): bool |
|
101 | + { |
|
102 | + return $this->hasGlobalCap('ee_read_global_messages', 'view_filtered_messages'); |
|
103 | + } |
|
104 | + |
|
105 | + |
|
106 | + /** |
|
107 | + * @throws EE_Error |
|
108 | + * @throws ReflectionException |
|
109 | + */ |
|
110 | + public function userCanResendMessage(EE_Registration $registration): bool |
|
111 | + { |
|
112 | + return $this->hasEntityCap( |
|
113 | + 'ee_send_message', |
|
114 | + 'espresso_registrations_resend_registration', |
|
115 | + $registration->ID() |
|
116 | + ); |
|
117 | + } |
|
118 | + |
|
119 | + |
|
120 | + public function userCanEditEvent(int $EVT_ID): bool |
|
121 | + { |
|
122 | + return $this->hasEntityCap('ee_edit_event', 'edit_event', $EVT_ID); |
|
123 | + } |
|
124 | + |
|
125 | + |
|
126 | + public function userCanEditContacts(): bool |
|
127 | + { |
|
128 | + return $this->hasGlobalCap('ee_edit_contacts', 'espresso_registrations_edit_attendee'); |
|
129 | + } |
|
130 | + |
|
131 | + |
|
132 | + public function userCanReadRegistrationCheckins(): bool |
|
133 | + { |
|
134 | + return $this->hasGlobalCap('ee_read_checkins', 'espresso_registrations_registration_checkins'); |
|
135 | + } |
|
136 | + |
|
137 | + |
|
138 | + /** |
|
139 | + * @throws EE_Error |
|
140 | + * @throws ReflectionException |
|
141 | + */ |
|
142 | + public function userCanReadRegistrationCheckin(EE_Registration $registration): bool |
|
143 | + { |
|
144 | + return $this->hasEntityCap( |
|
145 | + 'ee_read_checkin', |
|
146 | + 'espresso_registrations_registration_checkins', |
|
147 | + $registration->ID() |
|
148 | + ); |
|
149 | + } |
|
150 | + |
|
151 | + |
|
152 | + /** |
|
153 | + * @throws EE_Error |
|
154 | + * @throws ReflectionException |
|
155 | + */ |
|
156 | + public function userCanEditRegistrationCheckin(EE_Registration $registration): bool |
|
157 | + { |
|
158 | + return $this->hasEntityCap( |
|
159 | + 'ee_edit_checkin', |
|
160 | + 'espresso_registrations_toggle_checkin_status', |
|
161 | + $registration->ID() |
|
162 | + ); |
|
163 | + } |
|
164 | 164 | } |
@@ -6,45 +6,45 @@ |
||
6 | 6 | |
7 | 7 | abstract class UserCapabilities |
8 | 8 | { |
9 | - private EE_Capabilities $capabilities; |
|
10 | - |
|
11 | - private array $caps = []; |
|
12 | - |
|
13 | - |
|
14 | - /** |
|
15 | - * @param EE_Capabilities $capabilities |
|
16 | - */ |
|
17 | - public function __construct(EE_Capabilities $capabilities) |
|
18 | - { |
|
19 | - $this->capabilities = $capabilities; |
|
20 | - } |
|
21 | - |
|
22 | - |
|
23 | - /** |
|
24 | - * @param string $cap |
|
25 | - * @param string $context |
|
26 | - * @param int|string $ID |
|
27 | - * @return bool |
|
28 | - */ |
|
29 | - protected function hasEntityCap(string $cap, string $context, $ID): bool |
|
30 | - { |
|
31 | - if (! isset($this->caps[ $cap ][ $context ][ $ID ])) { |
|
32 | - $this->caps[ $cap ][ $context ][ $ID ] = $this->capabilities->current_user_can($cap, $context, $ID); |
|
33 | - } |
|
34 | - return $this->caps[ $cap ][ $context ][ $ID ]; |
|
35 | - } |
|
36 | - |
|
37 | - |
|
38 | - /** |
|
39 | - * @param string $cap |
|
40 | - * @param string $context |
|
41 | - * @return bool |
|
42 | - */ |
|
43 | - protected function hasGlobalCap(string $cap, string $context): bool |
|
44 | - { |
|
45 | - if (! isset($this->caps[ $cap ][ $context ])) { |
|
46 | - $this->caps[ $cap ][ $context ] = $this->capabilities->current_user_can($cap, $context); |
|
47 | - } |
|
48 | - return $this->caps[ $cap ][ $context ]; |
|
49 | - } |
|
9 | + private EE_Capabilities $capabilities; |
|
10 | + |
|
11 | + private array $caps = []; |
|
12 | + |
|
13 | + |
|
14 | + /** |
|
15 | + * @param EE_Capabilities $capabilities |
|
16 | + */ |
|
17 | + public function __construct(EE_Capabilities $capabilities) |
|
18 | + { |
|
19 | + $this->capabilities = $capabilities; |
|
20 | + } |
|
21 | + |
|
22 | + |
|
23 | + /** |
|
24 | + * @param string $cap |
|
25 | + * @param string $context |
|
26 | + * @param int|string $ID |
|
27 | + * @return bool |
|
28 | + */ |
|
29 | + protected function hasEntityCap(string $cap, string $context, $ID): bool |
|
30 | + { |
|
31 | + if (! isset($this->caps[ $cap ][ $context ][ $ID ])) { |
|
32 | + $this->caps[ $cap ][ $context ][ $ID ] = $this->capabilities->current_user_can($cap, $context, $ID); |
|
33 | + } |
|
34 | + return $this->caps[ $cap ][ $context ][ $ID ]; |
|
35 | + } |
|
36 | + |
|
37 | + |
|
38 | + /** |
|
39 | + * @param string $cap |
|
40 | + * @param string $context |
|
41 | + * @return bool |
|
42 | + */ |
|
43 | + protected function hasGlobalCap(string $cap, string $context): bool |
|
44 | + { |
|
45 | + if (! isset($this->caps[ $cap ][ $context ])) { |
|
46 | + $this->caps[ $cap ][ $context ] = $this->capabilities->current_user_can($cap, $context); |
|
47 | + } |
|
48 | + return $this->caps[ $cap ][ $context ]; |
|
49 | + } |
|
50 | 50 | } |
@@ -11,166 +11,166 @@ |
||
11 | 11 | class FeatureFlag |
12 | 12 | { |
13 | 13 | |
14 | - /** |
|
15 | - * Whether to use the New Event Editor (EDTR) or continue using the legacy Event Editor |
|
16 | - * deafult: Enabled for Caffeinated sites, disabled for Decaf or Multisite installs |
|
17 | - */ |
|
18 | - public const USE_ADVANCED_EVENT_EDITOR = 'ee_advanced_event_editor'; |
|
19 | - |
|
20 | - /** |
|
21 | - * Whether to enable the Bulk Edit feature in the Advanced Event Editor (EDTR) |
|
22 | - * default: Enabled for Caffeinated sites, disabled for Decaf or Multisite installs |
|
23 | - */ |
|
24 | - public const USE_EVENT_EDITOR_BULK_EDIT = 'ee_event_editor_bulk_edit'; |
|
25 | - |
|
26 | - /** |
|
27 | - * Whether to enable the new Default Ticket Manager in the EDTR |
|
28 | - * default: Enabled |
|
29 | - */ |
|
30 | - public const USE_DEFAULT_TICKET_MANAGER = 'use_default_ticket_manager'; |
|
31 | - |
|
32 | - /** |
|
33 | - * Whether to enable the Rich Text Editor for the Event Description field in the EDTR or use tinymce |
|
34 | - * default: Disabled |
|
35 | - */ |
|
36 | - public const USE_EVENT_DESCRIPTION_RTE = 'use_event_description_rte'; |
|
37 | - |
|
38 | - /** |
|
39 | - * Whether to enable the Rich Text Editor for all other RTE fields in the EDTR |
|
40 | - * default: Disabled |
|
41 | - */ |
|
42 | - public const USE_EXPERIMENTAL_RTE = 'use_experimental_rte'; |
|
43 | - |
|
44 | - /** |
|
45 | - * Whether to enable the new Registration Form Builder in the EDTR |
|
46 | - * or continue using the legacy Question Groups and Registration Form admin pages |
|
47 | - * default: Disabled |
|
48 | - */ |
|
49 | - public const USE_REG_FORM_BUILDER = 'use_reg_form_builder'; |
|
50 | - |
|
51 | - /** |
|
52 | - * Whether to enable the new Registration Options meta box in the EDTR |
|
53 | - * or continue using the legacy Event Registration Options |
|
54 | - * default: Disabled |
|
55 | - */ |
|
56 | - public const USE_REG_OPTIONS_META_BOX = 'use_reg_options_meta_box'; |
|
57 | - |
|
58 | - /** |
|
59 | - * Whether to enable the new Single Page Checkout form refactor changes |
|
60 | - * default: Disabled |
|
61 | - * |
|
62 | - * @since 5.0.18.p |
|
63 | - */ |
|
64 | - public const USE_SPCO_FORM_REFACTOR = 'use_spco_form_refactor'; |
|
65 | - |
|
66 | - /** |
|
67 | - * Whether to enable the new Reg Form Ticket Questions functionality |
|
68 | - * default: Disabled |
|
69 | - */ |
|
70 | - public const USE_REG_FORM_TICKET_QUESTIONS = 'use_reg_form_ticket_questions'; |
|
71 | - |
|
72 | - /** |
|
73 | - * Whether to use the EDD Plugin Licensing system to manage licenses for the EE plugins |
|
74 | - * default: Disabled |
|
75 | - */ |
|
76 | - public const USE_EDD_PLUGIN_LICENSING = 'use_edd_plugin_licensing'; |
|
77 | - |
|
78 | - /** |
|
79 | - * Whether to use the new Datetime Status Controls in the EDTR |
|
80 | - * default: Disabled |
|
81 | - */ |
|
82 | - public const USE_DATETIME_STATUS_CONTROLS = 'use_datetime_status_controls'; |
|
83 | - |
|
84 | - |
|
85 | - |
|
86 | - public static function getFormOptions(): array |
|
87 | - { |
|
88 | - return [ |
|
89 | - FeatureFlag::USE_EVENT_EDITOR_BULK_EDIT => [ |
|
90 | - 'name' => esc_html__('Event Editor Bulk Edit','event_espresso'), |
|
91 | - 'html_label_text' => esc_html__('Use Event Editor Bulk Edit','event_espresso'), |
|
92 | - 'help_text' => sprintf( |
|
93 | - esc_html__( |
|
94 | - 'Whether to enable the Bulk Edit feature in the Advanced Event Editor (EDTR).%1$s%2$sPLEASE NOTE: Bulk Editing is ALWAYS enabled if the Recurring Events Manager add-on is active.%3$s%1$s default: Enabled for Caffeinated sites, disabled for Decaf or Multisite installs', |
|
95 | - 'event_espresso' |
|
96 | - ), |
|
97 | - '<br/>', |
|
98 | - '<strong>', |
|
99 | - '</strong>' |
|
100 | - ) |
|
101 | - ], |
|
102 | - FeatureFlag::USE_DEFAULT_TICKET_MANAGER => [ |
|
103 | - 'name' => esc_html__('Default Ticket Manager','event_espresso'), |
|
104 | - 'html_label_text' => esc_html__('Use Default Ticket Manager','event_espresso'), |
|
105 | - 'help_text' => esc_html__( |
|
106 | - 'Whether to enable the new Default Ticket Manager in the EDTR. default: Enabled', |
|
107 | - 'event_espresso' |
|
108 | - ) |
|
109 | - ], |
|
110 | - FeatureFlag::USE_EVENT_DESCRIPTION_RTE => [ |
|
111 | - 'name' => esc_html__('Event Description RTE','event_espresso'), |
|
112 | - 'html_label_text' => esc_html__('Use Rich Text Editor for Event Description','event_espresso'), |
|
113 | - 'help_text' => esc_html__( |
|
114 | - 'Whether to enable the Rich Text Editor for the Event Description field in the EDTR or use tinymce. default: Disabled', |
|
115 | - 'event_espresso' |
|
116 | - ) |
|
117 | - ], |
|
118 | - FeatureFlag::USE_EXPERIMENTAL_RTE => [ |
|
119 | - 'name' => esc_html__('Rich Text Editor','event_espresso'), |
|
120 | - 'html_label_text' => esc_html__('Use Rich Text Editor for other RTE fields','event_espresso'), |
|
121 | - 'help_text' => esc_html__( |
|
122 | - 'Whether to enable the Rich Text Editor for all other RTE fields in the EDTR. default: Disabled', |
|
123 | - 'event_espresso' |
|
124 | - ) |
|
125 | - ], |
|
126 | - FeatureFlag::USE_REG_FORM_BUILDER => [ |
|
127 | - 'name' => esc_html__('Registration Form Builder','event_espresso'), |
|
128 | - 'html_label_text' => esc_html__('Use Registration Form Builder','event_espresso'), |
|
129 | - 'help_text' => esc_html__( |
|
130 | - 'Whether to enable the new Registration Form Builder in the EDTR or continue using the legacy Question Groups and Registration Form admin pages. default: Disabled', |
|
131 | - 'event_espresso' |
|
132 | - ) |
|
133 | - ], |
|
134 | - FeatureFlag::USE_REG_OPTIONS_META_BOX => [ |
|
135 | - 'name' => esc_html__('Registration Options','event_espresso'), |
|
136 | - 'html_label_text' => esc_html__('Use Registration Options','event_espresso'), |
|
137 | - 'help_text' => esc_html__( |
|
138 | - 'Whether to enable the new Registration Options meta box in the EDTR or continue using the legacy Event Registration Options. default: Disabled', |
|
139 | - 'event_espresso' |
|
140 | - ) |
|
141 | - ], |
|
142 | - FeatureFlag::USE_SPCO_FORM_REFACTOR => [ |
|
143 | - 'name' => esc_html__('SPCO Form Refactor','event_espresso'), |
|
144 | - 'html_label_text' => esc_html__('Use SPCO Form Refactor','event_espresso'), |
|
145 | - 'help_text' => esc_html__( |
|
146 | - 'Whether to enable the new Single Page Checkout form refactor changes or continue using the legacy Single Page Checkout form. default: Disabled', |
|
147 | - 'event_espresso' |
|
148 | - ) |
|
149 | - ], |
|
150 | - FeatureFlag::USE_REG_FORM_TICKET_QUESTIONS => [ |
|
151 | - 'name' => esc_html__('Reg Form Ticket Questions','event_espresso'), |
|
152 | - 'html_label_text' => esc_html__('Use Reg Form Ticket Questions','event_espresso'), |
|
153 | - 'help_text' => esc_html__( |
|
154 | - 'Whether to enable the new Reg Form Ticket Questions functionality. default: Disabled', |
|
155 | - 'event_espresso' |
|
156 | - ) |
|
157 | - ], |
|
158 | - FeatureFlag::USE_EDD_PLUGIN_LICENSING => [ |
|
159 | - 'name' => esc_html__('EDD Plugin Licensing','event_espresso'), |
|
160 | - 'html_label_text' => esc_html__('Use EDD Plugin Licensing','event_espresso'), |
|
161 | - 'help_text' => esc_html__( |
|
162 | - 'Whether to use the EDD Plugin Licensing system to manage licenses for the EE plugins. default: Disabled', |
|
163 | - 'event_espresso' |
|
164 | - ) |
|
165 | - ], |
|
166 | - FeatureFlag::USE_DATETIME_STATUS_CONTROLS => [ |
|
167 | - 'name' => esc_html__('Datetime Status Controls','event_espresso'), |
|
168 | - 'html_label_text' => esc_html__('Use Datetime Status Controls','event_espresso'), |
|
169 | - 'help_text' => esc_html__( |
|
170 | - 'Whether to use the new Datetime Status Controls in the EDTR. default: Disabled', |
|
171 | - 'event_espresso' |
|
172 | - ) |
|
173 | - ], |
|
174 | - ]; |
|
175 | - } |
|
14 | + /** |
|
15 | + * Whether to use the New Event Editor (EDTR) or continue using the legacy Event Editor |
|
16 | + * deafult: Enabled for Caffeinated sites, disabled for Decaf or Multisite installs |
|
17 | + */ |
|
18 | + public const USE_ADVANCED_EVENT_EDITOR = 'ee_advanced_event_editor'; |
|
19 | + |
|
20 | + /** |
|
21 | + * Whether to enable the Bulk Edit feature in the Advanced Event Editor (EDTR) |
|
22 | + * default: Enabled for Caffeinated sites, disabled for Decaf or Multisite installs |
|
23 | + */ |
|
24 | + public const USE_EVENT_EDITOR_BULK_EDIT = 'ee_event_editor_bulk_edit'; |
|
25 | + |
|
26 | + /** |
|
27 | + * Whether to enable the new Default Ticket Manager in the EDTR |
|
28 | + * default: Enabled |
|
29 | + */ |
|
30 | + public const USE_DEFAULT_TICKET_MANAGER = 'use_default_ticket_manager'; |
|
31 | + |
|
32 | + /** |
|
33 | + * Whether to enable the Rich Text Editor for the Event Description field in the EDTR or use tinymce |
|
34 | + * default: Disabled |
|
35 | + */ |
|
36 | + public const USE_EVENT_DESCRIPTION_RTE = 'use_event_description_rte'; |
|
37 | + |
|
38 | + /** |
|
39 | + * Whether to enable the Rich Text Editor for all other RTE fields in the EDTR |
|
40 | + * default: Disabled |
|
41 | + */ |
|
42 | + public const USE_EXPERIMENTAL_RTE = 'use_experimental_rte'; |
|
43 | + |
|
44 | + /** |
|
45 | + * Whether to enable the new Registration Form Builder in the EDTR |
|
46 | + * or continue using the legacy Question Groups and Registration Form admin pages |
|
47 | + * default: Disabled |
|
48 | + */ |
|
49 | + public const USE_REG_FORM_BUILDER = 'use_reg_form_builder'; |
|
50 | + |
|
51 | + /** |
|
52 | + * Whether to enable the new Registration Options meta box in the EDTR |
|
53 | + * or continue using the legacy Event Registration Options |
|
54 | + * default: Disabled |
|
55 | + */ |
|
56 | + public const USE_REG_OPTIONS_META_BOX = 'use_reg_options_meta_box'; |
|
57 | + |
|
58 | + /** |
|
59 | + * Whether to enable the new Single Page Checkout form refactor changes |
|
60 | + * default: Disabled |
|
61 | + * |
|
62 | + * @since 5.0.18.p |
|
63 | + */ |
|
64 | + public const USE_SPCO_FORM_REFACTOR = 'use_spco_form_refactor'; |
|
65 | + |
|
66 | + /** |
|
67 | + * Whether to enable the new Reg Form Ticket Questions functionality |
|
68 | + * default: Disabled |
|
69 | + */ |
|
70 | + public const USE_REG_FORM_TICKET_QUESTIONS = 'use_reg_form_ticket_questions'; |
|
71 | + |
|
72 | + /** |
|
73 | + * Whether to use the EDD Plugin Licensing system to manage licenses for the EE plugins |
|
74 | + * default: Disabled |
|
75 | + */ |
|
76 | + public const USE_EDD_PLUGIN_LICENSING = 'use_edd_plugin_licensing'; |
|
77 | + |
|
78 | + /** |
|
79 | + * Whether to use the new Datetime Status Controls in the EDTR |
|
80 | + * default: Disabled |
|
81 | + */ |
|
82 | + public const USE_DATETIME_STATUS_CONTROLS = 'use_datetime_status_controls'; |
|
83 | + |
|
84 | + |
|
85 | + |
|
86 | + public static function getFormOptions(): array |
|
87 | + { |
|
88 | + return [ |
|
89 | + FeatureFlag::USE_EVENT_EDITOR_BULK_EDIT => [ |
|
90 | + 'name' => esc_html__('Event Editor Bulk Edit','event_espresso'), |
|
91 | + 'html_label_text' => esc_html__('Use Event Editor Bulk Edit','event_espresso'), |
|
92 | + 'help_text' => sprintf( |
|
93 | + esc_html__( |
|
94 | + 'Whether to enable the Bulk Edit feature in the Advanced Event Editor (EDTR).%1$s%2$sPLEASE NOTE: Bulk Editing is ALWAYS enabled if the Recurring Events Manager add-on is active.%3$s%1$s default: Enabled for Caffeinated sites, disabled for Decaf or Multisite installs', |
|
95 | + 'event_espresso' |
|
96 | + ), |
|
97 | + '<br/>', |
|
98 | + '<strong>', |
|
99 | + '</strong>' |
|
100 | + ) |
|
101 | + ], |
|
102 | + FeatureFlag::USE_DEFAULT_TICKET_MANAGER => [ |
|
103 | + 'name' => esc_html__('Default Ticket Manager','event_espresso'), |
|
104 | + 'html_label_text' => esc_html__('Use Default Ticket Manager','event_espresso'), |
|
105 | + 'help_text' => esc_html__( |
|
106 | + 'Whether to enable the new Default Ticket Manager in the EDTR. default: Enabled', |
|
107 | + 'event_espresso' |
|
108 | + ) |
|
109 | + ], |
|
110 | + FeatureFlag::USE_EVENT_DESCRIPTION_RTE => [ |
|
111 | + 'name' => esc_html__('Event Description RTE','event_espresso'), |
|
112 | + 'html_label_text' => esc_html__('Use Rich Text Editor for Event Description','event_espresso'), |
|
113 | + 'help_text' => esc_html__( |
|
114 | + 'Whether to enable the Rich Text Editor for the Event Description field in the EDTR or use tinymce. default: Disabled', |
|
115 | + 'event_espresso' |
|
116 | + ) |
|
117 | + ], |
|
118 | + FeatureFlag::USE_EXPERIMENTAL_RTE => [ |
|
119 | + 'name' => esc_html__('Rich Text Editor','event_espresso'), |
|
120 | + 'html_label_text' => esc_html__('Use Rich Text Editor for other RTE fields','event_espresso'), |
|
121 | + 'help_text' => esc_html__( |
|
122 | + 'Whether to enable the Rich Text Editor for all other RTE fields in the EDTR. default: Disabled', |
|
123 | + 'event_espresso' |
|
124 | + ) |
|
125 | + ], |
|
126 | + FeatureFlag::USE_REG_FORM_BUILDER => [ |
|
127 | + 'name' => esc_html__('Registration Form Builder','event_espresso'), |
|
128 | + 'html_label_text' => esc_html__('Use Registration Form Builder','event_espresso'), |
|
129 | + 'help_text' => esc_html__( |
|
130 | + 'Whether to enable the new Registration Form Builder in the EDTR or continue using the legacy Question Groups and Registration Form admin pages. default: Disabled', |
|
131 | + 'event_espresso' |
|
132 | + ) |
|
133 | + ], |
|
134 | + FeatureFlag::USE_REG_OPTIONS_META_BOX => [ |
|
135 | + 'name' => esc_html__('Registration Options','event_espresso'), |
|
136 | + 'html_label_text' => esc_html__('Use Registration Options','event_espresso'), |
|
137 | + 'help_text' => esc_html__( |
|
138 | + 'Whether to enable the new Registration Options meta box in the EDTR or continue using the legacy Event Registration Options. default: Disabled', |
|
139 | + 'event_espresso' |
|
140 | + ) |
|
141 | + ], |
|
142 | + FeatureFlag::USE_SPCO_FORM_REFACTOR => [ |
|
143 | + 'name' => esc_html__('SPCO Form Refactor','event_espresso'), |
|
144 | + 'html_label_text' => esc_html__('Use SPCO Form Refactor','event_espresso'), |
|
145 | + 'help_text' => esc_html__( |
|
146 | + 'Whether to enable the new Single Page Checkout form refactor changes or continue using the legacy Single Page Checkout form. default: Disabled', |
|
147 | + 'event_espresso' |
|
148 | + ) |
|
149 | + ], |
|
150 | + FeatureFlag::USE_REG_FORM_TICKET_QUESTIONS => [ |
|
151 | + 'name' => esc_html__('Reg Form Ticket Questions','event_espresso'), |
|
152 | + 'html_label_text' => esc_html__('Use Reg Form Ticket Questions','event_espresso'), |
|
153 | + 'help_text' => esc_html__( |
|
154 | + 'Whether to enable the new Reg Form Ticket Questions functionality. default: Disabled', |
|
155 | + 'event_espresso' |
|
156 | + ) |
|
157 | + ], |
|
158 | + FeatureFlag::USE_EDD_PLUGIN_LICENSING => [ |
|
159 | + 'name' => esc_html__('EDD Plugin Licensing','event_espresso'), |
|
160 | + 'html_label_text' => esc_html__('Use EDD Plugin Licensing','event_espresso'), |
|
161 | + 'help_text' => esc_html__( |
|
162 | + 'Whether to use the EDD Plugin Licensing system to manage licenses for the EE plugins. default: Disabled', |
|
163 | + 'event_espresso' |
|
164 | + ) |
|
165 | + ], |
|
166 | + FeatureFlag::USE_DATETIME_STATUS_CONTROLS => [ |
|
167 | + 'name' => esc_html__('Datetime Status Controls','event_espresso'), |
|
168 | + 'html_label_text' => esc_html__('Use Datetime Status Controls','event_espresso'), |
|
169 | + 'help_text' => esc_html__( |
|
170 | + 'Whether to use the new Datetime Status Controls in the EDTR. default: Disabled', |
|
171 | + 'event_espresso' |
|
172 | + ) |
|
173 | + ], |
|
174 | + ]; |
|
175 | + } |
|
176 | 176 | } |
@@ -87,8 +87,8 @@ discard block |
||
87 | 87 | { |
88 | 88 | return [ |
89 | 89 | FeatureFlag::USE_EVENT_EDITOR_BULK_EDIT => [ |
90 | - 'name' => esc_html__('Event Editor Bulk Edit','event_espresso'), |
|
91 | - 'html_label_text' => esc_html__('Use Event Editor Bulk Edit','event_espresso'), |
|
90 | + 'name' => esc_html__('Event Editor Bulk Edit', 'event_espresso'), |
|
91 | + 'html_label_text' => esc_html__('Use Event Editor Bulk Edit', 'event_espresso'), |
|
92 | 92 | 'help_text' => sprintf( |
93 | 93 | esc_html__( |
94 | 94 | 'Whether to enable the Bulk Edit feature in the Advanced Event Editor (EDTR).%1$s%2$sPLEASE NOTE: Bulk Editing is ALWAYS enabled if the Recurring Events Manager add-on is active.%3$s%1$s default: Enabled for Caffeinated sites, disabled for Decaf or Multisite installs', |
@@ -100,72 +100,72 @@ discard block |
||
100 | 100 | ) |
101 | 101 | ], |
102 | 102 | FeatureFlag::USE_DEFAULT_TICKET_MANAGER => [ |
103 | - 'name' => esc_html__('Default Ticket Manager','event_espresso'), |
|
104 | - 'html_label_text' => esc_html__('Use Default Ticket Manager','event_espresso'), |
|
103 | + 'name' => esc_html__('Default Ticket Manager', 'event_espresso'), |
|
104 | + 'html_label_text' => esc_html__('Use Default Ticket Manager', 'event_espresso'), |
|
105 | 105 | 'help_text' => esc_html__( |
106 | 106 | 'Whether to enable the new Default Ticket Manager in the EDTR. default: Enabled', |
107 | 107 | 'event_espresso' |
108 | 108 | ) |
109 | 109 | ], |
110 | 110 | FeatureFlag::USE_EVENT_DESCRIPTION_RTE => [ |
111 | - 'name' => esc_html__('Event Description RTE','event_espresso'), |
|
112 | - 'html_label_text' => esc_html__('Use Rich Text Editor for Event Description','event_espresso'), |
|
111 | + 'name' => esc_html__('Event Description RTE', 'event_espresso'), |
|
112 | + 'html_label_text' => esc_html__('Use Rich Text Editor for Event Description', 'event_espresso'), |
|
113 | 113 | 'help_text' => esc_html__( |
114 | 114 | 'Whether to enable the Rich Text Editor for the Event Description field in the EDTR or use tinymce. default: Disabled', |
115 | 115 | 'event_espresso' |
116 | 116 | ) |
117 | 117 | ], |
118 | 118 | FeatureFlag::USE_EXPERIMENTAL_RTE => [ |
119 | - 'name' => esc_html__('Rich Text Editor','event_espresso'), |
|
120 | - 'html_label_text' => esc_html__('Use Rich Text Editor for other RTE fields','event_espresso'), |
|
119 | + 'name' => esc_html__('Rich Text Editor', 'event_espresso'), |
|
120 | + 'html_label_text' => esc_html__('Use Rich Text Editor for other RTE fields', 'event_espresso'), |
|
121 | 121 | 'help_text' => esc_html__( |
122 | 122 | 'Whether to enable the Rich Text Editor for all other RTE fields in the EDTR. default: Disabled', |
123 | 123 | 'event_espresso' |
124 | 124 | ) |
125 | 125 | ], |
126 | 126 | FeatureFlag::USE_REG_FORM_BUILDER => [ |
127 | - 'name' => esc_html__('Registration Form Builder','event_espresso'), |
|
128 | - 'html_label_text' => esc_html__('Use Registration Form Builder','event_espresso'), |
|
127 | + 'name' => esc_html__('Registration Form Builder', 'event_espresso'), |
|
128 | + 'html_label_text' => esc_html__('Use Registration Form Builder', 'event_espresso'), |
|
129 | 129 | 'help_text' => esc_html__( |
130 | 130 | 'Whether to enable the new Registration Form Builder in the EDTR or continue using the legacy Question Groups and Registration Form admin pages. default: Disabled', |
131 | 131 | 'event_espresso' |
132 | 132 | ) |
133 | 133 | ], |
134 | 134 | FeatureFlag::USE_REG_OPTIONS_META_BOX => [ |
135 | - 'name' => esc_html__('Registration Options','event_espresso'), |
|
136 | - 'html_label_text' => esc_html__('Use Registration Options','event_espresso'), |
|
135 | + 'name' => esc_html__('Registration Options', 'event_espresso'), |
|
136 | + 'html_label_text' => esc_html__('Use Registration Options', 'event_espresso'), |
|
137 | 137 | 'help_text' => esc_html__( |
138 | 138 | 'Whether to enable the new Registration Options meta box in the EDTR or continue using the legacy Event Registration Options. default: Disabled', |
139 | 139 | 'event_espresso' |
140 | 140 | ) |
141 | 141 | ], |
142 | 142 | FeatureFlag::USE_SPCO_FORM_REFACTOR => [ |
143 | - 'name' => esc_html__('SPCO Form Refactor','event_espresso'), |
|
144 | - 'html_label_text' => esc_html__('Use SPCO Form Refactor','event_espresso'), |
|
143 | + 'name' => esc_html__('SPCO Form Refactor', 'event_espresso'), |
|
144 | + 'html_label_text' => esc_html__('Use SPCO Form Refactor', 'event_espresso'), |
|
145 | 145 | 'help_text' => esc_html__( |
146 | 146 | 'Whether to enable the new Single Page Checkout form refactor changes or continue using the legacy Single Page Checkout form. default: Disabled', |
147 | 147 | 'event_espresso' |
148 | 148 | ) |
149 | 149 | ], |
150 | 150 | FeatureFlag::USE_REG_FORM_TICKET_QUESTIONS => [ |
151 | - 'name' => esc_html__('Reg Form Ticket Questions','event_espresso'), |
|
152 | - 'html_label_text' => esc_html__('Use Reg Form Ticket Questions','event_espresso'), |
|
151 | + 'name' => esc_html__('Reg Form Ticket Questions', 'event_espresso'), |
|
152 | + 'html_label_text' => esc_html__('Use Reg Form Ticket Questions', 'event_espresso'), |
|
153 | 153 | 'help_text' => esc_html__( |
154 | 154 | 'Whether to enable the new Reg Form Ticket Questions functionality. default: Disabled', |
155 | 155 | 'event_espresso' |
156 | 156 | ) |
157 | 157 | ], |
158 | 158 | FeatureFlag::USE_EDD_PLUGIN_LICENSING => [ |
159 | - 'name' => esc_html__('EDD Plugin Licensing','event_espresso'), |
|
160 | - 'html_label_text' => esc_html__('Use EDD Plugin Licensing','event_espresso'), |
|
159 | + 'name' => esc_html__('EDD Plugin Licensing', 'event_espresso'), |
|
160 | + 'html_label_text' => esc_html__('Use EDD Plugin Licensing', 'event_espresso'), |
|
161 | 161 | 'help_text' => esc_html__( |
162 | 162 | 'Whether to use the EDD Plugin Licensing system to manage licenses for the EE plugins. default: Disabled', |
163 | 163 | 'event_espresso' |
164 | 164 | ) |
165 | 165 | ], |
166 | 166 | FeatureFlag::USE_DATETIME_STATUS_CONTROLS => [ |
167 | - 'name' => esc_html__('Datetime Status Controls','event_espresso'), |
|
168 | - 'html_label_text' => esc_html__('Use Datetime Status Controls','event_espresso'), |
|
167 | + 'name' => esc_html__('Datetime Status Controls', 'event_espresso'), |
|
168 | + 'html_label_text' => esc_html__('Use Datetime Status Controls', 'event_espresso'), |
|
169 | 169 | 'help_text' => esc_html__( |
170 | 170 | 'Whether to use the new Datetime Status Controls in the EDTR. default: Disabled', |
171 | 171 | 'event_espresso' |
@@ -17,127 +17,127 @@ |
||
17 | 17 | */ |
18 | 18 | class FeatureFlagsConfig extends JsonDataWordpressOption |
19 | 19 | { |
20 | - /** |
|
21 | - * WP option name for saving the Feature Flags configuration |
|
22 | - */ |
|
23 | - private const OPTION_NAME = 'ee_feature_flags'; |
|
24 | - |
|
25 | - /** |
|
26 | - * use FeatureFlag::USE_EVENT_EDITOR_BULK_EDIT instead |
|
27 | - * this hasn't been deleted because it's used in the REM add-on |
|
28 | - * |
|
29 | - * @deprecated 5.0.18.p |
|
30 | - */ |
|
31 | - public const USE_EVENT_EDITOR_BULK_EDIT = FeatureFlag::USE_EVENT_EDITOR_BULK_EDIT; |
|
32 | - |
|
33 | - |
|
34 | - |
|
35 | - protected Domain $domain; |
|
36 | - |
|
37 | - |
|
38 | - public function __construct(Domain $domain, JsonDataHandler $json_data_handler) |
|
39 | - { |
|
40 | - $this->domain = $domain; |
|
41 | - parent::__construct($json_data_handler, FeatureFlagsConfig::OPTION_NAME, $this->getDefaultFeatureFlagOptions()); |
|
42 | - } |
|
43 | - |
|
44 | - |
|
45 | - /** |
|
46 | - * see the FeatureFlag::USE_* constants for descriptions of each feature flag and their default values |
|
47 | - * |
|
48 | - * @return stdClass |
|
49 | - */ |
|
50 | - public function getDefaultFeatureFlagOptions(): stdClass |
|
51 | - { |
|
52 | - return (object) [ |
|
53 | - FeatureFlag::USE_ADVANCED_EVENT_EDITOR => $this->domain->isCaffeinated() && ! $this->domain->isMultiSite(), |
|
54 | - FeatureFlag::USE_DEFAULT_TICKET_MANAGER => true, |
|
55 | - FeatureFlag::USE_EDD_PLUGIN_LICENSING => defined('EE_USE_EDD_PLUGIN_LICENSING') && EE_USE_EDD_PLUGIN_LICENSING, |
|
56 | - FeatureFlag::USE_EVENT_DESCRIPTION_RTE => false, |
|
57 | - FeatureFlag::USE_EVENT_EDITOR_BULK_EDIT => $this->domain->isCaffeinated() && ! $this->domain->isMultiSite(), |
|
58 | - FeatureFlag::USE_EXPERIMENTAL_RTE => false, |
|
59 | - FeatureFlag::USE_REG_FORM_BUILDER => false, |
|
60 | - FeatureFlag::USE_REG_FORM_TICKET_QUESTIONS => false, |
|
61 | - FeatureFlag::USE_REG_OPTIONS_META_BOX => false, |
|
62 | - FeatureFlag::USE_SPCO_FORM_REFACTOR => false, |
|
63 | - ]; |
|
64 | - } |
|
65 | - |
|
66 | - |
|
67 | - /** |
|
68 | - * @return stdClass |
|
69 | - */ |
|
70 | - public function getFeatureFlags(): stdClass |
|
71 | - { |
|
72 | - $default_options = $this->getDefaultFeatureFlagOptions(); |
|
73 | - if (apply_filters('FHEE__FeatureFlagsConfig__getFeatureFlags__use_default_feature_flags', true)) { |
|
74 | - return $default_options; |
|
75 | - } |
|
76 | - $feature_flags = $this->getAll(); |
|
77 | - // ensure that all feature flags are set |
|
78 | - foreach ($default_options as $key => $value) { |
|
79 | - // if the feature flag is not set, use the default value |
|
80 | - if (!isset($feature_flags->$key)) { |
|
81 | - $feature_flags->$key = $value; |
|
82 | - } |
|
83 | - } |
|
84 | - return $feature_flags; |
|
85 | - } |
|
86 | - |
|
87 | - |
|
88 | - public function saveFeatureFlagsConfig(stdClass $feature_flags): int |
|
89 | - { |
|
90 | - return $this->updateOption($feature_flags); |
|
91 | - } |
|
92 | - |
|
93 | - |
|
94 | - /** |
|
95 | - * enables a feature flag, ex: |
|
96 | - * $this->enableFeatureFlag(FeatureFlag::USE_ADVANCED_EVENT_EDITOR); |
|
97 | - * |
|
98 | - * @param string $feature_flag the feature flag to enable. One of the FeatureFlag::USE_* constants |
|
99 | - * @param bool $add_if_missing |
|
100 | - * @return int |
|
101 | - */ |
|
102 | - public function enableFeatureFlag(string $feature_flag, bool $add_if_missing = false): int |
|
103 | - { |
|
104 | - $feature_flags = $this->getFeatureFlags(); |
|
105 | - if (! property_exists($feature_flags, $feature_flag) && ! $add_if_missing) { |
|
106 | - return WordPressOption::UPDATE_ERROR; |
|
107 | - } |
|
108 | - $feature_flags->{$feature_flag} = true; |
|
109 | - // if feature flag is the advanced event editor or bulk edit options |
|
110 | - // then only enabled if the site is Caffeinated and not MultiSite |
|
111 | - if ( |
|
112 | - $feature_flag === FeatureFlag::USE_ADVANCED_EVENT_EDITOR |
|
113 | - || $feature_flag === FeatureFlag::USE_EVENT_EDITOR_BULK_EDIT |
|
114 | - ) { |
|
115 | - $feature_flags->{$feature_flag} = $this->domain->isCaffeinated() && ! $this->domain->isMultiSite(); |
|
116 | - } |
|
117 | - return $this->saveFeatureFlagsConfig($feature_flags); |
|
118 | - } |
|
119 | - |
|
120 | - |
|
121 | - /** |
|
122 | - * disables a feature flag, ex: |
|
123 | - * $this->disableFeatureFlag(FeatureFlag::USE_ADVANCED_EVENT_EDITOR); |
|
124 | - * |
|
125 | - * @param string $feature_flag the feature flag to disable. One of the FeatureFlag::USE_* constants |
|
126 | - * @return int |
|
127 | - */ |
|
128 | - public function disableFeatureFlag(string $feature_flag): int |
|
129 | - { |
|
130 | - $feature_flags = $this->getFeatureFlags(); |
|
131 | - if (! property_exists($feature_flags, $feature_flag)) { |
|
132 | - return WordPressOption::UPDATE_ERROR; |
|
133 | - } |
|
134 | - $feature_flags->{$feature_flag} = false; |
|
135 | - return $this->saveFeatureFlagsConfig($feature_flags); |
|
136 | - } |
|
137 | - |
|
138 | - |
|
139 | - public function getFeatureFlagsFormOptions(): ?array |
|
140 | - { |
|
141 | - return FeatureFlag::getFormOptions(); |
|
142 | - } |
|
20 | + /** |
|
21 | + * WP option name for saving the Feature Flags configuration |
|
22 | + */ |
|
23 | + private const OPTION_NAME = 'ee_feature_flags'; |
|
24 | + |
|
25 | + /** |
|
26 | + * use FeatureFlag::USE_EVENT_EDITOR_BULK_EDIT instead |
|
27 | + * this hasn't been deleted because it's used in the REM add-on |
|
28 | + * |
|
29 | + * @deprecated 5.0.18.p |
|
30 | + */ |
|
31 | + public const USE_EVENT_EDITOR_BULK_EDIT = FeatureFlag::USE_EVENT_EDITOR_BULK_EDIT; |
|
32 | + |
|
33 | + |
|
34 | + |
|
35 | + protected Domain $domain; |
|
36 | + |
|
37 | + |
|
38 | + public function __construct(Domain $domain, JsonDataHandler $json_data_handler) |
|
39 | + { |
|
40 | + $this->domain = $domain; |
|
41 | + parent::__construct($json_data_handler, FeatureFlagsConfig::OPTION_NAME, $this->getDefaultFeatureFlagOptions()); |
|
42 | + } |
|
43 | + |
|
44 | + |
|
45 | + /** |
|
46 | + * see the FeatureFlag::USE_* constants for descriptions of each feature flag and their default values |
|
47 | + * |
|
48 | + * @return stdClass |
|
49 | + */ |
|
50 | + public function getDefaultFeatureFlagOptions(): stdClass |
|
51 | + { |
|
52 | + return (object) [ |
|
53 | + FeatureFlag::USE_ADVANCED_EVENT_EDITOR => $this->domain->isCaffeinated() && ! $this->domain->isMultiSite(), |
|
54 | + FeatureFlag::USE_DEFAULT_TICKET_MANAGER => true, |
|
55 | + FeatureFlag::USE_EDD_PLUGIN_LICENSING => defined('EE_USE_EDD_PLUGIN_LICENSING') && EE_USE_EDD_PLUGIN_LICENSING, |
|
56 | + FeatureFlag::USE_EVENT_DESCRIPTION_RTE => false, |
|
57 | + FeatureFlag::USE_EVENT_EDITOR_BULK_EDIT => $this->domain->isCaffeinated() && ! $this->domain->isMultiSite(), |
|
58 | + FeatureFlag::USE_EXPERIMENTAL_RTE => false, |
|
59 | + FeatureFlag::USE_REG_FORM_BUILDER => false, |
|
60 | + FeatureFlag::USE_REG_FORM_TICKET_QUESTIONS => false, |
|
61 | + FeatureFlag::USE_REG_OPTIONS_META_BOX => false, |
|
62 | + FeatureFlag::USE_SPCO_FORM_REFACTOR => false, |
|
63 | + ]; |
|
64 | + } |
|
65 | + |
|
66 | + |
|
67 | + /** |
|
68 | + * @return stdClass |
|
69 | + */ |
|
70 | + public function getFeatureFlags(): stdClass |
|
71 | + { |
|
72 | + $default_options = $this->getDefaultFeatureFlagOptions(); |
|
73 | + if (apply_filters('FHEE__FeatureFlagsConfig__getFeatureFlags__use_default_feature_flags', true)) { |
|
74 | + return $default_options; |
|
75 | + } |
|
76 | + $feature_flags = $this->getAll(); |
|
77 | + // ensure that all feature flags are set |
|
78 | + foreach ($default_options as $key => $value) { |
|
79 | + // if the feature flag is not set, use the default value |
|
80 | + if (!isset($feature_flags->$key)) { |
|
81 | + $feature_flags->$key = $value; |
|
82 | + } |
|
83 | + } |
|
84 | + return $feature_flags; |
|
85 | + } |
|
86 | + |
|
87 | + |
|
88 | + public function saveFeatureFlagsConfig(stdClass $feature_flags): int |
|
89 | + { |
|
90 | + return $this->updateOption($feature_flags); |
|
91 | + } |
|
92 | + |
|
93 | + |
|
94 | + /** |
|
95 | + * enables a feature flag, ex: |
|
96 | + * $this->enableFeatureFlag(FeatureFlag::USE_ADVANCED_EVENT_EDITOR); |
|
97 | + * |
|
98 | + * @param string $feature_flag the feature flag to enable. One of the FeatureFlag::USE_* constants |
|
99 | + * @param bool $add_if_missing |
|
100 | + * @return int |
|
101 | + */ |
|
102 | + public function enableFeatureFlag(string $feature_flag, bool $add_if_missing = false): int |
|
103 | + { |
|
104 | + $feature_flags = $this->getFeatureFlags(); |
|
105 | + if (! property_exists($feature_flags, $feature_flag) && ! $add_if_missing) { |
|
106 | + return WordPressOption::UPDATE_ERROR; |
|
107 | + } |
|
108 | + $feature_flags->{$feature_flag} = true; |
|
109 | + // if feature flag is the advanced event editor or bulk edit options |
|
110 | + // then only enabled if the site is Caffeinated and not MultiSite |
|
111 | + if ( |
|
112 | + $feature_flag === FeatureFlag::USE_ADVANCED_EVENT_EDITOR |
|
113 | + || $feature_flag === FeatureFlag::USE_EVENT_EDITOR_BULK_EDIT |
|
114 | + ) { |
|
115 | + $feature_flags->{$feature_flag} = $this->domain->isCaffeinated() && ! $this->domain->isMultiSite(); |
|
116 | + } |
|
117 | + return $this->saveFeatureFlagsConfig($feature_flags); |
|
118 | + } |
|
119 | + |
|
120 | + |
|
121 | + /** |
|
122 | + * disables a feature flag, ex: |
|
123 | + * $this->disableFeatureFlag(FeatureFlag::USE_ADVANCED_EVENT_EDITOR); |
|
124 | + * |
|
125 | + * @param string $feature_flag the feature flag to disable. One of the FeatureFlag::USE_* constants |
|
126 | + * @return int |
|
127 | + */ |
|
128 | + public function disableFeatureFlag(string $feature_flag): int |
|
129 | + { |
|
130 | + $feature_flags = $this->getFeatureFlags(); |
|
131 | + if (! property_exists($feature_flags, $feature_flag)) { |
|
132 | + return WordPressOption::UPDATE_ERROR; |
|
133 | + } |
|
134 | + $feature_flags->{$feature_flag} = false; |
|
135 | + return $this->saveFeatureFlagsConfig($feature_flags); |
|
136 | + } |
|
137 | + |
|
138 | + |
|
139 | + public function getFeatureFlagsFormOptions(): ?array |
|
140 | + { |
|
141 | + return FeatureFlag::getFormOptions(); |
|
142 | + } |
|
143 | 143 | } |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | // ensure that all feature flags are set |
78 | 78 | foreach ($default_options as $key => $value) { |
79 | 79 | // if the feature flag is not set, use the default value |
80 | - if (!isset($feature_flags->$key)) { |
|
80 | + if ( ! isset($feature_flags->$key)) { |
|
81 | 81 | $feature_flags->$key = $value; |
82 | 82 | } |
83 | 83 | } |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | public function enableFeatureFlag(string $feature_flag, bool $add_if_missing = false): int |
103 | 103 | { |
104 | 104 | $feature_flags = $this->getFeatureFlags(); |
105 | - if (! property_exists($feature_flags, $feature_flag) && ! $add_if_missing) { |
|
105 | + if ( ! property_exists($feature_flags, $feature_flag) && ! $add_if_missing) { |
|
106 | 106 | return WordPressOption::UPDATE_ERROR; |
107 | 107 | } |
108 | 108 | $feature_flags->{$feature_flag} = true; |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | public function disableFeatureFlag(string $feature_flag): int |
129 | 129 | { |
130 | 130 | $feature_flags = $this->getFeatureFlags(); |
131 | - if (! property_exists($feature_flags, $feature_flag)) { |
|
131 | + if ( ! property_exists($feature_flags, $feature_flag)) { |
|
132 | 132 | return WordPressOption::UPDATE_ERROR; |
133 | 133 | } |
134 | 134 | $feature_flags->{$feature_flag} = false; |
@@ -19,43 +19,43 @@ discard block |
||
19 | 19 | */ |
20 | 20 | class EE_Message_Template_Defaults extends EE_Base |
21 | 21 | { |
22 | - /** |
|
23 | - * EE_Message_Template_Defaults constructor. |
|
24 | - * |
|
25 | - * @param EE_messages $messages |
|
26 | - * @param $messenger_name |
|
27 | - * @param $message_type_name |
|
28 | - * @param int $GRP_ID |
|
29 | - * @throws EE_Error |
|
30 | - * @throws ReflectionException |
|
31 | - */ |
|
32 | - public function __construct( |
|
33 | - EE_messages $messages, |
|
34 | - $messenger_name, |
|
35 | - $message_type_name, |
|
36 | - $GRP_ID = 0 |
|
37 | - ) { |
|
38 | - EE_Error::doing_it_wrong( |
|
39 | - __FUNCTION__, |
|
40 | - esc_html__( |
|
41 | - 'The class EE_Message_Template_Defaults has been deprecated and replaced by EE_Messages_Template_Defaults.', |
|
42 | - 'event_espresso' |
|
43 | - ), |
|
44 | - '4.9.0' |
|
45 | - ); |
|
46 | - /** @var EE_Message_Resource_Manager $message_resource_manager */ |
|
47 | - $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
48 | - $messenger = $message_resource_manager->get_messenger($messenger_name); |
|
49 | - $message_type = $message_resource_manager->get_message_type($message_type_name); |
|
50 | - return EE_Registry::instance()->load_lib( |
|
51 | - 'Messages_Template_Defaults', |
|
52 | - [ |
|
53 | - $messenger, |
|
54 | - $message_type, |
|
55 | - $GRP_ID, |
|
56 | - ] |
|
57 | - ); |
|
58 | - } |
|
22 | + /** |
|
23 | + * EE_Message_Template_Defaults constructor. |
|
24 | + * |
|
25 | + * @param EE_messages $messages |
|
26 | + * @param $messenger_name |
|
27 | + * @param $message_type_name |
|
28 | + * @param int $GRP_ID |
|
29 | + * @throws EE_Error |
|
30 | + * @throws ReflectionException |
|
31 | + */ |
|
32 | + public function __construct( |
|
33 | + EE_messages $messages, |
|
34 | + $messenger_name, |
|
35 | + $message_type_name, |
|
36 | + $GRP_ID = 0 |
|
37 | + ) { |
|
38 | + EE_Error::doing_it_wrong( |
|
39 | + __FUNCTION__, |
|
40 | + esc_html__( |
|
41 | + 'The class EE_Message_Template_Defaults has been deprecated and replaced by EE_Messages_Template_Defaults.', |
|
42 | + 'event_espresso' |
|
43 | + ), |
|
44 | + '4.9.0' |
|
45 | + ); |
|
46 | + /** @var EE_Message_Resource_Manager $message_resource_manager */ |
|
47 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
48 | + $messenger = $message_resource_manager->get_messenger($messenger_name); |
|
49 | + $message_type = $message_resource_manager->get_message_type($message_type_name); |
|
50 | + return EE_Registry::instance()->load_lib( |
|
51 | + 'Messages_Template_Defaults', |
|
52 | + [ |
|
53 | + $messenger, |
|
54 | + $message_type, |
|
55 | + $GRP_ID, |
|
56 | + ] |
|
57 | + ); |
|
58 | + } |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | |
@@ -72,565 +72,565 @@ discard block |
||
72 | 72 | */ |
73 | 73 | class EE_messages |
74 | 74 | { |
75 | - /** @type EE_messenger[] */ |
|
76 | - protected $_active_messengers = []; |
|
77 | - |
|
78 | - /** @type array */ |
|
79 | - protected $_active_message_types = []; |
|
80 | - |
|
81 | - /** @type EE_message_type[] */ |
|
82 | - protected $_installed_message_types = []; |
|
83 | - |
|
84 | - /** @type EE_messenger */ |
|
85 | - protected $_messenger; |
|
86 | - |
|
87 | - /** @type EE_message_type */ |
|
88 | - protected $_message_type; |
|
89 | - |
|
90 | - /** @type array */ |
|
91 | - protected $_contexts = []; |
|
92 | - |
|
93 | - /** @type EE_Message_Resource_Manager $_message_resource_manager */ |
|
94 | - protected $_message_resource_manager; |
|
95 | - |
|
96 | - |
|
97 | - /** |
|
98 | - * EE_messages constructor. |
|
99 | - * |
|
100 | - * @deprecated 4.9.0 |
|
101 | - */ |
|
102 | - public function __construct() |
|
103 | - { |
|
104 | - } |
|
105 | - |
|
106 | - |
|
107 | - /** |
|
108 | - * @param string $method |
|
109 | - * @throws EE_Error |
|
110 | - * @throws ReflectionException |
|
111 | - */ |
|
112 | - public function _class_is_deprecated($method) |
|
113 | - { |
|
114 | - EE_Error::doing_it_wrong( |
|
115 | - 'EE_messages::' . $method, |
|
116 | - esc_html__('EE_messages has been deprecated. Please use EE_Message_Resource_Manager instead.'), |
|
117 | - '4.9.0', |
|
118 | - '4.10.0.p' |
|
119 | - ); |
|
120 | - // Please use EE_Message_Resource_Manager instead |
|
121 | - $this->_message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
122 | - } |
|
123 | - |
|
124 | - |
|
125 | - /** |
|
126 | - * @param string $messenger_name |
|
127 | - * @return boolean TRUE if it was PREVIOUSLY active, and FALSE if it was previously inactive |
|
128 | - * @throws EE_Error |
|
129 | - * @throws ReflectionException |
|
130 | - * @deprecated 4.9.0 |
|
131 | - */ |
|
132 | - public function ensure_messenger_is_active($messenger_name) |
|
133 | - { |
|
134 | - // EE_messages has been deprecated |
|
135 | - $this->_class_is_deprecated(__FUNCTION__); |
|
136 | - return $this->_message_resource_manager->ensure_messenger_is_active($messenger_name); |
|
137 | - } |
|
138 | - |
|
139 | - |
|
140 | - /** |
|
141 | - * @param string $message_type message type name |
|
142 | - * @param $messenger |
|
143 | - * @return bool true if it got activated (or was active) and false if not. |
|
144 | - * @throws EE_Error |
|
145 | - * @throws ReflectionException |
|
146 | - * @deprecated 4.9.0 |
|
147 | - */ |
|
148 | - public function ensure_message_type_is_active($message_type, $messenger) |
|
149 | - { |
|
150 | - // EE_messages has been deprecated |
|
151 | - $this->_class_is_deprecated(__FUNCTION__); |
|
152 | - return $this->_message_resource_manager->ensure_message_type_is_active($message_type, $messenger); |
|
153 | - } |
|
154 | - |
|
155 | - |
|
156 | - /** |
|
157 | - * @param string $messenger_name |
|
158 | - * @param array $mts_to_activate (optional) An array of message types to activate with this messenger. |
|
159 | - * If included we do NOT setup the default message types (assuming they |
|
160 | - * are already setup.) |
|
161 | - * @return array an array of generated templates or false if nothing generated/activated. |
|
162 | - * @throws EE_Error |
|
163 | - * @throws ReflectionException |
|
164 | - * @deprecated 4.9.0 |
|
165 | - */ |
|
166 | - public function activate_messenger($messenger_name, $mts_to_activate = []) |
|
167 | - { |
|
168 | - // EE_messages has been deprecated |
|
169 | - $this->_class_is_deprecated(__FUNCTION__); |
|
170 | - return $this->_message_resource_manager->activate_messenger($messenger_name, $mts_to_activate); |
|
171 | - } |
|
172 | - |
|
173 | - |
|
174 | - /** |
|
175 | - * @param EE_messenger $messenger messenger used in trigger |
|
176 | - * @param EE_message_type $message_type message type used in trigger |
|
177 | - * |
|
178 | - * @return bool true is a generating messenger and can be sent OR FALSE meaning cannot send. |
|
179 | - * @throws EE_Error |
|
180 | - * @throws ReflectionException |
|
181 | - * @deprecated 4.9.0 |
|
182 | - */ |
|
183 | - public function is_generating_messenger_and_active(EE_messenger $messenger, EE_message_type $message_type) |
|
184 | - { |
|
185 | - // EE_messages has been deprecated |
|
186 | - $this->_class_is_deprecated(__FUNCTION__); |
|
187 | - return $this->_message_resource_manager->is_generating_messenger_and_active($messenger, $message_type); |
|
188 | - } |
|
189 | - |
|
190 | - |
|
191 | - /** |
|
192 | - * @param string $messenger |
|
193 | - * @return EE_messenger | null |
|
194 | - * @throws EE_Error |
|
195 | - * @throws ReflectionException |
|
196 | - * @deprecated 4.9.0 |
|
197 | - */ |
|
198 | - public function get_messenger_if_active($messenger) |
|
199 | - { |
|
200 | - // EE_messages has been deprecated |
|
201 | - $this->_class_is_deprecated(__FUNCTION__); |
|
202 | - return $this->_message_resource_manager->get_active_messenger($messenger); |
|
203 | - } |
|
204 | - |
|
205 | - |
|
206 | - /** |
|
207 | - * @param EE_Message $message |
|
208 | - * @return array An array with 'messenger' and 'message_type' as the index and the corresponding valid object if |
|
209 | - * available. |
|
210 | - * Eg. Valid Messenger and Message Type: |
|
211 | - * array( |
|
212 | - * 'messenger' => new EE_Email_messenger(), |
|
213 | - * 'message_type' => new EE_Registration_Approved_message_type() |
|
214 | - * ) |
|
215 | - * Valid Messenger and Invalid Message Type: |
|
216 | - * array( |
|
217 | - * 'messenger' => new EE_Email_messenger(), |
|
218 | - * 'message_type' => null |
|
219 | - * ) |
|
220 | - * @throws EE_Error |
|
221 | - * @throws ReflectionException |
|
222 | - * @deprecated 4.9.0 |
|
223 | - */ |
|
224 | - public function validate_for_use(EE_Message $message) |
|
225 | - { |
|
226 | - // EE_messages has been deprecated |
|
227 | - $this->_class_is_deprecated(__FUNCTION__); |
|
228 | - return [ |
|
229 | - 'messenger' => $message->messenger_object(), |
|
230 | - 'message_type' => $message->message_type_object(), |
|
231 | - ]; |
|
232 | - } |
|
233 | - |
|
234 | - |
|
235 | - /** |
|
236 | - * @param string $type What type of message are we sending (corresponds to message types) |
|
237 | - * @param mixed $vars Data being sent for parsing in the message |
|
238 | - * @param string $sending_messenger if included then we ONLY use the specified messenger for delivery. |
|
239 | - * Otherwise we cycle through all active messengers. |
|
240 | - * @param string $generating_messenger if included then this messenger is used for generating the message |
|
241 | - * templates (but not for sending). |
|
242 | - * @param string $context If included then only a message type for a specific context will be |
|
243 | - * generated. |
|
244 | - * @param bool $send Default TRUE. If false, then this will just return the generated |
|
245 | - * EE_messages objects which might be used by the trigger to setup a batch |
|
246 | - * message (typically html messenger uses it). |
|
247 | - * @return bool|array |
|
248 | - * @throws EE_Error |
|
249 | - * @throws ReflectionException |
|
250 | - * @deprecated 4.9.0 |
|
251 | - */ |
|
252 | - public function send_message( |
|
253 | - $type, |
|
254 | - $vars, |
|
255 | - $sending_messenger = '', |
|
256 | - $generating_messenger = '', |
|
257 | - $context = '', |
|
258 | - $send = true |
|
259 | - ) { |
|
260 | - // EE_messages has been deprecated |
|
261 | - $this->_class_is_deprecated(__FUNCTION__); |
|
262 | - /** @type EE_Messages_Processor $processor */ |
|
263 | - $processor = EE_Registry::instance()->load_lib('Messages_Processor'); |
|
264 | - $error = false; |
|
265 | - // try to intelligently determine what method we'll call based on the incoming data. |
|
266 | - // if generating and sending are different then generate and send immediately. |
|
267 | - if (! empty($sending_messenger) && $sending_messenger != $generating_messenger && $send) { |
|
268 | - // in the legacy system, when generating and sending were different, that means all the |
|
269 | - // vars are already in the request object. So let's just use that. |
|
270 | - try { |
|
271 | - /** @type EE_Message_To_Generate_From_Request $mtg */ |
|
272 | - $mtg = EE_Registry::instance()->load_lib('Message_To_Generate_From_Request'); |
|
273 | - $processor->generate_and_send_now($mtg); |
|
274 | - } catch (EE_Error $e) { |
|
275 | - $error_msg = esc_html__( |
|
276 | - 'Please note that a system message failed to send due to a technical issue.', |
|
277 | - 'event_espresso' |
|
278 | - ); |
|
279 | - // add specific message for developers if WP_DEBUG in on |
|
280 | - $error_msg .= '||' . $e->getMessage(); |
|
281 | - EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
282 | - $error = true; |
|
283 | - } |
|
284 | - } else { |
|
285 | - $processor->generate_for_all_active_messengers($type, $vars, $send); |
|
286 | - // let's find out if there were any errors and how many successfully were queued. |
|
287 | - $count_errors = $processor->get_queue()->count_STS_in_queue( |
|
288 | - [EEM_Message::status_failed, EEM_Message::status_debug_only] |
|
289 | - ); |
|
290 | - $count_queued = $processor->get_queue()->count_STS_in_queue(EEM_Message::status_incomplete); |
|
291 | - $count_retry = $processor->get_queue()->count_STS_in_queue(EEM_Message::status_retry); |
|
292 | - $count_errors = $count_errors + $count_retry; |
|
293 | - if ($count_errors > 0) { |
|
294 | - $error = true; |
|
295 | - if ($count_errors > 1 && $count_retry > 1 && $count_queued > 1) { |
|
296 | - $message = sprintf( |
|
297 | - esc_html__( |
|
298 | - 'There were %1$d errors and %2$d messages successfully queued for generation and sending', |
|
299 | - 'event_espresso' |
|
300 | - ), |
|
301 | - $count_errors, |
|
302 | - $count_queued |
|
303 | - ); |
|
304 | - } elseif ($count_errors > 1 && $count_queued === 1) { |
|
305 | - $message = sprintf( |
|
306 | - esc_html__( |
|
307 | - 'There were %1$d errors and %2$d message successfully queued for generation.', |
|
308 | - 'event_espresso' |
|
309 | - ), |
|
310 | - $count_errors, |
|
311 | - $count_queued |
|
312 | - ); |
|
313 | - } elseif ($count_errors === 1 && $count_queued > 1) { |
|
314 | - $message = sprintf( |
|
315 | - esc_html__( |
|
316 | - 'There was %1$d error and %2$d messages successfully queued for generation.', |
|
317 | - 'event_espresso' |
|
318 | - ), |
|
319 | - $count_errors, |
|
320 | - $count_queued |
|
321 | - ); |
|
322 | - } else { |
|
323 | - $message = sprintf( |
|
324 | - esc_html__( |
|
325 | - 'There was %d message that failed to be queued for generation.', |
|
326 | - 'event_espresso' |
|
327 | - ), |
|
328 | - $count_errors |
|
329 | - ); |
|
330 | - } |
|
331 | - EE_Error::add_error($message, __FILE__, __FUNCTION__, __LINE__); |
|
332 | - } else { |
|
333 | - if ($count_queued === 1) { |
|
334 | - $message = sprintf( |
|
335 | - esc_html__( |
|
336 | - '%d message successfully queued for generation.', |
|
337 | - 'event_espresso' |
|
338 | - ), |
|
339 | - $count_queued |
|
340 | - ); |
|
341 | - } else { |
|
342 | - $message = sprintf( |
|
343 | - esc_html__( |
|
344 | - '%d messages were successfully queued for generation.', |
|
345 | - 'event_espresso' |
|
346 | - ), |
|
347 | - $count_queued |
|
348 | - ); |
|
349 | - } |
|
350 | - EE_Error::add_success($message); |
|
351 | - } |
|
352 | - } |
|
353 | - // if no error then return the generated message(s). |
|
354 | - if (! $error && ! $send) { |
|
355 | - $generated_queue = $processor->generate_queue(false); |
|
356 | - // get message and return. |
|
357 | - $generated_queue->get_message_repository()->rewind(); |
|
358 | - $messages = []; |
|
359 | - while ($generated_queue->get_message_repository()->valid()) { |
|
360 | - $message = $generated_queue->get_message_repository()->current(); |
|
361 | - if ($message instanceof EE_Message) { |
|
362 | - // set properties that might be expected by add-ons (backward compat) |
|
363 | - $message->content = $message->content(); |
|
364 | - $message->template_pack = $message->get_template_pack(); |
|
365 | - $message->template_variation = $message->get_template_pack_variation(); |
|
366 | - $messages[] = $message; |
|
367 | - } |
|
368 | - $generated_queue->get_message_repository()->next(); |
|
369 | - } |
|
370 | - return $messages; |
|
371 | - } |
|
372 | - return $error ? false |
|
373 | - : true; // yeah backwards eh? Really what we're returning is if there is a total success for all the messages or not. We'll modify this once we get message recording in place. |
|
374 | - } |
|
375 | - |
|
376 | - |
|
377 | - /** |
|
378 | - * @param string $type This should correspond with a valid message type |
|
379 | - * @param string $context This should correspond with a valid context for the message type |
|
380 | - * @param string $messenger This should correspond with a valid messenger. |
|
381 | - * @param bool $send true we will do a test send using the messenger delivery, false we just do a regular |
|
382 | - * preview |
|
383 | - * @return string The body of the message. |
|
384 | - * @throws EE_Error |
|
385 | - * @throws ReflectionException |
|
386 | - * @deprecated 4.9.0 |
|
387 | - */ |
|
388 | - public function preview_message($type, $context, $messenger, $send = false) |
|
389 | - { |
|
390 | - // EE_messages has been deprecated |
|
391 | - $this->_class_is_deprecated(__FUNCTION__); |
|
392 | - return EED_Messages::preview_message($type, $context, $messenger, $send); |
|
393 | - } |
|
394 | - |
|
395 | - |
|
396 | - /** |
|
397 | - * @param string $messenger a string matching a valid active messenger in the system |
|
398 | - * @param string $message_type Although it seems contrary to the name of the method, a message type name is still |
|
399 | - * required to send along the message type to the messenger because this is used for |
|
400 | - * determining what specific variations might be loaded for the generated message. |
|
401 | - * @param stdClass $message a stdClass object in the format expected by the messenger. |
|
402 | - * |
|
403 | - * @return bool success or fail. |
|
404 | - * @throws EE_Error |
|
405 | - * @throws ReflectionException |
|
406 | - * @since 4.5.0 |
|
407 | - * @deprecated 4.9.0 Moved to EED_Messages Module |
|
408 | - */ |
|
409 | - public function send_message_with_messenger_only($messenger, $message_type, $message) |
|
410 | - { |
|
411 | - // EE_messages has been deprecated |
|
412 | - $this->_class_is_deprecated(__FUNCTION__); |
|
413 | - // setup for sending to new method. |
|
414 | - /** @type EE_Messages_Queue $queue */ |
|
415 | - $queue = EE_Registry::instance()->load_lib('Messages_Queue'); |
|
416 | - // make sure we have a proper message object |
|
417 | - if (! $message instanceof EE_Message && is_object($message) && isset($message->content)) { |
|
418 | - $msg = EE_Message_Factory::create( |
|
419 | - [ |
|
420 | - 'MSG_messenger' => $messenger, |
|
421 | - 'MSG_message_type' => $message_type, |
|
422 | - 'MSG_content' => $message->content, |
|
423 | - 'MSG_subject' => $message->subject, |
|
424 | - ] |
|
425 | - ); |
|
426 | - } else { |
|
427 | - $msg = $message; |
|
428 | - } |
|
429 | - if (! $msg instanceof EE_Message) { |
|
430 | - return false; |
|
431 | - } |
|
432 | - // make sure any content in a content property (if not empty) is set on the MSG_content. |
|
433 | - if (! empty($msg->content)) { |
|
434 | - $msg->set('MSG_content', $msg->content); |
|
435 | - } |
|
436 | - $queue->add($msg); |
|
437 | - return EED_Messages::send_message_with_messenger_only($messenger, $message_type, $queue); |
|
438 | - } |
|
439 | - |
|
440 | - |
|
441 | - /** |
|
442 | - * @param $messenger |
|
443 | - * @param string $message_type message type that the templates are being created for |
|
444 | - * @param int $GRP_ID |
|
445 | - * @param bool $is_global |
|
446 | - * @return array|object if creation is successful then we return an array of info, otherwise an error_object is |
|
447 | - * returned. |
|
448 | - * @throws EE_Error |
|
449 | - * @throws ReflectionException |
|
450 | - * @deprecated 4.9.0 |
|
451 | - */ |
|
452 | - public function create_new_templates($messenger, $message_type, $GRP_ID = 0, $is_global = false) |
|
453 | - { |
|
454 | - // EE_messages has been deprecated |
|
455 | - $this->_class_is_deprecated(__FUNCTION__); |
|
456 | - EE_Registry::instance()->load_helper('MSG_Template'); |
|
457 | - return EEH_MSG_Template::create_new_templates($messenger, $message_type, $GRP_ID, $is_global); |
|
458 | - } |
|
459 | - |
|
460 | - |
|
461 | - /** |
|
462 | - * @param string $messenger_name name of EE_messenger |
|
463 | - * @param string $message_type_name name of EE_message_type |
|
464 | - * @return array |
|
465 | - * @throws EE_Error |
|
466 | - * @throws ReflectionException |
|
467 | - * @deprecated 4.9.0 |
|
468 | - */ |
|
469 | - public function get_fields($messenger_name, $message_type_name) |
|
470 | - { |
|
471 | - // EE_messages has been deprecated |
|
472 | - $this->_class_is_deprecated(__FUNCTION__); |
|
473 | - EE_Registry::instance()->load_helper('MSG_Template'); |
|
474 | - return EEH_MSG_Template::get_fields($messenger_name, $message_type_name); |
|
475 | - } |
|
476 | - |
|
477 | - |
|
478 | - /** |
|
479 | - * @param string $type we can indicate just returning installed message types |
|
480 | - * or messengers (or both) via this parameter. |
|
481 | - * @param bool $skip_cache if true then we skip the cache and retrieve via files. |
|
482 | - * @return array multidimensional array of messenger and message_type objects |
|
483 | - * (messengers index, and message_type index); |
|
484 | - * @throws EE_Error |
|
485 | - * @throws ReflectionException |
|
486 | - * @deprecated 4.9.0 |
|
487 | - * @access public |
|
488 | - */ |
|
489 | - public function get_installed($type = 'all', $skip_cache = false) |
|
490 | - { |
|
491 | - // EE_messages has been deprecated |
|
492 | - $this->_class_is_deprecated(__FUNCTION__); |
|
493 | - if ($skip_cache) { |
|
494 | - $this->_message_resource_manager->reset_active_messengers_and_message_types(); |
|
495 | - } |
|
496 | - switch ($type) { |
|
497 | - case 'messengers': |
|
498 | - return [ |
|
499 | - 'messenger' => $this->_message_resource_manager->installed_messengers(), |
|
500 | - ]; |
|
501 | - break; |
|
502 | - case 'message_types': |
|
503 | - return [ |
|
504 | - 'message_type' => $this->_message_resource_manager->installed_message_types(), |
|
505 | - ]; |
|
506 | - break; |
|
507 | - case 'all': |
|
508 | - default: |
|
509 | - return [ |
|
510 | - 'messenger' => $this->_message_resource_manager->installed_messengers(), |
|
511 | - 'message_type' => $this->_message_resource_manager->installed_message_types(), |
|
512 | - ]; |
|
513 | - break; |
|
514 | - } |
|
515 | - } |
|
516 | - |
|
517 | - |
|
518 | - /** |
|
519 | - * @return \EE_messenger[] |
|
520 | - * @throws EE_Error |
|
521 | - * @throws ReflectionException |
|
522 | - * @deprecated 4.9.0 |
|
523 | - */ |
|
524 | - public function get_active_messengers() |
|
525 | - { |
|
526 | - // EE_messages has been deprecated |
|
527 | - $this->_class_is_deprecated(__FUNCTION__); |
|
528 | - return $this->_message_resource_manager->active_messengers(); |
|
529 | - } |
|
530 | - |
|
531 | - |
|
532 | - /** |
|
533 | - * @return array array of message_type references (string) |
|
534 | - * @throws EE_Error |
|
535 | - * @throws ReflectionException |
|
536 | - * @deprecated 4.9.0 |
|
537 | - */ |
|
538 | - public function get_active_message_types() |
|
539 | - { |
|
540 | - // EE_messages has been deprecated |
|
541 | - $this->_class_is_deprecated(__FUNCTION__); |
|
542 | - return $this->_message_resource_manager->list_of_active_message_types(); |
|
543 | - } |
|
544 | - |
|
545 | - |
|
546 | - /** |
|
547 | - * @return EE_message_type[] |
|
548 | - * @throws EE_Error |
|
549 | - * @throws ReflectionException |
|
550 | - * @deprecated 4.9.0 |
|
551 | - */ |
|
552 | - public function get_active_message_type_objects() |
|
553 | - { |
|
554 | - // EE_messages has been deprecated |
|
555 | - $this->_class_is_deprecated(__FUNCTION__); |
|
556 | - return $this->_message_resource_manager->get_active_message_type_objects(); |
|
557 | - } |
|
558 | - |
|
559 | - |
|
560 | - /** |
|
561 | - * @param string $messenger The messenger being checked |
|
562 | - * @return EE_message_type[] (or empty array if none present) |
|
563 | - * @throws EE_Error |
|
564 | - * @throws ReflectionException |
|
565 | - * @deprecated 4.9.0 |
|
566 | - * @since 4.5.0 |
|
567 | - */ |
|
568 | - public function get_active_message_types_per_messenger($messenger) |
|
569 | - { |
|
570 | - // EE_messages has been deprecated |
|
571 | - $this->_class_is_deprecated(__FUNCTION__); |
|
572 | - return $this->_message_resource_manager->get_active_message_types_for_messenger($messenger); |
|
573 | - } |
|
574 | - |
|
575 | - |
|
576 | - /** |
|
577 | - * @param string $messenger The string should correspond to the messenger (message types are |
|
578 | - * @param string $message_type The string should correspond to a message type. |
|
579 | - * @return EE_message_type|null |
|
580 | - * @throws EE_Error |
|
581 | - * @throws ReflectionException |
|
582 | - * @deprecated 4.9.0 |
|
583 | - */ |
|
584 | - public function get_active_message_type($messenger, $message_type) |
|
585 | - { |
|
586 | - // EE_messages has been deprecated |
|
587 | - $this->_class_is_deprecated(__FUNCTION__); |
|
588 | - return $this->_message_resource_manager->get_active_message_type_for_messenger($messenger, $message_type); |
|
589 | - } |
|
590 | - |
|
591 | - |
|
592 | - /** |
|
593 | - * @return array|\EE_message_type[] |
|
594 | - * @throws EE_Error |
|
595 | - * @throws ReflectionException |
|
596 | - * @deprecated 4.9.0 |
|
597 | - */ |
|
598 | - public function get_installed_message_types() |
|
599 | - { |
|
600 | - // EE_messages has been deprecated |
|
601 | - $this->_class_is_deprecated(__FUNCTION__); |
|
602 | - return $this->_message_resource_manager->installed_message_types(); |
|
603 | - } |
|
604 | - |
|
605 | - |
|
606 | - /** |
|
607 | - * @return array |
|
608 | - * @throws EE_Error |
|
609 | - * @throws ReflectionException |
|
610 | - * @deprecated 4.9.0 |
|
611 | - */ |
|
612 | - public function get_installed_messengers() |
|
613 | - { |
|
614 | - // EE_messages has been deprecated |
|
615 | - $this->_class_is_deprecated(__FUNCTION__); |
|
616 | - return $this->_message_resource_manager->installed_messengers(); |
|
617 | - } |
|
618 | - |
|
619 | - |
|
620 | - /** |
|
621 | - * @param bool $slugs_only Whether to return an array of just slugs and labels (true) or all contexts indexed by |
|
622 | - * message type. |
|
623 | - * @return array |
|
624 | - * @throws EE_Error |
|
625 | - * @throws ReflectionException |
|
626 | - * @deprecated 4.9.0 |
|
627 | - */ |
|
628 | - public function get_all_contexts($slugs_only = true) |
|
629 | - { |
|
630 | - // EE_messages has been deprecated |
|
631 | - $this->_class_is_deprecated(__FUNCTION__); |
|
632 | - return $this->_message_resource_manager->get_all_contexts($slugs_only); |
|
633 | - } |
|
75 | + /** @type EE_messenger[] */ |
|
76 | + protected $_active_messengers = []; |
|
77 | + |
|
78 | + /** @type array */ |
|
79 | + protected $_active_message_types = []; |
|
80 | + |
|
81 | + /** @type EE_message_type[] */ |
|
82 | + protected $_installed_message_types = []; |
|
83 | + |
|
84 | + /** @type EE_messenger */ |
|
85 | + protected $_messenger; |
|
86 | + |
|
87 | + /** @type EE_message_type */ |
|
88 | + protected $_message_type; |
|
89 | + |
|
90 | + /** @type array */ |
|
91 | + protected $_contexts = []; |
|
92 | + |
|
93 | + /** @type EE_Message_Resource_Manager $_message_resource_manager */ |
|
94 | + protected $_message_resource_manager; |
|
95 | + |
|
96 | + |
|
97 | + /** |
|
98 | + * EE_messages constructor. |
|
99 | + * |
|
100 | + * @deprecated 4.9.0 |
|
101 | + */ |
|
102 | + public function __construct() |
|
103 | + { |
|
104 | + } |
|
105 | + |
|
106 | + |
|
107 | + /** |
|
108 | + * @param string $method |
|
109 | + * @throws EE_Error |
|
110 | + * @throws ReflectionException |
|
111 | + */ |
|
112 | + public function _class_is_deprecated($method) |
|
113 | + { |
|
114 | + EE_Error::doing_it_wrong( |
|
115 | + 'EE_messages::' . $method, |
|
116 | + esc_html__('EE_messages has been deprecated. Please use EE_Message_Resource_Manager instead.'), |
|
117 | + '4.9.0', |
|
118 | + '4.10.0.p' |
|
119 | + ); |
|
120 | + // Please use EE_Message_Resource_Manager instead |
|
121 | + $this->_message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
122 | + } |
|
123 | + |
|
124 | + |
|
125 | + /** |
|
126 | + * @param string $messenger_name |
|
127 | + * @return boolean TRUE if it was PREVIOUSLY active, and FALSE if it was previously inactive |
|
128 | + * @throws EE_Error |
|
129 | + * @throws ReflectionException |
|
130 | + * @deprecated 4.9.0 |
|
131 | + */ |
|
132 | + public function ensure_messenger_is_active($messenger_name) |
|
133 | + { |
|
134 | + // EE_messages has been deprecated |
|
135 | + $this->_class_is_deprecated(__FUNCTION__); |
|
136 | + return $this->_message_resource_manager->ensure_messenger_is_active($messenger_name); |
|
137 | + } |
|
138 | + |
|
139 | + |
|
140 | + /** |
|
141 | + * @param string $message_type message type name |
|
142 | + * @param $messenger |
|
143 | + * @return bool true if it got activated (or was active) and false if not. |
|
144 | + * @throws EE_Error |
|
145 | + * @throws ReflectionException |
|
146 | + * @deprecated 4.9.0 |
|
147 | + */ |
|
148 | + public function ensure_message_type_is_active($message_type, $messenger) |
|
149 | + { |
|
150 | + // EE_messages has been deprecated |
|
151 | + $this->_class_is_deprecated(__FUNCTION__); |
|
152 | + return $this->_message_resource_manager->ensure_message_type_is_active($message_type, $messenger); |
|
153 | + } |
|
154 | + |
|
155 | + |
|
156 | + /** |
|
157 | + * @param string $messenger_name |
|
158 | + * @param array $mts_to_activate (optional) An array of message types to activate with this messenger. |
|
159 | + * If included we do NOT setup the default message types (assuming they |
|
160 | + * are already setup.) |
|
161 | + * @return array an array of generated templates or false if nothing generated/activated. |
|
162 | + * @throws EE_Error |
|
163 | + * @throws ReflectionException |
|
164 | + * @deprecated 4.9.0 |
|
165 | + */ |
|
166 | + public function activate_messenger($messenger_name, $mts_to_activate = []) |
|
167 | + { |
|
168 | + // EE_messages has been deprecated |
|
169 | + $this->_class_is_deprecated(__FUNCTION__); |
|
170 | + return $this->_message_resource_manager->activate_messenger($messenger_name, $mts_to_activate); |
|
171 | + } |
|
172 | + |
|
173 | + |
|
174 | + /** |
|
175 | + * @param EE_messenger $messenger messenger used in trigger |
|
176 | + * @param EE_message_type $message_type message type used in trigger |
|
177 | + * |
|
178 | + * @return bool true is a generating messenger and can be sent OR FALSE meaning cannot send. |
|
179 | + * @throws EE_Error |
|
180 | + * @throws ReflectionException |
|
181 | + * @deprecated 4.9.0 |
|
182 | + */ |
|
183 | + public function is_generating_messenger_and_active(EE_messenger $messenger, EE_message_type $message_type) |
|
184 | + { |
|
185 | + // EE_messages has been deprecated |
|
186 | + $this->_class_is_deprecated(__FUNCTION__); |
|
187 | + return $this->_message_resource_manager->is_generating_messenger_and_active($messenger, $message_type); |
|
188 | + } |
|
189 | + |
|
190 | + |
|
191 | + /** |
|
192 | + * @param string $messenger |
|
193 | + * @return EE_messenger | null |
|
194 | + * @throws EE_Error |
|
195 | + * @throws ReflectionException |
|
196 | + * @deprecated 4.9.0 |
|
197 | + */ |
|
198 | + public function get_messenger_if_active($messenger) |
|
199 | + { |
|
200 | + // EE_messages has been deprecated |
|
201 | + $this->_class_is_deprecated(__FUNCTION__); |
|
202 | + return $this->_message_resource_manager->get_active_messenger($messenger); |
|
203 | + } |
|
204 | + |
|
205 | + |
|
206 | + /** |
|
207 | + * @param EE_Message $message |
|
208 | + * @return array An array with 'messenger' and 'message_type' as the index and the corresponding valid object if |
|
209 | + * available. |
|
210 | + * Eg. Valid Messenger and Message Type: |
|
211 | + * array( |
|
212 | + * 'messenger' => new EE_Email_messenger(), |
|
213 | + * 'message_type' => new EE_Registration_Approved_message_type() |
|
214 | + * ) |
|
215 | + * Valid Messenger and Invalid Message Type: |
|
216 | + * array( |
|
217 | + * 'messenger' => new EE_Email_messenger(), |
|
218 | + * 'message_type' => null |
|
219 | + * ) |
|
220 | + * @throws EE_Error |
|
221 | + * @throws ReflectionException |
|
222 | + * @deprecated 4.9.0 |
|
223 | + */ |
|
224 | + public function validate_for_use(EE_Message $message) |
|
225 | + { |
|
226 | + // EE_messages has been deprecated |
|
227 | + $this->_class_is_deprecated(__FUNCTION__); |
|
228 | + return [ |
|
229 | + 'messenger' => $message->messenger_object(), |
|
230 | + 'message_type' => $message->message_type_object(), |
|
231 | + ]; |
|
232 | + } |
|
233 | + |
|
234 | + |
|
235 | + /** |
|
236 | + * @param string $type What type of message are we sending (corresponds to message types) |
|
237 | + * @param mixed $vars Data being sent for parsing in the message |
|
238 | + * @param string $sending_messenger if included then we ONLY use the specified messenger for delivery. |
|
239 | + * Otherwise we cycle through all active messengers. |
|
240 | + * @param string $generating_messenger if included then this messenger is used for generating the message |
|
241 | + * templates (but not for sending). |
|
242 | + * @param string $context If included then only a message type for a specific context will be |
|
243 | + * generated. |
|
244 | + * @param bool $send Default TRUE. If false, then this will just return the generated |
|
245 | + * EE_messages objects which might be used by the trigger to setup a batch |
|
246 | + * message (typically html messenger uses it). |
|
247 | + * @return bool|array |
|
248 | + * @throws EE_Error |
|
249 | + * @throws ReflectionException |
|
250 | + * @deprecated 4.9.0 |
|
251 | + */ |
|
252 | + public function send_message( |
|
253 | + $type, |
|
254 | + $vars, |
|
255 | + $sending_messenger = '', |
|
256 | + $generating_messenger = '', |
|
257 | + $context = '', |
|
258 | + $send = true |
|
259 | + ) { |
|
260 | + // EE_messages has been deprecated |
|
261 | + $this->_class_is_deprecated(__FUNCTION__); |
|
262 | + /** @type EE_Messages_Processor $processor */ |
|
263 | + $processor = EE_Registry::instance()->load_lib('Messages_Processor'); |
|
264 | + $error = false; |
|
265 | + // try to intelligently determine what method we'll call based on the incoming data. |
|
266 | + // if generating and sending are different then generate and send immediately. |
|
267 | + if (! empty($sending_messenger) && $sending_messenger != $generating_messenger && $send) { |
|
268 | + // in the legacy system, when generating and sending were different, that means all the |
|
269 | + // vars are already in the request object. So let's just use that. |
|
270 | + try { |
|
271 | + /** @type EE_Message_To_Generate_From_Request $mtg */ |
|
272 | + $mtg = EE_Registry::instance()->load_lib('Message_To_Generate_From_Request'); |
|
273 | + $processor->generate_and_send_now($mtg); |
|
274 | + } catch (EE_Error $e) { |
|
275 | + $error_msg = esc_html__( |
|
276 | + 'Please note that a system message failed to send due to a technical issue.', |
|
277 | + 'event_espresso' |
|
278 | + ); |
|
279 | + // add specific message for developers if WP_DEBUG in on |
|
280 | + $error_msg .= '||' . $e->getMessage(); |
|
281 | + EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
282 | + $error = true; |
|
283 | + } |
|
284 | + } else { |
|
285 | + $processor->generate_for_all_active_messengers($type, $vars, $send); |
|
286 | + // let's find out if there were any errors and how many successfully were queued. |
|
287 | + $count_errors = $processor->get_queue()->count_STS_in_queue( |
|
288 | + [EEM_Message::status_failed, EEM_Message::status_debug_only] |
|
289 | + ); |
|
290 | + $count_queued = $processor->get_queue()->count_STS_in_queue(EEM_Message::status_incomplete); |
|
291 | + $count_retry = $processor->get_queue()->count_STS_in_queue(EEM_Message::status_retry); |
|
292 | + $count_errors = $count_errors + $count_retry; |
|
293 | + if ($count_errors > 0) { |
|
294 | + $error = true; |
|
295 | + if ($count_errors > 1 && $count_retry > 1 && $count_queued > 1) { |
|
296 | + $message = sprintf( |
|
297 | + esc_html__( |
|
298 | + 'There were %1$d errors and %2$d messages successfully queued for generation and sending', |
|
299 | + 'event_espresso' |
|
300 | + ), |
|
301 | + $count_errors, |
|
302 | + $count_queued |
|
303 | + ); |
|
304 | + } elseif ($count_errors > 1 && $count_queued === 1) { |
|
305 | + $message = sprintf( |
|
306 | + esc_html__( |
|
307 | + 'There were %1$d errors and %2$d message successfully queued for generation.', |
|
308 | + 'event_espresso' |
|
309 | + ), |
|
310 | + $count_errors, |
|
311 | + $count_queued |
|
312 | + ); |
|
313 | + } elseif ($count_errors === 1 && $count_queued > 1) { |
|
314 | + $message = sprintf( |
|
315 | + esc_html__( |
|
316 | + 'There was %1$d error and %2$d messages successfully queued for generation.', |
|
317 | + 'event_espresso' |
|
318 | + ), |
|
319 | + $count_errors, |
|
320 | + $count_queued |
|
321 | + ); |
|
322 | + } else { |
|
323 | + $message = sprintf( |
|
324 | + esc_html__( |
|
325 | + 'There was %d message that failed to be queued for generation.', |
|
326 | + 'event_espresso' |
|
327 | + ), |
|
328 | + $count_errors |
|
329 | + ); |
|
330 | + } |
|
331 | + EE_Error::add_error($message, __FILE__, __FUNCTION__, __LINE__); |
|
332 | + } else { |
|
333 | + if ($count_queued === 1) { |
|
334 | + $message = sprintf( |
|
335 | + esc_html__( |
|
336 | + '%d message successfully queued for generation.', |
|
337 | + 'event_espresso' |
|
338 | + ), |
|
339 | + $count_queued |
|
340 | + ); |
|
341 | + } else { |
|
342 | + $message = sprintf( |
|
343 | + esc_html__( |
|
344 | + '%d messages were successfully queued for generation.', |
|
345 | + 'event_espresso' |
|
346 | + ), |
|
347 | + $count_queued |
|
348 | + ); |
|
349 | + } |
|
350 | + EE_Error::add_success($message); |
|
351 | + } |
|
352 | + } |
|
353 | + // if no error then return the generated message(s). |
|
354 | + if (! $error && ! $send) { |
|
355 | + $generated_queue = $processor->generate_queue(false); |
|
356 | + // get message and return. |
|
357 | + $generated_queue->get_message_repository()->rewind(); |
|
358 | + $messages = []; |
|
359 | + while ($generated_queue->get_message_repository()->valid()) { |
|
360 | + $message = $generated_queue->get_message_repository()->current(); |
|
361 | + if ($message instanceof EE_Message) { |
|
362 | + // set properties that might be expected by add-ons (backward compat) |
|
363 | + $message->content = $message->content(); |
|
364 | + $message->template_pack = $message->get_template_pack(); |
|
365 | + $message->template_variation = $message->get_template_pack_variation(); |
|
366 | + $messages[] = $message; |
|
367 | + } |
|
368 | + $generated_queue->get_message_repository()->next(); |
|
369 | + } |
|
370 | + return $messages; |
|
371 | + } |
|
372 | + return $error ? false |
|
373 | + : true; // yeah backwards eh? Really what we're returning is if there is a total success for all the messages or not. We'll modify this once we get message recording in place. |
|
374 | + } |
|
375 | + |
|
376 | + |
|
377 | + /** |
|
378 | + * @param string $type This should correspond with a valid message type |
|
379 | + * @param string $context This should correspond with a valid context for the message type |
|
380 | + * @param string $messenger This should correspond with a valid messenger. |
|
381 | + * @param bool $send true we will do a test send using the messenger delivery, false we just do a regular |
|
382 | + * preview |
|
383 | + * @return string The body of the message. |
|
384 | + * @throws EE_Error |
|
385 | + * @throws ReflectionException |
|
386 | + * @deprecated 4.9.0 |
|
387 | + */ |
|
388 | + public function preview_message($type, $context, $messenger, $send = false) |
|
389 | + { |
|
390 | + // EE_messages has been deprecated |
|
391 | + $this->_class_is_deprecated(__FUNCTION__); |
|
392 | + return EED_Messages::preview_message($type, $context, $messenger, $send); |
|
393 | + } |
|
394 | + |
|
395 | + |
|
396 | + /** |
|
397 | + * @param string $messenger a string matching a valid active messenger in the system |
|
398 | + * @param string $message_type Although it seems contrary to the name of the method, a message type name is still |
|
399 | + * required to send along the message type to the messenger because this is used for |
|
400 | + * determining what specific variations might be loaded for the generated message. |
|
401 | + * @param stdClass $message a stdClass object in the format expected by the messenger. |
|
402 | + * |
|
403 | + * @return bool success or fail. |
|
404 | + * @throws EE_Error |
|
405 | + * @throws ReflectionException |
|
406 | + * @since 4.5.0 |
|
407 | + * @deprecated 4.9.0 Moved to EED_Messages Module |
|
408 | + */ |
|
409 | + public function send_message_with_messenger_only($messenger, $message_type, $message) |
|
410 | + { |
|
411 | + // EE_messages has been deprecated |
|
412 | + $this->_class_is_deprecated(__FUNCTION__); |
|
413 | + // setup for sending to new method. |
|
414 | + /** @type EE_Messages_Queue $queue */ |
|
415 | + $queue = EE_Registry::instance()->load_lib('Messages_Queue'); |
|
416 | + // make sure we have a proper message object |
|
417 | + if (! $message instanceof EE_Message && is_object($message) && isset($message->content)) { |
|
418 | + $msg = EE_Message_Factory::create( |
|
419 | + [ |
|
420 | + 'MSG_messenger' => $messenger, |
|
421 | + 'MSG_message_type' => $message_type, |
|
422 | + 'MSG_content' => $message->content, |
|
423 | + 'MSG_subject' => $message->subject, |
|
424 | + ] |
|
425 | + ); |
|
426 | + } else { |
|
427 | + $msg = $message; |
|
428 | + } |
|
429 | + if (! $msg instanceof EE_Message) { |
|
430 | + return false; |
|
431 | + } |
|
432 | + // make sure any content in a content property (if not empty) is set on the MSG_content. |
|
433 | + if (! empty($msg->content)) { |
|
434 | + $msg->set('MSG_content', $msg->content); |
|
435 | + } |
|
436 | + $queue->add($msg); |
|
437 | + return EED_Messages::send_message_with_messenger_only($messenger, $message_type, $queue); |
|
438 | + } |
|
439 | + |
|
440 | + |
|
441 | + /** |
|
442 | + * @param $messenger |
|
443 | + * @param string $message_type message type that the templates are being created for |
|
444 | + * @param int $GRP_ID |
|
445 | + * @param bool $is_global |
|
446 | + * @return array|object if creation is successful then we return an array of info, otherwise an error_object is |
|
447 | + * returned. |
|
448 | + * @throws EE_Error |
|
449 | + * @throws ReflectionException |
|
450 | + * @deprecated 4.9.0 |
|
451 | + */ |
|
452 | + public function create_new_templates($messenger, $message_type, $GRP_ID = 0, $is_global = false) |
|
453 | + { |
|
454 | + // EE_messages has been deprecated |
|
455 | + $this->_class_is_deprecated(__FUNCTION__); |
|
456 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
457 | + return EEH_MSG_Template::create_new_templates($messenger, $message_type, $GRP_ID, $is_global); |
|
458 | + } |
|
459 | + |
|
460 | + |
|
461 | + /** |
|
462 | + * @param string $messenger_name name of EE_messenger |
|
463 | + * @param string $message_type_name name of EE_message_type |
|
464 | + * @return array |
|
465 | + * @throws EE_Error |
|
466 | + * @throws ReflectionException |
|
467 | + * @deprecated 4.9.0 |
|
468 | + */ |
|
469 | + public function get_fields($messenger_name, $message_type_name) |
|
470 | + { |
|
471 | + // EE_messages has been deprecated |
|
472 | + $this->_class_is_deprecated(__FUNCTION__); |
|
473 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
474 | + return EEH_MSG_Template::get_fields($messenger_name, $message_type_name); |
|
475 | + } |
|
476 | + |
|
477 | + |
|
478 | + /** |
|
479 | + * @param string $type we can indicate just returning installed message types |
|
480 | + * or messengers (or both) via this parameter. |
|
481 | + * @param bool $skip_cache if true then we skip the cache and retrieve via files. |
|
482 | + * @return array multidimensional array of messenger and message_type objects |
|
483 | + * (messengers index, and message_type index); |
|
484 | + * @throws EE_Error |
|
485 | + * @throws ReflectionException |
|
486 | + * @deprecated 4.9.0 |
|
487 | + * @access public |
|
488 | + */ |
|
489 | + public function get_installed($type = 'all', $skip_cache = false) |
|
490 | + { |
|
491 | + // EE_messages has been deprecated |
|
492 | + $this->_class_is_deprecated(__FUNCTION__); |
|
493 | + if ($skip_cache) { |
|
494 | + $this->_message_resource_manager->reset_active_messengers_and_message_types(); |
|
495 | + } |
|
496 | + switch ($type) { |
|
497 | + case 'messengers': |
|
498 | + return [ |
|
499 | + 'messenger' => $this->_message_resource_manager->installed_messengers(), |
|
500 | + ]; |
|
501 | + break; |
|
502 | + case 'message_types': |
|
503 | + return [ |
|
504 | + 'message_type' => $this->_message_resource_manager->installed_message_types(), |
|
505 | + ]; |
|
506 | + break; |
|
507 | + case 'all': |
|
508 | + default: |
|
509 | + return [ |
|
510 | + 'messenger' => $this->_message_resource_manager->installed_messengers(), |
|
511 | + 'message_type' => $this->_message_resource_manager->installed_message_types(), |
|
512 | + ]; |
|
513 | + break; |
|
514 | + } |
|
515 | + } |
|
516 | + |
|
517 | + |
|
518 | + /** |
|
519 | + * @return \EE_messenger[] |
|
520 | + * @throws EE_Error |
|
521 | + * @throws ReflectionException |
|
522 | + * @deprecated 4.9.0 |
|
523 | + */ |
|
524 | + public function get_active_messengers() |
|
525 | + { |
|
526 | + // EE_messages has been deprecated |
|
527 | + $this->_class_is_deprecated(__FUNCTION__); |
|
528 | + return $this->_message_resource_manager->active_messengers(); |
|
529 | + } |
|
530 | + |
|
531 | + |
|
532 | + /** |
|
533 | + * @return array array of message_type references (string) |
|
534 | + * @throws EE_Error |
|
535 | + * @throws ReflectionException |
|
536 | + * @deprecated 4.9.0 |
|
537 | + */ |
|
538 | + public function get_active_message_types() |
|
539 | + { |
|
540 | + // EE_messages has been deprecated |
|
541 | + $this->_class_is_deprecated(__FUNCTION__); |
|
542 | + return $this->_message_resource_manager->list_of_active_message_types(); |
|
543 | + } |
|
544 | + |
|
545 | + |
|
546 | + /** |
|
547 | + * @return EE_message_type[] |
|
548 | + * @throws EE_Error |
|
549 | + * @throws ReflectionException |
|
550 | + * @deprecated 4.9.0 |
|
551 | + */ |
|
552 | + public function get_active_message_type_objects() |
|
553 | + { |
|
554 | + // EE_messages has been deprecated |
|
555 | + $this->_class_is_deprecated(__FUNCTION__); |
|
556 | + return $this->_message_resource_manager->get_active_message_type_objects(); |
|
557 | + } |
|
558 | + |
|
559 | + |
|
560 | + /** |
|
561 | + * @param string $messenger The messenger being checked |
|
562 | + * @return EE_message_type[] (or empty array if none present) |
|
563 | + * @throws EE_Error |
|
564 | + * @throws ReflectionException |
|
565 | + * @deprecated 4.9.0 |
|
566 | + * @since 4.5.0 |
|
567 | + */ |
|
568 | + public function get_active_message_types_per_messenger($messenger) |
|
569 | + { |
|
570 | + // EE_messages has been deprecated |
|
571 | + $this->_class_is_deprecated(__FUNCTION__); |
|
572 | + return $this->_message_resource_manager->get_active_message_types_for_messenger($messenger); |
|
573 | + } |
|
574 | + |
|
575 | + |
|
576 | + /** |
|
577 | + * @param string $messenger The string should correspond to the messenger (message types are |
|
578 | + * @param string $message_type The string should correspond to a message type. |
|
579 | + * @return EE_message_type|null |
|
580 | + * @throws EE_Error |
|
581 | + * @throws ReflectionException |
|
582 | + * @deprecated 4.9.0 |
|
583 | + */ |
|
584 | + public function get_active_message_type($messenger, $message_type) |
|
585 | + { |
|
586 | + // EE_messages has been deprecated |
|
587 | + $this->_class_is_deprecated(__FUNCTION__); |
|
588 | + return $this->_message_resource_manager->get_active_message_type_for_messenger($messenger, $message_type); |
|
589 | + } |
|
590 | + |
|
591 | + |
|
592 | + /** |
|
593 | + * @return array|\EE_message_type[] |
|
594 | + * @throws EE_Error |
|
595 | + * @throws ReflectionException |
|
596 | + * @deprecated 4.9.0 |
|
597 | + */ |
|
598 | + public function get_installed_message_types() |
|
599 | + { |
|
600 | + // EE_messages has been deprecated |
|
601 | + $this->_class_is_deprecated(__FUNCTION__); |
|
602 | + return $this->_message_resource_manager->installed_message_types(); |
|
603 | + } |
|
604 | + |
|
605 | + |
|
606 | + /** |
|
607 | + * @return array |
|
608 | + * @throws EE_Error |
|
609 | + * @throws ReflectionException |
|
610 | + * @deprecated 4.9.0 |
|
611 | + */ |
|
612 | + public function get_installed_messengers() |
|
613 | + { |
|
614 | + // EE_messages has been deprecated |
|
615 | + $this->_class_is_deprecated(__FUNCTION__); |
|
616 | + return $this->_message_resource_manager->installed_messengers(); |
|
617 | + } |
|
618 | + |
|
619 | + |
|
620 | + /** |
|
621 | + * @param bool $slugs_only Whether to return an array of just slugs and labels (true) or all contexts indexed by |
|
622 | + * message type. |
|
623 | + * @return array |
|
624 | + * @throws EE_Error |
|
625 | + * @throws ReflectionException |
|
626 | + * @deprecated 4.9.0 |
|
627 | + */ |
|
628 | + public function get_all_contexts($slugs_only = true) |
|
629 | + { |
|
630 | + // EE_messages has been deprecated |
|
631 | + $this->_class_is_deprecated(__FUNCTION__); |
|
632 | + return $this->_message_resource_manager->get_all_contexts($slugs_only); |
|
633 | + } |
|
634 | 634 | } |
635 | 635 | |
636 | 636 | // end EE_messages class |
@@ -687,88 +687,88 @@ discard block |
||
687 | 687 | |
688 | 688 | |
689 | 689 | add_filter( |
690 | - 'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css', |
|
691 | - function ($event_list_iframe_css) { |
|
692 | - if (! has_filter('FHEE__EventsArchiveIframe__event_list_iframe__css')) { |
|
693 | - return $event_list_iframe_css; |
|
694 | - } |
|
695 | - deprecated_espresso_action_or_filter_doing_it_wrong( |
|
696 | - 'FHEE__EventsArchiveIframe__event_list_iframe__css', |
|
697 | - 'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css', |
|
698 | - '\EventEspresso\modules\events_archive\EventsArchiveIframe::display()', |
|
699 | - '4.9.14', |
|
700 | - '5.1.0', |
|
701 | - 'filter' |
|
702 | - ); |
|
703 | - return apply_filters( |
|
704 | - 'FHEE__EventsArchiveIframe__event_list_iframe__css', |
|
705 | - $event_list_iframe_css |
|
706 | - ); |
|
707 | - } |
|
690 | + 'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css', |
|
691 | + function ($event_list_iframe_css) { |
|
692 | + if (! has_filter('FHEE__EventsArchiveIframe__event_list_iframe__css')) { |
|
693 | + return $event_list_iframe_css; |
|
694 | + } |
|
695 | + deprecated_espresso_action_or_filter_doing_it_wrong( |
|
696 | + 'FHEE__EventsArchiveIframe__event_list_iframe__css', |
|
697 | + 'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css', |
|
698 | + '\EventEspresso\modules\events_archive\EventsArchiveIframe::display()', |
|
699 | + '4.9.14', |
|
700 | + '5.1.0', |
|
701 | + 'filter' |
|
702 | + ); |
|
703 | + return apply_filters( |
|
704 | + 'FHEE__EventsArchiveIframe__event_list_iframe__css', |
|
705 | + $event_list_iframe_css |
|
706 | + ); |
|
707 | + } |
|
708 | 708 | ); |
709 | 709 | add_filter( |
710 | - 'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js', |
|
711 | - function ($event_list_iframe_js) { |
|
712 | - if (! has_filter('FHEE__EED_Ticket_Selector__ticket_selector_iframe__js')) { |
|
713 | - return $event_list_iframe_js; |
|
714 | - } |
|
715 | - deprecated_espresso_action_or_filter_doing_it_wrong( |
|
716 | - 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js', |
|
717 | - 'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js', |
|
718 | - '\EventEspresso\modules\events_archive\EventsArchiveIframe::display()', |
|
719 | - '4.9.14', |
|
720 | - '5.1.0', |
|
721 | - 'filter' |
|
722 | - ); |
|
723 | - return apply_filters( |
|
724 | - 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js', |
|
725 | - $event_list_iframe_js |
|
726 | - ); |
|
727 | - } |
|
710 | + 'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js', |
|
711 | + function ($event_list_iframe_js) { |
|
712 | + if (! has_filter('FHEE__EED_Ticket_Selector__ticket_selector_iframe__js')) { |
|
713 | + return $event_list_iframe_js; |
|
714 | + } |
|
715 | + deprecated_espresso_action_or_filter_doing_it_wrong( |
|
716 | + 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js', |
|
717 | + 'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js', |
|
718 | + '\EventEspresso\modules\events_archive\EventsArchiveIframe::display()', |
|
719 | + '4.9.14', |
|
720 | + '5.1.0', |
|
721 | + 'filter' |
|
722 | + ); |
|
723 | + return apply_filters( |
|
724 | + 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js', |
|
725 | + $event_list_iframe_js |
|
726 | + ); |
|
727 | + } |
|
728 | 728 | ); |
729 | 729 | add_action( |
730 | - 'AHEE__EE_Capabilities__addCaps__complete', |
|
731 | - function ($capabilities_map) { |
|
732 | - if (! has_action('AHEE__EE_Capabilities__init_role_caps__complete')) { |
|
733 | - return; |
|
734 | - } |
|
735 | - deprecated_espresso_action_or_filter_doing_it_wrong( |
|
736 | - 'AHEE__EE_Capabilities__init_role_caps__complete', |
|
737 | - 'AHEE__EE_Capabilities__addCaps__complete', |
|
738 | - '\EE_Capabilities::addCaps()', |
|
739 | - '4.9.42', |
|
740 | - '5.1.0', |
|
741 | - ); |
|
742 | - do_action( |
|
743 | - 'AHEE__EE_Capabilities__init_role_caps__complete', |
|
744 | - $capabilities_map |
|
745 | - ); |
|
746 | - } |
|
730 | + 'AHEE__EE_Capabilities__addCaps__complete', |
|
731 | + function ($capabilities_map) { |
|
732 | + if (! has_action('AHEE__EE_Capabilities__init_role_caps__complete')) { |
|
733 | + return; |
|
734 | + } |
|
735 | + deprecated_espresso_action_or_filter_doing_it_wrong( |
|
736 | + 'AHEE__EE_Capabilities__init_role_caps__complete', |
|
737 | + 'AHEE__EE_Capabilities__addCaps__complete', |
|
738 | + '\EE_Capabilities::addCaps()', |
|
739 | + '4.9.42', |
|
740 | + '5.1.0', |
|
741 | + ); |
|
742 | + do_action( |
|
743 | + 'AHEE__EE_Capabilities__init_role_caps__complete', |
|
744 | + $capabilities_map |
|
745 | + ); |
|
746 | + } |
|
747 | 747 | ); |
748 | 748 | |
749 | 749 | add_filter( |
750 | - 'FHEE_EventEspresso_core_domain_services_commands_attendee_CreateAttendeeCommandHandler__findExistingAttendee__existing_attendee', |
|
751 | - function ($existing_attendee, $registration, $attendee_data) { |
|
752 | - if (! has_filter('FHEE_EE_Single_Page_Checkout__save_registration_items__find_existing_attendee')) { |
|
753 | - return $existing_attendee; |
|
754 | - } |
|
755 | - deprecated_espresso_action_or_filter_doing_it_wrong( |
|
756 | - 'FHEE_EE_Single_Page_Checkout__save_registration_items__find_existing_attendee', |
|
757 | - 'FHEE_EventEspresso_core_domain_services_commands_attendee_CreateAttendeeCommandHandler__findExistingAttendee__existing_attendee', |
|
758 | - '\EventEspresso\core\domain\services\commands\attendee\CreateAttendeeCommandHandler::findExistingAttendee()', |
|
759 | - '4.9.34', |
|
760 | - '5.1.0', |
|
761 | - 'filter' |
|
762 | - ); |
|
763 | - return apply_filters( |
|
764 | - 'FHEE_EE_Single_Page_Checkout__save_registration_items__find_existing_attendee', |
|
765 | - $existing_attendee, |
|
766 | - $registration, |
|
767 | - $attendee_data |
|
768 | - ); |
|
769 | - }, |
|
770 | - 10, |
|
771 | - 3 |
|
750 | + 'FHEE_EventEspresso_core_domain_services_commands_attendee_CreateAttendeeCommandHandler__findExistingAttendee__existing_attendee', |
|
751 | + function ($existing_attendee, $registration, $attendee_data) { |
|
752 | + if (! has_filter('FHEE_EE_Single_Page_Checkout__save_registration_items__find_existing_attendee')) { |
|
753 | + return $existing_attendee; |
|
754 | + } |
|
755 | + deprecated_espresso_action_or_filter_doing_it_wrong( |
|
756 | + 'FHEE_EE_Single_Page_Checkout__save_registration_items__find_existing_attendee', |
|
757 | + 'FHEE_EventEspresso_core_domain_services_commands_attendee_CreateAttendeeCommandHandler__findExistingAttendee__existing_attendee', |
|
758 | + '\EventEspresso\core\domain\services\commands\attendee\CreateAttendeeCommandHandler::findExistingAttendee()', |
|
759 | + '4.9.34', |
|
760 | + '5.1.0', |
|
761 | + 'filter' |
|
762 | + ); |
|
763 | + return apply_filters( |
|
764 | + 'FHEE_EE_Single_Page_Checkout__save_registration_items__find_existing_attendee', |
|
765 | + $existing_attendee, |
|
766 | + $registration, |
|
767 | + $attendee_data |
|
768 | + ); |
|
769 | + }, |
|
770 | + 10, |
|
771 | + 3 |
|
772 | 772 | ); |
773 | 773 | |
774 | 774 | /** |
@@ -778,89 +778,89 @@ discard block |
||
778 | 778 | */ |
779 | 779 | class EE_Event_List_Query extends WP_Query |
780 | 780 | { |
781 | - private $title; |
|
782 | - |
|
783 | - private $css_class; |
|
784 | - |
|
785 | - private $category_slug; |
|
786 | - |
|
787 | - |
|
788 | - /** |
|
789 | - * EE_Event_List_Query constructor. |
|
790 | - * |
|
791 | - * @param array $args |
|
792 | - */ |
|
793 | - public function __construct($args = []) |
|
794 | - { |
|
795 | - EE_Error::doing_it_wrong( |
|
796 | - __METHOD__, |
|
797 | - esc_html__( |
|
798 | - 'Usage is deprecated. Please use \EventEspresso\core\domain\services\wp_queries\EventListQuery instead.', |
|
799 | - 'event_espresso' |
|
800 | - ), |
|
801 | - '4.9.27', |
|
802 | - '5.0.0' |
|
803 | - ); |
|
804 | - $this->title = isset($args['title']) ? $args['title'] : ''; |
|
805 | - $this->css_class = isset($args['css_class']) ? $args['css_class'] : ''; |
|
806 | - $this->category_slug = isset($args['category_slug']) ? $args['category_slug'] : ''; |
|
807 | - $limit = isset($args['limit']) && absint($args['limit']) ? $args['limit'] : 10; |
|
808 | - // the current "page" we are viewing |
|
809 | - $paged = max(1, get_query_var('paged')); |
|
810 | - // Force these args |
|
811 | - $args = array_merge( |
|
812 | - $args, |
|
813 | - [ |
|
814 | - 'post_type' => EspressoPostType::EVENTS, |
|
815 | - 'posts_per_page' => $limit, |
|
816 | - 'update_post_term_cache' => false, |
|
817 | - 'update_post_meta_cache' => false, |
|
818 | - 'paged' => $paged, |
|
819 | - 'offset' => ($paged - 1) * $limit, |
|
820 | - ] |
|
821 | - ); |
|
822 | - // run the query |
|
823 | - parent::__construct($args); |
|
824 | - } |
|
825 | - |
|
826 | - |
|
827 | - /** |
|
828 | - * event_list_title |
|
829 | - * |
|
830 | - * @param string $event_list_title |
|
831 | - * @return string |
|
832 | - */ |
|
833 | - public function event_list_title($event_list_title = '') |
|
834 | - { |
|
835 | - if (! empty($this->title)) { |
|
836 | - return $this->title; |
|
837 | - } |
|
838 | - return $event_list_title; |
|
839 | - } |
|
840 | - |
|
841 | - |
|
842 | - /** |
|
843 | - * event_list_css |
|
844 | - * |
|
845 | - * @param string $event_list_css |
|
846 | - * @return string |
|
847 | - */ |
|
848 | - public function event_list_css($event_list_css = '') |
|
849 | - { |
|
850 | - $event_list_css .= ! empty($event_list_css) |
|
851 | - ? ' ' |
|
852 | - : ''; |
|
853 | - $event_list_css .= ! empty($this->css_class) |
|
854 | - ? $this->css_class |
|
855 | - : ''; |
|
856 | - $event_list_css .= ! empty($event_list_css) |
|
857 | - ? ' ' |
|
858 | - : ''; |
|
859 | - $event_list_css .= ! empty($this->category_slug) |
|
860 | - ? $this->category_slug |
|
861 | - : ''; |
|
862 | - return $event_list_css; |
|
863 | - } |
|
781 | + private $title; |
|
782 | + |
|
783 | + private $css_class; |
|
784 | + |
|
785 | + private $category_slug; |
|
786 | + |
|
787 | + |
|
788 | + /** |
|
789 | + * EE_Event_List_Query constructor. |
|
790 | + * |
|
791 | + * @param array $args |
|
792 | + */ |
|
793 | + public function __construct($args = []) |
|
794 | + { |
|
795 | + EE_Error::doing_it_wrong( |
|
796 | + __METHOD__, |
|
797 | + esc_html__( |
|
798 | + 'Usage is deprecated. Please use \EventEspresso\core\domain\services\wp_queries\EventListQuery instead.', |
|
799 | + 'event_espresso' |
|
800 | + ), |
|
801 | + '4.9.27', |
|
802 | + '5.0.0' |
|
803 | + ); |
|
804 | + $this->title = isset($args['title']) ? $args['title'] : ''; |
|
805 | + $this->css_class = isset($args['css_class']) ? $args['css_class'] : ''; |
|
806 | + $this->category_slug = isset($args['category_slug']) ? $args['category_slug'] : ''; |
|
807 | + $limit = isset($args['limit']) && absint($args['limit']) ? $args['limit'] : 10; |
|
808 | + // the current "page" we are viewing |
|
809 | + $paged = max(1, get_query_var('paged')); |
|
810 | + // Force these args |
|
811 | + $args = array_merge( |
|
812 | + $args, |
|
813 | + [ |
|
814 | + 'post_type' => EspressoPostType::EVENTS, |
|
815 | + 'posts_per_page' => $limit, |
|
816 | + 'update_post_term_cache' => false, |
|
817 | + 'update_post_meta_cache' => false, |
|
818 | + 'paged' => $paged, |
|
819 | + 'offset' => ($paged - 1) * $limit, |
|
820 | + ] |
|
821 | + ); |
|
822 | + // run the query |
|
823 | + parent::__construct($args); |
|
824 | + } |
|
825 | + |
|
826 | + |
|
827 | + /** |
|
828 | + * event_list_title |
|
829 | + * |
|
830 | + * @param string $event_list_title |
|
831 | + * @return string |
|
832 | + */ |
|
833 | + public function event_list_title($event_list_title = '') |
|
834 | + { |
|
835 | + if (! empty($this->title)) { |
|
836 | + return $this->title; |
|
837 | + } |
|
838 | + return $event_list_title; |
|
839 | + } |
|
840 | + |
|
841 | + |
|
842 | + /** |
|
843 | + * event_list_css |
|
844 | + * |
|
845 | + * @param string $event_list_css |
|
846 | + * @return string |
|
847 | + */ |
|
848 | + public function event_list_css($event_list_css = '') |
|
849 | + { |
|
850 | + $event_list_css .= ! empty($event_list_css) |
|
851 | + ? ' ' |
|
852 | + : ''; |
|
853 | + $event_list_css .= ! empty($this->css_class) |
|
854 | + ? $this->css_class |
|
855 | + : ''; |
|
856 | + $event_list_css .= ! empty($event_list_css) |
|
857 | + ? ' ' |
|
858 | + : ''; |
|
859 | + $event_list_css .= ! empty($this->category_slug) |
|
860 | + ? $this->category_slug |
|
861 | + : ''; |
|
862 | + return $event_list_css; |
|
863 | + } |
|
864 | 864 | } |
865 | 865 | |
866 | 866 | |
@@ -874,76 +874,76 @@ discard block |
||
874 | 874 | */ |
875 | 875 | class EE_PUE implements InterminableInterface |
876 | 876 | { |
877 | - /** |
|
878 | - * class constructor |
|
879 | - * |
|
880 | - * @deprecated 4.9.59.p |
|
881 | - */ |
|
882 | - public function __construct() |
|
883 | - { |
|
884 | - EE_Error::doing_it_wrong( |
|
885 | - __METHOD__, |
|
886 | - sprintf( |
|
887 | - esc_html__('%1$s has been replaced by %2$s.', 'event_espresso'), |
|
888 | - __CLASS__, |
|
889 | - 'EventEspresso\core\services\licensing\LicenseServices' |
|
890 | - ), |
|
891 | - '4.9.59.p' |
|
892 | - ); |
|
893 | - } |
|
894 | - |
|
895 | - |
|
896 | - /** |
|
897 | - * The purpose of this function is to display information about Event Espresso data collection |
|
898 | - * and a optin selection for extra data collecting by users. |
|
899 | - * |
|
900 | - * @param bool $extra |
|
901 | - * @return string html. |
|
902 | - * @deprecated 4.9.59.p |
|
903 | - */ |
|
904 | - public static function espresso_data_collection_optin_text($extra = true) |
|
905 | - { |
|
906 | - EE_Error::doing_it_wrong( |
|
907 | - __METHOD__, |
|
908 | - sprintf( |
|
909 | - esc_html__('%1$s has been replaced by %2$s.', 'event_espresso'), |
|
910 | - __METHOD__, |
|
911 | - 'EventEspresso\core\domain\services\Stats::optinText' |
|
912 | - ), |
|
913 | - '4.9.59.p' |
|
914 | - ); |
|
915 | - Stats::optinText($extra); |
|
916 | - } |
|
917 | - |
|
918 | - |
|
919 | - /** |
|
920 | - * This is a handy helper method for retrieving whether there is an update available for the given plugin. |
|
921 | - * |
|
922 | - * @param string $basename Use the equivalent result from plugin_basename() for this param as WP uses that to |
|
923 | - * identify plugins. Defaults to core update |
|
924 | - * @return boolean True if update available, false if not. |
|
925 | - * @deprecated 4.9.59.p |
|
926 | - */ |
|
927 | - public static function is_update_available($basename = '') |
|
928 | - { |
|
929 | - EE_Error::doing_it_wrong( |
|
930 | - __METHOD__, |
|
931 | - sprintf( |
|
932 | - esc_html__('%1$s has been replaced by %2$s.', 'event_espresso'), |
|
933 | - __METHOD__, |
|
934 | - 'EventEspresso\caffeinated\core\services\licensing\LicenseService::isUpdateAvailable' |
|
935 | - ), |
|
936 | - '4.9.59.p' |
|
937 | - ); |
|
938 | - return LicenseService::isUpdateAvailable($basename); |
|
939 | - } |
|
877 | + /** |
|
878 | + * class constructor |
|
879 | + * |
|
880 | + * @deprecated 4.9.59.p |
|
881 | + */ |
|
882 | + public function __construct() |
|
883 | + { |
|
884 | + EE_Error::doing_it_wrong( |
|
885 | + __METHOD__, |
|
886 | + sprintf( |
|
887 | + esc_html__('%1$s has been replaced by %2$s.', 'event_espresso'), |
|
888 | + __CLASS__, |
|
889 | + 'EventEspresso\core\services\licensing\LicenseServices' |
|
890 | + ), |
|
891 | + '4.9.59.p' |
|
892 | + ); |
|
893 | + } |
|
894 | + |
|
895 | + |
|
896 | + /** |
|
897 | + * The purpose of this function is to display information about Event Espresso data collection |
|
898 | + * and a optin selection for extra data collecting by users. |
|
899 | + * |
|
900 | + * @param bool $extra |
|
901 | + * @return string html. |
|
902 | + * @deprecated 4.9.59.p |
|
903 | + */ |
|
904 | + public static function espresso_data_collection_optin_text($extra = true) |
|
905 | + { |
|
906 | + EE_Error::doing_it_wrong( |
|
907 | + __METHOD__, |
|
908 | + sprintf( |
|
909 | + esc_html__('%1$s has been replaced by %2$s.', 'event_espresso'), |
|
910 | + __METHOD__, |
|
911 | + 'EventEspresso\core\domain\services\Stats::optinText' |
|
912 | + ), |
|
913 | + '4.9.59.p' |
|
914 | + ); |
|
915 | + Stats::optinText($extra); |
|
916 | + } |
|
917 | + |
|
918 | + |
|
919 | + /** |
|
920 | + * This is a handy helper method for retrieving whether there is an update available for the given plugin. |
|
921 | + * |
|
922 | + * @param string $basename Use the equivalent result from plugin_basename() for this param as WP uses that to |
|
923 | + * identify plugins. Defaults to core update |
|
924 | + * @return boolean True if update available, false if not. |
|
925 | + * @deprecated 4.9.59.p |
|
926 | + */ |
|
927 | + public static function is_update_available($basename = '') |
|
928 | + { |
|
929 | + EE_Error::doing_it_wrong( |
|
930 | + __METHOD__, |
|
931 | + sprintf( |
|
932 | + esc_html__('%1$s has been replaced by %2$s.', 'event_espresso'), |
|
933 | + __METHOD__, |
|
934 | + 'EventEspresso\caffeinated\core\services\licensing\LicenseService::isUpdateAvailable' |
|
935 | + ), |
|
936 | + '4.9.59.p' |
|
937 | + ); |
|
938 | + return LicenseService::isUpdateAvailable($basename); |
|
939 | + } |
|
940 | 940 | } |
941 | 941 | |
942 | 942 | add_filter( |
943 | - 'FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__reg_csv_array', |
|
944 | - 'ee_deprecated_registrations_report_csv_legacy_fields', |
|
945 | - 10, |
|
946 | - 2 |
|
943 | + 'FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__reg_csv_array', |
|
944 | + 'ee_deprecated_registrations_report_csv_legacy_fields', |
|
945 | + 10, |
|
946 | + 2 |
|
947 | 947 | ); |
948 | 948 | /** |
949 | 949 | * Filters the CSV row to make it appear like the old labels (which were "$pretty_name[$field_name]"). |
@@ -962,97 +962,97 @@ discard block |
||
962 | 962 | */ |
963 | 963 | function ee_deprecated_registrations_report_csv_legacy_fields($csv_row_data, $reg_row) |
964 | 964 | { |
965 | - // no need for all this if nobody is using the deprecated filter |
|
966 | - if (has_filter('FHEE__EE_Export__report_registrations__reg_csv_array')) { |
|
967 | - EE_Error::doing_it_wrong( |
|
968 | - __FUNCTION__, |
|
969 | - sprintf( |
|
970 | - // EE_Error::doing_it_wrong with escape HTML, so don't escape it twice by doing it here too. |
|
971 | - _x( |
|
972 | - 'The filter "%1$s" has been deprecated. Please use "%2$s" instead.', |
|
973 | - 'The filter "FHEE__EE_Export__report_registrations__reg_csv_array" has been deprecated. Please use "FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__reg_csv_array" instead.', |
|
974 | - 'event_espresso' |
|
975 | - ), |
|
976 | - 'FHEE__EE_Export__report_registrations__reg_csv_array', |
|
977 | - 'FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__reg_csv_array' |
|
978 | - ), |
|
979 | - '4.9.69.p', |
|
980 | - '4.9.75.p' |
|
981 | - ); |
|
982 | - // there's code that expected the old csv column headers/labels. Let's oblige. Put it back in the old format! |
|
983 | - // first: what model fields might be used as column headers? (whose format we need to change) |
|
984 | - $model_fields = array_merge( |
|
985 | - EEM_Registration::instance()->field_settings(), |
|
986 | - EEM_Attendee::instance()->field_settings() |
|
987 | - ); |
|
988 | - // create an array that uses the legacy column headers/labels. |
|
989 | - $new_csv_row = []; |
|
990 | - foreach ($csv_row_data as $label => $value) { |
|
991 | - $new_label = $label; |
|
992 | - foreach ($model_fields as $field) { |
|
993 | - if ($label === EEH_Export::get_column_name_for_field($field)) { |
|
994 | - // re-add the old field name |
|
995 | - $new_label = $label . '[' . $field->get_name() . ']'; |
|
996 | - break; |
|
997 | - } |
|
998 | - } |
|
999 | - $new_csv_row[ $new_label ] = $value; |
|
1000 | - } |
|
1001 | - // before we run it through the deprecated filter, set the method `EEH_Export::get_column_name_for_field()` |
|
1002 | - // to create the old column names, because that's what's in the row temporarily |
|
1003 | - add_filter( |
|
1004 | - 'FHEE__EEH_Export__get_column_name_for_field__add_field_name', |
|
1005 | - '__return_true', |
|
1006 | - 777 |
|
1007 | - ); |
|
1008 | - // now, those old filters can be run on this data. Have fun! |
|
1009 | - /** |
|
1010 | - * Deprecated. Use FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__reg_csv_array instead. |
|
1011 | - * |
|
1012 | - * Filter to change the contents of each row of the registrations report CSV file. |
|
1013 | - * This can be used to add or remote columns from the CSV file, or change their values. * |
|
1014 | - * Note: it has this name because originally that's where this filter resided, |
|
1015 | - * and we've left its name as-is for backward compatibility. |
|
1016 | - * Note when using: all rows in the CSV should have the same columns. |
|
1017 | - * |
|
1018 | - * @param array $reg_csv_array keys are column-header names, and values are that columns' value |
|
1019 | - * in this row |
|
1020 | - * @param array $reg_row is the row from the database's wp_esp_registration table |
|
1021 | - */ |
|
1022 | - $updated_row = apply_filters( |
|
1023 | - 'FHEE__EE_Export__report_registrations__reg_csv_array', |
|
1024 | - $new_csv_row, |
|
1025 | - $reg_row |
|
1026 | - ); |
|
1027 | - |
|
1028 | - // ok now we can revert to normal for EEH_Export::get_column_name_for_field(). |
|
1029 | - remove_filter( |
|
1030 | - 'FHEE__EEH_Export__get_column_name_for_field__add_field_name', |
|
1031 | - '__return_true', |
|
1032 | - 777 |
|
1033 | - ); |
|
1034 | - |
|
1035 | - // great. Now that the old filters are done, we can remove the ugly square brackets from column headers/labels. |
|
1036 | - $updated_and_restored_row = []; |
|
1037 | - foreach ($updated_row as $label => $value) { |
|
1038 | - $matches = []; |
|
1039 | - if ( |
|
1040 | - preg_match( |
|
1041 | - '~([^\[]*)\[(.*)\]~', |
|
1042 | - $label, |
|
1043 | - $matches |
|
1044 | - ) |
|
1045 | - && isset( |
|
1046 | - $matches[0], |
|
1047 | - $matches[1], |
|
1048 | - $matches[2] |
|
1049 | - ) |
|
1050 | - ) { |
|
1051 | - $label = $matches[1]; |
|
1052 | - } |
|
1053 | - $updated_and_restored_row[ $label ] = $value; |
|
1054 | - } |
|
1055 | - $csv_row_data = $updated_and_restored_row; |
|
1056 | - } |
|
1057 | - return $csv_row_data; |
|
965 | + // no need for all this if nobody is using the deprecated filter |
|
966 | + if (has_filter('FHEE__EE_Export__report_registrations__reg_csv_array')) { |
|
967 | + EE_Error::doing_it_wrong( |
|
968 | + __FUNCTION__, |
|
969 | + sprintf( |
|
970 | + // EE_Error::doing_it_wrong with escape HTML, so don't escape it twice by doing it here too. |
|
971 | + _x( |
|
972 | + 'The filter "%1$s" has been deprecated. Please use "%2$s" instead.', |
|
973 | + 'The filter "FHEE__EE_Export__report_registrations__reg_csv_array" has been deprecated. Please use "FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__reg_csv_array" instead.', |
|
974 | + 'event_espresso' |
|
975 | + ), |
|
976 | + 'FHEE__EE_Export__report_registrations__reg_csv_array', |
|
977 | + 'FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__reg_csv_array' |
|
978 | + ), |
|
979 | + '4.9.69.p', |
|
980 | + '4.9.75.p' |
|
981 | + ); |
|
982 | + // there's code that expected the old csv column headers/labels. Let's oblige. Put it back in the old format! |
|
983 | + // first: what model fields might be used as column headers? (whose format we need to change) |
|
984 | + $model_fields = array_merge( |
|
985 | + EEM_Registration::instance()->field_settings(), |
|
986 | + EEM_Attendee::instance()->field_settings() |
|
987 | + ); |
|
988 | + // create an array that uses the legacy column headers/labels. |
|
989 | + $new_csv_row = []; |
|
990 | + foreach ($csv_row_data as $label => $value) { |
|
991 | + $new_label = $label; |
|
992 | + foreach ($model_fields as $field) { |
|
993 | + if ($label === EEH_Export::get_column_name_for_field($field)) { |
|
994 | + // re-add the old field name |
|
995 | + $new_label = $label . '[' . $field->get_name() . ']'; |
|
996 | + break; |
|
997 | + } |
|
998 | + } |
|
999 | + $new_csv_row[ $new_label ] = $value; |
|
1000 | + } |
|
1001 | + // before we run it through the deprecated filter, set the method `EEH_Export::get_column_name_for_field()` |
|
1002 | + // to create the old column names, because that's what's in the row temporarily |
|
1003 | + add_filter( |
|
1004 | + 'FHEE__EEH_Export__get_column_name_for_field__add_field_name', |
|
1005 | + '__return_true', |
|
1006 | + 777 |
|
1007 | + ); |
|
1008 | + // now, those old filters can be run on this data. Have fun! |
|
1009 | + /** |
|
1010 | + * Deprecated. Use FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__reg_csv_array instead. |
|
1011 | + * |
|
1012 | + * Filter to change the contents of each row of the registrations report CSV file. |
|
1013 | + * This can be used to add or remote columns from the CSV file, or change their values. * |
|
1014 | + * Note: it has this name because originally that's where this filter resided, |
|
1015 | + * and we've left its name as-is for backward compatibility. |
|
1016 | + * Note when using: all rows in the CSV should have the same columns. |
|
1017 | + * |
|
1018 | + * @param array $reg_csv_array keys are column-header names, and values are that columns' value |
|
1019 | + * in this row |
|
1020 | + * @param array $reg_row is the row from the database's wp_esp_registration table |
|
1021 | + */ |
|
1022 | + $updated_row = apply_filters( |
|
1023 | + 'FHEE__EE_Export__report_registrations__reg_csv_array', |
|
1024 | + $new_csv_row, |
|
1025 | + $reg_row |
|
1026 | + ); |
|
1027 | + |
|
1028 | + // ok now we can revert to normal for EEH_Export::get_column_name_for_field(). |
|
1029 | + remove_filter( |
|
1030 | + 'FHEE__EEH_Export__get_column_name_for_field__add_field_name', |
|
1031 | + '__return_true', |
|
1032 | + 777 |
|
1033 | + ); |
|
1034 | + |
|
1035 | + // great. Now that the old filters are done, we can remove the ugly square brackets from column headers/labels. |
|
1036 | + $updated_and_restored_row = []; |
|
1037 | + foreach ($updated_row as $label => $value) { |
|
1038 | + $matches = []; |
|
1039 | + if ( |
|
1040 | + preg_match( |
|
1041 | + '~([^\[]*)\[(.*)\]~', |
|
1042 | + $label, |
|
1043 | + $matches |
|
1044 | + ) |
|
1045 | + && isset( |
|
1046 | + $matches[0], |
|
1047 | + $matches[1], |
|
1048 | + $matches[2] |
|
1049 | + ) |
|
1050 | + ) { |
|
1051 | + $label = $matches[1]; |
|
1052 | + } |
|
1053 | + $updated_and_restored_row[ $label ] = $value; |
|
1054 | + } |
|
1055 | + $csv_row_data = $updated_and_restored_row; |
|
1056 | + } |
|
1057 | + return $csv_row_data; |
|
1058 | 1058 | } |
@@ -16,299 +16,299 @@ |
||
16 | 16 | */ |
17 | 17 | class CustomPostTypeDefinitions |
18 | 18 | { |
19 | - /** |
|
20 | - * @var string $namespace The graphql namespace/prefix. |
|
21 | - */ |
|
22 | - protected $namespace = 'Espresso'; |
|
19 | + /** |
|
20 | + * @var string $namespace The graphql namespace/prefix. |
|
21 | + */ |
|
22 | + protected $namespace = 'Espresso'; |
|
23 | 23 | |
24 | - /** |
|
25 | - * @var EE_Core_Config |
|
26 | - */ |
|
27 | - public $core_config; |
|
24 | + /** |
|
25 | + * @var EE_Core_Config |
|
26 | + */ |
|
27 | + public $core_config; |
|
28 | 28 | |
29 | - /** |
|
30 | - * @var array $custom_post_types |
|
31 | - */ |
|
32 | - private $custom_post_types; |
|
29 | + /** |
|
30 | + * @var array $custom_post_types |
|
31 | + */ |
|
32 | + private $custom_post_types; |
|
33 | 33 | |
34 | - /** |
|
35 | - * @var LoaderInterface $loader |
|
36 | - */ |
|
37 | - private $loader; |
|
34 | + /** |
|
35 | + * @var LoaderInterface $loader |
|
36 | + */ |
|
37 | + private $loader; |
|
38 | 38 | |
39 | 39 | |
40 | - /** |
|
41 | - * EspressoCustomPostTypeDefinitions constructor. |
|
42 | - * |
|
43 | - * @param EE_Core_Config $core_config |
|
44 | - * @param LoaderInterface $loader |
|
45 | - */ |
|
46 | - public function __construct(EE_Core_Config $core_config, LoaderInterface $loader) |
|
47 | - { |
|
48 | - $this->core_config = $core_config; |
|
49 | - $this->loader = $loader; |
|
50 | - $this->setDefinitions(); |
|
51 | - } |
|
40 | + /** |
|
41 | + * EspressoCustomPostTypeDefinitions constructor. |
|
42 | + * |
|
43 | + * @param EE_Core_Config $core_config |
|
44 | + * @param LoaderInterface $loader |
|
45 | + */ |
|
46 | + public function __construct(EE_Core_Config $core_config, LoaderInterface $loader) |
|
47 | + { |
|
48 | + $this->core_config = $core_config; |
|
49 | + $this->loader = $loader; |
|
50 | + $this->setDefinitions(); |
|
51 | + } |
|
52 | 52 | |
53 | 53 | |
54 | - /** |
|
55 | - * defines Espresso Custom Post Types |
|
56 | - * NOTE the ['args']['page_templates'] array index is something specific to our CPTs |
|
57 | - * and not part of the WP custom post type api. |
|
58 | - * |
|
59 | - * @return void |
|
60 | - */ |
|
61 | - private function setDefinitions() |
|
62 | - { |
|
63 | - $this->custom_post_types = (array) apply_filters( |
|
64 | - 'FHEE__EventEspresso_core_domain_entities_custom_post_types_CustomPostTypeDefinitions__getCustomPostTypes', |
|
65 | - // legacy filter applied for now, |
|
66 | - // later on we'll run a has_filter($tag) check and throw a doing_it_wrong() notice |
|
67 | - apply_filters( |
|
68 | - 'FHEE__EE_Register_CPTs__get_CPTs__cpts', |
|
69 | - [ |
|
70 | - EspressoPostType::EVENTS => [ |
|
71 | - 'singular_name' => esc_html__('Event', 'event_espresso'), |
|
72 | - 'plural_name' => esc_html__('Events', 'event_espresso'), |
|
73 | - 'singular_slug' => esc_html__('event', 'event_espresso'), |
|
74 | - 'plural_slug' => $this->core_config->event_cpt_slug, |
|
75 | - 'class_name' => 'EE_Event', |
|
76 | - 'model_name' => 'EEM_Event', |
|
77 | - 'args' => [ |
|
78 | - 'public' => true, |
|
79 | - 'show_in_nav_menus' => true, |
|
80 | - 'show_in_graphql' => true, |
|
81 | - 'graphql_single_name' => $this->namespace . 'Event', |
|
82 | - 'graphql_plural_name' => $this->namespace . 'Events', |
|
83 | - 'capability_type' => 'event', |
|
84 | - 'capabilities' => [ |
|
85 | - 'edit_post' => 'ee_edit_event', |
|
86 | - 'read_post' => 'ee_read_event', |
|
87 | - 'delete_post' => 'ee_delete_event', |
|
88 | - 'edit_posts' => 'ee_edit_events', |
|
89 | - 'edit_others_posts' => 'ee_edit_others_events', |
|
90 | - 'publish_posts' => 'ee_publish_events', |
|
91 | - 'read_private_posts' => 'ee_read_private_events', |
|
92 | - 'delete_posts' => 'ee_delete_events', |
|
93 | - 'delete_private_posts' => 'ee_delete_private_events', |
|
94 | - 'delete_published_posts' => 'ee_delete_published_events', |
|
95 | - 'delete_others_posts' => 'ee_delete_others_events', |
|
96 | - 'edit_private_posts' => 'ee_edit_private_events', |
|
97 | - 'edit_published_posts' => 'ee_edit_published_events', |
|
98 | - ], |
|
99 | - 'taxonomies' => [ |
|
100 | - 'espresso_event_categories', |
|
101 | - 'espresso_event_type', |
|
102 | - 'post_tag', |
|
103 | - ], |
|
104 | - 'page_templates' => true, |
|
105 | - ], |
|
106 | - ], |
|
107 | - EspressoPostType::VENUES => [ |
|
108 | - 'singular_name' => esc_html__('Venue', 'event_espresso'), |
|
109 | - 'plural_name' => esc_html__('Venues', 'event_espresso'), |
|
110 | - 'singular_slug' => esc_html__('venue', 'event_espresso'), |
|
111 | - 'plural_slug' => esc_html__('venues', 'event_espresso'), |
|
112 | - 'class_name' => 'EE_Venue', |
|
113 | - 'model_name' => 'EEM_Venue', |
|
114 | - 'args' => [ |
|
115 | - 'public' => true, |
|
116 | - 'show_in_nav_menus' => false, // by default this doesn't show for decaf, |
|
117 | - 'show_in_graphql' => true, |
|
118 | - 'graphql_single_name' => $this->namespace . 'Venue', |
|
119 | - 'graphql_plural_name' => $this->namespace . 'Venues', |
|
120 | - 'capability_type' => 'venue', |
|
121 | - 'capabilities' => [ |
|
122 | - 'edit_post' => 'ee_edit_venue', |
|
123 | - 'read_post' => 'ee_read_venue', |
|
124 | - 'delete_post' => 'ee_delete_venue', |
|
125 | - 'edit_posts' => 'ee_edit_venues', |
|
126 | - 'edit_others_posts' => 'ee_edit_others_venues', |
|
127 | - 'publish_posts' => 'ee_publish_venues', |
|
128 | - 'read_private_posts' => 'ee_read_private_venues', |
|
129 | - 'delete_posts' => 'ee_delete_venues', |
|
130 | - 'delete_private_posts' => 'ee_delete_private_venues', |
|
131 | - 'delete_published_posts' => 'ee_delete_published_venues', |
|
132 | - 'delete_others_posts' => 'ee_edit_others_venues', |
|
133 | - 'edit_private_posts' => 'ee_edit_private_venues', |
|
134 | - 'edit_published_posts' => 'ee_edit_published_venues', |
|
135 | - ], |
|
136 | - 'taxonomies' => [ |
|
137 | - 'espresso_venue_categories', |
|
138 | - 'post_tag', |
|
139 | - ], |
|
140 | - 'page_templates' => true, |
|
141 | - ], |
|
142 | - ], |
|
143 | - EspressoPostType::ATTENDEES => [ |
|
144 | - 'singular_name' => esc_html__('Contact', 'event_espresso'), |
|
145 | - 'plural_name' => esc_html__('Contacts', 'event_espresso'), |
|
146 | - 'singular_slug' => esc_html__('contact', 'event_espresso'), |
|
147 | - 'plural_slug' => esc_html__('contacts', 'event_espresso'), |
|
148 | - 'class_name' => 'EE_Attendee', |
|
149 | - 'model_name' => 'EEM_Attendee', |
|
150 | - 'args' => [ |
|
151 | - 'public' => false, |
|
152 | - 'publicly_queryable' => false, |
|
153 | - 'hierarchical' => false, |
|
154 | - 'has_archive' => false, |
|
155 | - 'supports' => [ |
|
156 | - 'editor', |
|
157 | - 'thumbnail', |
|
158 | - 'excerpt', |
|
159 | - 'custom-fields', |
|
160 | - 'comments', |
|
161 | - ], |
|
162 | - 'taxonomies' => ['post_tag'], |
|
163 | - 'capability_type' => 'contact', |
|
164 | - 'capabilities' => [ |
|
165 | - 'edit_post' => 'ee_edit_contact', |
|
166 | - 'read_post' => 'ee_read_contact', |
|
167 | - 'delete_post' => 'ee_delete_contact', |
|
168 | - 'edit_posts' => 'ee_edit_contacts', |
|
169 | - 'edit_others_posts' => 'ee_edit_contacts', |
|
170 | - 'publish_posts' => 'ee_edit_contacts', |
|
171 | - 'read_private_posts' => 'ee_edit_contacts', |
|
172 | - 'delete_posts' => 'ee_delete_contacts', |
|
173 | - 'delete_private_posts' => 'ee_delete_contacts', |
|
174 | - 'delete_published_posts' => 'ee_delete_contacts', |
|
175 | - 'delete_others_posts' => 'ee_delete_contacts', |
|
176 | - 'edit_private_posts' => 'ee_edit_contacts', |
|
177 | - 'edit_published_posts' => 'ee_edit_contacts', |
|
178 | - ], |
|
179 | - ], |
|
180 | - ], |
|
181 | - ] |
|
182 | - ) |
|
183 | - ); |
|
184 | - } |
|
54 | + /** |
|
55 | + * defines Espresso Custom Post Types |
|
56 | + * NOTE the ['args']['page_templates'] array index is something specific to our CPTs |
|
57 | + * and not part of the WP custom post type api. |
|
58 | + * |
|
59 | + * @return void |
|
60 | + */ |
|
61 | + private function setDefinitions() |
|
62 | + { |
|
63 | + $this->custom_post_types = (array) apply_filters( |
|
64 | + 'FHEE__EventEspresso_core_domain_entities_custom_post_types_CustomPostTypeDefinitions__getCustomPostTypes', |
|
65 | + // legacy filter applied for now, |
|
66 | + // later on we'll run a has_filter($tag) check and throw a doing_it_wrong() notice |
|
67 | + apply_filters( |
|
68 | + 'FHEE__EE_Register_CPTs__get_CPTs__cpts', |
|
69 | + [ |
|
70 | + EspressoPostType::EVENTS => [ |
|
71 | + 'singular_name' => esc_html__('Event', 'event_espresso'), |
|
72 | + 'plural_name' => esc_html__('Events', 'event_espresso'), |
|
73 | + 'singular_slug' => esc_html__('event', 'event_espresso'), |
|
74 | + 'plural_slug' => $this->core_config->event_cpt_slug, |
|
75 | + 'class_name' => 'EE_Event', |
|
76 | + 'model_name' => 'EEM_Event', |
|
77 | + 'args' => [ |
|
78 | + 'public' => true, |
|
79 | + 'show_in_nav_menus' => true, |
|
80 | + 'show_in_graphql' => true, |
|
81 | + 'graphql_single_name' => $this->namespace . 'Event', |
|
82 | + 'graphql_plural_name' => $this->namespace . 'Events', |
|
83 | + 'capability_type' => 'event', |
|
84 | + 'capabilities' => [ |
|
85 | + 'edit_post' => 'ee_edit_event', |
|
86 | + 'read_post' => 'ee_read_event', |
|
87 | + 'delete_post' => 'ee_delete_event', |
|
88 | + 'edit_posts' => 'ee_edit_events', |
|
89 | + 'edit_others_posts' => 'ee_edit_others_events', |
|
90 | + 'publish_posts' => 'ee_publish_events', |
|
91 | + 'read_private_posts' => 'ee_read_private_events', |
|
92 | + 'delete_posts' => 'ee_delete_events', |
|
93 | + 'delete_private_posts' => 'ee_delete_private_events', |
|
94 | + 'delete_published_posts' => 'ee_delete_published_events', |
|
95 | + 'delete_others_posts' => 'ee_delete_others_events', |
|
96 | + 'edit_private_posts' => 'ee_edit_private_events', |
|
97 | + 'edit_published_posts' => 'ee_edit_published_events', |
|
98 | + ], |
|
99 | + 'taxonomies' => [ |
|
100 | + 'espresso_event_categories', |
|
101 | + 'espresso_event_type', |
|
102 | + 'post_tag', |
|
103 | + ], |
|
104 | + 'page_templates' => true, |
|
105 | + ], |
|
106 | + ], |
|
107 | + EspressoPostType::VENUES => [ |
|
108 | + 'singular_name' => esc_html__('Venue', 'event_espresso'), |
|
109 | + 'plural_name' => esc_html__('Venues', 'event_espresso'), |
|
110 | + 'singular_slug' => esc_html__('venue', 'event_espresso'), |
|
111 | + 'plural_slug' => esc_html__('venues', 'event_espresso'), |
|
112 | + 'class_name' => 'EE_Venue', |
|
113 | + 'model_name' => 'EEM_Venue', |
|
114 | + 'args' => [ |
|
115 | + 'public' => true, |
|
116 | + 'show_in_nav_menus' => false, // by default this doesn't show for decaf, |
|
117 | + 'show_in_graphql' => true, |
|
118 | + 'graphql_single_name' => $this->namespace . 'Venue', |
|
119 | + 'graphql_plural_name' => $this->namespace . 'Venues', |
|
120 | + 'capability_type' => 'venue', |
|
121 | + 'capabilities' => [ |
|
122 | + 'edit_post' => 'ee_edit_venue', |
|
123 | + 'read_post' => 'ee_read_venue', |
|
124 | + 'delete_post' => 'ee_delete_venue', |
|
125 | + 'edit_posts' => 'ee_edit_venues', |
|
126 | + 'edit_others_posts' => 'ee_edit_others_venues', |
|
127 | + 'publish_posts' => 'ee_publish_venues', |
|
128 | + 'read_private_posts' => 'ee_read_private_venues', |
|
129 | + 'delete_posts' => 'ee_delete_venues', |
|
130 | + 'delete_private_posts' => 'ee_delete_private_venues', |
|
131 | + 'delete_published_posts' => 'ee_delete_published_venues', |
|
132 | + 'delete_others_posts' => 'ee_edit_others_venues', |
|
133 | + 'edit_private_posts' => 'ee_edit_private_venues', |
|
134 | + 'edit_published_posts' => 'ee_edit_published_venues', |
|
135 | + ], |
|
136 | + 'taxonomies' => [ |
|
137 | + 'espresso_venue_categories', |
|
138 | + 'post_tag', |
|
139 | + ], |
|
140 | + 'page_templates' => true, |
|
141 | + ], |
|
142 | + ], |
|
143 | + EspressoPostType::ATTENDEES => [ |
|
144 | + 'singular_name' => esc_html__('Contact', 'event_espresso'), |
|
145 | + 'plural_name' => esc_html__('Contacts', 'event_espresso'), |
|
146 | + 'singular_slug' => esc_html__('contact', 'event_espresso'), |
|
147 | + 'plural_slug' => esc_html__('contacts', 'event_espresso'), |
|
148 | + 'class_name' => 'EE_Attendee', |
|
149 | + 'model_name' => 'EEM_Attendee', |
|
150 | + 'args' => [ |
|
151 | + 'public' => false, |
|
152 | + 'publicly_queryable' => false, |
|
153 | + 'hierarchical' => false, |
|
154 | + 'has_archive' => false, |
|
155 | + 'supports' => [ |
|
156 | + 'editor', |
|
157 | + 'thumbnail', |
|
158 | + 'excerpt', |
|
159 | + 'custom-fields', |
|
160 | + 'comments', |
|
161 | + ], |
|
162 | + 'taxonomies' => ['post_tag'], |
|
163 | + 'capability_type' => 'contact', |
|
164 | + 'capabilities' => [ |
|
165 | + 'edit_post' => 'ee_edit_contact', |
|
166 | + 'read_post' => 'ee_read_contact', |
|
167 | + 'delete_post' => 'ee_delete_contact', |
|
168 | + 'edit_posts' => 'ee_edit_contacts', |
|
169 | + 'edit_others_posts' => 'ee_edit_contacts', |
|
170 | + 'publish_posts' => 'ee_edit_contacts', |
|
171 | + 'read_private_posts' => 'ee_edit_contacts', |
|
172 | + 'delete_posts' => 'ee_delete_contacts', |
|
173 | + 'delete_private_posts' => 'ee_delete_contacts', |
|
174 | + 'delete_published_posts' => 'ee_delete_contacts', |
|
175 | + 'delete_others_posts' => 'ee_delete_contacts', |
|
176 | + 'edit_private_posts' => 'ee_edit_contacts', |
|
177 | + 'edit_published_posts' => 'ee_edit_contacts', |
|
178 | + ], |
|
179 | + ], |
|
180 | + ], |
|
181 | + ] |
|
182 | + ) |
|
183 | + ); |
|
184 | + } |
|
185 | 185 | |
186 | 186 | |
187 | - /** |
|
188 | - * @return array |
|
189 | - */ |
|
190 | - public function getDefinitions() |
|
191 | - { |
|
192 | - return $this->custom_post_types; |
|
193 | - } |
|
187 | + /** |
|
188 | + * @return array |
|
189 | + */ |
|
190 | + public function getDefinitions() |
|
191 | + { |
|
192 | + return $this->custom_post_types; |
|
193 | + } |
|
194 | 194 | |
195 | 195 | |
196 | - /** |
|
197 | - * @return array |
|
198 | - */ |
|
199 | - public function getCustomPostTypeSlugs() |
|
200 | - { |
|
201 | - return array_keys($this->getDefinitions()); |
|
202 | - } |
|
196 | + /** |
|
197 | + * @return array |
|
198 | + */ |
|
199 | + public function getCustomPostTypeSlugs() |
|
200 | + { |
|
201 | + return array_keys($this->getDefinitions()); |
|
202 | + } |
|
203 | 203 | |
204 | 204 | |
205 | - /** |
|
206 | - * This basically goes through the CPT array and returns only CPT's |
|
207 | - * that have the ['args']['public'] option set as false |
|
208 | - * |
|
209 | - * @return array |
|
210 | - */ |
|
211 | - public function getPrivateCustomPostTypes() |
|
212 | - { |
|
213 | - $private_CPTs = []; |
|
214 | - foreach ($this->getDefinitions() as $CPT => $details) { |
|
215 | - if (empty($details['args']['public'])) { |
|
216 | - $private_CPTs[ $CPT ] = $details; |
|
217 | - } |
|
218 | - } |
|
219 | - return $private_CPTs; |
|
220 | - } |
|
205 | + /** |
|
206 | + * This basically goes through the CPT array and returns only CPT's |
|
207 | + * that have the ['args']['public'] option set as false |
|
208 | + * |
|
209 | + * @return array |
|
210 | + */ |
|
211 | + public function getPrivateCustomPostTypes() |
|
212 | + { |
|
213 | + $private_CPTs = []; |
|
214 | + foreach ($this->getDefinitions() as $CPT => $details) { |
|
215 | + if (empty($details['args']['public'])) { |
|
216 | + $private_CPTs[ $CPT ] = $details; |
|
217 | + } |
|
218 | + } |
|
219 | + return $private_CPTs; |
|
220 | + } |
|
221 | 221 | |
222 | 222 | |
223 | - /** |
|
224 | - * This returns the corresponding model name for cpts registered by EE. |
|
225 | - * |
|
226 | - * @param string $post_type_slug If a slug is included, then attempt to retrieve |
|
227 | - * the model name for the given cpt slug. |
|
228 | - * Otherwise if empty, then we'll return |
|
229 | - * all cpt model names for cpts registered in EE. |
|
230 | - * @return array Empty array if no matching model names for the given slug |
|
231 | - * or an array of model names indexed by post type slug. |
|
232 | - */ |
|
233 | - public function getCustomPostTypeModelNames($post_type_slug = '') |
|
234 | - { |
|
235 | - $cpts = $this->getDefinitions(); |
|
236 | - // first if slug passed in... |
|
237 | - if (! empty($post_type_slug)) { |
|
238 | - // check that slug and cpt match |
|
239 | - if (! isset($cpts[ $post_type_slug ])) { |
|
240 | - return []; |
|
241 | - } |
|
242 | - if ( |
|
243 | - empty($cpts[ $post_type_slug ]['class_name']) |
|
244 | - && empty($cpts[ $post_type_slug ]['model_name']) |
|
245 | - ) { |
|
246 | - return []; |
|
247 | - } |
|
248 | - // k let's get the model name for this cpt. |
|
249 | - return $this->getCustomPostTypeModelName($post_type_slug, $cpts[ $post_type_slug ]); |
|
250 | - } |
|
251 | - // if we made it here then we're returning an array of cpt model names indexed by post_type_slug. |
|
252 | - $cpt_models = []; |
|
253 | - foreach ($cpts as $slug => $args) { |
|
254 | - $model = $this->getCustomPostTypeModelName($slug, $args); |
|
255 | - if (! empty($model)) { |
|
256 | - $cpt_models[ $slug ] = $model; |
|
257 | - } |
|
258 | - } |
|
259 | - return $cpt_models; |
|
260 | - } |
|
223 | + /** |
|
224 | + * This returns the corresponding model name for cpts registered by EE. |
|
225 | + * |
|
226 | + * @param string $post_type_slug If a slug is included, then attempt to retrieve |
|
227 | + * the model name for the given cpt slug. |
|
228 | + * Otherwise if empty, then we'll return |
|
229 | + * all cpt model names for cpts registered in EE. |
|
230 | + * @return array Empty array if no matching model names for the given slug |
|
231 | + * or an array of model names indexed by post type slug. |
|
232 | + */ |
|
233 | + public function getCustomPostTypeModelNames($post_type_slug = '') |
|
234 | + { |
|
235 | + $cpts = $this->getDefinitions(); |
|
236 | + // first if slug passed in... |
|
237 | + if (! empty($post_type_slug)) { |
|
238 | + // check that slug and cpt match |
|
239 | + if (! isset($cpts[ $post_type_slug ])) { |
|
240 | + return []; |
|
241 | + } |
|
242 | + if ( |
|
243 | + empty($cpts[ $post_type_slug ]['class_name']) |
|
244 | + && empty($cpts[ $post_type_slug ]['model_name']) |
|
245 | + ) { |
|
246 | + return []; |
|
247 | + } |
|
248 | + // k let's get the model name for this cpt. |
|
249 | + return $this->getCustomPostTypeModelName($post_type_slug, $cpts[ $post_type_slug ]); |
|
250 | + } |
|
251 | + // if we made it here then we're returning an array of cpt model names indexed by post_type_slug. |
|
252 | + $cpt_models = []; |
|
253 | + foreach ($cpts as $slug => $args) { |
|
254 | + $model = $this->getCustomPostTypeModelName($slug, $args); |
|
255 | + if (! empty($model)) { |
|
256 | + $cpt_models[ $slug ] = $model; |
|
257 | + } |
|
258 | + } |
|
259 | + return $cpt_models; |
|
260 | + } |
|
261 | 261 | |
262 | 262 | |
263 | - /** |
|
264 | - * @param $post_type_slug |
|
265 | - * @param array $cpt |
|
266 | - * @return array |
|
267 | - */ |
|
268 | - private function getCustomPostTypeModelName($post_type_slug, array $cpt) |
|
269 | - { |
|
270 | - if (! empty($cpt['model_name'])) { |
|
271 | - return [$post_type_slug => $cpt['model_name']]; |
|
272 | - } |
|
273 | - if (! empty($cpt['class_name'])) { |
|
274 | - return [ |
|
275 | - $post_type_slug => $this->deriveCptModelNameFromClassName($cpt['class_name']), |
|
276 | - ]; |
|
277 | - } |
|
278 | - return []; |
|
279 | - } |
|
263 | + /** |
|
264 | + * @param $post_type_slug |
|
265 | + * @param array $cpt |
|
266 | + * @return array |
|
267 | + */ |
|
268 | + private function getCustomPostTypeModelName($post_type_slug, array $cpt) |
|
269 | + { |
|
270 | + if (! empty($cpt['model_name'])) { |
|
271 | + return [$post_type_slug => $cpt['model_name']]; |
|
272 | + } |
|
273 | + if (! empty($cpt['class_name'])) { |
|
274 | + return [ |
|
275 | + $post_type_slug => $this->deriveCptModelNameFromClassName($cpt['class_name']), |
|
276 | + ]; |
|
277 | + } |
|
278 | + return []; |
|
279 | + } |
|
280 | 280 | |
281 | 281 | |
282 | - /** |
|
283 | - * @param string $class_name |
|
284 | - * @return string |
|
285 | - */ |
|
286 | - private function deriveCptModelNameFromClassName($class_name) |
|
287 | - { |
|
288 | - return str_replace('EE', 'EEM', $class_name); |
|
289 | - } |
|
282 | + /** |
|
283 | + * @param string $class_name |
|
284 | + * @return string |
|
285 | + */ |
|
286 | + private function deriveCptModelNameFromClassName($class_name) |
|
287 | + { |
|
288 | + return str_replace('EE', 'EEM', $class_name); |
|
289 | + } |
|
290 | 290 | |
291 | 291 | |
292 | - /** |
|
293 | - * This instantiates cpt models related to the cpts registered via EE. |
|
294 | - * |
|
295 | - * @param string $post_type_slug If valid slug is provided, then will instantiate the model only for |
|
296 | - * the cpt matching the given slug. Otherwise all cpt models will be |
|
297 | - * instantiated (if possible). |
|
298 | - * @return EEM_CPT_Base[] successful instantiation will return an array of successfully instantiated |
|
299 | - * EEM models indexed by post slug. |
|
300 | - * @since 4.6.16.rc.000 |
|
301 | - */ |
|
302 | - public function getCustomPostTypeModels($post_type_slug = '') |
|
303 | - { |
|
304 | - $cpt_model_names = $this->getCustomPostTypeModelNames($post_type_slug); |
|
305 | - $instantiated = []; |
|
306 | - foreach ($cpt_model_names as $slug => $model_name) { |
|
307 | - $model = $this->loader->getShared($model_name); |
|
308 | - if ($model instanceof EEM_CPT_Base) { |
|
309 | - $instantiated[ $slug ] = $model; |
|
310 | - } |
|
311 | - } |
|
312 | - return $instantiated; |
|
313 | - } |
|
292 | + /** |
|
293 | + * This instantiates cpt models related to the cpts registered via EE. |
|
294 | + * |
|
295 | + * @param string $post_type_slug If valid slug is provided, then will instantiate the model only for |
|
296 | + * the cpt matching the given slug. Otherwise all cpt models will be |
|
297 | + * instantiated (if possible). |
|
298 | + * @return EEM_CPT_Base[] successful instantiation will return an array of successfully instantiated |
|
299 | + * EEM models indexed by post slug. |
|
300 | + * @since 4.6.16.rc.000 |
|
301 | + */ |
|
302 | + public function getCustomPostTypeModels($post_type_slug = '') |
|
303 | + { |
|
304 | + $cpt_model_names = $this->getCustomPostTypeModelNames($post_type_slug); |
|
305 | + $instantiated = []; |
|
306 | + foreach ($cpt_model_names as $slug => $model_name) { |
|
307 | + $model = $this->loader->getShared($model_name); |
|
308 | + if ($model instanceof EEM_CPT_Base) { |
|
309 | + $instantiated[ $slug ] = $model; |
|
310 | + } |
|
311 | + } |
|
312 | + return $instantiated; |
|
313 | + } |
|
314 | 314 | } |
@@ -4,10 +4,10 @@ |
||
4 | 4 | |
5 | 5 | class EspressoPostType |
6 | 6 | { |
7 | - public const EVENTS = 'espresso_events'; |
|
7 | + public const EVENTS = 'espresso_events'; |
|
8 | 8 | |
9 | - public const VENUES = 'espresso_venues'; |
|
9 | + public const VENUES = 'espresso_venues'; |
|
10 | 10 | |
11 | - public const ATTENDEES = 'espresso_attendees'; |
|
11 | + public const ATTENDEES = 'espresso_attendees'; |
|
12 | 12 | |
13 | 13 | } |
@@ -20,51 +20,51 @@ |
||
20 | 20 | */ |
21 | 21 | class EventEditor extends JsonDataNode |
22 | 22 | { |
23 | - const NODE_NAME = 'eventEditor'; |
|
23 | + const NODE_NAME = 'eventEditor'; |
|
24 | 24 | |
25 | 25 | |
26 | - /** |
|
27 | - * @var EventEditorGraphQLData |
|
28 | - */ |
|
29 | - protected $event_editor_gql_data; |
|
26 | + /** |
|
27 | + * @var EventEditorGraphQLData |
|
28 | + */ |
|
29 | + protected $event_editor_gql_data; |
|
30 | 30 | |
31 | 31 | |
32 | - /** |
|
33 | - * EventEditor JsonDataNode constructor. |
|
34 | - * |
|
35 | - * @param EventEditorGraphQLData $event_editor_gql_data |
|
36 | - * @param JsonDataNodeValidator $validator |
|
37 | - */ |
|
38 | - public function __construct( |
|
39 | - EventEditorGraphQLData $event_editor_gql_data, |
|
40 | - JsonDataNodeValidator $validator |
|
41 | - ) { |
|
42 | - parent::__construct($validator); |
|
43 | - $this->event_editor_gql_data = $event_editor_gql_data; |
|
44 | - $this->setDomain(EventEditor::NODE_NAME); |
|
45 | - $this->setNodeName(EventEditor::NODE_NAME); |
|
46 | - } |
|
32 | + /** |
|
33 | + * EventEditor JsonDataNode constructor. |
|
34 | + * |
|
35 | + * @param EventEditorGraphQLData $event_editor_gql_data |
|
36 | + * @param JsonDataNodeValidator $validator |
|
37 | + */ |
|
38 | + public function __construct( |
|
39 | + EventEditorGraphQLData $event_editor_gql_data, |
|
40 | + JsonDataNodeValidator $validator |
|
41 | + ) { |
|
42 | + parent::__construct($validator); |
|
43 | + $this->event_editor_gql_data = $event_editor_gql_data; |
|
44 | + $this->setDomain(EventEditor::NODE_NAME); |
|
45 | + $this->setNodeName(EventEditor::NODE_NAME); |
|
46 | + } |
|
47 | 47 | |
48 | 48 | |
49 | - /** |
|
50 | - * @throws EE_Error |
|
51 | - * @throws ReflectionException |
|
52 | - * @since 5.0.0.p |
|
53 | - */ |
|
54 | - public function initialize() |
|
55 | - { |
|
56 | - global $post; |
|
57 | - $eventId = isset($_REQUEST['post']) ? absint($_REQUEST['post']) : 0; |
|
58 | - // if there's no event ID but there IS a WP Post... then use the Post ID |
|
59 | - $use_post_id = $eventId === 0 && $post instanceof WP_Post && $post->post_type === EspressoPostType::EVENTS; |
|
60 | - $eventId = $use_post_id ? $post->ID : $eventId; |
|
61 | - $related_data = apply_filters( |
|
62 | - 'FHEE__EventEspresso_core_domain_entities_routing_data_nodes_domains_EventEditor__initialize__related_data', |
|
63 | - $this->event_editor_gql_data->getData($eventId), |
|
64 | - $eventId |
|
65 | - ); |
|
66 | - foreach ($related_data as $key => $value) { |
|
67 | - $this->addData($key, $value); |
|
68 | - } |
|
69 | - } |
|
49 | + /** |
|
50 | + * @throws EE_Error |
|
51 | + * @throws ReflectionException |
|
52 | + * @since 5.0.0.p |
|
53 | + */ |
|
54 | + public function initialize() |
|
55 | + { |
|
56 | + global $post; |
|
57 | + $eventId = isset($_REQUEST['post']) ? absint($_REQUEST['post']) : 0; |
|
58 | + // if there's no event ID but there IS a WP Post... then use the Post ID |
|
59 | + $use_post_id = $eventId === 0 && $post instanceof WP_Post && $post->post_type === EspressoPostType::EVENTS; |
|
60 | + $eventId = $use_post_id ? $post->ID : $eventId; |
|
61 | + $related_data = apply_filters( |
|
62 | + 'FHEE__EventEspresso_core_domain_entities_routing_data_nodes_domains_EventEditor__initialize__related_data', |
|
63 | + $this->event_editor_gql_data->getData($eventId), |
|
64 | + $eventId |
|
65 | + ); |
|
66 | + foreach ($related_data as $key => $value) { |
|
67 | + $this->addData($key, $value); |
|
68 | + } |
|
69 | + } |
|
70 | 70 | } |