@@ -14,263 +14,263 @@ |
||
14 | 14 | class EEM_Term extends EEM_Base |
15 | 15 | { |
16 | 16 | |
17 | - // private instance of the Attendee object |
|
18 | - protected static $_instance = null; |
|
17 | + // private instance of the Attendee object |
|
18 | + protected static $_instance = null; |
|
19 | 19 | |
20 | 20 | |
21 | 21 | |
22 | - /** |
|
23 | - *__construct |
|
24 | - * |
|
25 | - * @param string $timezone |
|
26 | - */ |
|
27 | - protected function __construct($timezone = null) |
|
28 | - { |
|
29 | - $this->singular_item = __('Term', 'event_espresso'); |
|
30 | - $this->plural_item = __('Terms', 'event_espresso'); |
|
31 | - $this->_tables = array( |
|
32 | - 'Term' => new EE_Primary_Table('terms', 'term_id'), |
|
33 | - ); |
|
34 | - $this->_fields = array( |
|
35 | - 'Term' => array( |
|
36 | - 'term_id' => new EE_Primary_Key_Int_Field('term_id', __('Term ID', 'event_espresso')), |
|
37 | - 'name' => new EE_Plain_Text_Field('name', __('Term Name', 'event_espresso'), false, ''), |
|
38 | - 'slug' => new EE_Slug_Field('slug', __('Term Slug', 'event_espresso'), false), |
|
39 | - 'term_group' => new EE_Integer_Field('term_group', __("Term Group", "event_espresso"), false, 0), |
|
40 | - ), |
|
41 | - ); |
|
42 | - $this->_model_relations = array( |
|
43 | - 'Term_Taxonomy' => new EE_Has_Many_Relation(), |
|
44 | - ); |
|
45 | - $this->_wp_core_model = true; |
|
46 | - $path_to_tax_model = 'Term_Taxonomy'; |
|
47 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public(); |
|
48 | - $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Taxonomy_Protected( |
|
49 | - $path_to_tax_model |
|
50 | - ); |
|
51 | - $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = false; |
|
52 | - $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = false; |
|
53 | - $path_to_tax_model = $path_to_tax_model . '.'; |
|
54 | - // add cap restrictions for editing relating to the "ee_edit_*" |
|
55 | - $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_event_category'] = new EE_Default_Where_Conditions( |
|
56 | - array( |
|
57 | - $path_to_tax_model . 'taxonomy*ee_edit_event_category' => array('!=', 'espresso_event_categories'), |
|
58 | - ) |
|
59 | - ); |
|
60 | - $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_venue_category'] = new EE_Default_Where_Conditions( |
|
61 | - array( |
|
62 | - $path_to_tax_model . 'taxonomy*ee_edit_venue_category' => array('!=', 'espresso_venue_categories'), |
|
63 | - ) |
|
64 | - ); |
|
65 | - $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_event_type'] = new EE_Default_Where_Conditions( |
|
66 | - array( |
|
67 | - $path_to_tax_model . 'taxonomy*ee_edit_event_type' => array('!=', 'espresso_event_type'), |
|
68 | - ) |
|
69 | - ); |
|
70 | - // add cap restrictions for deleting relating to the "ee_deleting_*" |
|
71 | - $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_event_category'] = new EE_Default_Where_Conditions( |
|
72 | - array( |
|
73 | - $path_to_tax_model . 'taxonomy*ee_delete_event_category' => array('!=', 'espresso_event_categories'), |
|
74 | - ) |
|
75 | - ); |
|
76 | - $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_venue_category'] = new EE_Default_Where_Conditions( |
|
77 | - array( |
|
78 | - $path_to_tax_model . 'taxonomy*ee_delete_venue_category' => array('!=', 'espresso_venue_categories'), |
|
79 | - ) |
|
80 | - ); |
|
81 | - $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_event_type'] = new EE_Default_Where_Conditions( |
|
82 | - array( |
|
83 | - $path_to_tax_model . 'taxonomy*ee_delete_event_type' => array('!=', 'espresso_event_type'), |
|
84 | - ) |
|
85 | - ); |
|
86 | - parent::__construct($timezone); |
|
87 | - add_filter('FHEE__Read__create_model_query_params', array('EEM_Term', 'rest_api_query_params'), 10, 3); |
|
88 | - } |
|
22 | + /** |
|
23 | + *__construct |
|
24 | + * |
|
25 | + * @param string $timezone |
|
26 | + */ |
|
27 | + protected function __construct($timezone = null) |
|
28 | + { |
|
29 | + $this->singular_item = __('Term', 'event_espresso'); |
|
30 | + $this->plural_item = __('Terms', 'event_espresso'); |
|
31 | + $this->_tables = array( |
|
32 | + 'Term' => new EE_Primary_Table('terms', 'term_id'), |
|
33 | + ); |
|
34 | + $this->_fields = array( |
|
35 | + 'Term' => array( |
|
36 | + 'term_id' => new EE_Primary_Key_Int_Field('term_id', __('Term ID', 'event_espresso')), |
|
37 | + 'name' => new EE_Plain_Text_Field('name', __('Term Name', 'event_espresso'), false, ''), |
|
38 | + 'slug' => new EE_Slug_Field('slug', __('Term Slug', 'event_espresso'), false), |
|
39 | + 'term_group' => new EE_Integer_Field('term_group', __("Term Group", "event_espresso"), false, 0), |
|
40 | + ), |
|
41 | + ); |
|
42 | + $this->_model_relations = array( |
|
43 | + 'Term_Taxonomy' => new EE_Has_Many_Relation(), |
|
44 | + ); |
|
45 | + $this->_wp_core_model = true; |
|
46 | + $path_to_tax_model = 'Term_Taxonomy'; |
|
47 | + $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public(); |
|
48 | + $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Taxonomy_Protected( |
|
49 | + $path_to_tax_model |
|
50 | + ); |
|
51 | + $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = false; |
|
52 | + $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = false; |
|
53 | + $path_to_tax_model = $path_to_tax_model . '.'; |
|
54 | + // add cap restrictions for editing relating to the "ee_edit_*" |
|
55 | + $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_event_category'] = new EE_Default_Where_Conditions( |
|
56 | + array( |
|
57 | + $path_to_tax_model . 'taxonomy*ee_edit_event_category' => array('!=', 'espresso_event_categories'), |
|
58 | + ) |
|
59 | + ); |
|
60 | + $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_venue_category'] = new EE_Default_Where_Conditions( |
|
61 | + array( |
|
62 | + $path_to_tax_model . 'taxonomy*ee_edit_venue_category' => array('!=', 'espresso_venue_categories'), |
|
63 | + ) |
|
64 | + ); |
|
65 | + $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_event_type'] = new EE_Default_Where_Conditions( |
|
66 | + array( |
|
67 | + $path_to_tax_model . 'taxonomy*ee_edit_event_type' => array('!=', 'espresso_event_type'), |
|
68 | + ) |
|
69 | + ); |
|
70 | + // add cap restrictions for deleting relating to the "ee_deleting_*" |
|
71 | + $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_event_category'] = new EE_Default_Where_Conditions( |
|
72 | + array( |
|
73 | + $path_to_tax_model . 'taxonomy*ee_delete_event_category' => array('!=', 'espresso_event_categories'), |
|
74 | + ) |
|
75 | + ); |
|
76 | + $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_venue_category'] = new EE_Default_Where_Conditions( |
|
77 | + array( |
|
78 | + $path_to_tax_model . 'taxonomy*ee_delete_venue_category' => array('!=', 'espresso_venue_categories'), |
|
79 | + ) |
|
80 | + ); |
|
81 | + $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_event_type'] = new EE_Default_Where_Conditions( |
|
82 | + array( |
|
83 | + $path_to_tax_model . 'taxonomy*ee_delete_event_type' => array('!=', 'espresso_event_type'), |
|
84 | + ) |
|
85 | + ); |
|
86 | + parent::__construct($timezone); |
|
87 | + add_filter('FHEE__Read__create_model_query_params', array('EEM_Term', 'rest_api_query_params'), 10, 3); |
|
88 | + } |
|
89 | 89 | |
90 | 90 | |
91 | 91 | |
92 | - /** |
|
93 | - * retrieves a list of all EE event categories |
|
94 | - * |
|
95 | - * @access public |
|
96 | - * @param bool $show_uncategorized |
|
97 | - * @return \EE_Base_Class[] |
|
98 | - */ |
|
99 | - public function get_all_ee_categories($show_uncategorized = false) |
|
100 | - { |
|
101 | - $where_params = array( |
|
102 | - 'Term_Taxonomy.taxonomy' => 'espresso_event_categories', |
|
103 | - 'NOT' => array('name' => __('Uncategorized', 'event_espresso')), |
|
104 | - ); |
|
105 | - if ($show_uncategorized) { |
|
106 | - unset($where_params['NOT']); |
|
107 | - } |
|
108 | - return EEM_Term::instance()->get_all( |
|
109 | - array( |
|
110 | - $where_params, |
|
111 | - 'order_by' => array('name' => 'ASC'), |
|
112 | - ) |
|
113 | - ); |
|
114 | - } |
|
92 | + /** |
|
93 | + * retrieves a list of all EE event categories |
|
94 | + * |
|
95 | + * @access public |
|
96 | + * @param bool $show_uncategorized |
|
97 | + * @return \EE_Base_Class[] |
|
98 | + */ |
|
99 | + public function get_all_ee_categories($show_uncategorized = false) |
|
100 | + { |
|
101 | + $where_params = array( |
|
102 | + 'Term_Taxonomy.taxonomy' => 'espresso_event_categories', |
|
103 | + 'NOT' => array('name' => __('Uncategorized', 'event_espresso')), |
|
104 | + ); |
|
105 | + if ($show_uncategorized) { |
|
106 | + unset($where_params['NOT']); |
|
107 | + } |
|
108 | + return EEM_Term::instance()->get_all( |
|
109 | + array( |
|
110 | + $where_params, |
|
111 | + 'order_by' => array('name' => 'ASC'), |
|
112 | + ) |
|
113 | + ); |
|
114 | + } |
|
115 | 115 | |
116 | 116 | |
117 | 117 | |
118 | - /** |
|
119 | - * retrieves a list of all post_tags associated with an EE CPT |
|
120 | - * |
|
121 | - * @access public |
|
122 | - * @param string $post_type |
|
123 | - * @return array |
|
124 | - */ |
|
125 | - public function get_all_CPT_post_tags($post_type = '') |
|
126 | - { |
|
127 | - switch ($post_type) { |
|
128 | - case 'espresso_events': |
|
129 | - return $this->get_all_event_post_tags(); |
|
130 | - break; |
|
131 | - case 'espresso_venues': |
|
132 | - return $this->get_all_venue_post_tags(); |
|
133 | - break; |
|
134 | - default: |
|
135 | - $event_tags = $this->get_all_event_post_tags(); |
|
136 | - $venue_tags = $this->get_all_venue_post_tags(); |
|
137 | - return array_merge($event_tags, $venue_tags); |
|
138 | - } |
|
139 | - } |
|
118 | + /** |
|
119 | + * retrieves a list of all post_tags associated with an EE CPT |
|
120 | + * |
|
121 | + * @access public |
|
122 | + * @param string $post_type |
|
123 | + * @return array |
|
124 | + */ |
|
125 | + public function get_all_CPT_post_tags($post_type = '') |
|
126 | + { |
|
127 | + switch ($post_type) { |
|
128 | + case 'espresso_events': |
|
129 | + return $this->get_all_event_post_tags(); |
|
130 | + break; |
|
131 | + case 'espresso_venues': |
|
132 | + return $this->get_all_venue_post_tags(); |
|
133 | + break; |
|
134 | + default: |
|
135 | + $event_tags = $this->get_all_event_post_tags(); |
|
136 | + $venue_tags = $this->get_all_venue_post_tags(); |
|
137 | + return array_merge($event_tags, $venue_tags); |
|
138 | + } |
|
139 | + } |
|
140 | 140 | |
141 | 141 | |
142 | - /** |
|
143 | - * returns an EE_Term object for the given tag |
|
144 | - * if it has been utilized by any EE_Events or EE_Venues |
|
145 | - * |
|
146 | - * @param string $tag |
|
147 | - * @return EE_Term|null |
|
148 | - * @throws EE_Error |
|
149 | - * @throws InvalidArgumentException |
|
150 | - * @throws InvalidDataTypeException |
|
151 | - * @throws InvalidInterfaceException |
|
152 | - */ |
|
153 | - public function get_post_tag_for_event_or_venue($tag) |
|
154 | - { |
|
155 | - $post_tag_results = $this->get_all_wpdb_results( |
|
156 | - array( |
|
157 | - array( |
|
158 | - 'slug' => $tag, |
|
159 | - 'Term_Taxonomy.taxonomy' => 'post_tag', |
|
160 | - 'OR' => array( |
|
161 | - 'Term_Taxonomy.Venue.post_type' => 'espresso_venues', |
|
162 | - 'Term_Taxonomy.Event.post_type' => 'espresso_events', |
|
163 | - ), |
|
164 | - ), |
|
165 | - 'default_where_conditions' => 'none', |
|
166 | - 'extra_selects' => array( |
|
167 | - 'event_post_type' => array('Term_Taxonomy___Event_CPT.post_type', '%s'), |
|
168 | - 'venue_post_type' => array('Term_Taxonomy___Venue_CPT.post_type', '%s') |
|
169 | - ), |
|
170 | - 'group_by' => array( |
|
171 | - 'event_post_type', |
|
172 | - 'venue_post_type', |
|
173 | - ), |
|
174 | - 'limit' => 2 |
|
175 | - ) |
|
176 | - ); |
|
142 | + /** |
|
143 | + * returns an EE_Term object for the given tag |
|
144 | + * if it has been utilized by any EE_Events or EE_Venues |
|
145 | + * |
|
146 | + * @param string $tag |
|
147 | + * @return EE_Term|null |
|
148 | + * @throws EE_Error |
|
149 | + * @throws InvalidArgumentException |
|
150 | + * @throws InvalidDataTypeException |
|
151 | + * @throws InvalidInterfaceException |
|
152 | + */ |
|
153 | + public function get_post_tag_for_event_or_venue($tag) |
|
154 | + { |
|
155 | + $post_tag_results = $this->get_all_wpdb_results( |
|
156 | + array( |
|
157 | + array( |
|
158 | + 'slug' => $tag, |
|
159 | + 'Term_Taxonomy.taxonomy' => 'post_tag', |
|
160 | + 'OR' => array( |
|
161 | + 'Term_Taxonomy.Venue.post_type' => 'espresso_venues', |
|
162 | + 'Term_Taxonomy.Event.post_type' => 'espresso_events', |
|
163 | + ), |
|
164 | + ), |
|
165 | + 'default_where_conditions' => 'none', |
|
166 | + 'extra_selects' => array( |
|
167 | + 'event_post_type' => array('Term_Taxonomy___Event_CPT.post_type', '%s'), |
|
168 | + 'venue_post_type' => array('Term_Taxonomy___Venue_CPT.post_type', '%s') |
|
169 | + ), |
|
170 | + 'group_by' => array( |
|
171 | + 'event_post_type', |
|
172 | + 'venue_post_type', |
|
173 | + ), |
|
174 | + 'limit' => 2 |
|
175 | + ) |
|
176 | + ); |
|
177 | 177 | |
178 | - $post_types = array(); |
|
179 | - foreach ((array) $post_tag_results as $row) { |
|
180 | - if ($row['event_post_type'] === 'espresso_events') { |
|
181 | - $post_types[] = EEM_Event::instance()->post_type(); |
|
182 | - } elseif ($row['venue_post_type'] === 'espresso_venues') { |
|
183 | - $post_types[] = EEM_Venue::instance()->post_type(); |
|
184 | - } |
|
185 | - } |
|
186 | - $post_tag_row = reset($post_tag_results); |
|
187 | - $post_tag = $this->instantiate_class_from_array_or_object($post_tag_row); |
|
188 | - if (! $post_tag instanceof EE_Term) { |
|
189 | - return null; |
|
190 | - } |
|
178 | + $post_types = array(); |
|
179 | + foreach ((array) $post_tag_results as $row) { |
|
180 | + if ($row['event_post_type'] === 'espresso_events') { |
|
181 | + $post_types[] = EEM_Event::instance()->post_type(); |
|
182 | + } elseif ($row['venue_post_type'] === 'espresso_venues') { |
|
183 | + $post_types[] = EEM_Venue::instance()->post_type(); |
|
184 | + } |
|
185 | + } |
|
186 | + $post_tag_row = reset($post_tag_results); |
|
187 | + $post_tag = $this->instantiate_class_from_array_or_object($post_tag_row); |
|
188 | + if (! $post_tag instanceof EE_Term) { |
|
189 | + return null; |
|
190 | + } |
|
191 | 191 | |
192 | - if ($post_tag->post_type === null) { |
|
193 | - $post_tag->post_type = array(); |
|
194 | - } |
|
195 | - $post_tag->post_type = array_merge($post_tag->post_type, array_unique($post_types)); |
|
196 | - return $post_tag; |
|
197 | - } |
|
192 | + if ($post_tag->post_type === null) { |
|
193 | + $post_tag->post_type = array(); |
|
194 | + } |
|
195 | + $post_tag->post_type = array_merge($post_tag->post_type, array_unique($post_types)); |
|
196 | + return $post_tag; |
|
197 | + } |
|
198 | 198 | |
199 | 199 | |
200 | 200 | |
201 | - /** |
|
202 | - * get_all_event_post_tags |
|
203 | - * |
|
204 | - * @return EE_Base_Class[] |
|
205 | - */ |
|
206 | - public function get_all_event_post_tags() |
|
207 | - { |
|
208 | - $post_tags = EEM_Term::instance()->get_all( |
|
209 | - array( |
|
210 | - array( |
|
211 | - 'Term_Taxonomy.taxonomy' => 'post_tag', |
|
212 | - 'Term_Taxonomy.Event.post_type' => 'espresso_events', |
|
213 | - ), |
|
214 | - 'order_by' => array('name' => 'ASC'), |
|
215 | - 'force_join' => array('Term_Taxonomy.Event'), |
|
216 | - ) |
|
217 | - ); |
|
218 | - foreach ($post_tags as $key => $post_tag) { |
|
219 | - if (! isset($post_tags[ $key ]->post_type)) { |
|
220 | - $post_tags[ $key ]->post_type = array(); |
|
221 | - } |
|
222 | - $post_tags[ $key ]->post_type[] = 'espresso_events'; |
|
223 | - } |
|
224 | - return $post_tags; |
|
225 | - } |
|
201 | + /** |
|
202 | + * get_all_event_post_tags |
|
203 | + * |
|
204 | + * @return EE_Base_Class[] |
|
205 | + */ |
|
206 | + public function get_all_event_post_tags() |
|
207 | + { |
|
208 | + $post_tags = EEM_Term::instance()->get_all( |
|
209 | + array( |
|
210 | + array( |
|
211 | + 'Term_Taxonomy.taxonomy' => 'post_tag', |
|
212 | + 'Term_Taxonomy.Event.post_type' => 'espresso_events', |
|
213 | + ), |
|
214 | + 'order_by' => array('name' => 'ASC'), |
|
215 | + 'force_join' => array('Term_Taxonomy.Event'), |
|
216 | + ) |
|
217 | + ); |
|
218 | + foreach ($post_tags as $key => $post_tag) { |
|
219 | + if (! isset($post_tags[ $key ]->post_type)) { |
|
220 | + $post_tags[ $key ]->post_type = array(); |
|
221 | + } |
|
222 | + $post_tags[ $key ]->post_type[] = 'espresso_events'; |
|
223 | + } |
|
224 | + return $post_tags; |
|
225 | + } |
|
226 | 226 | |
227 | 227 | |
228 | 228 | |
229 | - /** |
|
230 | - * get_all_venue_post_tags |
|
231 | - * |
|
232 | - * @return EE_Base_Class[] |
|
233 | - */ |
|
234 | - public function get_all_venue_post_tags() |
|
235 | - { |
|
236 | - $post_tags = EEM_Term::instance()->get_all( |
|
237 | - array( |
|
238 | - array( |
|
239 | - 'Term_Taxonomy.taxonomy' => 'post_tag', |
|
240 | - 'Term_Taxonomy.Venue.post_type' => 'espresso_venues', |
|
241 | - ), |
|
242 | - 'order_by' => array('name' => 'ASC'), |
|
243 | - 'force_join' => array('Term_Taxonomy'), |
|
244 | - ) |
|
245 | - ); |
|
246 | - foreach ($post_tags as $key => $post_tag) { |
|
247 | - if (! isset($post_tags[ $key ]->post_type)) { |
|
248 | - $post_tags[ $key ]->post_type = array(); |
|
249 | - } |
|
250 | - $post_tags[ $key ]->post_type[] = 'espresso_venues'; |
|
251 | - } |
|
252 | - return $post_tags; |
|
253 | - } |
|
229 | + /** |
|
230 | + * get_all_venue_post_tags |
|
231 | + * |
|
232 | + * @return EE_Base_Class[] |
|
233 | + */ |
|
234 | + public function get_all_venue_post_tags() |
|
235 | + { |
|
236 | + $post_tags = EEM_Term::instance()->get_all( |
|
237 | + array( |
|
238 | + array( |
|
239 | + 'Term_Taxonomy.taxonomy' => 'post_tag', |
|
240 | + 'Term_Taxonomy.Venue.post_type' => 'espresso_venues', |
|
241 | + ), |
|
242 | + 'order_by' => array('name' => 'ASC'), |
|
243 | + 'force_join' => array('Term_Taxonomy'), |
|
244 | + ) |
|
245 | + ); |
|
246 | + foreach ($post_tags as $key => $post_tag) { |
|
247 | + if (! isset($post_tags[ $key ]->post_type)) { |
|
248 | + $post_tags[ $key ]->post_type = array(); |
|
249 | + } |
|
250 | + $post_tags[ $key ]->post_type[] = 'espresso_venues'; |
|
251 | + } |
|
252 | + return $post_tags; |
|
253 | + } |
|
254 | 254 | |
255 | 255 | |
256 | 256 | |
257 | - /** |
|
258 | - * Makes sure that during REST API queries, we only return terms |
|
259 | - * for term taxonomies which should be shown in the rest api |
|
260 | - * |
|
261 | - * @param array $model_query_params |
|
262 | - * @param array $querystring_query_params |
|
263 | - * @param EEM_Base $model |
|
264 | - * @return array |
|
265 | - */ |
|
266 | - public static function rest_api_query_params($model_query_params, $querystring_query_params, $model) |
|
267 | - { |
|
268 | - if ($model === EEM_Term::instance()) { |
|
269 | - $taxonomies = get_taxonomies(array('show_in_rest' => true)); |
|
270 | - if (! empty($taxonomies)) { |
|
271 | - $model_query_params[0]['Term_Taxonomy.taxonomy'] = array('IN', $taxonomies); |
|
272 | - } |
|
273 | - } |
|
274 | - return $model_query_params; |
|
275 | - } |
|
257 | + /** |
|
258 | + * Makes sure that during REST API queries, we only return terms |
|
259 | + * for term taxonomies which should be shown in the rest api |
|
260 | + * |
|
261 | + * @param array $model_query_params |
|
262 | + * @param array $querystring_query_params |
|
263 | + * @param EEM_Base $model |
|
264 | + * @return array |
|
265 | + */ |
|
266 | + public static function rest_api_query_params($model_query_params, $querystring_query_params, $model) |
|
267 | + { |
|
268 | + if ($model === EEM_Term::instance()) { |
|
269 | + $taxonomies = get_taxonomies(array('show_in_rest' => true)); |
|
270 | + if (! empty($taxonomies)) { |
|
271 | + $model_query_params[0]['Term_Taxonomy.taxonomy'] = array('IN', $taxonomies); |
|
272 | + } |
|
273 | + } |
|
274 | + return $model_query_params; |
|
275 | + } |
|
276 | 276 | } |
@@ -44,43 +44,43 @@ discard block |
||
44 | 44 | ); |
45 | 45 | $this->_wp_core_model = true; |
46 | 46 | $path_to_tax_model = 'Term_Taxonomy'; |
47 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public(); |
|
48 | - $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Taxonomy_Protected( |
|
47 | + $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public(); |
|
48 | + $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Taxonomy_Protected( |
|
49 | 49 | $path_to_tax_model |
50 | 50 | ); |
51 | - $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = false; |
|
52 | - $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = false; |
|
53 | - $path_to_tax_model = $path_to_tax_model . '.'; |
|
51 | + $this->_cap_restriction_generators[EEM_Base::caps_edit] = false; |
|
52 | + $this->_cap_restriction_generators[EEM_Base::caps_delete] = false; |
|
53 | + $path_to_tax_model = $path_to_tax_model.'.'; |
|
54 | 54 | // add cap restrictions for editing relating to the "ee_edit_*" |
55 | - $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_event_category'] = new EE_Default_Where_Conditions( |
|
55 | + $this->_cap_restrictions[EEM_Base::caps_edit]['ee_edit_event_category'] = new EE_Default_Where_Conditions( |
|
56 | 56 | array( |
57 | - $path_to_tax_model . 'taxonomy*ee_edit_event_category' => array('!=', 'espresso_event_categories'), |
|
57 | + $path_to_tax_model.'taxonomy*ee_edit_event_category' => array('!=', 'espresso_event_categories'), |
|
58 | 58 | ) |
59 | 59 | ); |
60 | - $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_venue_category'] = new EE_Default_Where_Conditions( |
|
60 | + $this->_cap_restrictions[EEM_Base::caps_edit]['ee_edit_venue_category'] = new EE_Default_Where_Conditions( |
|
61 | 61 | array( |
62 | - $path_to_tax_model . 'taxonomy*ee_edit_venue_category' => array('!=', 'espresso_venue_categories'), |
|
62 | + $path_to_tax_model.'taxonomy*ee_edit_venue_category' => array('!=', 'espresso_venue_categories'), |
|
63 | 63 | ) |
64 | 64 | ); |
65 | - $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_event_type'] = new EE_Default_Where_Conditions( |
|
65 | + $this->_cap_restrictions[EEM_Base::caps_edit]['ee_edit_event_type'] = new EE_Default_Where_Conditions( |
|
66 | 66 | array( |
67 | - $path_to_tax_model . 'taxonomy*ee_edit_event_type' => array('!=', 'espresso_event_type'), |
|
67 | + $path_to_tax_model.'taxonomy*ee_edit_event_type' => array('!=', 'espresso_event_type'), |
|
68 | 68 | ) |
69 | 69 | ); |
70 | 70 | // add cap restrictions for deleting relating to the "ee_deleting_*" |
71 | - $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_event_category'] = new EE_Default_Where_Conditions( |
|
71 | + $this->_cap_restrictions[EEM_Base::caps_delete]['ee_delete_event_category'] = new EE_Default_Where_Conditions( |
|
72 | 72 | array( |
73 | - $path_to_tax_model . 'taxonomy*ee_delete_event_category' => array('!=', 'espresso_event_categories'), |
|
73 | + $path_to_tax_model.'taxonomy*ee_delete_event_category' => array('!=', 'espresso_event_categories'), |
|
74 | 74 | ) |
75 | 75 | ); |
76 | - $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_venue_category'] = new EE_Default_Where_Conditions( |
|
76 | + $this->_cap_restrictions[EEM_Base::caps_delete]['ee_delete_venue_category'] = new EE_Default_Where_Conditions( |
|
77 | 77 | array( |
78 | - $path_to_tax_model . 'taxonomy*ee_delete_venue_category' => array('!=', 'espresso_venue_categories'), |
|
78 | + $path_to_tax_model.'taxonomy*ee_delete_venue_category' => array('!=', 'espresso_venue_categories'), |
|
79 | 79 | ) |
80 | 80 | ); |
81 | - $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_event_type'] = new EE_Default_Where_Conditions( |
|
81 | + $this->_cap_restrictions[EEM_Base::caps_delete]['ee_delete_event_type'] = new EE_Default_Where_Conditions( |
|
82 | 82 | array( |
83 | - $path_to_tax_model . 'taxonomy*ee_delete_event_type' => array('!=', 'espresso_event_type'), |
|
83 | + $path_to_tax_model.'taxonomy*ee_delete_event_type' => array('!=', 'espresso_event_type'), |
|
84 | 84 | ) |
85 | 85 | ); |
86 | 86 | parent::__construct($timezone); |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | } |
186 | 186 | $post_tag_row = reset($post_tag_results); |
187 | 187 | $post_tag = $this->instantiate_class_from_array_or_object($post_tag_row); |
188 | - if (! $post_tag instanceof EE_Term) { |
|
188 | + if ( ! $post_tag instanceof EE_Term) { |
|
189 | 189 | return null; |
190 | 190 | } |
191 | 191 | |
@@ -216,10 +216,10 @@ discard block |
||
216 | 216 | ) |
217 | 217 | ); |
218 | 218 | foreach ($post_tags as $key => $post_tag) { |
219 | - if (! isset($post_tags[ $key ]->post_type)) { |
|
220 | - $post_tags[ $key ]->post_type = array(); |
|
219 | + if ( ! isset($post_tags[$key]->post_type)) { |
|
220 | + $post_tags[$key]->post_type = array(); |
|
221 | 221 | } |
222 | - $post_tags[ $key ]->post_type[] = 'espresso_events'; |
|
222 | + $post_tags[$key]->post_type[] = 'espresso_events'; |
|
223 | 223 | } |
224 | 224 | return $post_tags; |
225 | 225 | } |
@@ -244,10 +244,10 @@ discard block |
||
244 | 244 | ) |
245 | 245 | ); |
246 | 246 | foreach ($post_tags as $key => $post_tag) { |
247 | - if (! isset($post_tags[ $key ]->post_type)) { |
|
248 | - $post_tags[ $key ]->post_type = array(); |
|
247 | + if ( ! isset($post_tags[$key]->post_type)) { |
|
248 | + $post_tags[$key]->post_type = array(); |
|
249 | 249 | } |
250 | - $post_tags[ $key ]->post_type[] = 'espresso_venues'; |
|
250 | + $post_tags[$key]->post_type[] = 'espresso_venues'; |
|
251 | 251 | } |
252 | 252 | return $post_tags; |
253 | 253 | } |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | { |
268 | 268 | if ($model === EEM_Term::instance()) { |
269 | 269 | $taxonomies = get_taxonomies(array('show_in_rest' => true)); |
270 | - if (! empty($taxonomies)) { |
|
270 | + if ( ! empty($taxonomies)) { |
|
271 | 271 | $model_query_params[0]['Term_Taxonomy.taxonomy'] = array('IN', $taxonomies); |
272 | 272 | } |
273 | 273 | } |
@@ -10,9 +10,9 @@ discard block |
||
10 | 10 | |
11 | 11 | <h2 class="ee-admin-settings-hdr"> |
12 | 12 | <?php _e( |
13 | - 'Countries and States/Provinces', |
|
14 | - 'event_espresso' |
|
15 | - ); ?><?php echo EEH_Template::get_help_tab_link('country_select_info'); ?></h2> |
|
13 | + 'Countries and States/Provinces', |
|
14 | + 'event_espresso' |
|
15 | + ); ?><?php echo EEH_Template::get_help_tab_link('country_select_info'); ?></h2> |
|
16 | 16 | <table class="form-table"> |
17 | 17 | <tbody> |
18 | 18 | <?php echo EEH_Form_Fields::generate_form_input($countries); ?> |
@@ -21,38 +21,38 @@ discard block |
||
21 | 21 | <br/> |
22 | 22 | <p> |
23 | 23 | <?php |
24 | - esc_html_e( |
|
25 | - 'The country that is selected above will populate the Country Details settings and the options for States/Provinces. This information will be used throughout Event Espresso including for registration purposes and how currency is displayed. If you make a change to the country on this page, it is important that you also update your Contact Information on the Your Organization tab.', |
|
26 | - 'event_espresso' |
|
27 | - ); |
|
28 | - ?> |
|
24 | + esc_html_e( |
|
25 | + 'The country that is selected above will populate the Country Details settings and the options for States/Provinces. This information will be used throughout Event Espresso including for registration purposes and how currency is displayed. If you make a change to the country on this page, it is important that you also update your Contact Information on the Your Organization tab.', |
|
26 | + 'event_espresso' |
|
27 | + ); |
|
28 | + ?> |
|
29 | 29 | </p> |
30 | 30 | <p id="country-currency-setting-disabled-pg" style="display: none;"> |
31 | 31 | <span class="reminder-spn"> |
32 | 32 | <?php printf( |
33 | - esc_html__( |
|
34 | - 'Currency setting inputs are currently only enabled for the country "%1$s" which is the selected country for the site. This can be changed in the "Contact Information" section under the "Your Organization" tab of the Event Espresso - General Settings.', |
|
35 | - 'event_espresso' |
|
36 | - ), |
|
37 | - $CNT_name_for_site |
|
38 | - ); ?> |
|
33 | + esc_html__( |
|
34 | + 'Currency setting inputs are currently only enabled for the country "%1$s" which is the selected country for the site. This can be changed in the "Contact Information" section under the "Your Organization" tab of the Event Espresso - General Settings.', |
|
35 | + 'event_espresso' |
|
36 | + ), |
|
37 | + $CNT_name_for_site |
|
38 | + ); ?> |
|
39 | 39 | </span> |
40 | 40 | </p> |
41 | 41 | <div id="country-details-settings-dv"> |
42 | 42 | <h2 class="ee-admin-settings-hdr"> |
43 | 43 | <?php _e( |
44 | - 'Country Details', |
|
45 | - 'event_espresso' |
|
46 | - ); ?><?php echo EEH_Template::get_help_tab_link('country_details_info'); ?></h2> |
|
44 | + 'Country Details', |
|
45 | + 'event_espresso' |
|
46 | + ); ?><?php echo EEH_Template::get_help_tab_link('country_details_info'); ?></h2> |
|
47 | 47 | <div id="country-details-dv"><?php echo $country_details_settings; ?></div> |
48 | 48 | </div> |
49 | 49 | |
50 | 50 | <div id="country-states-settings-dv"> |
51 | 51 | <h2 class="ee-admin-settings-hdr"> |
52 | 52 | <?php _e( |
53 | - 'States/Provinces', |
|
54 | - 'event_espresso' |
|
55 | - ); ?><?php echo EEH_Template::get_help_tab_link('country_states_info'); ?></h2> |
|
53 | + 'States/Provinces', |
|
54 | + 'event_espresso' |
|
55 | + ); ?><?php echo EEH_Template::get_help_tab_link('country_states_info'); ?></h2> |
|
56 | 56 | <div id="country-states-dv"><?php echo $country_states_settings; ?></div> |
57 | 57 | </div> |
58 | 58 |
@@ -8,10 +8,10 @@ |
||
8 | 8 | <table id="general-setting-country-details-tbl" class="form-table"> |
9 | 9 | <tbody> |
10 | 10 | <?php |
11 | - foreach ($inputs as $ID => $input) { |
|
12 | - echo EEH_Form_Fields::generate_form_input($input); |
|
13 | - } |
|
14 | - ?> |
|
11 | + foreach ($inputs as $ID => $input) { |
|
12 | + echo EEH_Form_Fields::generate_form_input($input); |
|
13 | + } |
|
14 | + ?> |
|
15 | 15 | <tr> |
16 | 16 | <th></th> |
17 | 17 | <td> |
@@ -84,20 +84,20 @@ discard block |
||
84 | 84 | // loop thru and call doing_it_wrong() or remove any that aren't being used |
85 | 85 | foreach ($deprecated_filters as $deprecated_filter => $on) { |
86 | 86 | // was this filter called ? |
87 | - if (has_action('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter)) { |
|
87 | + if (has_action('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__'.$deprecated_filter)) { |
|
88 | 88 | // only display doing_it_wrong() notice to Event Admins during non-AJAX requests |
89 | 89 | if (EE_Registry::instance()->CAP->current_user_can( |
90 | 90 | 'ee_read_ee', |
91 | 91 | 'hide_doing_it_wrong_for_deprecated_SPCO_filter' |
92 | 92 | ) && ! defined('DOING_AJAX')) { |
93 | 93 | EE_Error::doing_it_wrong( |
94 | - 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter, |
|
94 | + 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__'.$deprecated_filter, |
|
95 | 95 | sprintf( |
96 | 96 | __( |
97 | 97 | 'The %1$s filter is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use the following new filter: %2$s"%3$s" found in "%4$s"', |
98 | 98 | 'event_espresso' |
99 | 99 | ), |
100 | - 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter, |
|
100 | + 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__'.$deprecated_filter, |
|
101 | 101 | '<br />', |
102 | 102 | 'FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text', |
103 | 103 | '/modules/single_page_checkout/inc/EE_SPCO_Reg_Step.class.php' |
@@ -106,10 +106,10 @@ discard block |
||
106 | 106 | ); |
107 | 107 | } |
108 | 108 | } else { |
109 | - unset($deprecated_filters[ $deprecated_filter ]); |
|
109 | + unset($deprecated_filters[$deprecated_filter]); |
|
110 | 110 | } |
111 | 111 | } |
112 | - if (! empty($deprecated_filters)) { |
|
112 | + if ( ! empty($deprecated_filters)) { |
|
113 | 113 | |
114 | 114 | if ($checkout->current_step->slug( |
115 | 115 | ) == 'attendee_information' && $checkout->revisit && isset($deprecated_filters['update_registration_details'])) { |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | $submit_button_text = apply_filters( |
144 | 144 | 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__proceed_to', |
145 | 145 | $submit_button_text |
146 | - ) . $checkout->next_step->name(); |
|
146 | + ).$checkout->next_step->name(); |
|
147 | 147 | } |
148 | 148 | } |
149 | 149 | |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | 'event_espresso' |
328 | 328 | ); |
329 | 329 | EE_Error::doing_it_wrong( |
330 | - __CLASS__ . '::' . __FUNCTION__, |
|
330 | + __CLASS__.'::'.__FUNCTION__, |
|
331 | 331 | $msg, |
332 | 332 | '4.8.32.rc.000' |
333 | 333 | ); |
@@ -354,7 +354,7 @@ discard block |
||
354 | 354 | function ee_deprecated_update_attendee_registration_form_old($admin_page) |
355 | 355 | { |
356 | 356 | // check if the old hooks are in use. If not, do the default |
357 | - if (! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks() |
|
357 | + if ( ! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks() |
|
358 | 358 | || ! $admin_page instanceof EE_Admin_Page) { |
359 | 359 | return; |
360 | 360 | } |
@@ -362,7 +362,7 @@ discard block |
||
362 | 362 | $qstns = isset($req_data['qstn']) ? $req_data['qstn'] : false; |
363 | 363 | $REG_ID = isset($req_data['_REG_ID']) ? absint($req_data['_REG_ID']) : false; |
364 | 364 | $qstns = apply_filters('FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns', $qstns); |
365 | - if (! $REG_ID || ! $qstns) { |
|
365 | + if ( ! $REG_ID || ! $qstns) { |
|
366 | 366 | EE_Error::add_error( |
367 | 367 | __('An error occurred. No registration ID and/or registration questions were received.', 'event_espresso'), |
368 | 368 | __FILE__, |
@@ -382,7 +382,7 @@ discard block |
||
382 | 382 | |
383 | 383 | foreach ($qstns as $QST_ID => $qstn) { |
384 | 384 | // if $qstn isn't an array then it doesn't already have an answer, so let's create the answer |
385 | - if (! is_array($qstn)) { |
|
385 | + if ( ! is_array($qstn)) { |
|
386 | 386 | $success = $this->_save_new_answer($REG_ID, $QST_ID, $qstn); |
387 | 387 | continue; |
388 | 388 | } |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | ); |
400 | 400 | $answer = EEM_Answer::instance()->get_one($query_params); |
401 | 401 | // this MAY be an array but NOT have an answer because its multi select. If so then we need to create the answer |
402 | - if (! $answer instanceof EE_Answer) { |
|
402 | + if ( ! $answer instanceof EE_Answer) { |
|
403 | 403 | $set_values = array( |
404 | 404 | 'QST_ID' => $QST_ID, |
405 | 405 | 'REG_ID' => $REG_ID, |
@@ -440,7 +440,7 @@ discard block |
||
440 | 440 | function ee_deprecated_reg_questions_meta_box_old($do_default_action, $admin_page, $registration) |
441 | 441 | { |
442 | 442 | // check if the old hooks are in use. If not, do the default |
443 | - if (! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks() |
|
443 | + if ( ! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks() |
|
444 | 444 | || ! $admin_page instanceof EE_Admin_Page) { |
445 | 445 | return $do_default_action; |
446 | 446 | } |
@@ -472,7 +472,7 @@ discard block |
||
472 | 472 | 'reg_questions_form_action' => 'edit_registration', |
473 | 473 | 'REG_ID' => $registration->ID(), |
474 | 474 | ); |
475 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php'; |
|
475 | + $template_path = REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_reg_questions.template.php'; |
|
476 | 476 | echo EEH_Template::display_template($template_path, $template_args, true); |
477 | 477 | // indicate that we should not do the default admin page code |
478 | 478 | return false; |
@@ -590,7 +590,7 @@ discard block |
||
590 | 590 | public function _class_is_deprecated($method) |
591 | 591 | { |
592 | 592 | EE_Error::doing_it_wrong( |
593 | - 'EE_messages::' . $method, |
|
593 | + 'EE_messages::'.$method, |
|
594 | 594 | __('EE_messages has been deprecated. Please use EE_Message_Resource_Manager instead.'), |
595 | 595 | '4.9.0', |
596 | 596 | '4.10.0.p' |
@@ -729,7 +729,7 @@ discard block |
||
729 | 729 | $error = false; |
730 | 730 | // try to intelligently determine what method we'll call based on the incoming data. |
731 | 731 | // if generating and sending are different then generate and send immediately. |
732 | - if (! empty($sending_messenger) && $sending_messenger != $generating_messenger && $send) { |
|
732 | + if ( ! empty($sending_messenger) && $sending_messenger != $generating_messenger && $send) { |
|
733 | 733 | // in the legacy system, when generating and sending were different, that means all the |
734 | 734 | // vars are already in the request object. So let's just use that. |
735 | 735 | try { |
@@ -742,7 +742,7 @@ discard block |
||
742 | 742 | 'event_espresso' |
743 | 743 | ); |
744 | 744 | // add specific message for developers if WP_DEBUG in on |
745 | - $error_msg .= '||' . $e->getMessage(); |
|
745 | + $error_msg .= '||'.$e->getMessage(); |
|
746 | 746 | EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
747 | 747 | $error = true; |
748 | 748 | } |
@@ -816,7 +816,7 @@ discard block |
||
816 | 816 | } |
817 | 817 | } |
818 | 818 | // if no error then return the generated message(s). |
819 | - if (! $error && ! $send) { |
|
819 | + if ( ! $error && ! $send) { |
|
820 | 820 | $generated_queue = $processor->generate_queue(false); |
821 | 821 | // get message and return. |
822 | 822 | $generated_queue->get_message_repository()->rewind(); |
@@ -875,7 +875,7 @@ discard block |
||
875 | 875 | /** @type EE_Messages_Queue $queue */ |
876 | 876 | $queue = EE_Registry::instance()->load_lib('Messages_Queue'); |
877 | 877 | // make sure we have a proper message object |
878 | - if (! $message instanceof EE_Message && is_object($message) && isset($message->content)) { |
|
878 | + if ( ! $message instanceof EE_Message && is_object($message) && isset($message->content)) { |
|
879 | 879 | $msg = EE_Message_Factory::create( |
880 | 880 | array( |
881 | 881 | 'MSG_messenger' => $messenger, |
@@ -887,11 +887,11 @@ discard block |
||
887 | 887 | } else { |
888 | 888 | $msg = $message; |
889 | 889 | } |
890 | - if (! $msg instanceof EE_Message) { |
|
890 | + if ( ! $msg instanceof EE_Message) { |
|
891 | 891 | return false; |
892 | 892 | } |
893 | 893 | // make sure any content in a content property (if not empty) is set on the MSG_content. |
894 | - if (! empty($msg->content)) { |
|
894 | + if ( ! empty($msg->content)) { |
|
895 | 895 | $msg->set('MSG_content', $msg->content); |
896 | 896 | } |
897 | 897 | $queue->add($msg); |
@@ -1130,8 +1130,8 @@ discard block |
||
1130 | 1130 | |
1131 | 1131 | add_filter( |
1132 | 1132 | 'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css', |
1133 | - function ($event_list_iframe_css) { |
|
1134 | - if (! has_filter('FHEE__EventsArchiveIframe__event_list_iframe__css')) { |
|
1133 | + function($event_list_iframe_css) { |
|
1134 | + if ( ! has_filter('FHEE__EventsArchiveIframe__event_list_iframe__css')) { |
|
1135 | 1135 | return $event_list_iframe_css; |
1136 | 1136 | } |
1137 | 1137 | deprecated_espresso_action_or_filter_doing_it_wrong( |
@@ -1150,8 +1150,8 @@ discard block |
||
1150 | 1150 | ); |
1151 | 1151 | add_filter( |
1152 | 1152 | 'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js', |
1153 | - function ($event_list_iframe_js) { |
|
1154 | - if (! has_filter('FHEE__EED_Ticket_Selector__ticket_selector_iframe__js')) { |
|
1153 | + function($event_list_iframe_js) { |
|
1154 | + if ( ! has_filter('FHEE__EED_Ticket_Selector__ticket_selector_iframe__js')) { |
|
1155 | 1155 | return $event_list_iframe_js; |
1156 | 1156 | } |
1157 | 1157 | deprecated_espresso_action_or_filter_doing_it_wrong( |
@@ -1170,8 +1170,8 @@ discard block |
||
1170 | 1170 | ); |
1171 | 1171 | add_action( |
1172 | 1172 | 'AHEE__EE_Capabilities__addCaps__complete', |
1173 | - function ($capabilities_map) { |
|
1174 | - if (! has_action('AHEE__EE_Capabilities__init_role_caps__complete')) { |
|
1173 | + function($capabilities_map) { |
|
1174 | + if ( ! has_action('AHEE__EE_Capabilities__init_role_caps__complete')) { |
|
1175 | 1175 | return; |
1176 | 1176 | } |
1177 | 1177 | deprecated_espresso_action_or_filter_doing_it_wrong( |
@@ -1190,8 +1190,8 @@ discard block |
||
1190 | 1190 | |
1191 | 1191 | add_filter( |
1192 | 1192 | 'FHEE_EventEspresso_core_services_commands_attendee_CreateAttendeeCommandHandler__findExistingAttendee__existing_attendee', |
1193 | - function ($existing_attendee, $registration, $attendee_data) { |
|
1194 | - if (! has_filter('FHEE_EE_Single_Page_Checkout__save_registration_items__find_existing_attendee')) { |
|
1193 | + function($existing_attendee, $registration, $attendee_data) { |
|
1194 | + if ( ! has_filter('FHEE_EE_Single_Page_Checkout__save_registration_items__find_existing_attendee')) { |
|
1195 | 1195 | return $existing_attendee; |
1196 | 1196 | } |
1197 | 1197 | deprecated_espresso_action_or_filter_doing_it_wrong( |
@@ -1274,7 +1274,7 @@ discard block |
||
1274 | 1274 | */ |
1275 | 1275 | public function event_list_title($event_list_title = '') |
1276 | 1276 | { |
1277 | - if (! empty($this->title)) { |
|
1277 | + if ( ! empty($this->title)) { |
|
1278 | 1278 | return $this->title; |
1279 | 1279 | } |
1280 | 1280 | return $event_list_title; |
@@ -1417,7 +1417,7 @@ discard block |
||
1417 | 1417 | foreach ($model_fields as $field) { |
1418 | 1418 | if ($label === EEH_Export::get_column_name_for_field($field)) { |
1419 | 1419 | // re-add the old field name |
1420 | - $new_label = $label . '[' . $field->get_name() . ']'; |
|
1420 | + $new_label = $label.'['.$field->get_name().']'; |
|
1421 | 1421 | break; |
1422 | 1422 | } |
1423 | 1423 | } |
@@ -39,31 +39,31 @@ discard block |
||
39 | 39 | * @param string $action_or_filter |
40 | 40 | */ |
41 | 41 | function deprecated_espresso_action_or_filter_doing_it_wrong( |
42 | - $deprecated_filter, |
|
43 | - $replacement, |
|
44 | - $replacement_location, |
|
45 | - $version_deprecated, |
|
46 | - $version_applies, |
|
47 | - $action_or_filter = 'action' |
|
42 | + $deprecated_filter, |
|
43 | + $replacement, |
|
44 | + $replacement_location, |
|
45 | + $version_deprecated, |
|
46 | + $version_applies, |
|
47 | + $action_or_filter = 'action' |
|
48 | 48 | ) { |
49 | - $action_or_filter = $action_or_filter === 'action' |
|
50 | - ? esc_html__('action', 'event_espresso') |
|
51 | - : esc_html__('filter', 'event_espresso'); |
|
52 | - EE_Error::doing_it_wrong( |
|
53 | - $deprecated_filter, |
|
54 | - sprintf( |
|
55 | - __( |
|
56 | - 'This %1$s is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use the following new %1$s: %4$s"%2$s" found in "%3$s"', |
|
57 | - 'event_espresso' |
|
58 | - ), |
|
59 | - $action_or_filter, |
|
60 | - $replacement, |
|
61 | - $replacement_location, |
|
62 | - '<br />' |
|
63 | - ), |
|
64 | - $version_deprecated, |
|
65 | - $version_applies |
|
66 | - ); |
|
49 | + $action_or_filter = $action_or_filter === 'action' |
|
50 | + ? esc_html__('action', 'event_espresso') |
|
51 | + : esc_html__('filter', 'event_espresso'); |
|
52 | + EE_Error::doing_it_wrong( |
|
53 | + $deprecated_filter, |
|
54 | + sprintf( |
|
55 | + __( |
|
56 | + 'This %1$s is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use the following new %1$s: %4$s"%2$s" found in "%3$s"', |
|
57 | + 'event_espresso' |
|
58 | + ), |
|
59 | + $action_or_filter, |
|
60 | + $replacement, |
|
61 | + $replacement_location, |
|
62 | + '<br />' |
|
63 | + ), |
|
64 | + $version_deprecated, |
|
65 | + $version_applies |
|
66 | + ); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | /** |
@@ -75,90 +75,90 @@ discard block |
||
75 | 75 | */ |
76 | 76 | function ee_deprecated__registration_checkout__button_text($submit_button_text, EE_Checkout $checkout) |
77 | 77 | { |
78 | - // list of old filters |
|
79 | - $deprecated_filters = array( |
|
80 | - 'update_registration_details' => true, |
|
81 | - 'process_payment' => true, |
|
82 | - 'finalize_registration' => true, |
|
83 | - 'and_proceed_to_payment' => true, |
|
84 | - 'proceed_to' => true, |
|
85 | - ); |
|
86 | - // loop thru and call doing_it_wrong() or remove any that aren't being used |
|
87 | - foreach ($deprecated_filters as $deprecated_filter => $on) { |
|
88 | - // was this filter called ? |
|
89 | - if (has_action('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter)) { |
|
90 | - // only display doing_it_wrong() notice to Event Admins during non-AJAX requests |
|
91 | - if (EE_Registry::instance()->CAP->current_user_can( |
|
92 | - 'ee_read_ee', |
|
93 | - 'hide_doing_it_wrong_for_deprecated_SPCO_filter' |
|
94 | - ) && ! defined('DOING_AJAX')) { |
|
95 | - EE_Error::doing_it_wrong( |
|
96 | - 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter, |
|
97 | - sprintf( |
|
98 | - __( |
|
99 | - 'The %1$s filter is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use the following new filter: %2$s"%3$s" found in "%4$s"', |
|
100 | - 'event_espresso' |
|
101 | - ), |
|
102 | - 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter, |
|
103 | - '<br />', |
|
104 | - 'FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text', |
|
105 | - '/modules/single_page_checkout/inc/EE_SPCO_Reg_Step.class.php' |
|
106 | - ), |
|
107 | - '4.6.10' |
|
108 | - ); |
|
109 | - } |
|
110 | - } else { |
|
111 | - unset($deprecated_filters[ $deprecated_filter ]); |
|
112 | - } |
|
113 | - } |
|
114 | - if (! empty($deprecated_filters)) { |
|
115 | - |
|
116 | - if ($checkout->current_step->slug( |
|
117 | - ) == 'attendee_information' && $checkout->revisit && isset($deprecated_filters['update_registration_details'])) { |
|
118 | - $submit_button_text = apply_filters( |
|
119 | - 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__update_registration_details', |
|
120 | - $submit_button_text |
|
121 | - ); |
|
122 | - } elseif ($checkout->current_step->slug( |
|
123 | - ) == 'payment_options' && $checkout->revisit && isset($deprecated_filters['process_payment'])) { |
|
124 | - $submit_button_text = apply_filters( |
|
125 | - 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__process_payment', |
|
126 | - $submit_button_text |
|
127 | - ); |
|
128 | - } elseif ($checkout->next_step instanceof EE_SPCO_Reg_Step && $checkout->next_step->slug( |
|
129 | - ) == 'finalize_registration' && isset($deprecated_filters['finalize_registration'])) { |
|
130 | - $submit_button_text = apply_filters( |
|
131 | - 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__finalize_registration', |
|
132 | - $submit_button_text |
|
133 | - ); |
|
134 | - } |
|
135 | - if ($checkout->next_step instanceof EE_SPCO_Reg_Step) { |
|
136 | - if ($checkout->payment_required() && $checkout->next_step->slug( |
|
137 | - ) == 'payment_options' && isset($deprecated_filters['and_proceed_to_payment'])) { |
|
138 | - $submit_button_text .= apply_filters( |
|
139 | - 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__and_proceed_to_payment', |
|
140 | - $submit_button_text |
|
141 | - ); |
|
142 | - } |
|
143 | - if ($checkout->next_step->slug( |
|
144 | - ) != 'finalize_registration' && ! $checkout->revisit && isset($deprecated_filters['proceed_to'])) { |
|
145 | - $submit_button_text = apply_filters( |
|
146 | - 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__proceed_to', |
|
147 | - $submit_button_text |
|
148 | - ) . $checkout->next_step->name(); |
|
149 | - } |
|
150 | - } |
|
151 | - |
|
152 | - } |
|
153 | - return $submit_button_text; |
|
78 | + // list of old filters |
|
79 | + $deprecated_filters = array( |
|
80 | + 'update_registration_details' => true, |
|
81 | + 'process_payment' => true, |
|
82 | + 'finalize_registration' => true, |
|
83 | + 'and_proceed_to_payment' => true, |
|
84 | + 'proceed_to' => true, |
|
85 | + ); |
|
86 | + // loop thru and call doing_it_wrong() or remove any that aren't being used |
|
87 | + foreach ($deprecated_filters as $deprecated_filter => $on) { |
|
88 | + // was this filter called ? |
|
89 | + if (has_action('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter)) { |
|
90 | + // only display doing_it_wrong() notice to Event Admins during non-AJAX requests |
|
91 | + if (EE_Registry::instance()->CAP->current_user_can( |
|
92 | + 'ee_read_ee', |
|
93 | + 'hide_doing_it_wrong_for_deprecated_SPCO_filter' |
|
94 | + ) && ! defined('DOING_AJAX')) { |
|
95 | + EE_Error::doing_it_wrong( |
|
96 | + 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter, |
|
97 | + sprintf( |
|
98 | + __( |
|
99 | + 'The %1$s filter is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use the following new filter: %2$s"%3$s" found in "%4$s"', |
|
100 | + 'event_espresso' |
|
101 | + ), |
|
102 | + 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter, |
|
103 | + '<br />', |
|
104 | + 'FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text', |
|
105 | + '/modules/single_page_checkout/inc/EE_SPCO_Reg_Step.class.php' |
|
106 | + ), |
|
107 | + '4.6.10' |
|
108 | + ); |
|
109 | + } |
|
110 | + } else { |
|
111 | + unset($deprecated_filters[ $deprecated_filter ]); |
|
112 | + } |
|
113 | + } |
|
114 | + if (! empty($deprecated_filters)) { |
|
115 | + |
|
116 | + if ($checkout->current_step->slug( |
|
117 | + ) == 'attendee_information' && $checkout->revisit && isset($deprecated_filters['update_registration_details'])) { |
|
118 | + $submit_button_text = apply_filters( |
|
119 | + 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__update_registration_details', |
|
120 | + $submit_button_text |
|
121 | + ); |
|
122 | + } elseif ($checkout->current_step->slug( |
|
123 | + ) == 'payment_options' && $checkout->revisit && isset($deprecated_filters['process_payment'])) { |
|
124 | + $submit_button_text = apply_filters( |
|
125 | + 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__process_payment', |
|
126 | + $submit_button_text |
|
127 | + ); |
|
128 | + } elseif ($checkout->next_step instanceof EE_SPCO_Reg_Step && $checkout->next_step->slug( |
|
129 | + ) == 'finalize_registration' && isset($deprecated_filters['finalize_registration'])) { |
|
130 | + $submit_button_text = apply_filters( |
|
131 | + 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__finalize_registration', |
|
132 | + $submit_button_text |
|
133 | + ); |
|
134 | + } |
|
135 | + if ($checkout->next_step instanceof EE_SPCO_Reg_Step) { |
|
136 | + if ($checkout->payment_required() && $checkout->next_step->slug( |
|
137 | + ) == 'payment_options' && isset($deprecated_filters['and_proceed_to_payment'])) { |
|
138 | + $submit_button_text .= apply_filters( |
|
139 | + 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__and_proceed_to_payment', |
|
140 | + $submit_button_text |
|
141 | + ); |
|
142 | + } |
|
143 | + if ($checkout->next_step->slug( |
|
144 | + ) != 'finalize_registration' && ! $checkout->revisit && isset($deprecated_filters['proceed_to'])) { |
|
145 | + $submit_button_text = apply_filters( |
|
146 | + 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__proceed_to', |
|
147 | + $submit_button_text |
|
148 | + ) . $checkout->next_step->name(); |
|
149 | + } |
|
150 | + } |
|
151 | + |
|
152 | + } |
|
153 | + return $submit_button_text; |
|
154 | 154 | |
155 | 155 | } |
156 | 156 | |
157 | 157 | add_filter( |
158 | - 'FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text', |
|
159 | - 'ee_deprecated__registration_checkout__button_text', |
|
160 | - 10, |
|
161 | - 2 |
|
158 | + 'FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text', |
|
159 | + 'ee_deprecated__registration_checkout__button_text', |
|
160 | + 10, |
|
161 | + 2 |
|
162 | 162 | ); |
163 | 163 | |
164 | 164 | |
@@ -170,54 +170,54 @@ discard block |
||
170 | 170 | */ |
171 | 171 | function ee_deprecated_finalize_transaction(EE_Checkout $checkout, $status_updates) |
172 | 172 | { |
173 | - $action_ref = null; |
|
174 | - $action_ref = has_action('AHEE__EE_Transaction__finalize__new_transaction') |
|
175 | - ? 'AHEE__EE_Transaction__finalize__new_transaction' : $action_ref; |
|
176 | - $action_ref = has_action('AHEE__EE_Transaction__finalize__all_transaction') |
|
177 | - ? 'AHEE__EE_Transaction__finalize__all_transaction' : $action_ref; |
|
178 | - if ($action_ref) { |
|
179 | - |
|
180 | - EE_Error::doing_it_wrong( |
|
181 | - $action_ref, |
|
182 | - sprintf( |
|
183 | - __( |
|
184 | - 'This action is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use one of the following new actions: %1$s"%3$s" found in "%2$s" %1$s"%4$s" found in "%2$s" %1$s"%5$s" found in "%2$s" %1$s"%6$s" found in "%2$s"', |
|
185 | - 'event_espresso' |
|
186 | - ), |
|
187 | - '<br />', |
|
188 | - '/core/business/EE_Transaction_Processor.class.php', |
|
189 | - 'AHEE__EE_Transaction_Processor__finalize', |
|
190 | - 'AHEE__EE_Transaction_Processor__manually_update_registration_statuses', |
|
191 | - 'AHEE__EE_Transaction_Processor__toggle_registration_statuses_for_default_approved_events', |
|
192 | - 'AHEE__EE_Transaction_Processor__toggle_registration_statuses_if_no_monies_owing' |
|
193 | - ), |
|
194 | - '4.6.0' |
|
195 | - ); |
|
196 | - switch ($action_ref) { |
|
197 | - case 'AHEE__EE_Transaction__finalize__new_transaction' : |
|
198 | - do_action( |
|
199 | - 'AHEE__EE_Transaction__finalize__new_transaction', |
|
200 | - $checkout->transaction, |
|
201 | - $checkout->admin_request |
|
202 | - ); |
|
203 | - break; |
|
204 | - case 'AHEE__EE_Transaction__finalize__all_transaction' : |
|
205 | - do_action( |
|
206 | - 'AHEE__EE_Transaction__finalize__new_transaction', |
|
207 | - $checkout->transaction, |
|
208 | - array('new_reg' => ! $checkout->revisit, 'to_approved' => $status_updates), |
|
209 | - $checkout->admin_request |
|
210 | - ); |
|
211 | - break; |
|
212 | - } |
|
213 | - } |
|
173 | + $action_ref = null; |
|
174 | + $action_ref = has_action('AHEE__EE_Transaction__finalize__new_transaction') |
|
175 | + ? 'AHEE__EE_Transaction__finalize__new_transaction' : $action_ref; |
|
176 | + $action_ref = has_action('AHEE__EE_Transaction__finalize__all_transaction') |
|
177 | + ? 'AHEE__EE_Transaction__finalize__all_transaction' : $action_ref; |
|
178 | + if ($action_ref) { |
|
179 | + |
|
180 | + EE_Error::doing_it_wrong( |
|
181 | + $action_ref, |
|
182 | + sprintf( |
|
183 | + __( |
|
184 | + 'This action is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use one of the following new actions: %1$s"%3$s" found in "%2$s" %1$s"%4$s" found in "%2$s" %1$s"%5$s" found in "%2$s" %1$s"%6$s" found in "%2$s"', |
|
185 | + 'event_espresso' |
|
186 | + ), |
|
187 | + '<br />', |
|
188 | + '/core/business/EE_Transaction_Processor.class.php', |
|
189 | + 'AHEE__EE_Transaction_Processor__finalize', |
|
190 | + 'AHEE__EE_Transaction_Processor__manually_update_registration_statuses', |
|
191 | + 'AHEE__EE_Transaction_Processor__toggle_registration_statuses_for_default_approved_events', |
|
192 | + 'AHEE__EE_Transaction_Processor__toggle_registration_statuses_if_no_monies_owing' |
|
193 | + ), |
|
194 | + '4.6.0' |
|
195 | + ); |
|
196 | + switch ($action_ref) { |
|
197 | + case 'AHEE__EE_Transaction__finalize__new_transaction' : |
|
198 | + do_action( |
|
199 | + 'AHEE__EE_Transaction__finalize__new_transaction', |
|
200 | + $checkout->transaction, |
|
201 | + $checkout->admin_request |
|
202 | + ); |
|
203 | + break; |
|
204 | + case 'AHEE__EE_Transaction__finalize__all_transaction' : |
|
205 | + do_action( |
|
206 | + 'AHEE__EE_Transaction__finalize__new_transaction', |
|
207 | + $checkout->transaction, |
|
208 | + array('new_reg' => ! $checkout->revisit, 'to_approved' => $status_updates), |
|
209 | + $checkout->admin_request |
|
210 | + ); |
|
211 | + break; |
|
212 | + } |
|
213 | + } |
|
214 | 214 | } |
215 | 215 | |
216 | 216 | add_action( |
217 | - 'AHEE__EE_SPCO_Reg_Step_Finalize_Registration__process_reg_step__completed', |
|
218 | - 'ee_deprecated_finalize_transaction', |
|
219 | - 10, |
|
220 | - 2 |
|
217 | + 'AHEE__EE_SPCO_Reg_Step_Finalize_Registration__process_reg_step__completed', |
|
218 | + 'ee_deprecated_finalize_transaction', |
|
219 | + 10, |
|
220 | + 2 |
|
221 | 221 | ); |
222 | 222 | /** |
223 | 223 | * ee_deprecated_finalize_registration |
@@ -226,35 +226,35 @@ discard block |
||
226 | 226 | */ |
227 | 227 | function ee_deprecated_finalize_registration(EE_Registration $registration) |
228 | 228 | { |
229 | - $action_ref = has_action('AHEE__EE_Registration__finalize__update_and_new_reg') |
|
230 | - ? 'AHEE__EE_Registration__finalize__update_and_new_reg' : null; |
|
231 | - if ($action_ref) { |
|
232 | - EE_Error::doing_it_wrong( |
|
233 | - $action_ref, |
|
234 | - sprintf( |
|
235 | - __( |
|
236 | - 'This action is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use the following new action: %1$s"%3$s" found in "%2$s"', |
|
237 | - 'event_espresso' |
|
238 | - ), |
|
239 | - '<br />', |
|
240 | - '/core/business/EE_Registration_Processor.class.php', |
|
241 | - 'AHEE__EE_Registration_Processor__trigger_registration_update_notifications' |
|
242 | - ), |
|
243 | - '4.6.0' |
|
244 | - ); |
|
245 | - do_action( |
|
246 | - 'AHEE__EE_Registration__finalize__update_and_new_reg', |
|
247 | - $registration, |
|
248 | - (is_admin() && ! (defined('DOING_AJAX') && DOING_AJAX)) |
|
249 | - ); |
|
250 | - } |
|
229 | + $action_ref = has_action('AHEE__EE_Registration__finalize__update_and_new_reg') |
|
230 | + ? 'AHEE__EE_Registration__finalize__update_and_new_reg' : null; |
|
231 | + if ($action_ref) { |
|
232 | + EE_Error::doing_it_wrong( |
|
233 | + $action_ref, |
|
234 | + sprintf( |
|
235 | + __( |
|
236 | + 'This action is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use the following new action: %1$s"%3$s" found in "%2$s"', |
|
237 | + 'event_espresso' |
|
238 | + ), |
|
239 | + '<br />', |
|
240 | + '/core/business/EE_Registration_Processor.class.php', |
|
241 | + 'AHEE__EE_Registration_Processor__trigger_registration_update_notifications' |
|
242 | + ), |
|
243 | + '4.6.0' |
|
244 | + ); |
|
245 | + do_action( |
|
246 | + 'AHEE__EE_Registration__finalize__update_and_new_reg', |
|
247 | + $registration, |
|
248 | + (is_admin() && ! (defined('DOING_AJAX') && DOING_AJAX)) |
|
249 | + ); |
|
250 | + } |
|
251 | 251 | } |
252 | 252 | |
253 | 253 | add_action( |
254 | - 'AHEE__EE_Registration_Processor__trigger_registration_update_notifications', |
|
255 | - 'ee_deprecated_finalize_registration', |
|
256 | - 10, |
|
257 | - 1 |
|
254 | + 'AHEE__EE_Registration_Processor__trigger_registration_update_notifications', |
|
255 | + 'ee_deprecated_finalize_registration', |
|
256 | + 10, |
|
257 | + 1 |
|
258 | 258 | ); |
259 | 259 | |
260 | 260 | |
@@ -264,44 +264,44 @@ discard block |
||
264 | 264 | */ |
265 | 265 | function ee_deprecated_hooks() |
266 | 266 | { |
267 | - /** |
|
268 | - * @var $hooks array where keys are hook names, and their values are array{ |
|
269 | - * @type string $version when deprecated |
|
270 | - * @type string $alternative saying what to use instead |
|
271 | - * @type boolean $still_works whether or not the hook still works |
|
272 | - * } |
|
273 | - */ |
|
274 | - $hooks = array( |
|
275 | - 'AHEE__EE_System___do_setup_validations' => array( |
|
276 | - 'version' => '4.6.0', |
|
277 | - 'alternative' => __( |
|
278 | - 'Instead use "AHEE__EEH_Activation__validate_messages_system" which is called after validating messages (done on every new install, upgrade, reactivation, and downgrade)', |
|
279 | - 'event_espresso' |
|
280 | - ), |
|
281 | - 'still_works' => false, |
|
282 | - ), |
|
283 | - ); |
|
284 | - foreach ($hooks as $name => $deprecation_info) { |
|
285 | - if (has_action($name)) { |
|
286 | - EE_Error::doing_it_wrong( |
|
287 | - $name, |
|
288 | - sprintf( |
|
289 | - __('This filter is deprecated. %1$s%2$s', 'event_espresso'), |
|
290 | - $deprecation_info['still_works'] ? __( |
|
291 | - 'It *may* work as an attempt to build in backwards compatibility.', |
|
292 | - 'event_espresso' |
|
293 | - ) : __('It has been completely removed.', 'event_espresso'), |
|
294 | - isset($deprecation_info['alternative']) |
|
295 | - ? $deprecation_info['alternative'] |
|
296 | - : __( |
|
297 | - 'Please read the current EE4 documentation further or contact Support.', |
|
298 | - 'event_espresso' |
|
299 | - ) |
|
300 | - ), |
|
301 | - isset($deprecation_info['version']) ? $deprecation_info['version'] : __('recently', 'event_espresso') |
|
302 | - ); |
|
303 | - } |
|
304 | - } |
|
267 | + /** |
|
268 | + * @var $hooks array where keys are hook names, and their values are array{ |
|
269 | + * @type string $version when deprecated |
|
270 | + * @type string $alternative saying what to use instead |
|
271 | + * @type boolean $still_works whether or not the hook still works |
|
272 | + * } |
|
273 | + */ |
|
274 | + $hooks = array( |
|
275 | + 'AHEE__EE_System___do_setup_validations' => array( |
|
276 | + 'version' => '4.6.0', |
|
277 | + 'alternative' => __( |
|
278 | + 'Instead use "AHEE__EEH_Activation__validate_messages_system" which is called after validating messages (done on every new install, upgrade, reactivation, and downgrade)', |
|
279 | + 'event_espresso' |
|
280 | + ), |
|
281 | + 'still_works' => false, |
|
282 | + ), |
|
283 | + ); |
|
284 | + foreach ($hooks as $name => $deprecation_info) { |
|
285 | + if (has_action($name)) { |
|
286 | + EE_Error::doing_it_wrong( |
|
287 | + $name, |
|
288 | + sprintf( |
|
289 | + __('This filter is deprecated. %1$s%2$s', 'event_espresso'), |
|
290 | + $deprecation_info['still_works'] ? __( |
|
291 | + 'It *may* work as an attempt to build in backwards compatibility.', |
|
292 | + 'event_espresso' |
|
293 | + ) : __('It has been completely removed.', 'event_espresso'), |
|
294 | + isset($deprecation_info['alternative']) |
|
295 | + ? $deprecation_info['alternative'] |
|
296 | + : __( |
|
297 | + 'Please read the current EE4 documentation further or contact Support.', |
|
298 | + 'event_espresso' |
|
299 | + ) |
|
300 | + ), |
|
301 | + isset($deprecation_info['version']) ? $deprecation_info['version'] : __('recently', 'event_espresso') |
|
302 | + ); |
|
303 | + } |
|
304 | + } |
|
305 | 305 | } |
306 | 306 | |
307 | 307 | add_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', 'ee_deprecated_hooks'); |
@@ -316,34 +316,34 @@ discard block |
||
316 | 316 | */ |
317 | 317 | function ee_deprecated_using_old_registration_admin_custom_questions_form_hooks() |
318 | 318 | { |
319 | - $in_use = has_filter('FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns') |
|
320 | - || has_action( |
|
321 | - 'AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save' |
|
322 | - ); |
|
323 | - if ($in_use) { |
|
324 | - $msg = __( |
|
325 | - 'We detected you are using the filter FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns or AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save.' |
|
326 | - . 'Both of these have been deprecated and should not be used anymore. You should instead use FHEE__EE_Form_Section_Proper___construct__options_array to customize the contents of the form,' |
|
327 | - . 'use FHEE__EE_Form_Section_Proper__receive_form_submission__req_data to customize the submission data, or AHEE__EE_Form_Section_Proper__receive_form_submission__end ' |
|
328 | - . 'to add other actions after a form submission has been received.', |
|
329 | - 'event_espresso' |
|
330 | - ); |
|
331 | - EE_Error::doing_it_wrong( |
|
332 | - __CLASS__ . '::' . __FUNCTION__, |
|
333 | - $msg, |
|
334 | - '4.8.32.rc.000' |
|
335 | - ); |
|
336 | - // it seems the doing_it_wrong messages get output during some hidden html tags, so add an error to make sure this gets noticed |
|
337 | - if (is_admin() && ! defined('DOING_AJAX')) { |
|
338 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
339 | - } |
|
340 | - } |
|
341 | - return $in_use; |
|
319 | + $in_use = has_filter('FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns') |
|
320 | + || has_action( |
|
321 | + 'AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save' |
|
322 | + ); |
|
323 | + if ($in_use) { |
|
324 | + $msg = __( |
|
325 | + 'We detected you are using the filter FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns or AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save.' |
|
326 | + . 'Both of these have been deprecated and should not be used anymore. You should instead use FHEE__EE_Form_Section_Proper___construct__options_array to customize the contents of the form,' |
|
327 | + . 'use FHEE__EE_Form_Section_Proper__receive_form_submission__req_data to customize the submission data, or AHEE__EE_Form_Section_Proper__receive_form_submission__end ' |
|
328 | + . 'to add other actions after a form submission has been received.', |
|
329 | + 'event_espresso' |
|
330 | + ); |
|
331 | + EE_Error::doing_it_wrong( |
|
332 | + __CLASS__ . '::' . __FUNCTION__, |
|
333 | + $msg, |
|
334 | + '4.8.32.rc.000' |
|
335 | + ); |
|
336 | + // it seems the doing_it_wrong messages get output during some hidden html tags, so add an error to make sure this gets noticed |
|
337 | + if (is_admin() && ! defined('DOING_AJAX')) { |
|
338 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
339 | + } |
|
340 | + } |
|
341 | + return $in_use; |
|
342 | 342 | } |
343 | 343 | |
344 | 344 | add_action( |
345 | - 'AHEE__Registrations_Admin_Page___registration_details_metabox__start', |
|
346 | - 'ee_deprecated_using_old_registration_admin_custom_questions_form_hooks' |
|
345 | + 'AHEE__Registrations_Admin_Page___registration_details_metabox__start', |
|
346 | + 'ee_deprecated_using_old_registration_admin_custom_questions_form_hooks' |
|
347 | 347 | ); |
348 | 348 | |
349 | 349 | /** |
@@ -355,77 +355,77 @@ discard block |
||
355 | 355 | */ |
356 | 356 | function ee_deprecated_update_attendee_registration_form_old($admin_page) |
357 | 357 | { |
358 | - // check if the old hooks are in use. If not, do the default |
|
359 | - if (! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks() |
|
360 | - || ! $admin_page instanceof EE_Admin_Page) { |
|
361 | - return; |
|
362 | - } |
|
363 | - $req_data = $admin_page->get_request_data(); |
|
364 | - $qstns = isset($req_data['qstn']) ? $req_data['qstn'] : false; |
|
365 | - $REG_ID = isset($req_data['_REG_ID']) ? absint($req_data['_REG_ID']) : false; |
|
366 | - $qstns = apply_filters('FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns', $qstns); |
|
367 | - if (! $REG_ID || ! $qstns) { |
|
368 | - EE_Error::add_error( |
|
369 | - __('An error occurred. No registration ID and/or registration questions were received.', 'event_espresso'), |
|
370 | - __FILE__, |
|
371 | - __FUNCTION__, |
|
372 | - __LINE__ |
|
373 | - ); |
|
374 | - } |
|
375 | - $success = true; |
|
376 | - |
|
377 | - // allow others to get in on this awesome fun :D |
|
378 | - do_action( |
|
379 | - 'AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save', |
|
380 | - $REG_ID, |
|
381 | - $qstns |
|
382 | - ); |
|
383 | - // loop thru questions... FINALLY!!! |
|
384 | - |
|
385 | - foreach ($qstns as $QST_ID => $qstn) { |
|
386 | - // if $qstn isn't an array then it doesn't already have an answer, so let's create the answer |
|
387 | - if (! is_array($qstn)) { |
|
388 | - $success = $this->_save_new_answer($REG_ID, $QST_ID, $qstn); |
|
389 | - continue; |
|
390 | - } |
|
391 | - |
|
392 | - |
|
393 | - foreach ($qstn as $ANS_ID => $ANS_value) { |
|
394 | - // get answer |
|
395 | - $query_params = array( |
|
396 | - 0 => array( |
|
397 | - 'ANS_ID' => $ANS_ID, |
|
398 | - 'REG_ID' => $REG_ID, |
|
399 | - 'QST_ID' => $QST_ID, |
|
400 | - ), |
|
401 | - ); |
|
402 | - $answer = EEM_Answer::instance()->get_one($query_params); |
|
403 | - // this MAY be an array but NOT have an answer because its multi select. If so then we need to create the answer |
|
404 | - if (! $answer instanceof EE_Answer) { |
|
405 | - $set_values = array( |
|
406 | - 'QST_ID' => $QST_ID, |
|
407 | - 'REG_ID' => $REG_ID, |
|
408 | - 'ANS_value' => $qstn, |
|
409 | - ); |
|
410 | - $success = EEM_Answer::instance()->insert($set_values); |
|
411 | - continue 2; |
|
412 | - } |
|
413 | - |
|
414 | - $answer->set('ANS_value', $ANS_value); |
|
415 | - $success = $answer->save(); |
|
416 | - } |
|
417 | - } |
|
418 | - $what = __('Registration Form', 'event_espresso'); |
|
419 | - $route = $REG_ID ? array('action' => 'view_registration', '_REG_ID' => $REG_ID) : array('action' => 'default'); |
|
420 | - $admin_page->redirect_after_action($success, $what, __('updated', 'event_espresso'), $route); |
|
421 | - exit; |
|
358 | + // check if the old hooks are in use. If not, do the default |
|
359 | + if (! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks() |
|
360 | + || ! $admin_page instanceof EE_Admin_Page) { |
|
361 | + return; |
|
362 | + } |
|
363 | + $req_data = $admin_page->get_request_data(); |
|
364 | + $qstns = isset($req_data['qstn']) ? $req_data['qstn'] : false; |
|
365 | + $REG_ID = isset($req_data['_REG_ID']) ? absint($req_data['_REG_ID']) : false; |
|
366 | + $qstns = apply_filters('FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns', $qstns); |
|
367 | + if (! $REG_ID || ! $qstns) { |
|
368 | + EE_Error::add_error( |
|
369 | + __('An error occurred. No registration ID and/or registration questions were received.', 'event_espresso'), |
|
370 | + __FILE__, |
|
371 | + __FUNCTION__, |
|
372 | + __LINE__ |
|
373 | + ); |
|
374 | + } |
|
375 | + $success = true; |
|
376 | + |
|
377 | + // allow others to get in on this awesome fun :D |
|
378 | + do_action( |
|
379 | + 'AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save', |
|
380 | + $REG_ID, |
|
381 | + $qstns |
|
382 | + ); |
|
383 | + // loop thru questions... FINALLY!!! |
|
384 | + |
|
385 | + foreach ($qstns as $QST_ID => $qstn) { |
|
386 | + // if $qstn isn't an array then it doesn't already have an answer, so let's create the answer |
|
387 | + if (! is_array($qstn)) { |
|
388 | + $success = $this->_save_new_answer($REG_ID, $QST_ID, $qstn); |
|
389 | + continue; |
|
390 | + } |
|
391 | + |
|
392 | + |
|
393 | + foreach ($qstn as $ANS_ID => $ANS_value) { |
|
394 | + // get answer |
|
395 | + $query_params = array( |
|
396 | + 0 => array( |
|
397 | + 'ANS_ID' => $ANS_ID, |
|
398 | + 'REG_ID' => $REG_ID, |
|
399 | + 'QST_ID' => $QST_ID, |
|
400 | + ), |
|
401 | + ); |
|
402 | + $answer = EEM_Answer::instance()->get_one($query_params); |
|
403 | + // this MAY be an array but NOT have an answer because its multi select. If so then we need to create the answer |
|
404 | + if (! $answer instanceof EE_Answer) { |
|
405 | + $set_values = array( |
|
406 | + 'QST_ID' => $QST_ID, |
|
407 | + 'REG_ID' => $REG_ID, |
|
408 | + 'ANS_value' => $qstn, |
|
409 | + ); |
|
410 | + $success = EEM_Answer::instance()->insert($set_values); |
|
411 | + continue 2; |
|
412 | + } |
|
413 | + |
|
414 | + $answer->set('ANS_value', $ANS_value); |
|
415 | + $success = $answer->save(); |
|
416 | + } |
|
417 | + } |
|
418 | + $what = __('Registration Form', 'event_espresso'); |
|
419 | + $route = $REG_ID ? array('action' => 'view_registration', '_REG_ID' => $REG_ID) : array('action' => 'default'); |
|
420 | + $admin_page->redirect_after_action($success, $what, __('updated', 'event_espresso'), $route); |
|
421 | + exit; |
|
422 | 422 | } |
423 | 423 | |
424 | 424 | add_action( |
425 | - 'AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', |
|
426 | - 'ee_deprecated_update_attendee_registration_form_old', |
|
427 | - 10, |
|
428 | - 1 |
|
425 | + 'AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', |
|
426 | + 'ee_deprecated_update_attendee_registration_form_old', |
|
427 | + 10, |
|
428 | + 1 |
|
429 | 429 | ); |
430 | 430 | /** |
431 | 431 | * Render the registration admin page's custom questions area in the old fashion |
@@ -441,50 +441,50 @@ discard block |
||
441 | 441 | */ |
442 | 442 | function ee_deprecated_reg_questions_meta_box_old($do_default_action, $admin_page, $registration) |
443 | 443 | { |
444 | - // check if the old hooks are in use. If not, do the default |
|
445 | - if (! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks() |
|
446 | - || ! $admin_page instanceof EE_Admin_Page) { |
|
447 | - return $do_default_action; |
|
448 | - } |
|
449 | - add_filter( |
|
450 | - 'FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', |
|
451 | - array($admin_page, 'form_before_question_group'), |
|
452 | - 10, |
|
453 | - 1 |
|
454 | - ); |
|
455 | - add_filter( |
|
456 | - 'FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', |
|
457 | - array($admin_page, 'form_after_question_group'), |
|
458 | - 10, |
|
459 | - 1 |
|
460 | - ); |
|
461 | - add_filter('FHEE__EEH_Form_Fields__label_html', array($admin_page, 'form_form_field_label_wrap'), 10, 1); |
|
462 | - add_filter('FHEE__EEH_Form_Fields__input_html', array($admin_page, 'form_form_field_input__wrap'), 10, 1); |
|
463 | - |
|
464 | - $question_groups = EEM_Event::instance()->assemble_array_of_groups_questions_and_options( |
|
465 | - $registration, |
|
466 | - $registration->get( |
|
467 | - 'EVT_ID' |
|
468 | - ) |
|
469 | - ); |
|
470 | - |
|
471 | - EE_Registry::instance()->load_helper('Form_Fields'); |
|
472 | - $template_args = array( |
|
473 | - 'att_questions' => EEH_Form_Fields::generate_question_groups_html($question_groups), |
|
474 | - 'reg_questions_form_action' => 'edit_registration', |
|
475 | - 'REG_ID' => $registration->ID(), |
|
476 | - ); |
|
477 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php'; |
|
478 | - echo EEH_Template::display_template($template_path, $template_args, true); |
|
479 | - // indicate that we should not do the default admin page code |
|
480 | - return false; |
|
444 | + // check if the old hooks are in use. If not, do the default |
|
445 | + if (! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks() |
|
446 | + || ! $admin_page instanceof EE_Admin_Page) { |
|
447 | + return $do_default_action; |
|
448 | + } |
|
449 | + add_filter( |
|
450 | + 'FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', |
|
451 | + array($admin_page, 'form_before_question_group'), |
|
452 | + 10, |
|
453 | + 1 |
|
454 | + ); |
|
455 | + add_filter( |
|
456 | + 'FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', |
|
457 | + array($admin_page, 'form_after_question_group'), |
|
458 | + 10, |
|
459 | + 1 |
|
460 | + ); |
|
461 | + add_filter('FHEE__EEH_Form_Fields__label_html', array($admin_page, 'form_form_field_label_wrap'), 10, 1); |
|
462 | + add_filter('FHEE__EEH_Form_Fields__input_html', array($admin_page, 'form_form_field_input__wrap'), 10, 1); |
|
463 | + |
|
464 | + $question_groups = EEM_Event::instance()->assemble_array_of_groups_questions_and_options( |
|
465 | + $registration, |
|
466 | + $registration->get( |
|
467 | + 'EVT_ID' |
|
468 | + ) |
|
469 | + ); |
|
470 | + |
|
471 | + EE_Registry::instance()->load_helper('Form_Fields'); |
|
472 | + $template_args = array( |
|
473 | + 'att_questions' => EEH_Form_Fields::generate_question_groups_html($question_groups), |
|
474 | + 'reg_questions_form_action' => 'edit_registration', |
|
475 | + 'REG_ID' => $registration->ID(), |
|
476 | + ); |
|
477 | + $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php'; |
|
478 | + echo EEH_Template::display_template($template_path, $template_args, true); |
|
479 | + // indicate that we should not do the default admin page code |
|
480 | + return false; |
|
481 | 481 | } |
482 | 482 | |
483 | 483 | add_action( |
484 | - 'FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default', |
|
485 | - 'ee_deprecated_reg_questions_meta_box_old', |
|
486 | - 10, |
|
487 | - 3 |
|
484 | + 'FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default', |
|
485 | + 'ee_deprecated_reg_questions_meta_box_old', |
|
486 | + 10, |
|
487 | + 3 |
|
488 | 488 | ); |
489 | 489 | |
490 | 490 | |
@@ -501,42 +501,42 @@ discard block |
||
501 | 501 | class EE_Message_Template_Defaults extends EE_Base |
502 | 502 | { |
503 | 503 | |
504 | - /** |
|
505 | - * EE_Message_Template_Defaults constructor. |
|
506 | - * |
|
507 | - * @param EE_messages $messages |
|
508 | - * @param $messenger_name |
|
509 | - * @param $message_type_name |
|
510 | - * @param int $GRP_ID |
|
511 | - * @return EE_Messages_Template_Defaults |
|
512 | - */ |
|
513 | - public function __construct( |
|
514 | - EE_messages $messages, |
|
515 | - $messenger_name, |
|
516 | - $message_type_name, |
|
517 | - $GRP_ID = 0 |
|
518 | - ) { |
|
519 | - EE_Error::doing_it_wrong( |
|
520 | - __FUNCTION__, |
|
521 | - __( |
|
522 | - 'The class EE_Message_Template_Defaults has been deprecated and replaced by EE_Messages_Template_Defaults.', |
|
523 | - 'event_espresso' |
|
524 | - ), |
|
525 | - '4.9.0' |
|
526 | - ); |
|
527 | - /** @var EE_Message_Resource_Manager $message_resource_manager */ |
|
528 | - $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
529 | - $messenger = $message_resource_manager->get_messenger($messenger_name); |
|
530 | - $message_type = $message_resource_manager->get_message_type($message_type_name); |
|
531 | - return EE_Registry::instance()->load_lib( |
|
532 | - 'Messages_Template_Defaults', |
|
533 | - array( |
|
534 | - $GRP_ID, |
|
535 | - $messenger, |
|
536 | - $message_type, |
|
537 | - ) |
|
538 | - ); |
|
539 | - } |
|
504 | + /** |
|
505 | + * EE_Message_Template_Defaults constructor. |
|
506 | + * |
|
507 | + * @param EE_messages $messages |
|
508 | + * @param $messenger_name |
|
509 | + * @param $message_type_name |
|
510 | + * @param int $GRP_ID |
|
511 | + * @return EE_Messages_Template_Defaults |
|
512 | + */ |
|
513 | + public function __construct( |
|
514 | + EE_messages $messages, |
|
515 | + $messenger_name, |
|
516 | + $message_type_name, |
|
517 | + $GRP_ID = 0 |
|
518 | + ) { |
|
519 | + EE_Error::doing_it_wrong( |
|
520 | + __FUNCTION__, |
|
521 | + __( |
|
522 | + 'The class EE_Message_Template_Defaults has been deprecated and replaced by EE_Messages_Template_Defaults.', |
|
523 | + 'event_espresso' |
|
524 | + ), |
|
525 | + '4.9.0' |
|
526 | + ); |
|
527 | + /** @var EE_Message_Resource_Manager $message_resource_manager */ |
|
528 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
529 | + $messenger = $message_resource_manager->get_messenger($messenger_name); |
|
530 | + $message_type = $message_resource_manager->get_message_type($message_type_name); |
|
531 | + return EE_Registry::instance()->load_lib( |
|
532 | + 'Messages_Template_Defaults', |
|
533 | + array( |
|
534 | + $GRP_ID, |
|
535 | + $messenger, |
|
536 | + $message_type, |
|
537 | + ) |
|
538 | + ); |
|
539 | + } |
|
540 | 540 | } |
541 | 541 | |
542 | 542 | |
@@ -554,525 +554,525 @@ discard block |
||
554 | 554 | class EE_messages |
555 | 555 | { |
556 | 556 | |
557 | - /** @type EE_messenger[] */ |
|
558 | - protected $_active_messengers = array(); |
|
559 | - |
|
560 | - /** @type array */ |
|
561 | - protected $_active_message_types = array(); |
|
562 | - |
|
563 | - /** @type EE_message_type[] */ |
|
564 | - protected $_installed_message_types = array(); |
|
565 | - |
|
566 | - /** @type EE_messenger */ |
|
567 | - protected $_messenger; |
|
568 | - |
|
569 | - /** @type EE_message_type */ |
|
570 | - protected $_message_type; |
|
571 | - |
|
572 | - /** @type array */ |
|
573 | - protected $_contexts = array(); |
|
574 | - |
|
575 | - /** @type EE_Message_Resource_Manager $_message_resource_manager */ |
|
576 | - protected $_message_resource_manager; |
|
577 | - |
|
578 | - |
|
579 | - /** |
|
580 | - * EE_messages constructor. |
|
581 | - * |
|
582 | - * @deprecated 4.9.0 |
|
583 | - */ |
|
584 | - public function __construct() |
|
585 | - { |
|
586 | - } |
|
587 | - |
|
588 | - |
|
589 | - /** |
|
590 | - * @param string $method |
|
591 | - */ |
|
592 | - public function _class_is_deprecated($method) |
|
593 | - { |
|
594 | - EE_Error::doing_it_wrong( |
|
595 | - 'EE_messages::' . $method, |
|
596 | - __('EE_messages has been deprecated. Please use EE_Message_Resource_Manager instead.'), |
|
597 | - '4.9.0', |
|
598 | - '4.10.0.p' |
|
599 | - ); |
|
600 | - // Please use EE_Message_Resource_Manager instead |
|
601 | - $this->_message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
602 | - } |
|
603 | - |
|
604 | - |
|
605 | - /** |
|
606 | - * @deprecated 4.9.0 |
|
607 | - * @param string $messenger_name |
|
608 | - * @return boolean TRUE if it was PREVIOUSLY active, and FALSE if it was previously inactive |
|
609 | - */ |
|
610 | - public function ensure_messenger_is_active($messenger_name) |
|
611 | - { |
|
612 | - // EE_messages has been deprecated |
|
613 | - $this->_class_is_deprecated(__FUNCTION__); |
|
614 | - return $this->_message_resource_manager->ensure_messenger_is_active($messenger_name); |
|
615 | - } |
|
616 | - |
|
617 | - |
|
618 | - /** |
|
619 | - * @deprecated 4.9.0 |
|
620 | - * @param string $message_type message type name |
|
621 | - * @param $messenger |
|
622 | - * @return bool true if it got activated (or was active) and false if not. |
|
623 | - * @throws \EE_Error |
|
624 | - */ |
|
625 | - public function ensure_message_type_is_active($message_type, $messenger) |
|
626 | - { |
|
627 | - // EE_messages has been deprecated |
|
628 | - $this->_class_is_deprecated(__FUNCTION__); |
|
629 | - return $this->_message_resource_manager->ensure_message_type_is_active($message_type, $messenger); |
|
630 | - } |
|
631 | - |
|
632 | - |
|
633 | - /** |
|
634 | - * @deprecated 4.9.0 |
|
635 | - * @param string $messenger_name |
|
636 | - * @param array $mts_to_activate (optional) An array of message types to activate with this messenger. |
|
637 | - * If included we do NOT setup the default message types (assuming they |
|
638 | - * are already setup.) |
|
639 | - * @return boolean an array of generated templates or false if nothing generated/activated. |
|
640 | - */ |
|
641 | - public function activate_messenger($messenger_name, $mts_to_activate = array()) |
|
642 | - { |
|
643 | - // EE_messages has been deprecated |
|
644 | - $this->_class_is_deprecated(__FUNCTION__); |
|
645 | - return $this->_message_resource_manager->activate_messenger($messenger_name, $mts_to_activate); |
|
646 | - } |
|
647 | - |
|
648 | - |
|
649 | - /** |
|
650 | - * @deprecated 4.9.0 |
|
651 | - * @param EE_messenger $messenger messenger used in trigger |
|
652 | - * @param EE_message_type $message_type message type used in trigger |
|
653 | - * |
|
654 | - * @return bool true is a generating messenger and can be sent OR FALSE meaning cannot send. |
|
655 | - */ |
|
656 | - public function is_generating_messenger_and_active(EE_messenger $messenger, EE_message_type $message_type) |
|
657 | - { |
|
658 | - // EE_messages has been deprecated |
|
659 | - $this->_class_is_deprecated(__FUNCTION__); |
|
660 | - return $this->_message_resource_manager->is_generating_messenger_and_active($messenger, $message_type); |
|
661 | - } |
|
662 | - |
|
663 | - |
|
664 | - /** |
|
665 | - * @deprecated 4.9.0 |
|
666 | - * @param string $messenger |
|
667 | - * @return EE_messenger | null |
|
668 | - */ |
|
669 | - public function get_messenger_if_active($messenger) |
|
670 | - { |
|
671 | - // EE_messages has been deprecated |
|
672 | - $this->_class_is_deprecated(__FUNCTION__); |
|
673 | - return $this->_message_resource_manager->get_active_messenger($messenger); |
|
674 | - } |
|
675 | - |
|
676 | - |
|
677 | - /** |
|
678 | - * @deprecated 4.9.0 |
|
679 | - * @param EE_Message $message |
|
680 | - * @return array An array with 'messenger' and 'message_type' as the index and the corresponding valid object if |
|
681 | - * available. |
|
682 | - * Eg. Valid Messenger and Message Type: |
|
683 | - * array( |
|
684 | - * 'messenger' => new EE_Email_messenger(), |
|
685 | - * 'message_type' => new EE_Registration_Approved_message_type() |
|
686 | - * ) |
|
687 | - * Valid Messenger and Invalid Message Type: |
|
688 | - * array( |
|
689 | - * 'messenger' => new EE_Email_messenger(), |
|
690 | - * 'message_type' => null |
|
691 | - * ) |
|
692 | - */ |
|
693 | - public function validate_for_use(EE_Message $message) |
|
694 | - { |
|
695 | - // EE_messages has been deprecated |
|
696 | - $this->_class_is_deprecated(__FUNCTION__); |
|
697 | - return array( |
|
698 | - 'messenger' => $message->messenger_object(), |
|
699 | - 'message_type' => $message->message_type_object(), |
|
700 | - ); |
|
701 | - } |
|
702 | - |
|
703 | - |
|
704 | - /** |
|
705 | - * @deprecated 4.9.0 |
|
706 | - * @param string $type What type of message are we sending (corresponds to message types) |
|
707 | - * @param mixed $vars Data being sent for parsing in the message |
|
708 | - * @param string $sending_messenger if included then we ONLY use the specified messenger for delivery. |
|
709 | - * Otherwise we cycle through all active messengers. |
|
710 | - * @param string $generating_messenger if included then this messenger is used for generating the message |
|
711 | - * templates (but not for sending). |
|
712 | - * @param string $context If included then only a message type for a specific context will be |
|
713 | - * generated. |
|
714 | - * @param bool $send Default TRUE. If false, then this will just return the generated |
|
715 | - * EE_messages objects which might be used by the trigger to setup a batch |
|
716 | - * message (typically html messenger uses it). |
|
717 | - * @return bool |
|
718 | - */ |
|
719 | - public function send_message( |
|
720 | - $type, |
|
721 | - $vars, |
|
722 | - $sending_messenger = '', |
|
723 | - $generating_messenger = '', |
|
724 | - $context = '', |
|
725 | - $send = true |
|
726 | - ) { |
|
727 | - // EE_messages has been deprecated |
|
728 | - $this->_class_is_deprecated(__FUNCTION__); |
|
729 | - /** @type EE_Messages_Processor $processor */ |
|
730 | - $processor = EE_Registry::instance()->load_lib('Messages_Processor'); |
|
731 | - $error = false; |
|
732 | - // try to intelligently determine what method we'll call based on the incoming data. |
|
733 | - // if generating and sending are different then generate and send immediately. |
|
734 | - if (! empty($sending_messenger) && $sending_messenger != $generating_messenger && $send) { |
|
735 | - // in the legacy system, when generating and sending were different, that means all the |
|
736 | - // vars are already in the request object. So let's just use that. |
|
737 | - try { |
|
738 | - /** @type EE_Message_To_Generate_From_Request $mtg */ |
|
739 | - $mtg = EE_Registry::instance()->load_lib('Message_To_Generate_From_Request'); |
|
740 | - $processor->generate_and_send_now($mtg); |
|
741 | - } catch (EE_Error $e) { |
|
742 | - $error_msg = __( |
|
743 | - 'Please note that a system message failed to send due to a technical issue.', |
|
744 | - 'event_espresso' |
|
745 | - ); |
|
746 | - // add specific message for developers if WP_DEBUG in on |
|
747 | - $error_msg .= '||' . $e->getMessage(); |
|
748 | - EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
749 | - $error = true; |
|
750 | - } |
|
751 | - } else { |
|
752 | - $processor->generate_for_all_active_messengers($type, $vars, $send); |
|
753 | - // let's find out if there were any errors and how many successfully were queued. |
|
754 | - $count_errors = $processor->get_queue()->count_STS_in_queue( |
|
755 | - array(EEM_Message::status_failed, EEM_Message::status_debug_only) |
|
756 | - ); |
|
757 | - $count_queued = $processor->get_queue()->count_STS_in_queue(EEM_Message::status_incomplete); |
|
758 | - $count_retry = $processor->get_queue()->count_STS_in_queue(EEM_Message::status_retry); |
|
759 | - $count_errors = $count_errors + $count_retry; |
|
760 | - if ($count_errors > 0) { |
|
761 | - $error = true; |
|
762 | - if ($count_errors > 1 && $count_retry > 1 && $count_queued > 1) { |
|
763 | - $message = sprintf( |
|
764 | - __( |
|
765 | - 'There were %d errors and %d messages successfully queued for generation and sending', |
|
766 | - 'event_espresso' |
|
767 | - ), |
|
768 | - $count_errors, |
|
769 | - $count_queued |
|
770 | - ); |
|
771 | - } elseif ($count_errors > 1 && $count_queued === 1) { |
|
772 | - $message = sprintf( |
|
773 | - __( |
|
774 | - 'There were %d errors and %d message successfully queued for generation.', |
|
775 | - 'event_espresso' |
|
776 | - ), |
|
777 | - $count_errors, |
|
778 | - $count_queued |
|
779 | - ); |
|
780 | - } elseif ($count_errors === 1 && $count_queued > 1) { |
|
781 | - $message = sprintf( |
|
782 | - __( |
|
783 | - 'There was %d error and %d messages successfully queued for generation.', |
|
784 | - 'event_espresso' |
|
785 | - ), |
|
786 | - $count_errors, |
|
787 | - $count_queued |
|
788 | - ); |
|
789 | - } else { |
|
790 | - $message = sprintf( |
|
791 | - __( |
|
792 | - 'There was %d message that failed to be queued for generation.', |
|
793 | - 'event_espresso' |
|
794 | - ), |
|
795 | - $count_errors |
|
796 | - ); |
|
797 | - } |
|
798 | - EE_Error::add_error($message, __FILE__, __FUNCTION__, __LINE__); |
|
799 | - } else { |
|
800 | - if ($count_queued === 1) { |
|
801 | - $message = sprintf( |
|
802 | - __( |
|
803 | - '%d message successfully queued for generation.', |
|
804 | - 'event_espresso' |
|
805 | - ), |
|
806 | - $count_queued |
|
807 | - ); |
|
808 | - } else { |
|
809 | - $message = sprintf( |
|
810 | - __( |
|
811 | - '%d messages were successfully queued for generation.', |
|
812 | - 'event_espresso' |
|
813 | - ), |
|
814 | - $count_queued |
|
815 | - ); |
|
816 | - } |
|
817 | - EE_Error::add_success($message); |
|
818 | - } |
|
819 | - } |
|
820 | - // if no error then return the generated message(s). |
|
821 | - if (! $error && ! $send) { |
|
822 | - $generated_queue = $processor->generate_queue(false); |
|
823 | - // get message and return. |
|
824 | - $generated_queue->get_message_repository()->rewind(); |
|
825 | - $messages = array(); |
|
826 | - while ($generated_queue->get_message_repository()->valid()) { |
|
827 | - $message = $generated_queue->get_message_repository()->current(); |
|
828 | - if ($message instanceof EE_Message) { |
|
829 | - // set properties that might be expected by add-ons (backward compat) |
|
830 | - $message->content = $message->content(); |
|
831 | - $message->template_pack = $message->get_template_pack(); |
|
832 | - $message->template_variation = $message->get_template_pack_variation(); |
|
833 | - $messages[] = $message; |
|
834 | - } |
|
835 | - $generated_queue->get_message_repository()->next(); |
|
836 | - } |
|
837 | - return $messages; |
|
838 | - } |
|
839 | - return $error ? false |
|
840 | - : 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. |
|
841 | - } |
|
842 | - |
|
843 | - |
|
844 | - /** |
|
845 | - * @deprecated 4.9.0 |
|
846 | - * @param string $type This should correspond with a valid message type |
|
847 | - * @param string $context This should correspond with a valid context for the message type |
|
848 | - * @param string $messenger This should correspond with a valid messenger. |
|
849 | - * @param bool $send true we will do a test send using the messenger delivery, false we just do a regular |
|
850 | - * preview |
|
851 | - * @return string The body of the message. |
|
852 | - */ |
|
853 | - public function preview_message($type, $context, $messenger, $send = false) |
|
854 | - { |
|
855 | - // EE_messages has been deprecated |
|
856 | - $this->_class_is_deprecated(__FUNCTION__); |
|
857 | - return EED_Messages::preview_message($type, $context, $messenger, $send); |
|
858 | - } |
|
859 | - |
|
860 | - |
|
861 | - /** |
|
862 | - * @since 4.5.0 |
|
863 | - * @deprecated 4.9.0 Moved to EED_Messages Module |
|
864 | - * @param string $messenger a string matching a valid active messenger in the system |
|
865 | - * @param string $message_type Although it seems contrary to the name of the method, a message type name is still |
|
866 | - * required to send along the message type to the messenger because this is used for |
|
867 | - * determining what specific variations might be loaded for the generated message. |
|
868 | - * @param stdClass $message a stdClass object in the format expected by the messenger. |
|
869 | - * |
|
870 | - * @return bool success or fail. |
|
871 | - */ |
|
872 | - public function send_message_with_messenger_only($messenger, $message_type, $message) |
|
873 | - { |
|
874 | - // EE_messages has been deprecated |
|
875 | - $this->_class_is_deprecated(__FUNCTION__); |
|
876 | - // setup for sending to new method. |
|
877 | - /** @type EE_Messages_Queue $queue */ |
|
878 | - $queue = EE_Registry::instance()->load_lib('Messages_Queue'); |
|
879 | - // make sure we have a proper message object |
|
880 | - if (! $message instanceof EE_Message && is_object($message) && isset($message->content)) { |
|
881 | - $msg = EE_Message_Factory::create( |
|
882 | - array( |
|
883 | - 'MSG_messenger' => $messenger, |
|
884 | - 'MSG_message_type' => $message_type, |
|
885 | - 'MSG_content' => $message->content, |
|
886 | - 'MSG_subject' => $message->subject, |
|
887 | - ) |
|
888 | - ); |
|
889 | - } else { |
|
890 | - $msg = $message; |
|
891 | - } |
|
892 | - if (! $msg instanceof EE_Message) { |
|
893 | - return false; |
|
894 | - } |
|
895 | - // make sure any content in a content property (if not empty) is set on the MSG_content. |
|
896 | - if (! empty($msg->content)) { |
|
897 | - $msg->set('MSG_content', $msg->content); |
|
898 | - } |
|
899 | - $queue->add($msg); |
|
900 | - return EED_Messages::send_message_with_messenger_only($messenger, $message_type, $queue); |
|
901 | - } |
|
902 | - |
|
903 | - |
|
904 | - /** |
|
905 | - * @deprecated 4.9.0 |
|
906 | - * @param $messenger |
|
907 | - * @param string $message_type message type that the templates are being created for |
|
908 | - * @param int $GRP_ID |
|
909 | - * @param bool $is_global |
|
910 | - * @return array|object if creation is successful then we return an array of info, otherwise an error_object is |
|
911 | - * returned. |
|
912 | - * @throws \EE_Error |
|
913 | - */ |
|
914 | - public function create_new_templates($messenger, $message_type, $GRP_ID = 0, $is_global = false) |
|
915 | - { |
|
916 | - // EE_messages has been deprecated |
|
917 | - $this->_class_is_deprecated(__FUNCTION__); |
|
918 | - EE_Registry::instance()->load_helper('MSG_Template'); |
|
919 | - return EEH_MSG_Template::create_new_templates($messenger, $message_type, $GRP_ID, $is_global); |
|
920 | - } |
|
921 | - |
|
922 | - |
|
923 | - /** |
|
924 | - * @deprecated 4.9.0 |
|
925 | - * @param string $messenger_name name of EE_messenger |
|
926 | - * @param string $message_type_name name of EE_message_type |
|
927 | - * @return array |
|
928 | - */ |
|
929 | - public function get_fields($messenger_name, $message_type_name) |
|
930 | - { |
|
931 | - // EE_messages has been deprecated |
|
932 | - $this->_class_is_deprecated(__FUNCTION__); |
|
933 | - EE_Registry::instance()->load_helper('MSG_Template'); |
|
934 | - return EEH_MSG_Template::get_fields($messenger_name, $message_type_name); |
|
935 | - } |
|
936 | - |
|
937 | - |
|
938 | - /** |
|
939 | - * @deprecated 4.9.0 |
|
940 | - * @access public |
|
941 | - * @param string $type we can indicate just returning installed message types |
|
942 | - * or messengers (or both) via this parameter. |
|
943 | - * @param bool $skip_cache if true then we skip the cache and retrieve via files. |
|
944 | - * @return array multidimensional array of messenger and message_type objects |
|
945 | - * (messengers index, and message_type index); |
|
946 | - */ |
|
947 | - public function get_installed($type = 'all', $skip_cache = false) |
|
948 | - { |
|
949 | - // EE_messages has been deprecated |
|
950 | - $this->_class_is_deprecated(__FUNCTION__); |
|
951 | - if ($skip_cache) { |
|
952 | - $this->_message_resource_manager->reset_active_messengers_and_message_types(); |
|
953 | - } |
|
954 | - switch ($type) { |
|
955 | - case 'messengers' : |
|
956 | - return array( |
|
957 | - 'messenger' => $this->_message_resource_manager->installed_messengers(), |
|
958 | - ); |
|
959 | - break; |
|
960 | - case 'message_types' : |
|
961 | - return array( |
|
962 | - 'message_type' => $this->_message_resource_manager->installed_message_types(), |
|
963 | - ); |
|
964 | - break; |
|
965 | - case 'all' : |
|
966 | - default : |
|
967 | - return array( |
|
968 | - 'messenger' => $this->_message_resource_manager->installed_messengers(), |
|
969 | - 'message_type' => $this->_message_resource_manager->installed_message_types(), |
|
970 | - ); |
|
971 | - break; |
|
972 | - } |
|
973 | - } |
|
974 | - |
|
975 | - |
|
976 | - /** |
|
977 | - * @deprecated 4.9.0 |
|
978 | - * @return \EE_messenger[] |
|
979 | - */ |
|
980 | - public function get_active_messengers() |
|
981 | - { |
|
982 | - // EE_messages has been deprecated |
|
983 | - $this->_class_is_deprecated(__FUNCTION__); |
|
984 | - return $this->_message_resource_manager->active_messengers(); |
|
985 | - } |
|
986 | - |
|
987 | - |
|
988 | - /** |
|
989 | - * @deprecated 4.9.0 |
|
990 | - * @return array array of message_type references (string) |
|
991 | - */ |
|
992 | - public function get_active_message_types() |
|
993 | - { |
|
994 | - // EE_messages has been deprecated |
|
995 | - $this->_class_is_deprecated(__FUNCTION__); |
|
996 | - return $this->_message_resource_manager->list_of_active_message_types(); |
|
997 | - } |
|
998 | - |
|
999 | - |
|
1000 | - /** |
|
1001 | - * @deprecated 4.9.0 |
|
1002 | - * @return EE_message_type[] |
|
1003 | - */ |
|
1004 | - public function get_active_message_type_objects() |
|
1005 | - { |
|
1006 | - // EE_messages has been deprecated |
|
1007 | - $this->_class_is_deprecated(__FUNCTION__); |
|
1008 | - return $this->_message_resource_manager->get_active_message_type_objects(); |
|
1009 | - } |
|
1010 | - |
|
1011 | - |
|
1012 | - /** |
|
1013 | - * @deprecated 4.9.0 |
|
1014 | - * @since 4.5.0 |
|
1015 | - * @param string $messenger The messenger being checked |
|
1016 | - * @return EE_message_type[] (or empty array if none present) |
|
1017 | - */ |
|
1018 | - public function get_active_message_types_per_messenger($messenger) |
|
1019 | - { |
|
1020 | - // EE_messages has been deprecated |
|
1021 | - $this->_class_is_deprecated(__FUNCTION__); |
|
1022 | - return $this->_message_resource_manager->get_active_message_types_for_messenger($messenger); |
|
1023 | - } |
|
1024 | - |
|
1025 | - |
|
1026 | - /** |
|
1027 | - * @deprecated 4.9.0 |
|
1028 | - * @param string $messenger The string should correspond to the messenger (message types are |
|
1029 | - * @param string $message_type The string should correspond to a message type. |
|
1030 | - * @return EE_message_type|null |
|
1031 | - */ |
|
1032 | - public function get_active_message_type($messenger, $message_type) |
|
1033 | - { |
|
1034 | - // EE_messages has been deprecated |
|
1035 | - $this->_class_is_deprecated(__FUNCTION__); |
|
1036 | - return $this->_message_resource_manager->get_active_message_type_for_messenger($messenger, $message_type); |
|
1037 | - } |
|
1038 | - |
|
1039 | - |
|
1040 | - /** |
|
1041 | - * @deprecated 4.9.0 |
|
1042 | - * @return array|\EE_message_type[] |
|
1043 | - */ |
|
1044 | - public function get_installed_message_types() |
|
1045 | - { |
|
1046 | - // EE_messages has been deprecated |
|
1047 | - $this->_class_is_deprecated(__FUNCTION__); |
|
1048 | - return $this->_message_resource_manager->installed_message_types(); |
|
1049 | - } |
|
1050 | - |
|
1051 | - |
|
1052 | - /** |
|
1053 | - * @deprecated 4.9.0 |
|
1054 | - * @return array |
|
1055 | - */ |
|
1056 | - public function get_installed_messengers() |
|
1057 | - { |
|
1058 | - // EE_messages has been deprecated |
|
1059 | - $this->_class_is_deprecated(__FUNCTION__); |
|
1060 | - return $this->_message_resource_manager->installed_messengers(); |
|
1061 | - } |
|
1062 | - |
|
1063 | - |
|
1064 | - /** |
|
1065 | - * @deprecated 4.9.0 |
|
1066 | - * @param bool $slugs_only Whether to return an array of just slugs and labels (true) or all contexts indexed by |
|
1067 | - * message type. |
|
1068 | - * @return array |
|
1069 | - */ |
|
1070 | - public function get_all_contexts($slugs_only = true) |
|
1071 | - { |
|
1072 | - // EE_messages has been deprecated |
|
1073 | - $this->_class_is_deprecated(__FUNCTION__); |
|
1074 | - return $this->_message_resource_manager->get_all_contexts($slugs_only); |
|
1075 | - } |
|
557 | + /** @type EE_messenger[] */ |
|
558 | + protected $_active_messengers = array(); |
|
559 | + |
|
560 | + /** @type array */ |
|
561 | + protected $_active_message_types = array(); |
|
562 | + |
|
563 | + /** @type EE_message_type[] */ |
|
564 | + protected $_installed_message_types = array(); |
|
565 | + |
|
566 | + /** @type EE_messenger */ |
|
567 | + protected $_messenger; |
|
568 | + |
|
569 | + /** @type EE_message_type */ |
|
570 | + protected $_message_type; |
|
571 | + |
|
572 | + /** @type array */ |
|
573 | + protected $_contexts = array(); |
|
574 | + |
|
575 | + /** @type EE_Message_Resource_Manager $_message_resource_manager */ |
|
576 | + protected $_message_resource_manager; |
|
577 | + |
|
578 | + |
|
579 | + /** |
|
580 | + * EE_messages constructor. |
|
581 | + * |
|
582 | + * @deprecated 4.9.0 |
|
583 | + */ |
|
584 | + public function __construct() |
|
585 | + { |
|
586 | + } |
|
587 | + |
|
588 | + |
|
589 | + /** |
|
590 | + * @param string $method |
|
591 | + */ |
|
592 | + public function _class_is_deprecated($method) |
|
593 | + { |
|
594 | + EE_Error::doing_it_wrong( |
|
595 | + 'EE_messages::' . $method, |
|
596 | + __('EE_messages has been deprecated. Please use EE_Message_Resource_Manager instead.'), |
|
597 | + '4.9.0', |
|
598 | + '4.10.0.p' |
|
599 | + ); |
|
600 | + // Please use EE_Message_Resource_Manager instead |
|
601 | + $this->_message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
602 | + } |
|
603 | + |
|
604 | + |
|
605 | + /** |
|
606 | + * @deprecated 4.9.0 |
|
607 | + * @param string $messenger_name |
|
608 | + * @return boolean TRUE if it was PREVIOUSLY active, and FALSE if it was previously inactive |
|
609 | + */ |
|
610 | + public function ensure_messenger_is_active($messenger_name) |
|
611 | + { |
|
612 | + // EE_messages has been deprecated |
|
613 | + $this->_class_is_deprecated(__FUNCTION__); |
|
614 | + return $this->_message_resource_manager->ensure_messenger_is_active($messenger_name); |
|
615 | + } |
|
616 | + |
|
617 | + |
|
618 | + /** |
|
619 | + * @deprecated 4.9.0 |
|
620 | + * @param string $message_type message type name |
|
621 | + * @param $messenger |
|
622 | + * @return bool true if it got activated (or was active) and false if not. |
|
623 | + * @throws \EE_Error |
|
624 | + */ |
|
625 | + public function ensure_message_type_is_active($message_type, $messenger) |
|
626 | + { |
|
627 | + // EE_messages has been deprecated |
|
628 | + $this->_class_is_deprecated(__FUNCTION__); |
|
629 | + return $this->_message_resource_manager->ensure_message_type_is_active($message_type, $messenger); |
|
630 | + } |
|
631 | + |
|
632 | + |
|
633 | + /** |
|
634 | + * @deprecated 4.9.0 |
|
635 | + * @param string $messenger_name |
|
636 | + * @param array $mts_to_activate (optional) An array of message types to activate with this messenger. |
|
637 | + * If included we do NOT setup the default message types (assuming they |
|
638 | + * are already setup.) |
|
639 | + * @return boolean an array of generated templates or false if nothing generated/activated. |
|
640 | + */ |
|
641 | + public function activate_messenger($messenger_name, $mts_to_activate = array()) |
|
642 | + { |
|
643 | + // EE_messages has been deprecated |
|
644 | + $this->_class_is_deprecated(__FUNCTION__); |
|
645 | + return $this->_message_resource_manager->activate_messenger($messenger_name, $mts_to_activate); |
|
646 | + } |
|
647 | + |
|
648 | + |
|
649 | + /** |
|
650 | + * @deprecated 4.9.0 |
|
651 | + * @param EE_messenger $messenger messenger used in trigger |
|
652 | + * @param EE_message_type $message_type message type used in trigger |
|
653 | + * |
|
654 | + * @return bool true is a generating messenger and can be sent OR FALSE meaning cannot send. |
|
655 | + */ |
|
656 | + public function is_generating_messenger_and_active(EE_messenger $messenger, EE_message_type $message_type) |
|
657 | + { |
|
658 | + // EE_messages has been deprecated |
|
659 | + $this->_class_is_deprecated(__FUNCTION__); |
|
660 | + return $this->_message_resource_manager->is_generating_messenger_and_active($messenger, $message_type); |
|
661 | + } |
|
662 | + |
|
663 | + |
|
664 | + /** |
|
665 | + * @deprecated 4.9.0 |
|
666 | + * @param string $messenger |
|
667 | + * @return EE_messenger | null |
|
668 | + */ |
|
669 | + public function get_messenger_if_active($messenger) |
|
670 | + { |
|
671 | + // EE_messages has been deprecated |
|
672 | + $this->_class_is_deprecated(__FUNCTION__); |
|
673 | + return $this->_message_resource_manager->get_active_messenger($messenger); |
|
674 | + } |
|
675 | + |
|
676 | + |
|
677 | + /** |
|
678 | + * @deprecated 4.9.0 |
|
679 | + * @param EE_Message $message |
|
680 | + * @return array An array with 'messenger' and 'message_type' as the index and the corresponding valid object if |
|
681 | + * available. |
|
682 | + * Eg. Valid Messenger and Message Type: |
|
683 | + * array( |
|
684 | + * 'messenger' => new EE_Email_messenger(), |
|
685 | + * 'message_type' => new EE_Registration_Approved_message_type() |
|
686 | + * ) |
|
687 | + * Valid Messenger and Invalid Message Type: |
|
688 | + * array( |
|
689 | + * 'messenger' => new EE_Email_messenger(), |
|
690 | + * 'message_type' => null |
|
691 | + * ) |
|
692 | + */ |
|
693 | + public function validate_for_use(EE_Message $message) |
|
694 | + { |
|
695 | + // EE_messages has been deprecated |
|
696 | + $this->_class_is_deprecated(__FUNCTION__); |
|
697 | + return array( |
|
698 | + 'messenger' => $message->messenger_object(), |
|
699 | + 'message_type' => $message->message_type_object(), |
|
700 | + ); |
|
701 | + } |
|
702 | + |
|
703 | + |
|
704 | + /** |
|
705 | + * @deprecated 4.9.0 |
|
706 | + * @param string $type What type of message are we sending (corresponds to message types) |
|
707 | + * @param mixed $vars Data being sent for parsing in the message |
|
708 | + * @param string $sending_messenger if included then we ONLY use the specified messenger for delivery. |
|
709 | + * Otherwise we cycle through all active messengers. |
|
710 | + * @param string $generating_messenger if included then this messenger is used for generating the message |
|
711 | + * templates (but not for sending). |
|
712 | + * @param string $context If included then only a message type for a specific context will be |
|
713 | + * generated. |
|
714 | + * @param bool $send Default TRUE. If false, then this will just return the generated |
|
715 | + * EE_messages objects which might be used by the trigger to setup a batch |
|
716 | + * message (typically html messenger uses it). |
|
717 | + * @return bool |
|
718 | + */ |
|
719 | + public function send_message( |
|
720 | + $type, |
|
721 | + $vars, |
|
722 | + $sending_messenger = '', |
|
723 | + $generating_messenger = '', |
|
724 | + $context = '', |
|
725 | + $send = true |
|
726 | + ) { |
|
727 | + // EE_messages has been deprecated |
|
728 | + $this->_class_is_deprecated(__FUNCTION__); |
|
729 | + /** @type EE_Messages_Processor $processor */ |
|
730 | + $processor = EE_Registry::instance()->load_lib('Messages_Processor'); |
|
731 | + $error = false; |
|
732 | + // try to intelligently determine what method we'll call based on the incoming data. |
|
733 | + // if generating and sending are different then generate and send immediately. |
|
734 | + if (! empty($sending_messenger) && $sending_messenger != $generating_messenger && $send) { |
|
735 | + // in the legacy system, when generating and sending were different, that means all the |
|
736 | + // vars are already in the request object. So let's just use that. |
|
737 | + try { |
|
738 | + /** @type EE_Message_To_Generate_From_Request $mtg */ |
|
739 | + $mtg = EE_Registry::instance()->load_lib('Message_To_Generate_From_Request'); |
|
740 | + $processor->generate_and_send_now($mtg); |
|
741 | + } catch (EE_Error $e) { |
|
742 | + $error_msg = __( |
|
743 | + 'Please note that a system message failed to send due to a technical issue.', |
|
744 | + 'event_espresso' |
|
745 | + ); |
|
746 | + // add specific message for developers if WP_DEBUG in on |
|
747 | + $error_msg .= '||' . $e->getMessage(); |
|
748 | + EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
749 | + $error = true; |
|
750 | + } |
|
751 | + } else { |
|
752 | + $processor->generate_for_all_active_messengers($type, $vars, $send); |
|
753 | + // let's find out if there were any errors and how many successfully were queued. |
|
754 | + $count_errors = $processor->get_queue()->count_STS_in_queue( |
|
755 | + array(EEM_Message::status_failed, EEM_Message::status_debug_only) |
|
756 | + ); |
|
757 | + $count_queued = $processor->get_queue()->count_STS_in_queue(EEM_Message::status_incomplete); |
|
758 | + $count_retry = $processor->get_queue()->count_STS_in_queue(EEM_Message::status_retry); |
|
759 | + $count_errors = $count_errors + $count_retry; |
|
760 | + if ($count_errors > 0) { |
|
761 | + $error = true; |
|
762 | + if ($count_errors > 1 && $count_retry > 1 && $count_queued > 1) { |
|
763 | + $message = sprintf( |
|
764 | + __( |
|
765 | + 'There were %d errors and %d messages successfully queued for generation and sending', |
|
766 | + 'event_espresso' |
|
767 | + ), |
|
768 | + $count_errors, |
|
769 | + $count_queued |
|
770 | + ); |
|
771 | + } elseif ($count_errors > 1 && $count_queued === 1) { |
|
772 | + $message = sprintf( |
|
773 | + __( |
|
774 | + 'There were %d errors and %d message successfully queued for generation.', |
|
775 | + 'event_espresso' |
|
776 | + ), |
|
777 | + $count_errors, |
|
778 | + $count_queued |
|
779 | + ); |
|
780 | + } elseif ($count_errors === 1 && $count_queued > 1) { |
|
781 | + $message = sprintf( |
|
782 | + __( |
|
783 | + 'There was %d error and %d messages successfully queued for generation.', |
|
784 | + 'event_espresso' |
|
785 | + ), |
|
786 | + $count_errors, |
|
787 | + $count_queued |
|
788 | + ); |
|
789 | + } else { |
|
790 | + $message = sprintf( |
|
791 | + __( |
|
792 | + 'There was %d message that failed to be queued for generation.', |
|
793 | + 'event_espresso' |
|
794 | + ), |
|
795 | + $count_errors |
|
796 | + ); |
|
797 | + } |
|
798 | + EE_Error::add_error($message, __FILE__, __FUNCTION__, __LINE__); |
|
799 | + } else { |
|
800 | + if ($count_queued === 1) { |
|
801 | + $message = sprintf( |
|
802 | + __( |
|
803 | + '%d message successfully queued for generation.', |
|
804 | + 'event_espresso' |
|
805 | + ), |
|
806 | + $count_queued |
|
807 | + ); |
|
808 | + } else { |
|
809 | + $message = sprintf( |
|
810 | + __( |
|
811 | + '%d messages were successfully queued for generation.', |
|
812 | + 'event_espresso' |
|
813 | + ), |
|
814 | + $count_queued |
|
815 | + ); |
|
816 | + } |
|
817 | + EE_Error::add_success($message); |
|
818 | + } |
|
819 | + } |
|
820 | + // if no error then return the generated message(s). |
|
821 | + if (! $error && ! $send) { |
|
822 | + $generated_queue = $processor->generate_queue(false); |
|
823 | + // get message and return. |
|
824 | + $generated_queue->get_message_repository()->rewind(); |
|
825 | + $messages = array(); |
|
826 | + while ($generated_queue->get_message_repository()->valid()) { |
|
827 | + $message = $generated_queue->get_message_repository()->current(); |
|
828 | + if ($message instanceof EE_Message) { |
|
829 | + // set properties that might be expected by add-ons (backward compat) |
|
830 | + $message->content = $message->content(); |
|
831 | + $message->template_pack = $message->get_template_pack(); |
|
832 | + $message->template_variation = $message->get_template_pack_variation(); |
|
833 | + $messages[] = $message; |
|
834 | + } |
|
835 | + $generated_queue->get_message_repository()->next(); |
|
836 | + } |
|
837 | + return $messages; |
|
838 | + } |
|
839 | + return $error ? false |
|
840 | + : 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. |
|
841 | + } |
|
842 | + |
|
843 | + |
|
844 | + /** |
|
845 | + * @deprecated 4.9.0 |
|
846 | + * @param string $type This should correspond with a valid message type |
|
847 | + * @param string $context This should correspond with a valid context for the message type |
|
848 | + * @param string $messenger This should correspond with a valid messenger. |
|
849 | + * @param bool $send true we will do a test send using the messenger delivery, false we just do a regular |
|
850 | + * preview |
|
851 | + * @return string The body of the message. |
|
852 | + */ |
|
853 | + public function preview_message($type, $context, $messenger, $send = false) |
|
854 | + { |
|
855 | + // EE_messages has been deprecated |
|
856 | + $this->_class_is_deprecated(__FUNCTION__); |
|
857 | + return EED_Messages::preview_message($type, $context, $messenger, $send); |
|
858 | + } |
|
859 | + |
|
860 | + |
|
861 | + /** |
|
862 | + * @since 4.5.0 |
|
863 | + * @deprecated 4.9.0 Moved to EED_Messages Module |
|
864 | + * @param string $messenger a string matching a valid active messenger in the system |
|
865 | + * @param string $message_type Although it seems contrary to the name of the method, a message type name is still |
|
866 | + * required to send along the message type to the messenger because this is used for |
|
867 | + * determining what specific variations might be loaded for the generated message. |
|
868 | + * @param stdClass $message a stdClass object in the format expected by the messenger. |
|
869 | + * |
|
870 | + * @return bool success or fail. |
|
871 | + */ |
|
872 | + public function send_message_with_messenger_only($messenger, $message_type, $message) |
|
873 | + { |
|
874 | + // EE_messages has been deprecated |
|
875 | + $this->_class_is_deprecated(__FUNCTION__); |
|
876 | + // setup for sending to new method. |
|
877 | + /** @type EE_Messages_Queue $queue */ |
|
878 | + $queue = EE_Registry::instance()->load_lib('Messages_Queue'); |
|
879 | + // make sure we have a proper message object |
|
880 | + if (! $message instanceof EE_Message && is_object($message) && isset($message->content)) { |
|
881 | + $msg = EE_Message_Factory::create( |
|
882 | + array( |
|
883 | + 'MSG_messenger' => $messenger, |
|
884 | + 'MSG_message_type' => $message_type, |
|
885 | + 'MSG_content' => $message->content, |
|
886 | + 'MSG_subject' => $message->subject, |
|
887 | + ) |
|
888 | + ); |
|
889 | + } else { |
|
890 | + $msg = $message; |
|
891 | + } |
|
892 | + if (! $msg instanceof EE_Message) { |
|
893 | + return false; |
|
894 | + } |
|
895 | + // make sure any content in a content property (if not empty) is set on the MSG_content. |
|
896 | + if (! empty($msg->content)) { |
|
897 | + $msg->set('MSG_content', $msg->content); |
|
898 | + } |
|
899 | + $queue->add($msg); |
|
900 | + return EED_Messages::send_message_with_messenger_only($messenger, $message_type, $queue); |
|
901 | + } |
|
902 | + |
|
903 | + |
|
904 | + /** |
|
905 | + * @deprecated 4.9.0 |
|
906 | + * @param $messenger |
|
907 | + * @param string $message_type message type that the templates are being created for |
|
908 | + * @param int $GRP_ID |
|
909 | + * @param bool $is_global |
|
910 | + * @return array|object if creation is successful then we return an array of info, otherwise an error_object is |
|
911 | + * returned. |
|
912 | + * @throws \EE_Error |
|
913 | + */ |
|
914 | + public function create_new_templates($messenger, $message_type, $GRP_ID = 0, $is_global = false) |
|
915 | + { |
|
916 | + // EE_messages has been deprecated |
|
917 | + $this->_class_is_deprecated(__FUNCTION__); |
|
918 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
919 | + return EEH_MSG_Template::create_new_templates($messenger, $message_type, $GRP_ID, $is_global); |
|
920 | + } |
|
921 | + |
|
922 | + |
|
923 | + /** |
|
924 | + * @deprecated 4.9.0 |
|
925 | + * @param string $messenger_name name of EE_messenger |
|
926 | + * @param string $message_type_name name of EE_message_type |
|
927 | + * @return array |
|
928 | + */ |
|
929 | + public function get_fields($messenger_name, $message_type_name) |
|
930 | + { |
|
931 | + // EE_messages has been deprecated |
|
932 | + $this->_class_is_deprecated(__FUNCTION__); |
|
933 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
934 | + return EEH_MSG_Template::get_fields($messenger_name, $message_type_name); |
|
935 | + } |
|
936 | + |
|
937 | + |
|
938 | + /** |
|
939 | + * @deprecated 4.9.0 |
|
940 | + * @access public |
|
941 | + * @param string $type we can indicate just returning installed message types |
|
942 | + * or messengers (or both) via this parameter. |
|
943 | + * @param bool $skip_cache if true then we skip the cache and retrieve via files. |
|
944 | + * @return array multidimensional array of messenger and message_type objects |
|
945 | + * (messengers index, and message_type index); |
|
946 | + */ |
|
947 | + public function get_installed($type = 'all', $skip_cache = false) |
|
948 | + { |
|
949 | + // EE_messages has been deprecated |
|
950 | + $this->_class_is_deprecated(__FUNCTION__); |
|
951 | + if ($skip_cache) { |
|
952 | + $this->_message_resource_manager->reset_active_messengers_and_message_types(); |
|
953 | + } |
|
954 | + switch ($type) { |
|
955 | + case 'messengers' : |
|
956 | + return array( |
|
957 | + 'messenger' => $this->_message_resource_manager->installed_messengers(), |
|
958 | + ); |
|
959 | + break; |
|
960 | + case 'message_types' : |
|
961 | + return array( |
|
962 | + 'message_type' => $this->_message_resource_manager->installed_message_types(), |
|
963 | + ); |
|
964 | + break; |
|
965 | + case 'all' : |
|
966 | + default : |
|
967 | + return array( |
|
968 | + 'messenger' => $this->_message_resource_manager->installed_messengers(), |
|
969 | + 'message_type' => $this->_message_resource_manager->installed_message_types(), |
|
970 | + ); |
|
971 | + break; |
|
972 | + } |
|
973 | + } |
|
974 | + |
|
975 | + |
|
976 | + /** |
|
977 | + * @deprecated 4.9.0 |
|
978 | + * @return \EE_messenger[] |
|
979 | + */ |
|
980 | + public function get_active_messengers() |
|
981 | + { |
|
982 | + // EE_messages has been deprecated |
|
983 | + $this->_class_is_deprecated(__FUNCTION__); |
|
984 | + return $this->_message_resource_manager->active_messengers(); |
|
985 | + } |
|
986 | + |
|
987 | + |
|
988 | + /** |
|
989 | + * @deprecated 4.9.0 |
|
990 | + * @return array array of message_type references (string) |
|
991 | + */ |
|
992 | + public function get_active_message_types() |
|
993 | + { |
|
994 | + // EE_messages has been deprecated |
|
995 | + $this->_class_is_deprecated(__FUNCTION__); |
|
996 | + return $this->_message_resource_manager->list_of_active_message_types(); |
|
997 | + } |
|
998 | + |
|
999 | + |
|
1000 | + /** |
|
1001 | + * @deprecated 4.9.0 |
|
1002 | + * @return EE_message_type[] |
|
1003 | + */ |
|
1004 | + public function get_active_message_type_objects() |
|
1005 | + { |
|
1006 | + // EE_messages has been deprecated |
|
1007 | + $this->_class_is_deprecated(__FUNCTION__); |
|
1008 | + return $this->_message_resource_manager->get_active_message_type_objects(); |
|
1009 | + } |
|
1010 | + |
|
1011 | + |
|
1012 | + /** |
|
1013 | + * @deprecated 4.9.0 |
|
1014 | + * @since 4.5.0 |
|
1015 | + * @param string $messenger The messenger being checked |
|
1016 | + * @return EE_message_type[] (or empty array if none present) |
|
1017 | + */ |
|
1018 | + public function get_active_message_types_per_messenger($messenger) |
|
1019 | + { |
|
1020 | + // EE_messages has been deprecated |
|
1021 | + $this->_class_is_deprecated(__FUNCTION__); |
|
1022 | + return $this->_message_resource_manager->get_active_message_types_for_messenger($messenger); |
|
1023 | + } |
|
1024 | + |
|
1025 | + |
|
1026 | + /** |
|
1027 | + * @deprecated 4.9.0 |
|
1028 | + * @param string $messenger The string should correspond to the messenger (message types are |
|
1029 | + * @param string $message_type The string should correspond to a message type. |
|
1030 | + * @return EE_message_type|null |
|
1031 | + */ |
|
1032 | + public function get_active_message_type($messenger, $message_type) |
|
1033 | + { |
|
1034 | + // EE_messages has been deprecated |
|
1035 | + $this->_class_is_deprecated(__FUNCTION__); |
|
1036 | + return $this->_message_resource_manager->get_active_message_type_for_messenger($messenger, $message_type); |
|
1037 | + } |
|
1038 | + |
|
1039 | + |
|
1040 | + /** |
|
1041 | + * @deprecated 4.9.0 |
|
1042 | + * @return array|\EE_message_type[] |
|
1043 | + */ |
|
1044 | + public function get_installed_message_types() |
|
1045 | + { |
|
1046 | + // EE_messages has been deprecated |
|
1047 | + $this->_class_is_deprecated(__FUNCTION__); |
|
1048 | + return $this->_message_resource_manager->installed_message_types(); |
|
1049 | + } |
|
1050 | + |
|
1051 | + |
|
1052 | + /** |
|
1053 | + * @deprecated 4.9.0 |
|
1054 | + * @return array |
|
1055 | + */ |
|
1056 | + public function get_installed_messengers() |
|
1057 | + { |
|
1058 | + // EE_messages has been deprecated |
|
1059 | + $this->_class_is_deprecated(__FUNCTION__); |
|
1060 | + return $this->_message_resource_manager->installed_messengers(); |
|
1061 | + } |
|
1062 | + |
|
1063 | + |
|
1064 | + /** |
|
1065 | + * @deprecated 4.9.0 |
|
1066 | + * @param bool $slugs_only Whether to return an array of just slugs and labels (true) or all contexts indexed by |
|
1067 | + * message type. |
|
1068 | + * @return array |
|
1069 | + */ |
|
1070 | + public function get_all_contexts($slugs_only = true) |
|
1071 | + { |
|
1072 | + // EE_messages has been deprecated |
|
1073 | + $this->_class_is_deprecated(__FUNCTION__); |
|
1074 | + return $this->_message_resource_manager->get_all_contexts($slugs_only); |
|
1075 | + } |
|
1076 | 1076 | |
1077 | 1077 | |
1078 | 1078 | } |
@@ -1131,88 +1131,88 @@ discard block |
||
1131 | 1131 | |
1132 | 1132 | |
1133 | 1133 | add_filter( |
1134 | - 'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css', |
|
1135 | - function ($event_list_iframe_css) { |
|
1136 | - if (! has_filter('FHEE__EventsArchiveIframe__event_list_iframe__css')) { |
|
1137 | - return $event_list_iframe_css; |
|
1138 | - } |
|
1139 | - deprecated_espresso_action_or_filter_doing_it_wrong( |
|
1140 | - 'FHEE__EventsArchiveIframe__event_list_iframe__css', |
|
1141 | - 'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css', |
|
1142 | - '\EventEspresso\modules\events_archive\EventsArchiveIframe::display()', |
|
1143 | - '4.9.14', |
|
1144 | - '5.0.0', |
|
1145 | - 'filter' |
|
1146 | - ); |
|
1147 | - return apply_filters( |
|
1148 | - 'FHEE__EventsArchiveIframe__event_list_iframe__css', |
|
1149 | - $event_list_iframe_css |
|
1150 | - ); |
|
1151 | - } |
|
1134 | + 'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css', |
|
1135 | + function ($event_list_iframe_css) { |
|
1136 | + if (! has_filter('FHEE__EventsArchiveIframe__event_list_iframe__css')) { |
|
1137 | + return $event_list_iframe_css; |
|
1138 | + } |
|
1139 | + deprecated_espresso_action_or_filter_doing_it_wrong( |
|
1140 | + 'FHEE__EventsArchiveIframe__event_list_iframe__css', |
|
1141 | + 'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css', |
|
1142 | + '\EventEspresso\modules\events_archive\EventsArchiveIframe::display()', |
|
1143 | + '4.9.14', |
|
1144 | + '5.0.0', |
|
1145 | + 'filter' |
|
1146 | + ); |
|
1147 | + return apply_filters( |
|
1148 | + 'FHEE__EventsArchiveIframe__event_list_iframe__css', |
|
1149 | + $event_list_iframe_css |
|
1150 | + ); |
|
1151 | + } |
|
1152 | 1152 | ); |
1153 | 1153 | add_filter( |
1154 | - 'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js', |
|
1155 | - function ($event_list_iframe_js) { |
|
1156 | - if (! has_filter('FHEE__EED_Ticket_Selector__ticket_selector_iframe__js')) { |
|
1157 | - return $event_list_iframe_js; |
|
1158 | - } |
|
1159 | - deprecated_espresso_action_or_filter_doing_it_wrong( |
|
1160 | - 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js', |
|
1161 | - 'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js', |
|
1162 | - '\EventEspresso\modules\events_archive\EventsArchiveIframe::display()', |
|
1163 | - '4.9.14', |
|
1164 | - '5.0.0', |
|
1165 | - 'filter' |
|
1166 | - ); |
|
1167 | - return apply_filters( |
|
1168 | - 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js', |
|
1169 | - $event_list_iframe_js |
|
1170 | - ); |
|
1171 | - } |
|
1154 | + 'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js', |
|
1155 | + function ($event_list_iframe_js) { |
|
1156 | + if (! has_filter('FHEE__EED_Ticket_Selector__ticket_selector_iframe__js')) { |
|
1157 | + return $event_list_iframe_js; |
|
1158 | + } |
|
1159 | + deprecated_espresso_action_or_filter_doing_it_wrong( |
|
1160 | + 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js', |
|
1161 | + 'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js', |
|
1162 | + '\EventEspresso\modules\events_archive\EventsArchiveIframe::display()', |
|
1163 | + '4.9.14', |
|
1164 | + '5.0.0', |
|
1165 | + 'filter' |
|
1166 | + ); |
|
1167 | + return apply_filters( |
|
1168 | + 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js', |
|
1169 | + $event_list_iframe_js |
|
1170 | + ); |
|
1171 | + } |
|
1172 | 1172 | ); |
1173 | 1173 | add_action( |
1174 | - 'AHEE__EE_Capabilities__addCaps__complete', |
|
1175 | - function ($capabilities_map) { |
|
1176 | - if (! has_action('AHEE__EE_Capabilities__init_role_caps__complete')) { |
|
1177 | - return; |
|
1178 | - } |
|
1179 | - deprecated_espresso_action_or_filter_doing_it_wrong( |
|
1180 | - 'AHEE__EE_Capabilities__init_role_caps__complete', |
|
1181 | - 'AHEE__EE_Capabilities__addCaps__complete', |
|
1182 | - '\EE_Capabilities::addCaps()', |
|
1183 | - '4.9.42', |
|
1184 | - '5.0.0' |
|
1185 | - ); |
|
1186 | - do_action( |
|
1187 | - 'AHEE__EE_Capabilities__init_role_caps__complete', |
|
1188 | - $capabilities_map |
|
1189 | - ); |
|
1190 | - } |
|
1174 | + 'AHEE__EE_Capabilities__addCaps__complete', |
|
1175 | + function ($capabilities_map) { |
|
1176 | + if (! has_action('AHEE__EE_Capabilities__init_role_caps__complete')) { |
|
1177 | + return; |
|
1178 | + } |
|
1179 | + deprecated_espresso_action_or_filter_doing_it_wrong( |
|
1180 | + 'AHEE__EE_Capabilities__init_role_caps__complete', |
|
1181 | + 'AHEE__EE_Capabilities__addCaps__complete', |
|
1182 | + '\EE_Capabilities::addCaps()', |
|
1183 | + '4.9.42', |
|
1184 | + '5.0.0' |
|
1185 | + ); |
|
1186 | + do_action( |
|
1187 | + 'AHEE__EE_Capabilities__init_role_caps__complete', |
|
1188 | + $capabilities_map |
|
1189 | + ); |
|
1190 | + } |
|
1191 | 1191 | ); |
1192 | 1192 | |
1193 | 1193 | add_filter( |
1194 | - 'FHEE_EventEspresso_core_services_commands_attendee_CreateAttendeeCommandHandler__findExistingAttendee__existing_attendee', |
|
1195 | - function ($existing_attendee, $registration, $attendee_data) { |
|
1196 | - if (! has_filter('FHEE_EE_Single_Page_Checkout__save_registration_items__find_existing_attendee')) { |
|
1197 | - return $existing_attendee; |
|
1198 | - } |
|
1199 | - deprecated_espresso_action_or_filter_doing_it_wrong( |
|
1200 | - 'FHEE_EE_Single_Page_Checkout__save_registration_items__find_existing_attendee', |
|
1201 | - 'FHEE_EventEspresso_core_services_commands_attendee_CreateAttendeeCommandHandler__findExistingAttendee__existing_attendee', |
|
1202 | - '\EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler::findExistingAttendee()', |
|
1203 | - '4.9.34', |
|
1204 | - '5.0.0', |
|
1205 | - 'filter' |
|
1206 | - ); |
|
1207 | - return apply_filters( |
|
1208 | - 'FHEE_EE_Single_Page_Checkout__save_registration_items__find_existing_attendee', |
|
1209 | - $existing_attendee, |
|
1210 | - $registration, |
|
1211 | - $attendee_data |
|
1212 | - ); |
|
1213 | - }, |
|
1214 | - 10, |
|
1215 | - 3 |
|
1194 | + 'FHEE_EventEspresso_core_services_commands_attendee_CreateAttendeeCommandHandler__findExistingAttendee__existing_attendee', |
|
1195 | + function ($existing_attendee, $registration, $attendee_data) { |
|
1196 | + if (! has_filter('FHEE_EE_Single_Page_Checkout__save_registration_items__find_existing_attendee')) { |
|
1197 | + return $existing_attendee; |
|
1198 | + } |
|
1199 | + deprecated_espresso_action_or_filter_doing_it_wrong( |
|
1200 | + 'FHEE_EE_Single_Page_Checkout__save_registration_items__find_existing_attendee', |
|
1201 | + 'FHEE_EventEspresso_core_services_commands_attendee_CreateAttendeeCommandHandler__findExistingAttendee__existing_attendee', |
|
1202 | + '\EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler::findExistingAttendee()', |
|
1203 | + '4.9.34', |
|
1204 | + '5.0.0', |
|
1205 | + 'filter' |
|
1206 | + ); |
|
1207 | + return apply_filters( |
|
1208 | + 'FHEE_EE_Single_Page_Checkout__save_registration_items__find_existing_attendee', |
|
1209 | + $existing_attendee, |
|
1210 | + $registration, |
|
1211 | + $attendee_data |
|
1212 | + ); |
|
1213 | + }, |
|
1214 | + 10, |
|
1215 | + 3 |
|
1216 | 1216 | ); |
1217 | 1217 | |
1218 | 1218 | /** |
@@ -1223,88 +1223,88 @@ discard block |
||
1223 | 1223 | class EE_Event_List_Query extends WP_Query |
1224 | 1224 | { |
1225 | 1225 | |
1226 | - private $title; |
|
1227 | - |
|
1228 | - private $css_class; |
|
1229 | - |
|
1230 | - private $category_slug; |
|
1231 | - |
|
1232 | - /** |
|
1233 | - * EE_Event_List_Query constructor. |
|
1234 | - * |
|
1235 | - * @param array $args |
|
1236 | - */ |
|
1237 | - public function __construct($args = array()) |
|
1238 | - { |
|
1239 | - \EE_Error::doing_it_wrong( |
|
1240 | - __METHOD__, |
|
1241 | - __( |
|
1242 | - 'Usage is deprecated. Please use \EventEspresso\core\domain\services\wp_queries\EventListQuery instead.', |
|
1243 | - 'event_espresso' |
|
1244 | - ), |
|
1245 | - '4.9.27', |
|
1246 | - '5.0.0' |
|
1247 | - ); |
|
1248 | - $this->title = isset($args['title']) ? $args['title'] : ''; |
|
1249 | - $this->css_class = isset($args['css_class']) ? $args['css_class'] : ''; |
|
1250 | - $this->category_slug = isset($args['category_slug']) ? $args['category_slug'] : ''; |
|
1251 | - $limit = isset($args['limit']) && absint($args['limit']) ? $args['limit'] : 10; |
|
1252 | - // the current "page" we are viewing |
|
1253 | - $paged = max(1, get_query_var('paged')); |
|
1254 | - // Force these args |
|
1255 | - $args = array_merge( |
|
1256 | - $args, |
|
1257 | - array( |
|
1258 | - 'post_type' => 'espresso_events', |
|
1259 | - 'posts_per_page' => $limit, |
|
1260 | - 'update_post_term_cache' => false, |
|
1261 | - 'update_post_meta_cache' => false, |
|
1262 | - 'paged' => $paged, |
|
1263 | - 'offset' => ($paged - 1) * $limit, |
|
1264 | - ) |
|
1265 | - ); |
|
1266 | - // run the query |
|
1267 | - parent::__construct($args); |
|
1268 | - } |
|
1269 | - |
|
1270 | - |
|
1271 | - /** |
|
1272 | - * event_list_title |
|
1273 | - * |
|
1274 | - * @param string $event_list_title |
|
1275 | - * @return string |
|
1276 | - */ |
|
1277 | - public function event_list_title($event_list_title = '') |
|
1278 | - { |
|
1279 | - if (! empty($this->title)) { |
|
1280 | - return $this->title; |
|
1281 | - } |
|
1282 | - return $event_list_title; |
|
1283 | - } |
|
1284 | - |
|
1285 | - |
|
1286 | - /** |
|
1287 | - * event_list_css |
|
1288 | - * |
|
1289 | - * @param string $event_list_css |
|
1290 | - * @return string |
|
1291 | - */ |
|
1292 | - public function event_list_css($event_list_css = '') |
|
1293 | - { |
|
1294 | - $event_list_css .= ! empty($event_list_css) |
|
1295 | - ? ' ' |
|
1296 | - : ''; |
|
1297 | - $event_list_css .= ! empty($this->css_class) |
|
1298 | - ? $this->css_class |
|
1299 | - : ''; |
|
1300 | - $event_list_css .= ! empty($event_list_css) |
|
1301 | - ? ' ' |
|
1302 | - : ''; |
|
1303 | - $event_list_css .= ! empty($this->category_slug) |
|
1304 | - ? $this->category_slug |
|
1305 | - : ''; |
|
1306 | - return $event_list_css; |
|
1307 | - } |
|
1226 | + private $title; |
|
1227 | + |
|
1228 | + private $css_class; |
|
1229 | + |
|
1230 | + private $category_slug; |
|
1231 | + |
|
1232 | + /** |
|
1233 | + * EE_Event_List_Query constructor. |
|
1234 | + * |
|
1235 | + * @param array $args |
|
1236 | + */ |
|
1237 | + public function __construct($args = array()) |
|
1238 | + { |
|
1239 | + \EE_Error::doing_it_wrong( |
|
1240 | + __METHOD__, |
|
1241 | + __( |
|
1242 | + 'Usage is deprecated. Please use \EventEspresso\core\domain\services\wp_queries\EventListQuery instead.', |
|
1243 | + 'event_espresso' |
|
1244 | + ), |
|
1245 | + '4.9.27', |
|
1246 | + '5.0.0' |
|
1247 | + ); |
|
1248 | + $this->title = isset($args['title']) ? $args['title'] : ''; |
|
1249 | + $this->css_class = isset($args['css_class']) ? $args['css_class'] : ''; |
|
1250 | + $this->category_slug = isset($args['category_slug']) ? $args['category_slug'] : ''; |
|
1251 | + $limit = isset($args['limit']) && absint($args['limit']) ? $args['limit'] : 10; |
|
1252 | + // the current "page" we are viewing |
|
1253 | + $paged = max(1, get_query_var('paged')); |
|
1254 | + // Force these args |
|
1255 | + $args = array_merge( |
|
1256 | + $args, |
|
1257 | + array( |
|
1258 | + 'post_type' => 'espresso_events', |
|
1259 | + 'posts_per_page' => $limit, |
|
1260 | + 'update_post_term_cache' => false, |
|
1261 | + 'update_post_meta_cache' => false, |
|
1262 | + 'paged' => $paged, |
|
1263 | + 'offset' => ($paged - 1) * $limit, |
|
1264 | + ) |
|
1265 | + ); |
|
1266 | + // run the query |
|
1267 | + parent::__construct($args); |
|
1268 | + } |
|
1269 | + |
|
1270 | + |
|
1271 | + /** |
|
1272 | + * event_list_title |
|
1273 | + * |
|
1274 | + * @param string $event_list_title |
|
1275 | + * @return string |
|
1276 | + */ |
|
1277 | + public function event_list_title($event_list_title = '') |
|
1278 | + { |
|
1279 | + if (! empty($this->title)) { |
|
1280 | + return $this->title; |
|
1281 | + } |
|
1282 | + return $event_list_title; |
|
1283 | + } |
|
1284 | + |
|
1285 | + |
|
1286 | + /** |
|
1287 | + * event_list_css |
|
1288 | + * |
|
1289 | + * @param string $event_list_css |
|
1290 | + * @return string |
|
1291 | + */ |
|
1292 | + public function event_list_css($event_list_css = '') |
|
1293 | + { |
|
1294 | + $event_list_css .= ! empty($event_list_css) |
|
1295 | + ? ' ' |
|
1296 | + : ''; |
|
1297 | + $event_list_css .= ! empty($this->css_class) |
|
1298 | + ? $this->css_class |
|
1299 | + : ''; |
|
1300 | + $event_list_css .= ! empty($event_list_css) |
|
1301 | + ? ' ' |
|
1302 | + : ''; |
|
1303 | + $event_list_css .= ! empty($this->category_slug) |
|
1304 | + ? $this->category_slug |
|
1305 | + : ''; |
|
1306 | + return $event_list_css; |
|
1307 | + } |
|
1308 | 1308 | |
1309 | 1309 | } |
1310 | 1310 | |
@@ -1321,75 +1321,75 @@ discard block |
||
1321 | 1321 | { |
1322 | 1322 | |
1323 | 1323 | |
1324 | - /** |
|
1325 | - * class constructor |
|
1326 | - * |
|
1327 | - * @deprecated 4.9.59.p |
|
1328 | - */ |
|
1329 | - public function __construct() |
|
1330 | - { |
|
1331 | - EE_Error::doing_it_wrong( |
|
1332 | - __METHOD__, |
|
1333 | - sprintf( |
|
1334 | - esc_html__('%1$s has been replaced by %2$s.', 'event_espresso'), |
|
1335 | - __CLASS__, |
|
1336 | - 'EventEspresso\core\services\licensing\LicenseServices' |
|
1337 | - ), |
|
1338 | - '4.9.59.p' |
|
1339 | - ); |
|
1340 | - } |
|
1341 | - |
|
1342 | - |
|
1343 | - /** |
|
1344 | - * The purpose of this function is to display information about Event Espresso data collection |
|
1345 | - * and a optin selection for extra data collecting by users. |
|
1346 | - * |
|
1347 | - * @param bool $extra |
|
1348 | - * @return string html. |
|
1349 | - * @deprecated 4.9.59.p |
|
1350 | - */ |
|
1351 | - public static function espresso_data_collection_optin_text($extra = true) |
|
1352 | - { |
|
1353 | - EE_Error::doing_it_wrong( |
|
1354 | - __METHOD__, |
|
1355 | - sprintf( |
|
1356 | - esc_html__('%1$s has been replaced by %2$s.', 'event_espresso'), |
|
1357 | - __METHOD__, |
|
1358 | - 'EventEspresso\core\domain\services\Stats::optinText' |
|
1359 | - ), |
|
1360 | - '4.9.59.p' |
|
1361 | - ); |
|
1362 | - Stats::optinText($extra); |
|
1363 | - } |
|
1364 | - |
|
1365 | - /** |
|
1366 | - * This is a handy helper method for retrieving whether there is an update available for the given plugin. |
|
1367 | - * |
|
1368 | - * @param string $basename Use the equivalent result from plugin_basename() for this param as WP uses that to |
|
1369 | - * identify plugins. Defaults to core update |
|
1370 | - * @return boolean True if update available, false if not. |
|
1371 | - * @deprecated 4.9.59.p |
|
1372 | - */ |
|
1373 | - public static function is_update_available($basename = '') |
|
1374 | - { |
|
1375 | - EE_Error::doing_it_wrong( |
|
1376 | - __METHOD__, |
|
1377 | - sprintf( |
|
1378 | - esc_html__('%1$s has been replaced by %2$s.', 'event_espresso'), |
|
1379 | - __METHOD__, |
|
1380 | - 'EventEspresso\core\services\licensing\LicenseService::isUpdateAvailable' |
|
1381 | - ), |
|
1382 | - '4.9.59.p' |
|
1383 | - ); |
|
1384 | - return LicenseService::isUpdateAvailable($basename); |
|
1385 | - } |
|
1324 | + /** |
|
1325 | + * class constructor |
|
1326 | + * |
|
1327 | + * @deprecated 4.9.59.p |
|
1328 | + */ |
|
1329 | + public function __construct() |
|
1330 | + { |
|
1331 | + EE_Error::doing_it_wrong( |
|
1332 | + __METHOD__, |
|
1333 | + sprintf( |
|
1334 | + esc_html__('%1$s has been replaced by %2$s.', 'event_espresso'), |
|
1335 | + __CLASS__, |
|
1336 | + 'EventEspresso\core\services\licensing\LicenseServices' |
|
1337 | + ), |
|
1338 | + '4.9.59.p' |
|
1339 | + ); |
|
1340 | + } |
|
1341 | + |
|
1342 | + |
|
1343 | + /** |
|
1344 | + * The purpose of this function is to display information about Event Espresso data collection |
|
1345 | + * and a optin selection for extra data collecting by users. |
|
1346 | + * |
|
1347 | + * @param bool $extra |
|
1348 | + * @return string html. |
|
1349 | + * @deprecated 4.9.59.p |
|
1350 | + */ |
|
1351 | + public static function espresso_data_collection_optin_text($extra = true) |
|
1352 | + { |
|
1353 | + EE_Error::doing_it_wrong( |
|
1354 | + __METHOD__, |
|
1355 | + sprintf( |
|
1356 | + esc_html__('%1$s has been replaced by %2$s.', 'event_espresso'), |
|
1357 | + __METHOD__, |
|
1358 | + 'EventEspresso\core\domain\services\Stats::optinText' |
|
1359 | + ), |
|
1360 | + '4.9.59.p' |
|
1361 | + ); |
|
1362 | + Stats::optinText($extra); |
|
1363 | + } |
|
1364 | + |
|
1365 | + /** |
|
1366 | + * This is a handy helper method for retrieving whether there is an update available for the given plugin. |
|
1367 | + * |
|
1368 | + * @param string $basename Use the equivalent result from plugin_basename() for this param as WP uses that to |
|
1369 | + * identify plugins. Defaults to core update |
|
1370 | + * @return boolean True if update available, false if not. |
|
1371 | + * @deprecated 4.9.59.p |
|
1372 | + */ |
|
1373 | + public static function is_update_available($basename = '') |
|
1374 | + { |
|
1375 | + EE_Error::doing_it_wrong( |
|
1376 | + __METHOD__, |
|
1377 | + sprintf( |
|
1378 | + esc_html__('%1$s has been replaced by %2$s.', 'event_espresso'), |
|
1379 | + __METHOD__, |
|
1380 | + 'EventEspresso\core\services\licensing\LicenseService::isUpdateAvailable' |
|
1381 | + ), |
|
1382 | + '4.9.59.p' |
|
1383 | + ); |
|
1384 | + return LicenseService::isUpdateAvailable($basename); |
|
1385 | + } |
|
1386 | 1386 | } |
1387 | 1387 | |
1388 | 1388 | add_filter( |
1389 | - 'FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__reg_csv_array', |
|
1390 | - 'ee_deprecated_registrations_report_csv_legacy_fields', |
|
1391 | - 10, |
|
1392 | - 2 |
|
1389 | + 'FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__reg_csv_array', |
|
1390 | + 'ee_deprecated_registrations_report_csv_legacy_fields', |
|
1391 | + 10, |
|
1392 | + 2 |
|
1393 | 1393 | ); |
1394 | 1394 | /** |
1395 | 1395 | * Filters the CSV row to make it appear like the old labels (which were "$pretty_name[$field_name]"). |
@@ -1406,96 +1406,96 @@ discard block |
||
1406 | 1406 | */ |
1407 | 1407 | function ee_deprecated_registrations_report_csv_legacy_fields($csv_row_data, $reg_row) |
1408 | 1408 | { |
1409 | - // no need for all this if nobody is using the deprecated filter |
|
1410 | - if (has_filter('FHEE__EE_Export__report_registrations__reg_csv_array')) { |
|
1411 | - EE_Error::doing_it_wrong( |
|
1412 | - __FUNCTION__, |
|
1413 | - sprintf( |
|
1414 | - // EE_Error::doing_it_wrong with escape HTML, so don't escape it twice by doing it here too. |
|
1415 | - _x( |
|
1416 | - 'The filter "%1$s" has been deprecated. Please use "%2$s" instead.', |
|
1417 | - 'The filter "FHEE__EE_Export__report_registrations__reg_csv_array" has been deprecated. Please use "FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__reg_csv_array" instead.', |
|
1418 | - 'event_espresso' |
|
1419 | - ), |
|
1420 | - 'FHEE__EE_Export__report_registrations__reg_csv_array', |
|
1421 | - 'FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__reg_csv_array' |
|
1422 | - ), |
|
1423 | - '4.9.69.p', |
|
1424 | - '4.9.75.p' |
|
1425 | - ); |
|
1426 | - // there's code that expected the old csv column headers/labels. Let's oblige. Put it back in the old format! |
|
1427 | - // first: what model fields might be used as column headers? (whose format we need to change) |
|
1428 | - $model_fields = array_merge( |
|
1429 | - EEM_Registration::instance()->field_settings(), |
|
1430 | - EEM_Attendee::instance()->field_settings() |
|
1431 | - ); |
|
1432 | - // create an array that uses the legacy column headers/labels. |
|
1433 | - $new_csv_row = array(); |
|
1434 | - foreach ($csv_row_data as $label => $value) { |
|
1435 | - $new_label = $label; |
|
1436 | - foreach ($model_fields as $field) { |
|
1437 | - if ($label === EEH_Export::get_column_name_for_field($field)) { |
|
1438 | - // re-add the old field name |
|
1439 | - $new_label = $label . '[' . $field->get_name() . ']'; |
|
1440 | - break; |
|
1441 | - } |
|
1442 | - } |
|
1443 | - $new_csv_row[$new_label] = $value; |
|
1444 | - } |
|
1445 | - // before we run it through the deprecated filter, set the method `EEH_Export::get_column_name_for_field()` |
|
1446 | - // to create the old column names, because that's what's in the row temporarily |
|
1447 | - add_filter( |
|
1448 | - 'FHEE__EEH_Export__get_column_name_for_field__add_field_name', |
|
1449 | - '__return_true', |
|
1450 | - 777 |
|
1451 | - ); |
|
1452 | - // now, those old filters can be run on this data. Have fun! |
|
1453 | - /** |
|
1454 | - * Deprecated. Use FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__reg_csv_array instead. |
|
1455 | - * |
|
1456 | - * Filter to change the contents of each row of the registrations report CSV file. |
|
1457 | - * This can be used to add or remote columns from the CSV file, or change their values. * |
|
1458 | - * Note: it has this name because originally that's where this filter resided, |
|
1459 | - * and we've left its name as-is for backward compatibility. |
|
1460 | - * Note when using: all rows in the CSV should have the same columns. |
|
1461 | - * |
|
1462 | - * @param array $reg_csv_array keys are column-header names, and values are that columns' value |
|
1463 | - * in this row |
|
1464 | - * @param array $reg_row is the row from the database's wp_esp_registration table |
|
1465 | - */ |
|
1466 | - $updated_row = apply_filters( |
|
1467 | - 'FHEE__EE_Export__report_registrations__reg_csv_array', |
|
1468 | - $new_csv_row, |
|
1469 | - $reg_row |
|
1470 | - ); |
|
1471 | - |
|
1472 | - // ok now we can revert to normal for EEH_Export::get_column_name_for_field(). |
|
1473 | - remove_filter( |
|
1474 | - 'FHEE__EEH_Export__get_column_name_for_field__add_field_name', |
|
1475 | - '__return_true', |
|
1476 | - 777 |
|
1477 | - ); |
|
1478 | - |
|
1479 | - // great. Now that the old filters are done, we can remove the ugly square brackets from column headers/labels. |
|
1480 | - $updated_and_restored_row = array(); |
|
1481 | - foreach ($updated_row as $label => $value) { |
|
1482 | - $matches = array(); |
|
1483 | - if (preg_match( |
|
1484 | - '~([^\[]*)\[(.*)\]~', |
|
1485 | - $label, |
|
1486 | - $matches |
|
1487 | - ) |
|
1488 | - && isset( |
|
1489 | - $matches[0], |
|
1490 | - $matches[1], |
|
1491 | - $matches[2] |
|
1492 | - ) |
|
1493 | - ) { |
|
1494 | - $label = $matches[1]; |
|
1495 | - } |
|
1496 | - $updated_and_restored_row[$label] = $value; |
|
1497 | - } |
|
1498 | - $csv_row_data = $updated_and_restored_row; |
|
1499 | - } |
|
1500 | - return $csv_row_data; |
|
1409 | + // no need for all this if nobody is using the deprecated filter |
|
1410 | + if (has_filter('FHEE__EE_Export__report_registrations__reg_csv_array')) { |
|
1411 | + EE_Error::doing_it_wrong( |
|
1412 | + __FUNCTION__, |
|
1413 | + sprintf( |
|
1414 | + // EE_Error::doing_it_wrong with escape HTML, so don't escape it twice by doing it here too. |
|
1415 | + _x( |
|
1416 | + 'The filter "%1$s" has been deprecated. Please use "%2$s" instead.', |
|
1417 | + 'The filter "FHEE__EE_Export__report_registrations__reg_csv_array" has been deprecated. Please use "FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__reg_csv_array" instead.', |
|
1418 | + 'event_espresso' |
|
1419 | + ), |
|
1420 | + 'FHEE__EE_Export__report_registrations__reg_csv_array', |
|
1421 | + 'FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__reg_csv_array' |
|
1422 | + ), |
|
1423 | + '4.9.69.p', |
|
1424 | + '4.9.75.p' |
|
1425 | + ); |
|
1426 | + // there's code that expected the old csv column headers/labels. Let's oblige. Put it back in the old format! |
|
1427 | + // first: what model fields might be used as column headers? (whose format we need to change) |
|
1428 | + $model_fields = array_merge( |
|
1429 | + EEM_Registration::instance()->field_settings(), |
|
1430 | + EEM_Attendee::instance()->field_settings() |
|
1431 | + ); |
|
1432 | + // create an array that uses the legacy column headers/labels. |
|
1433 | + $new_csv_row = array(); |
|
1434 | + foreach ($csv_row_data as $label => $value) { |
|
1435 | + $new_label = $label; |
|
1436 | + foreach ($model_fields as $field) { |
|
1437 | + if ($label === EEH_Export::get_column_name_for_field($field)) { |
|
1438 | + // re-add the old field name |
|
1439 | + $new_label = $label . '[' . $field->get_name() . ']'; |
|
1440 | + break; |
|
1441 | + } |
|
1442 | + } |
|
1443 | + $new_csv_row[$new_label] = $value; |
|
1444 | + } |
|
1445 | + // before we run it through the deprecated filter, set the method `EEH_Export::get_column_name_for_field()` |
|
1446 | + // to create the old column names, because that's what's in the row temporarily |
|
1447 | + add_filter( |
|
1448 | + 'FHEE__EEH_Export__get_column_name_for_field__add_field_name', |
|
1449 | + '__return_true', |
|
1450 | + 777 |
|
1451 | + ); |
|
1452 | + // now, those old filters can be run on this data. Have fun! |
|
1453 | + /** |
|
1454 | + * Deprecated. Use FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__reg_csv_array instead. |
|
1455 | + * |
|
1456 | + * Filter to change the contents of each row of the registrations report CSV file. |
|
1457 | + * This can be used to add or remote columns from the CSV file, or change their values. * |
|
1458 | + * Note: it has this name because originally that's where this filter resided, |
|
1459 | + * and we've left its name as-is for backward compatibility. |
|
1460 | + * Note when using: all rows in the CSV should have the same columns. |
|
1461 | + * |
|
1462 | + * @param array $reg_csv_array keys are column-header names, and values are that columns' value |
|
1463 | + * in this row |
|
1464 | + * @param array $reg_row is the row from the database's wp_esp_registration table |
|
1465 | + */ |
|
1466 | + $updated_row = apply_filters( |
|
1467 | + 'FHEE__EE_Export__report_registrations__reg_csv_array', |
|
1468 | + $new_csv_row, |
|
1469 | + $reg_row |
|
1470 | + ); |
|
1471 | + |
|
1472 | + // ok now we can revert to normal for EEH_Export::get_column_name_for_field(). |
|
1473 | + remove_filter( |
|
1474 | + 'FHEE__EEH_Export__get_column_name_for_field__add_field_name', |
|
1475 | + '__return_true', |
|
1476 | + 777 |
|
1477 | + ); |
|
1478 | + |
|
1479 | + // great. Now that the old filters are done, we can remove the ugly square brackets from column headers/labels. |
|
1480 | + $updated_and_restored_row = array(); |
|
1481 | + foreach ($updated_row as $label => $value) { |
|
1482 | + $matches = array(); |
|
1483 | + if (preg_match( |
|
1484 | + '~([^\[]*)\[(.*)\]~', |
|
1485 | + $label, |
|
1486 | + $matches |
|
1487 | + ) |
|
1488 | + && isset( |
|
1489 | + $matches[0], |
|
1490 | + $matches[1], |
|
1491 | + $matches[2] |
|
1492 | + ) |
|
1493 | + ) { |
|
1494 | + $label = $matches[1]; |
|
1495 | + } |
|
1496 | + $updated_and_restored_row[$label] = $value; |
|
1497 | + } |
|
1498 | + $csv_row_data = $updated_and_restored_row; |
|
1499 | + } |
|
1500 | + return $csv_row_data; |
|
1501 | 1501 | } |
1502 | 1502 | \ No newline at end of file |
@@ -37,18 +37,18 @@ discard block |
||
37 | 37 | 'priority' => 'high', |
38 | 38 | 'context' => 'normal', |
39 | 39 | ), |
40 | - );/**/ |
|
40 | + ); /**/ |
|
41 | 41 | |
42 | 42 | $this->_scripts_styles = array( |
43 | 43 | 'registers' => array( |
44 | 44 | 'ee_event_venues' => array( |
45 | 45 | 'type' => 'js', |
46 | - 'url' => EE_VENUES_ASSETS_URL . 'ee-event-venues-admin.js', |
|
46 | + 'url' => EE_VENUES_ASSETS_URL.'ee-event-venues-admin.js', |
|
47 | 47 | 'depends' => array('jquery'), |
48 | 48 | ), |
49 | 49 | 'ee_event_venues_css' => array( |
50 | 50 | 'type' => 'css', |
51 | - 'url' => EE_VENUES_ASSETS_URL . 'ee-event-venues-admin.css', |
|
51 | + 'url' => EE_VENUES_ASSETS_URL.'ee-event-venues-admin.css', |
|
52 | 52 | ), |
53 | 53 | ), |
54 | 54 | 'enqueues' => array( |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | // first remove default venue callback |
75 | 75 | foreach ($callbacks as $key => $callback) { |
76 | 76 | if ($callback[1] == '_default_venue_update') { |
77 | - unset($callbacks[ $key ]); |
|
77 | + unset($callbacks[$key]); |
|
78 | 78 | } |
79 | 79 | } |
80 | 80 | |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | } |
103 | 103 | |
104 | 104 | // cap checks |
105 | - if (! EE_Registry::instance()->CAP->current_user_can('ee_read_others_venues', 'get_venues')) { |
|
105 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_venues', 'get_venues')) { |
|
106 | 106 | $vnu_where['VNU_wp_user'] = get_current_user_id(); |
107 | 107 | } |
108 | 108 | |
@@ -113,14 +113,14 @@ discard block |
||
113 | 113 | $ven_select[0] = __('Select a Venue', 'event_espresso'); |
114 | 114 | // setup venues for selector |
115 | 115 | foreach ($venues as $venue) { |
116 | - $ven_select[ $venue->ID() ] = $venue->name(); |
|
116 | + $ven_select[$venue->ID()] = $venue->name(); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | // if $ven_select does not have the existing venue attached to event then let's add that because we'll always |
120 | 120 | // show existing attached venues even if it's trashed (or some other restricted status). |
121 | 121 | |
122 | - if ($evt_venue_id && ! isset($ven_select[ $evt_venue_id ])) { |
|
123 | - $ven_select[ $evt_venue_id ] = $evt_venue->name(); |
|
122 | + if ($evt_venue_id && ! isset($ven_select[$evt_venue_id])) { |
|
123 | + $ven_select[$evt_venue_id] = $evt_venue->name(); |
|
124 | 124 | $venues = array_merge($venues, array($evt_venue)); |
125 | 125 | } |
126 | 126 | |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | ); |
185 | 185 | |
186 | 186 | $template_path = empty($venues) ? EE_VENUES_TEMPLATE_PATH . 'event_venues_metabox_content.template.php' |
187 | - : EE_VENUES_TEMPLATE_PATH . 'event_venues_metabox_content_from_manager.template.php'; |
|
187 | + : EE_VENUES_TEMPLATE_PATH.'event_venues_metabox_content_from_manager.template.php'; |
|
188 | 188 | |
189 | 189 | // Allow events venue metabox template args filtering. |
190 | 190 | $template_args = apply_filters( |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | $evt_venue = $evtobj->venues(); |
208 | 208 | $evt_venue = ! empty($evt_venue) ? array_shift($evt_venue) : null; |
209 | 209 | |
210 | - if (! empty($evt_venue) && $evt_venue->ID() != $venue_id) { |
|
210 | + if ( ! empty($evt_venue) && $evt_venue->ID() != $venue_id) { |
|
211 | 211 | $evtobj->_remove_relation_to($evt_venue->ID(), 'Venue'); |
212 | 212 | } |
213 | 213 |
@@ -16,207 +16,207 @@ |
||
16 | 16 | { |
17 | 17 | |
18 | 18 | |
19 | - protected $_event; |
|
20 | - |
|
21 | - |
|
22 | - public function __construct(EE_Admin_Page $admin_page) |
|
23 | - { |
|
24 | - parent::__construct($admin_page); |
|
25 | - } |
|
26 | - |
|
27 | - |
|
28 | - protected function _set_hooks_properties() |
|
29 | - { |
|
30 | - $this->_name = 'venues'; |
|
31 | - |
|
32 | - $this->_metaboxes = array( |
|
33 | - 0 => array( |
|
34 | - 'page_route' => array('edit', 'create_new'), |
|
35 | - 'func' => 'venue_metabox', |
|
36 | - 'label' => __('Venue Details', 'event_espresso'), |
|
37 | - 'priority' => 'high', |
|
38 | - 'context' => 'normal', |
|
39 | - ), |
|
40 | - );/**/ |
|
41 | - |
|
42 | - $this->_scripts_styles = array( |
|
43 | - 'registers' => array( |
|
44 | - 'ee_event_venues' => array( |
|
45 | - 'type' => 'js', |
|
46 | - 'url' => EE_VENUES_ASSETS_URL . 'ee-event-venues-admin.js', |
|
47 | - 'depends' => array('jquery'), |
|
48 | - ), |
|
49 | - 'ee_event_venues_css' => array( |
|
50 | - 'type' => 'css', |
|
51 | - 'url' => EE_VENUES_ASSETS_URL . 'ee-event-venues-admin.css', |
|
52 | - ), |
|
53 | - ), |
|
54 | - 'enqueues' => array( |
|
55 | - 'ee_event_venues' => array('edit', 'create_new'), |
|
56 | - 'ee_event_venues_css' => array('edit', 'create_new'), |
|
57 | - ), |
|
58 | - ); |
|
59 | - |
|
60 | - // hook into the handler for saving venue |
|
61 | - add_filter( |
|
62 | - 'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', |
|
63 | - array($this, 'modify_callbacks'), |
|
64 | - 10 |
|
65 | - ); |
|
66 | - |
|
67 | - // remove default ee_autosave returns for DECAF venues (not needed for CAF venues cause we have a dropdown selector) |
|
68 | - add_filter('FHEE__Events_Admin_Page__ee_autosave_edit_do_decaf_venue_save', '__return_false'); |
|
69 | - } |
|
70 | - |
|
71 | - |
|
72 | - public function modify_callbacks($callbacks) |
|
73 | - { |
|
74 | - // first remove default venue callback |
|
75 | - foreach ($callbacks as $key => $callback) { |
|
76 | - if ($callback[1] == '_default_venue_update') { |
|
77 | - unset($callbacks[ $key ]); |
|
78 | - } |
|
79 | - } |
|
80 | - |
|
81 | - // now let's add the caf version |
|
82 | - $callbacks[] = array($this, 'caf_venue_update'); |
|
83 | - return $callbacks; |
|
84 | - } |
|
85 | - |
|
86 | - |
|
87 | - public function venue_metabox() |
|
88 | - { |
|
89 | - $evt_obj = $this->_adminpage_obj->get_event_object(); |
|
90 | - $evt_id = $evt_obj->ID(); |
|
91 | - |
|
92 | - // first let's see if we have a venue already |
|
93 | - $evt_venues = ! empty($evt_id) ? $evt_obj->venues() : array(); |
|
94 | - $evt_venue = $evt_venues && is_array($evt_venues) ? reset($evt_venues) : null; |
|
95 | - $evt_venue_id = $evt_venue instanceof EE_Venue ? $evt_venue->ID() : null; |
|
96 | - |
|
97 | - // possibly private venues. |
|
98 | - if (EE_Registry::instance()->CAP->current_user_can('ee_read_private_venues', 'get_venues')) { |
|
99 | - $vnu_where['status'] = array('IN', array('publish', 'private')); |
|
100 | - } else { |
|
101 | - $vnu_where['status'] = 'publish'; |
|
102 | - } |
|
103 | - |
|
104 | - // cap checks |
|
105 | - if (! EE_Registry::instance()->CAP->current_user_can('ee_read_others_venues', 'get_venues')) { |
|
106 | - $vnu_where['VNU_wp_user'] = get_current_user_id(); |
|
107 | - } |
|
108 | - |
|
109 | - $vnumdl = EE_Registry::instance()->load_model('Venue'); |
|
110 | - $venues = $vnumdl->get_all(array($vnu_where, 'order_by' => array('VNU_name' => 'ASC'))); |
|
111 | - |
|
112 | - $ven_select = array(); |
|
113 | - $ven_select[0] = __('Select a Venue', 'event_espresso'); |
|
114 | - // setup venues for selector |
|
115 | - foreach ($venues as $venue) { |
|
116 | - $ven_select[ $venue->ID() ] = $venue->name(); |
|
117 | - } |
|
118 | - |
|
119 | - // if $ven_select does not have the existing venue attached to event then let's add that because we'll always |
|
120 | - // show existing attached venues even if it's trashed (or some other restricted status). |
|
121 | - |
|
122 | - if ($evt_venue_id && ! isset($ven_select[ $evt_venue_id ])) { |
|
123 | - $ven_select[ $evt_venue_id ] = $evt_venue->name(); |
|
124 | - $venues = array_merge($venues, array($evt_venue)); |
|
125 | - } |
|
126 | - |
|
127 | - $template_args['venues'] = $venues; |
|
128 | - $template_args['evt_venue_id'] = $evt_venue_id; |
|
129 | - $venue_selector = new EE_Select_Input( |
|
130 | - $ven_select, |
|
131 | - array( |
|
132 | - 'html_name' => 'venue_id', |
|
133 | - 'html_id' => 'venue_id', |
|
134 | - 'html_class' => 'wide', |
|
135 | - 'default' => $evt_venue_id ? $evt_venue_id : '0' |
|
136 | - ) |
|
137 | - ); |
|
138 | - $template_args['venue_selector'] = $venue_selector->get_html_for_input(); |
|
139 | - $enable_for_gmap = new EE_Yes_No_Input( |
|
140 | - array( |
|
141 | - 'html_name' => 'enable_for_gmap', |
|
142 | - 'html_id' => 'enable_for_gmap', |
|
143 | - 'default' => $evt_venue instanceof EE_Venue ? $evt_venue->enable_for_gmap() : false |
|
144 | - ) |
|
145 | - ); |
|
146 | - $template_args['enable_for_gmap'] = $enable_for_gmap->get_html_for_input(); |
|
147 | - $template_args['new_venue_link'] = EEH_HTML::link( |
|
148 | - EE_Admin_Page::add_query_args_and_nonce( |
|
149 | - array('action' => 'create_new'), |
|
150 | - EE_VENUES_ADMIN_URL |
|
151 | - ), |
|
152 | - esc_html_x('Add new Venue', 'a link to add a new venue', 'event_espresso'), |
|
153 | - esc_html_x('Add new Venue', 'a link to add a new venue', 'event_espresso'), |
|
154 | - 'ev_new_venue_link', |
|
155 | - 'button', |
|
156 | - 'margin-left:10px;', |
|
157 | - 'target="_blank"' |
|
158 | - ); |
|
159 | - |
|
160 | - // Decide on an info text when there are no venues to display. |
|
161 | - $no_venues_info_txt = esc_html_x( |
|
162 | - 'You have not created any venues yet.', |
|
163 | - 'Information text displayed in the venues metabox when there are no venues to display', |
|
164 | - 'event_espresso' |
|
165 | - ); |
|
166 | - if (empty($venues)) { |
|
167 | - $unpublished_where = $vnu_where; |
|
168 | - $unpublished_where['status'] = 'draft'; |
|
169 | - $unpublished_venues = $vnumdl->get_all(array($unpublished_where, 'order_by' => array('VNU_name' => 'ASC'))); |
|
170 | - if (count($unpublished_venues) > 0) { |
|
171 | - $no_venues_info_txt = esc_html_x( |
|
172 | - // @codingStandardsIgnoreStart |
|
173 | - 'Use the link below to publish your venue through the venue editor so it appears here for selection.', |
|
174 | - // @codingStandardsIgnoreEnd |
|
175 | - 'Information text displayed in the venues metabox when there are no venues to display', |
|
176 | - 'event_espresso' |
|
177 | - ); |
|
178 | - } |
|
179 | - } |
|
180 | - $template_args['no_venues_info'] = EEH_HTML::p( |
|
181 | - EEH_HTML::strong($no_venues_info_txt), |
|
182 | - 'no_venues_info', |
|
183 | - 'info' |
|
184 | - ); |
|
185 | - |
|
186 | - $template_path = empty($venues) ? EE_VENUES_TEMPLATE_PATH . 'event_venues_metabox_content.template.php' |
|
187 | - : EE_VENUES_TEMPLATE_PATH . 'event_venues_metabox_content_from_manager.template.php'; |
|
188 | - |
|
189 | - // Allow events venue metabox template args filtering. |
|
190 | - $template_args = apply_filters( |
|
191 | - 'FHEE__espresso_events_Venues_Hooks___venue_metabox__template_args', |
|
192 | - $template_args, |
|
193 | - $template_path |
|
194 | - ); |
|
195 | - |
|
196 | - EEH_Template::display_template($template_path, $template_args); |
|
197 | - } |
|
198 | - |
|
199 | - |
|
200 | - public function caf_venue_update($evtobj, $data) |
|
201 | - { |
|
202 | - EE_Registry::instance()->load_model('Venue'); |
|
203 | - $venue_id = ! empty($data['venue_id']) ? $data['venue_id'] : null; |
|
204 | - |
|
205 | - |
|
206 | - // first let's check if the selected venue matches any existing venue attached to the event |
|
207 | - $evt_venue = $evtobj->venues(); |
|
208 | - $evt_venue = ! empty($evt_venue) ? array_shift($evt_venue) : null; |
|
209 | - |
|
210 | - if (! empty($evt_venue) && $evt_venue->ID() != $venue_id) { |
|
211 | - $evtobj->_remove_relation_to($evt_venue->ID(), 'Venue'); |
|
212 | - } |
|
213 | - |
|
214 | - if (empty($venue_id)) { |
|
215 | - return true; |
|
216 | - } //no venue to attach |
|
217 | - |
|
218 | - // this should take care of adding to revisions as well as main post object |
|
219 | - $success = $evtobj->_add_relation_to($venue_id, 'Venue'); |
|
220 | - return ! empty($success) ? true : false; |
|
221 | - } |
|
19 | + protected $_event; |
|
20 | + |
|
21 | + |
|
22 | + public function __construct(EE_Admin_Page $admin_page) |
|
23 | + { |
|
24 | + parent::__construct($admin_page); |
|
25 | + } |
|
26 | + |
|
27 | + |
|
28 | + protected function _set_hooks_properties() |
|
29 | + { |
|
30 | + $this->_name = 'venues'; |
|
31 | + |
|
32 | + $this->_metaboxes = array( |
|
33 | + 0 => array( |
|
34 | + 'page_route' => array('edit', 'create_new'), |
|
35 | + 'func' => 'venue_metabox', |
|
36 | + 'label' => __('Venue Details', 'event_espresso'), |
|
37 | + 'priority' => 'high', |
|
38 | + 'context' => 'normal', |
|
39 | + ), |
|
40 | + );/**/ |
|
41 | + |
|
42 | + $this->_scripts_styles = array( |
|
43 | + 'registers' => array( |
|
44 | + 'ee_event_venues' => array( |
|
45 | + 'type' => 'js', |
|
46 | + 'url' => EE_VENUES_ASSETS_URL . 'ee-event-venues-admin.js', |
|
47 | + 'depends' => array('jquery'), |
|
48 | + ), |
|
49 | + 'ee_event_venues_css' => array( |
|
50 | + 'type' => 'css', |
|
51 | + 'url' => EE_VENUES_ASSETS_URL . 'ee-event-venues-admin.css', |
|
52 | + ), |
|
53 | + ), |
|
54 | + 'enqueues' => array( |
|
55 | + 'ee_event_venues' => array('edit', 'create_new'), |
|
56 | + 'ee_event_venues_css' => array('edit', 'create_new'), |
|
57 | + ), |
|
58 | + ); |
|
59 | + |
|
60 | + // hook into the handler for saving venue |
|
61 | + add_filter( |
|
62 | + 'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', |
|
63 | + array($this, 'modify_callbacks'), |
|
64 | + 10 |
|
65 | + ); |
|
66 | + |
|
67 | + // remove default ee_autosave returns for DECAF venues (not needed for CAF venues cause we have a dropdown selector) |
|
68 | + add_filter('FHEE__Events_Admin_Page__ee_autosave_edit_do_decaf_venue_save', '__return_false'); |
|
69 | + } |
|
70 | + |
|
71 | + |
|
72 | + public function modify_callbacks($callbacks) |
|
73 | + { |
|
74 | + // first remove default venue callback |
|
75 | + foreach ($callbacks as $key => $callback) { |
|
76 | + if ($callback[1] == '_default_venue_update') { |
|
77 | + unset($callbacks[ $key ]); |
|
78 | + } |
|
79 | + } |
|
80 | + |
|
81 | + // now let's add the caf version |
|
82 | + $callbacks[] = array($this, 'caf_venue_update'); |
|
83 | + return $callbacks; |
|
84 | + } |
|
85 | + |
|
86 | + |
|
87 | + public function venue_metabox() |
|
88 | + { |
|
89 | + $evt_obj = $this->_adminpage_obj->get_event_object(); |
|
90 | + $evt_id = $evt_obj->ID(); |
|
91 | + |
|
92 | + // first let's see if we have a venue already |
|
93 | + $evt_venues = ! empty($evt_id) ? $evt_obj->venues() : array(); |
|
94 | + $evt_venue = $evt_venues && is_array($evt_venues) ? reset($evt_venues) : null; |
|
95 | + $evt_venue_id = $evt_venue instanceof EE_Venue ? $evt_venue->ID() : null; |
|
96 | + |
|
97 | + // possibly private venues. |
|
98 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_private_venues', 'get_venues')) { |
|
99 | + $vnu_where['status'] = array('IN', array('publish', 'private')); |
|
100 | + } else { |
|
101 | + $vnu_where['status'] = 'publish'; |
|
102 | + } |
|
103 | + |
|
104 | + // cap checks |
|
105 | + if (! EE_Registry::instance()->CAP->current_user_can('ee_read_others_venues', 'get_venues')) { |
|
106 | + $vnu_where['VNU_wp_user'] = get_current_user_id(); |
|
107 | + } |
|
108 | + |
|
109 | + $vnumdl = EE_Registry::instance()->load_model('Venue'); |
|
110 | + $venues = $vnumdl->get_all(array($vnu_where, 'order_by' => array('VNU_name' => 'ASC'))); |
|
111 | + |
|
112 | + $ven_select = array(); |
|
113 | + $ven_select[0] = __('Select a Venue', 'event_espresso'); |
|
114 | + // setup venues for selector |
|
115 | + foreach ($venues as $venue) { |
|
116 | + $ven_select[ $venue->ID() ] = $venue->name(); |
|
117 | + } |
|
118 | + |
|
119 | + // if $ven_select does not have the existing venue attached to event then let's add that because we'll always |
|
120 | + // show existing attached venues even if it's trashed (or some other restricted status). |
|
121 | + |
|
122 | + if ($evt_venue_id && ! isset($ven_select[ $evt_venue_id ])) { |
|
123 | + $ven_select[ $evt_venue_id ] = $evt_venue->name(); |
|
124 | + $venues = array_merge($venues, array($evt_venue)); |
|
125 | + } |
|
126 | + |
|
127 | + $template_args['venues'] = $venues; |
|
128 | + $template_args['evt_venue_id'] = $evt_venue_id; |
|
129 | + $venue_selector = new EE_Select_Input( |
|
130 | + $ven_select, |
|
131 | + array( |
|
132 | + 'html_name' => 'venue_id', |
|
133 | + 'html_id' => 'venue_id', |
|
134 | + 'html_class' => 'wide', |
|
135 | + 'default' => $evt_venue_id ? $evt_venue_id : '0' |
|
136 | + ) |
|
137 | + ); |
|
138 | + $template_args['venue_selector'] = $venue_selector->get_html_for_input(); |
|
139 | + $enable_for_gmap = new EE_Yes_No_Input( |
|
140 | + array( |
|
141 | + 'html_name' => 'enable_for_gmap', |
|
142 | + 'html_id' => 'enable_for_gmap', |
|
143 | + 'default' => $evt_venue instanceof EE_Venue ? $evt_venue->enable_for_gmap() : false |
|
144 | + ) |
|
145 | + ); |
|
146 | + $template_args['enable_for_gmap'] = $enable_for_gmap->get_html_for_input(); |
|
147 | + $template_args['new_venue_link'] = EEH_HTML::link( |
|
148 | + EE_Admin_Page::add_query_args_and_nonce( |
|
149 | + array('action' => 'create_new'), |
|
150 | + EE_VENUES_ADMIN_URL |
|
151 | + ), |
|
152 | + esc_html_x('Add new Venue', 'a link to add a new venue', 'event_espresso'), |
|
153 | + esc_html_x('Add new Venue', 'a link to add a new venue', 'event_espresso'), |
|
154 | + 'ev_new_venue_link', |
|
155 | + 'button', |
|
156 | + 'margin-left:10px;', |
|
157 | + 'target="_blank"' |
|
158 | + ); |
|
159 | + |
|
160 | + // Decide on an info text when there are no venues to display. |
|
161 | + $no_venues_info_txt = esc_html_x( |
|
162 | + 'You have not created any venues yet.', |
|
163 | + 'Information text displayed in the venues metabox when there are no venues to display', |
|
164 | + 'event_espresso' |
|
165 | + ); |
|
166 | + if (empty($venues)) { |
|
167 | + $unpublished_where = $vnu_where; |
|
168 | + $unpublished_where['status'] = 'draft'; |
|
169 | + $unpublished_venues = $vnumdl->get_all(array($unpublished_where, 'order_by' => array('VNU_name' => 'ASC'))); |
|
170 | + if (count($unpublished_venues) > 0) { |
|
171 | + $no_venues_info_txt = esc_html_x( |
|
172 | + // @codingStandardsIgnoreStart |
|
173 | + 'Use the link below to publish your venue through the venue editor so it appears here for selection.', |
|
174 | + // @codingStandardsIgnoreEnd |
|
175 | + 'Information text displayed in the venues metabox when there are no venues to display', |
|
176 | + 'event_espresso' |
|
177 | + ); |
|
178 | + } |
|
179 | + } |
|
180 | + $template_args['no_venues_info'] = EEH_HTML::p( |
|
181 | + EEH_HTML::strong($no_venues_info_txt), |
|
182 | + 'no_venues_info', |
|
183 | + 'info' |
|
184 | + ); |
|
185 | + |
|
186 | + $template_path = empty($venues) ? EE_VENUES_TEMPLATE_PATH . 'event_venues_metabox_content.template.php' |
|
187 | + : EE_VENUES_TEMPLATE_PATH . 'event_venues_metabox_content_from_manager.template.php'; |
|
188 | + |
|
189 | + // Allow events venue metabox template args filtering. |
|
190 | + $template_args = apply_filters( |
|
191 | + 'FHEE__espresso_events_Venues_Hooks___venue_metabox__template_args', |
|
192 | + $template_args, |
|
193 | + $template_path |
|
194 | + ); |
|
195 | + |
|
196 | + EEH_Template::display_template($template_path, $template_args); |
|
197 | + } |
|
198 | + |
|
199 | + |
|
200 | + public function caf_venue_update($evtobj, $data) |
|
201 | + { |
|
202 | + EE_Registry::instance()->load_model('Venue'); |
|
203 | + $venue_id = ! empty($data['venue_id']) ? $data['venue_id'] : null; |
|
204 | + |
|
205 | + |
|
206 | + // first let's check if the selected venue matches any existing venue attached to the event |
|
207 | + $evt_venue = $evtobj->venues(); |
|
208 | + $evt_venue = ! empty($evt_venue) ? array_shift($evt_venue) : null; |
|
209 | + |
|
210 | + if (! empty($evt_venue) && $evt_venue->ID() != $venue_id) { |
|
211 | + $evtobj->_remove_relation_to($evt_venue->ID(), 'Venue'); |
|
212 | + } |
|
213 | + |
|
214 | + if (empty($venue_id)) { |
|
215 | + return true; |
|
216 | + } //no venue to attach |
|
217 | + |
|
218 | + // this should take care of adding to revisions as well as main post object |
|
219 | + $success = $evtobj->_add_relation_to($venue_id, 'Venue'); |
|
220 | + return ! empty($success) ? true : false; |
|
221 | + } |
|
222 | 222 | } |
@@ -5,14 +5,14 @@ discard block |
||
5 | 5 | <?php echo $venue_selector; ?> |
6 | 6 | <?php echo $new_venue_link; ?> |
7 | 7 | <?php foreach ($venues as $venue) : |
8 | - $selected = $evt_venue_id == $venue->ID() ? '' : ' style="display:none;"'; |
|
9 | - $edit_url = EE_Admin_Page::add_query_args_and_nonce( |
|
10 | - array('action' => 'edit', 'post' => $venue->ID()), |
|
11 | - EE_VENUES_ADMIN_URL |
|
12 | - ); |
|
13 | - $state_name = is_object($venue->state_obj()) ? $venue->state_obj()->name() : null; |
|
14 | - $country_name = is_object($venue->country_obj()) ? $venue->country_obj()->name() : null; |
|
15 | - ?> |
|
8 | + $selected = $evt_venue_id == $venue->ID() ? '' : ' style="display:none;"'; |
|
9 | + $edit_url = EE_Admin_Page::add_query_args_and_nonce( |
|
10 | + array('action' => 'edit', 'post' => $venue->ID()), |
|
11 | + EE_VENUES_ADMIN_URL |
|
12 | + ); |
|
13 | + $state_name = is_object($venue->state_obj()) ? $venue->state_obj()->name() : null; |
|
14 | + $country_name = is_object($venue->country_obj()) ? $venue->country_obj()->name() : null; |
|
15 | + ?> |
|
16 | 16 | <fieldset id="eebox_<?php echo $venue->ID(); ?>" class="eebox"<?php echo $selected; ?>> |
17 | 17 | <ul class="address-view"> |
18 | 18 | <li> |
@@ -27,9 +27,9 @@ discard block |
||
27 | 27 | <br/></p> |
28 | 28 | <a href="<?php echo $edit_url; ?>" target="_blank"> |
29 | 29 | <?php _e( |
30 | - 'Edit this Venue', |
|
31 | - 'event_espresso' |
|
32 | - ); ?></a> |
|
30 | + 'Edit this Venue', |
|
31 | + 'event_espresso' |
|
32 | + ); ?></a> |
|
33 | 33 | </li> |
34 | 34 | </ul> |
35 | 35 | </fieldset> |
@@ -15,9 +15,9 @@ |
||
15 | 15 | interface RequestTypeContextFactoryInterface |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * @param string $slug |
|
20 | - * @return RequestTypeContext |
|
21 | - */ |
|
22 | - public function create($slug); |
|
18 | + /** |
|
19 | + * @param string $slug |
|
20 | + * @return RequestTypeContext |
|
21 | + */ |
|
22 | + public function create($slug); |
|
23 | 23 | } |
@@ -5,9 +5,9 @@ |
||
5 | 5 | <?php echo $no_venues_info; ?> |
6 | 6 | <p><a href="admin.php?page=espresso_venues" target="_blank"> |
7 | 7 | <?php echo __( |
8 | - 'Add venues to the Venue Manager', |
|
9 | - 'event_espresso' |
|
10 | - ) ?></a></p> |
|
8 | + 'Add venues to the Venue Manager', |
|
9 | + 'event_espresso' |
|
10 | + ) ?></a></p> |
|
11 | 11 | </fieldset> |
12 | 12 | </td> |
13 | 13 | </tr> |
@@ -15,757 +15,757 @@ |
||
15 | 15 | class EE_Datetime_Field extends EE_Model_Field_Base |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * The pattern we're looking for is if only the characters 0-9 are found and there are only |
|
20 | - * 10 or more numbers (because 9 numbers even with all 9's would be sometime in 2001 ) |
|
21 | - * |
|
22 | - * @type string unix_timestamp_regex |
|
23 | - */ |
|
24 | - const unix_timestamp_regex = '/[0-9]{10,}/'; |
|
25 | - |
|
26 | - /** |
|
27 | - * @type string mysql_timestamp_format |
|
28 | - */ |
|
29 | - const mysql_timestamp_format = 'Y-m-d H:i:s'; |
|
30 | - |
|
31 | - /** |
|
32 | - * @type string mysql_date_format |
|
33 | - */ |
|
34 | - const mysql_date_format = 'Y-m-d'; |
|
35 | - |
|
36 | - /** |
|
37 | - * @type string mysql_time_format |
|
38 | - */ |
|
39 | - const mysql_time_format = 'H:i:s'; |
|
40 | - |
|
41 | - /** |
|
42 | - * Const for using in the default value. If the field's default is set to this, |
|
43 | - * then we will return the time of calling `get_default_value()`, not |
|
44 | - * just the current time at construction |
|
45 | - */ |
|
46 | - const now = 'now'; |
|
47 | - |
|
48 | - /** |
|
49 | - * The following properties hold the default formats for date and time. |
|
50 | - * Defaults are set via the constructor and can be overridden on class instantiation. |
|
51 | - * However they can also be overridden later by the set_format() method |
|
52 | - * (and corresponding set_date_format, set_time_format methods); |
|
53 | - */ |
|
54 | - /** |
|
55 | - * @type string $_date_format |
|
56 | - */ |
|
57 | - protected $_date_format = ''; |
|
58 | - |
|
59 | - /** |
|
60 | - * @type string $_time_format |
|
61 | - */ |
|
62 | - protected $_time_format = ''; |
|
63 | - |
|
64 | - /** |
|
65 | - * @type string $_pretty_date_format |
|
66 | - */ |
|
67 | - protected $_pretty_date_format = ''; |
|
68 | - |
|
69 | - /** |
|
70 | - * @type string $_pretty_time_format |
|
71 | - */ |
|
72 | - protected $_pretty_time_format = ''; |
|
73 | - |
|
74 | - /** |
|
75 | - * @type DateTimeZone $_DateTimeZone |
|
76 | - */ |
|
77 | - protected $_DateTimeZone; |
|
78 | - |
|
79 | - /** |
|
80 | - * @type DateTimeZone $_UTC_DateTimeZone |
|
81 | - */ |
|
82 | - protected $_UTC_DateTimeZone; |
|
83 | - |
|
84 | - /** |
|
85 | - * @type DateTimeZone $_blog_DateTimeZone |
|
86 | - */ |
|
87 | - protected $_blog_DateTimeZone; |
|
88 | - |
|
89 | - |
|
90 | - /** |
|
91 | - * This property holds how we want the output returned when getting a datetime string. It is set for the |
|
92 | - * set_date_time_output() method. By default this is empty. When empty, we are assuming that we want both date |
|
93 | - * and time returned via getters. |
|
94 | - * |
|
95 | - * @var mixed (null|string) |
|
96 | - */ |
|
97 | - protected $_date_time_output; |
|
98 | - |
|
99 | - |
|
100 | - /** |
|
101 | - * timezone string |
|
102 | - * This gets set by the constructor and can be changed by the "set_timezone()" method so that we know what timezone |
|
103 | - * incoming strings|timestamps are in. This can also be used before a get to set what timezone you want strings |
|
104 | - * coming out of the object to be in. Default timezone is the current WP timezone option setting |
|
105 | - * |
|
106 | - * @var string |
|
107 | - */ |
|
108 | - protected $_timezone_string; |
|
109 | - |
|
110 | - |
|
111 | - /** |
|
112 | - * This holds whatever UTC offset for the blog (we automatically convert timezone strings into their related |
|
113 | - * offsets for comparison purposes). |
|
114 | - * |
|
115 | - * @var int |
|
116 | - */ |
|
117 | - protected $_blog_offset; |
|
118 | - |
|
119 | - |
|
120 | - |
|
121 | - /** |
|
122 | - * @param string $table_column |
|
123 | - * @param string $nice_name |
|
124 | - * @param bool $nullable |
|
125 | - * @param string $default_value |
|
126 | - * @param string $timezone_string |
|
127 | - * @param string $date_format |
|
128 | - * @param string $time_format |
|
129 | - * @param string $pretty_date_format |
|
130 | - * @param string $pretty_time_format |
|
131 | - * @throws EE_Error |
|
132 | - * @throws InvalidArgumentException |
|
133 | - */ |
|
134 | - public function __construct( |
|
135 | - $table_column, |
|
136 | - $nice_name, |
|
137 | - $nullable, |
|
138 | - $default_value, |
|
139 | - $timezone_string = '', |
|
140 | - $date_format = '', |
|
141 | - $time_format = '', |
|
142 | - $pretty_date_format = '', |
|
143 | - $pretty_time_format = '' |
|
144 | - ) { |
|
145 | - |
|
146 | - $this->_date_format = ! empty($date_format) ? $date_format : get_option('date_format'); |
|
147 | - $this->_time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
|
148 | - $this->_pretty_date_format = ! empty($pretty_date_format) ? $pretty_date_format : get_option('date_format'); |
|
149 | - $this->_pretty_time_format = ! empty($pretty_time_format) ? $pretty_time_format : get_option('time_format'); |
|
150 | - |
|
151 | - parent::__construct($table_column, $nice_name, $nullable, $default_value); |
|
152 | - $this->set_timezone($timezone_string); |
|
153 | - $this->setSchemaFormat('date-time'); |
|
154 | - } |
|
155 | - |
|
156 | - |
|
157 | - /** |
|
158 | - * @return DateTimeZone |
|
159 | - * @throws \EE_Error |
|
160 | - */ |
|
161 | - public function get_UTC_DateTimeZone() |
|
162 | - { |
|
163 | - return $this->_UTC_DateTimeZone instanceof DateTimeZone |
|
164 | - ? $this->_UTC_DateTimeZone |
|
165 | - : $this->_create_timezone_object_from_timezone_string('UTC'); |
|
166 | - } |
|
167 | - |
|
168 | - |
|
169 | - /** |
|
170 | - * @return DateTimeZone |
|
171 | - * @throws \EE_Error |
|
172 | - */ |
|
173 | - public function get_blog_DateTimeZone() |
|
174 | - { |
|
175 | - return $this->_blog_DateTimeZone instanceof DateTimeZone |
|
176 | - ? $this->_blog_DateTimeZone |
|
177 | - : $this->_create_timezone_object_from_timezone_string(''); |
|
178 | - } |
|
179 | - |
|
180 | - |
|
181 | - /** |
|
182 | - * this prepares any incoming date data and make sure its converted to a utc unix timestamp |
|
183 | - * |
|
184 | - * @param string|int $value_inputted_for_field_on_model_object could be a string formatted date time or int unix |
|
185 | - * timestamp |
|
186 | - * @return DateTime |
|
187 | - */ |
|
188 | - public function prepare_for_set($value_inputted_for_field_on_model_object) |
|
189 | - { |
|
190 | - return $this->_get_date_object($value_inputted_for_field_on_model_object); |
|
191 | - } |
|
192 | - |
|
193 | - |
|
194 | - /** |
|
195 | - * This returns the format string to be used by getters depending on what the $_date_time_output property is set at. |
|
196 | - * getters need to know whether we're just returning the date or the time or both. By default we return both. |
|
197 | - * |
|
198 | - * @param bool $pretty If we're returning the pretty formats or standard format string. |
|
199 | - * @return string The final assembled format string. |
|
200 | - */ |
|
201 | - protected function _get_date_time_output($pretty = false) |
|
202 | - { |
|
203 | - |
|
204 | - switch ($this->_date_time_output) { |
|
205 | - case 'time': |
|
206 | - return $pretty ? $this->_pretty_time_format : $this->_time_format; |
|
207 | - break; |
|
208 | - |
|
209 | - case 'date': |
|
210 | - return $pretty ? $this->_pretty_date_format : $this->_date_format; |
|
211 | - break; |
|
212 | - |
|
213 | - default: |
|
214 | - return $pretty |
|
215 | - ? $this->_pretty_date_format . ' ' . $this->_pretty_time_format |
|
216 | - : $this->_date_format . ' ' . $this->_time_format; |
|
217 | - } |
|
218 | - } |
|
219 | - |
|
220 | - |
|
221 | - /** |
|
222 | - * This just sets the $_date_time_output property so we can flag how date and times are formatted before being |
|
223 | - * returned (using the format properties) |
|
224 | - * |
|
225 | - * @param string $what acceptable values are 'time' or 'date'. |
|
226 | - * Any other value will be set but will always result |
|
227 | - * in both 'date' and 'time' being returned. |
|
228 | - * @return void |
|
229 | - */ |
|
230 | - public function set_date_time_output($what = null) |
|
231 | - { |
|
232 | - $this->_date_time_output = $what; |
|
233 | - } |
|
234 | - |
|
235 | - |
|
236 | - /** |
|
237 | - * See $_timezone property for description of what the timezone property is for. This SETS the timezone internally |
|
238 | - * for being able to reference what timezone we are running conversions on when converting TO the internal timezone |
|
239 | - * (UTC Unix Timestamp) for the object OR when converting FROM the internal timezone (UTC Unix Timestamp). |
|
240 | - * We also set some other properties in this method. |
|
241 | - * |
|
242 | - * @param string $timezone_string A valid timezone string as described by @link |
|
243 | - * http://www.php.net/manual/en/timezones.php |
|
244 | - * @return void |
|
245 | - * @throws InvalidArgumentException |
|
246 | - * @throws InvalidDataTypeException |
|
247 | - * @throws InvalidInterfaceException |
|
248 | - */ |
|
249 | - public function set_timezone($timezone_string) |
|
250 | - { |
|
251 | - if (empty($timezone_string) && $this->_timezone_string !== null) { |
|
252 | - // leave the timezone AS-IS if we already have one and |
|
253 | - // the function arg didn't provide one |
|
254 | - return; |
|
255 | - } |
|
256 | - $timezone_string = EEH_DTT_Helper::get_valid_timezone_string($timezone_string); |
|
257 | - $this->_timezone_string = ! empty($timezone_string) ? $timezone_string : 'UTC'; |
|
258 | - $this->_DateTimeZone = $this->_create_timezone_object_from_timezone_string($this->_timezone_string); |
|
259 | - } |
|
260 | - |
|
261 | - |
|
262 | - /** |
|
263 | - * _create_timezone_object_from_timezone_name |
|
264 | - * |
|
265 | - * @access protected |
|
266 | - * @param string $timezone_string |
|
267 | - * @return \DateTimeZone |
|
268 | - * @throws InvalidArgumentException |
|
269 | - * @throws InvalidDataTypeException |
|
270 | - * @throws InvalidInterfaceException |
|
271 | - */ |
|
272 | - protected function _create_timezone_object_from_timezone_string($timezone_string = '') |
|
273 | - { |
|
274 | - return new DateTimeZone(EEH_DTT_Helper::get_valid_timezone_string($timezone_string)); |
|
275 | - } |
|
276 | - |
|
277 | - |
|
278 | - /** |
|
279 | - * This just returns whatever is set for the current timezone. |
|
280 | - * |
|
281 | - * @access public |
|
282 | - * @return string timezone string |
|
283 | - */ |
|
284 | - public function get_timezone() |
|
285 | - { |
|
286 | - return $this->_timezone_string; |
|
287 | - } |
|
288 | - |
|
289 | - |
|
290 | - /** |
|
291 | - * set the $_date_format property |
|
292 | - * |
|
293 | - * @access public |
|
294 | - * @param string $format a new date format (corresponding to formats accepted by PHP date() function) |
|
295 | - * @param bool $pretty Whether to set pretty format or not. |
|
296 | - * @return void |
|
297 | - */ |
|
298 | - public function set_date_format($format, $pretty = false) |
|
299 | - { |
|
300 | - if ($pretty) { |
|
301 | - $this->_pretty_date_format = $format; |
|
302 | - } else { |
|
303 | - $this->_date_format = $format; |
|
304 | - } |
|
305 | - } |
|
306 | - |
|
307 | - |
|
308 | - /** |
|
309 | - * return the $_date_format property value. |
|
310 | - * |
|
311 | - * @param bool $pretty Whether to get pretty format or not. |
|
312 | - * @return string |
|
313 | - */ |
|
314 | - public function get_date_format($pretty = false) |
|
315 | - { |
|
316 | - return $pretty ? $this->_pretty_date_format : $this->_date_format; |
|
317 | - } |
|
318 | - |
|
319 | - |
|
320 | - /** |
|
321 | - * set the $_time_format property |
|
322 | - * |
|
323 | - * @access public |
|
324 | - * @param string $format a new time format (corresponding to formats accepted by PHP date() function) |
|
325 | - * @param bool $pretty Whether to set pretty format or not. |
|
326 | - * @return void |
|
327 | - */ |
|
328 | - public function set_time_format($format, $pretty = false) |
|
329 | - { |
|
330 | - if ($pretty) { |
|
331 | - $this->_pretty_time_format = $format; |
|
332 | - } else { |
|
333 | - $this->_time_format = $format; |
|
334 | - } |
|
335 | - } |
|
336 | - |
|
337 | - |
|
338 | - /** |
|
339 | - * return the $_time_format property value. |
|
340 | - * |
|
341 | - * @param bool $pretty Whether to get pretty format or not. |
|
342 | - * @return string |
|
343 | - */ |
|
344 | - public function get_time_format($pretty = false) |
|
345 | - { |
|
346 | - return $pretty ? $this->_pretty_time_format : $this->_time_format; |
|
347 | - } |
|
348 | - |
|
349 | - |
|
350 | - /** |
|
351 | - * set the $_pretty_date_format property |
|
352 | - * |
|
353 | - * @access public |
|
354 | - * @param string $format a new pretty date format (corresponding to formats accepted by PHP date() function) |
|
355 | - * @return void |
|
356 | - */ |
|
357 | - public function set_pretty_date_format($format) |
|
358 | - { |
|
359 | - $this->_pretty_date_format = $format; |
|
360 | - } |
|
361 | - |
|
362 | - |
|
363 | - /** |
|
364 | - * set the $_pretty_time_format property |
|
365 | - * |
|
366 | - * @access public |
|
367 | - * @param string $format a new pretty time format (corresponding to formats accepted by PHP date() function) |
|
368 | - * @return void |
|
369 | - */ |
|
370 | - public function set_pretty_time_format($format) |
|
371 | - { |
|
372 | - $this->_pretty_time_format = $format; |
|
373 | - } |
|
374 | - |
|
375 | - |
|
376 | - /** |
|
377 | - * Only sets the time portion of the datetime. |
|
378 | - * |
|
379 | - * @param string|DateTime $time_to_set_string like 8am OR a DateTime object. |
|
380 | - * @param DateTime $current current DateTime object for the datetime field |
|
381 | - * @return DateTime |
|
382 | - */ |
|
383 | - public function prepare_for_set_with_new_time($time_to_set_string, DateTime $current) |
|
384 | - { |
|
385 | - // if $time_to_set_string is datetime object, then let's use it to set the parse array. |
|
386 | - // Otherwise parse the string. |
|
387 | - if ($time_to_set_string instanceof DateTime) { |
|
388 | - $parsed = array( |
|
389 | - 'hour' => $time_to_set_string->format('H'), |
|
390 | - 'minute' => $time_to_set_string->format('i'), |
|
391 | - 'second' => $time_to_set_string->format('s'), |
|
392 | - ); |
|
393 | - } else { |
|
394 | - // parse incoming string |
|
395 | - $parsed = date_parse_from_format($this->_time_format, $time_to_set_string); |
|
396 | - } |
|
397 | - EEH_DTT_Helper::setTimezone($current, $this->_DateTimeZone); |
|
398 | - return $current->setTime($parsed['hour'], $parsed['minute'], $parsed['second']); |
|
399 | - } |
|
400 | - |
|
401 | - |
|
402 | - /** |
|
403 | - * Only sets the date portion of the datetime. |
|
404 | - * |
|
405 | - * @param string|DateTime $date_to_set_string like Friday, January 8th or a DateTime object. |
|
406 | - * @param DateTime $current current DateTime object for the datetime field |
|
407 | - * @return DateTime |
|
408 | - */ |
|
409 | - public function prepare_for_set_with_new_date($date_to_set_string, DateTime $current) |
|
410 | - { |
|
411 | - // if $time_to_set_string is datetime object, then let's use it to set the parse array. |
|
412 | - // Otherwise parse the string. |
|
413 | - if ($date_to_set_string instanceof DateTime) { |
|
414 | - $parsed = array( |
|
415 | - 'year' => $date_to_set_string->format('Y'), |
|
416 | - 'month' => $date_to_set_string->format('m'), |
|
417 | - 'day' => $date_to_set_string->format('d'), |
|
418 | - ); |
|
419 | - } else { |
|
420 | - // parse incoming string |
|
421 | - $parsed = date_parse_from_format($this->_date_format, $date_to_set_string); |
|
422 | - } |
|
423 | - EEH_DTT_Helper::setTimezone($current, $this->_DateTimeZone); |
|
424 | - return $current->setDate($parsed['year'], $parsed['month'], $parsed['day']); |
|
425 | - } |
|
426 | - |
|
427 | - |
|
428 | - /** |
|
429 | - * This prepares the EE_DateTime value to be saved to the db as mysql timestamp (UTC +0 timezone). When the |
|
430 | - * datetime gets to this stage it should ALREADY be in UTC time |
|
431 | - * |
|
432 | - * @param DateTime $DateTime |
|
433 | - * @return string formatted date time for given timezone |
|
434 | - * @throws \EE_Error |
|
435 | - */ |
|
436 | - public function prepare_for_get($DateTime) |
|
437 | - { |
|
438 | - return $this->_prepare_for_display($DateTime); |
|
439 | - } |
|
440 | - |
|
441 | - |
|
442 | - /** |
|
443 | - * This differs from prepare_for_get in that it considers whether the internal $_timezone differs |
|
444 | - * from the set wp timezone. If so, then it returns the datetime string formatted via |
|
445 | - * _pretty_date_format, and _pretty_time_format. However, it also appends a timezone |
|
446 | - * abbreviation to the date_string. |
|
447 | - * |
|
448 | - * @param mixed $DateTime |
|
449 | - * @param null $schema |
|
450 | - * @return string |
|
451 | - * @throws \EE_Error |
|
452 | - */ |
|
453 | - public function prepare_for_pretty_echoing($DateTime, $schema = null) |
|
454 | - { |
|
455 | - return $this->_prepare_for_display($DateTime, $schema ? $schema : true); |
|
456 | - } |
|
457 | - |
|
458 | - |
|
459 | - /** |
|
460 | - * This prepares the EE_DateTime value to be saved to the db as mysql timestamp (UTC +0 |
|
461 | - * timezone). |
|
462 | - * |
|
463 | - * @param DateTime $DateTime |
|
464 | - * @param bool|string $schema |
|
465 | - * @return string |
|
466 | - * @throws \EE_Error |
|
467 | - */ |
|
468 | - protected function _prepare_for_display($DateTime, $schema = false) |
|
469 | - { |
|
470 | - if (! $DateTime instanceof DateTime) { |
|
471 | - if ($this->_nullable) { |
|
472 | - return ''; |
|
473 | - } else { |
|
474 | - if (WP_DEBUG) { |
|
475 | - throw new EE_Error( |
|
476 | - sprintf( |
|
477 | - __( |
|
478 | - 'EE_Datetime_Field::_prepare_for_display requires a DateTime class to be the value for the $DateTime argument because the %s field is not nullable.', |
|
479 | - 'event_espresso' |
|
480 | - ), |
|
481 | - $this->_nicename |
|
482 | - ) |
|
483 | - ); |
|
484 | - } else { |
|
485 | - $DateTime = new DbSafeDateTime(\EE_Datetime_Field::now); |
|
486 | - EE_Error::add_error( |
|
487 | - sprintf( |
|
488 | - __( |
|
489 | - 'EE_Datetime_Field::_prepare_for_display requires a DateTime class to be the value for the $DateTime argument because the %s field is not nullable. When WP_DEBUG is false, the value is set to "now" instead of throwing an exception.', |
|
490 | - 'event_espresso' |
|
491 | - ), |
|
492 | - $this->_nicename |
|
493 | - ) |
|
494 | - ); |
|
495 | - } |
|
496 | - } |
|
497 | - } |
|
498 | - $format_string = $this->_get_date_time_output($schema); |
|
499 | - EEH_DTT_Helper::setTimezone($DateTime, $this->_DateTimeZone); |
|
500 | - if ($schema) { |
|
501 | - if ($this->_display_timezone()) { |
|
502 | - // must be explicit because schema could equal true. |
|
503 | - if ($schema === 'no_html') { |
|
504 | - $timezone_string = ' (' . $DateTime->format('T') . ')'; |
|
505 | - } else { |
|
506 | - $timezone_string = ' <span class="ee_dtt_timezone_string">(' . $DateTime->format('T') . ')</span>'; |
|
507 | - } |
|
508 | - } else { |
|
509 | - $timezone_string = ''; |
|
510 | - } |
|
511 | - |
|
512 | - return $DateTime->format($format_string) . $timezone_string; |
|
513 | - } |
|
514 | - return $DateTime->format($format_string); |
|
515 | - } |
|
516 | - |
|
517 | - |
|
518 | - /** |
|
519 | - * This prepares the EE_DateTime value to be saved to the db as mysql timestamp (UTC +0 |
|
520 | - * timezone). |
|
521 | - * |
|
522 | - * @param mixed $datetime_value u |
|
523 | - * @return string mysql timestamp in UTC |
|
524 | - * @throws \EE_Error |
|
525 | - */ |
|
526 | - public function prepare_for_use_in_db($datetime_value) |
|
527 | - { |
|
528 | - // we allow an empty value or DateTime object, but nothing else. |
|
529 | - if (! empty($datetime_value) && ! $datetime_value instanceof DateTime) { |
|
530 | - throw new EE_Error( |
|
531 | - sprintf( |
|
532 | - __( |
|
533 | - 'The incoming value being prepared for setting in the database must either be empty or a php |
|
18 | + /** |
|
19 | + * The pattern we're looking for is if only the characters 0-9 are found and there are only |
|
20 | + * 10 or more numbers (because 9 numbers even with all 9's would be sometime in 2001 ) |
|
21 | + * |
|
22 | + * @type string unix_timestamp_regex |
|
23 | + */ |
|
24 | + const unix_timestamp_regex = '/[0-9]{10,}/'; |
|
25 | + |
|
26 | + /** |
|
27 | + * @type string mysql_timestamp_format |
|
28 | + */ |
|
29 | + const mysql_timestamp_format = 'Y-m-d H:i:s'; |
|
30 | + |
|
31 | + /** |
|
32 | + * @type string mysql_date_format |
|
33 | + */ |
|
34 | + const mysql_date_format = 'Y-m-d'; |
|
35 | + |
|
36 | + /** |
|
37 | + * @type string mysql_time_format |
|
38 | + */ |
|
39 | + const mysql_time_format = 'H:i:s'; |
|
40 | + |
|
41 | + /** |
|
42 | + * Const for using in the default value. If the field's default is set to this, |
|
43 | + * then we will return the time of calling `get_default_value()`, not |
|
44 | + * just the current time at construction |
|
45 | + */ |
|
46 | + const now = 'now'; |
|
47 | + |
|
48 | + /** |
|
49 | + * The following properties hold the default formats for date and time. |
|
50 | + * Defaults are set via the constructor and can be overridden on class instantiation. |
|
51 | + * However they can also be overridden later by the set_format() method |
|
52 | + * (and corresponding set_date_format, set_time_format methods); |
|
53 | + */ |
|
54 | + /** |
|
55 | + * @type string $_date_format |
|
56 | + */ |
|
57 | + protected $_date_format = ''; |
|
58 | + |
|
59 | + /** |
|
60 | + * @type string $_time_format |
|
61 | + */ |
|
62 | + protected $_time_format = ''; |
|
63 | + |
|
64 | + /** |
|
65 | + * @type string $_pretty_date_format |
|
66 | + */ |
|
67 | + protected $_pretty_date_format = ''; |
|
68 | + |
|
69 | + /** |
|
70 | + * @type string $_pretty_time_format |
|
71 | + */ |
|
72 | + protected $_pretty_time_format = ''; |
|
73 | + |
|
74 | + /** |
|
75 | + * @type DateTimeZone $_DateTimeZone |
|
76 | + */ |
|
77 | + protected $_DateTimeZone; |
|
78 | + |
|
79 | + /** |
|
80 | + * @type DateTimeZone $_UTC_DateTimeZone |
|
81 | + */ |
|
82 | + protected $_UTC_DateTimeZone; |
|
83 | + |
|
84 | + /** |
|
85 | + * @type DateTimeZone $_blog_DateTimeZone |
|
86 | + */ |
|
87 | + protected $_blog_DateTimeZone; |
|
88 | + |
|
89 | + |
|
90 | + /** |
|
91 | + * This property holds how we want the output returned when getting a datetime string. It is set for the |
|
92 | + * set_date_time_output() method. By default this is empty. When empty, we are assuming that we want both date |
|
93 | + * and time returned via getters. |
|
94 | + * |
|
95 | + * @var mixed (null|string) |
|
96 | + */ |
|
97 | + protected $_date_time_output; |
|
98 | + |
|
99 | + |
|
100 | + /** |
|
101 | + * timezone string |
|
102 | + * This gets set by the constructor and can be changed by the "set_timezone()" method so that we know what timezone |
|
103 | + * incoming strings|timestamps are in. This can also be used before a get to set what timezone you want strings |
|
104 | + * coming out of the object to be in. Default timezone is the current WP timezone option setting |
|
105 | + * |
|
106 | + * @var string |
|
107 | + */ |
|
108 | + protected $_timezone_string; |
|
109 | + |
|
110 | + |
|
111 | + /** |
|
112 | + * This holds whatever UTC offset for the blog (we automatically convert timezone strings into their related |
|
113 | + * offsets for comparison purposes). |
|
114 | + * |
|
115 | + * @var int |
|
116 | + */ |
|
117 | + protected $_blog_offset; |
|
118 | + |
|
119 | + |
|
120 | + |
|
121 | + /** |
|
122 | + * @param string $table_column |
|
123 | + * @param string $nice_name |
|
124 | + * @param bool $nullable |
|
125 | + * @param string $default_value |
|
126 | + * @param string $timezone_string |
|
127 | + * @param string $date_format |
|
128 | + * @param string $time_format |
|
129 | + * @param string $pretty_date_format |
|
130 | + * @param string $pretty_time_format |
|
131 | + * @throws EE_Error |
|
132 | + * @throws InvalidArgumentException |
|
133 | + */ |
|
134 | + public function __construct( |
|
135 | + $table_column, |
|
136 | + $nice_name, |
|
137 | + $nullable, |
|
138 | + $default_value, |
|
139 | + $timezone_string = '', |
|
140 | + $date_format = '', |
|
141 | + $time_format = '', |
|
142 | + $pretty_date_format = '', |
|
143 | + $pretty_time_format = '' |
|
144 | + ) { |
|
145 | + |
|
146 | + $this->_date_format = ! empty($date_format) ? $date_format : get_option('date_format'); |
|
147 | + $this->_time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
|
148 | + $this->_pretty_date_format = ! empty($pretty_date_format) ? $pretty_date_format : get_option('date_format'); |
|
149 | + $this->_pretty_time_format = ! empty($pretty_time_format) ? $pretty_time_format : get_option('time_format'); |
|
150 | + |
|
151 | + parent::__construct($table_column, $nice_name, $nullable, $default_value); |
|
152 | + $this->set_timezone($timezone_string); |
|
153 | + $this->setSchemaFormat('date-time'); |
|
154 | + } |
|
155 | + |
|
156 | + |
|
157 | + /** |
|
158 | + * @return DateTimeZone |
|
159 | + * @throws \EE_Error |
|
160 | + */ |
|
161 | + public function get_UTC_DateTimeZone() |
|
162 | + { |
|
163 | + return $this->_UTC_DateTimeZone instanceof DateTimeZone |
|
164 | + ? $this->_UTC_DateTimeZone |
|
165 | + : $this->_create_timezone_object_from_timezone_string('UTC'); |
|
166 | + } |
|
167 | + |
|
168 | + |
|
169 | + /** |
|
170 | + * @return DateTimeZone |
|
171 | + * @throws \EE_Error |
|
172 | + */ |
|
173 | + public function get_blog_DateTimeZone() |
|
174 | + { |
|
175 | + return $this->_blog_DateTimeZone instanceof DateTimeZone |
|
176 | + ? $this->_blog_DateTimeZone |
|
177 | + : $this->_create_timezone_object_from_timezone_string(''); |
|
178 | + } |
|
179 | + |
|
180 | + |
|
181 | + /** |
|
182 | + * this prepares any incoming date data and make sure its converted to a utc unix timestamp |
|
183 | + * |
|
184 | + * @param string|int $value_inputted_for_field_on_model_object could be a string formatted date time or int unix |
|
185 | + * timestamp |
|
186 | + * @return DateTime |
|
187 | + */ |
|
188 | + public function prepare_for_set($value_inputted_for_field_on_model_object) |
|
189 | + { |
|
190 | + return $this->_get_date_object($value_inputted_for_field_on_model_object); |
|
191 | + } |
|
192 | + |
|
193 | + |
|
194 | + /** |
|
195 | + * This returns the format string to be used by getters depending on what the $_date_time_output property is set at. |
|
196 | + * getters need to know whether we're just returning the date or the time or both. By default we return both. |
|
197 | + * |
|
198 | + * @param bool $pretty If we're returning the pretty formats or standard format string. |
|
199 | + * @return string The final assembled format string. |
|
200 | + */ |
|
201 | + protected function _get_date_time_output($pretty = false) |
|
202 | + { |
|
203 | + |
|
204 | + switch ($this->_date_time_output) { |
|
205 | + case 'time': |
|
206 | + return $pretty ? $this->_pretty_time_format : $this->_time_format; |
|
207 | + break; |
|
208 | + |
|
209 | + case 'date': |
|
210 | + return $pretty ? $this->_pretty_date_format : $this->_date_format; |
|
211 | + break; |
|
212 | + |
|
213 | + default: |
|
214 | + return $pretty |
|
215 | + ? $this->_pretty_date_format . ' ' . $this->_pretty_time_format |
|
216 | + : $this->_date_format . ' ' . $this->_time_format; |
|
217 | + } |
|
218 | + } |
|
219 | + |
|
220 | + |
|
221 | + /** |
|
222 | + * This just sets the $_date_time_output property so we can flag how date and times are formatted before being |
|
223 | + * returned (using the format properties) |
|
224 | + * |
|
225 | + * @param string $what acceptable values are 'time' or 'date'. |
|
226 | + * Any other value will be set but will always result |
|
227 | + * in both 'date' and 'time' being returned. |
|
228 | + * @return void |
|
229 | + */ |
|
230 | + public function set_date_time_output($what = null) |
|
231 | + { |
|
232 | + $this->_date_time_output = $what; |
|
233 | + } |
|
234 | + |
|
235 | + |
|
236 | + /** |
|
237 | + * See $_timezone property for description of what the timezone property is for. This SETS the timezone internally |
|
238 | + * for being able to reference what timezone we are running conversions on when converting TO the internal timezone |
|
239 | + * (UTC Unix Timestamp) for the object OR when converting FROM the internal timezone (UTC Unix Timestamp). |
|
240 | + * We also set some other properties in this method. |
|
241 | + * |
|
242 | + * @param string $timezone_string A valid timezone string as described by @link |
|
243 | + * http://www.php.net/manual/en/timezones.php |
|
244 | + * @return void |
|
245 | + * @throws InvalidArgumentException |
|
246 | + * @throws InvalidDataTypeException |
|
247 | + * @throws InvalidInterfaceException |
|
248 | + */ |
|
249 | + public function set_timezone($timezone_string) |
|
250 | + { |
|
251 | + if (empty($timezone_string) && $this->_timezone_string !== null) { |
|
252 | + // leave the timezone AS-IS if we already have one and |
|
253 | + // the function arg didn't provide one |
|
254 | + return; |
|
255 | + } |
|
256 | + $timezone_string = EEH_DTT_Helper::get_valid_timezone_string($timezone_string); |
|
257 | + $this->_timezone_string = ! empty($timezone_string) ? $timezone_string : 'UTC'; |
|
258 | + $this->_DateTimeZone = $this->_create_timezone_object_from_timezone_string($this->_timezone_string); |
|
259 | + } |
|
260 | + |
|
261 | + |
|
262 | + /** |
|
263 | + * _create_timezone_object_from_timezone_name |
|
264 | + * |
|
265 | + * @access protected |
|
266 | + * @param string $timezone_string |
|
267 | + * @return \DateTimeZone |
|
268 | + * @throws InvalidArgumentException |
|
269 | + * @throws InvalidDataTypeException |
|
270 | + * @throws InvalidInterfaceException |
|
271 | + */ |
|
272 | + protected function _create_timezone_object_from_timezone_string($timezone_string = '') |
|
273 | + { |
|
274 | + return new DateTimeZone(EEH_DTT_Helper::get_valid_timezone_string($timezone_string)); |
|
275 | + } |
|
276 | + |
|
277 | + |
|
278 | + /** |
|
279 | + * This just returns whatever is set for the current timezone. |
|
280 | + * |
|
281 | + * @access public |
|
282 | + * @return string timezone string |
|
283 | + */ |
|
284 | + public function get_timezone() |
|
285 | + { |
|
286 | + return $this->_timezone_string; |
|
287 | + } |
|
288 | + |
|
289 | + |
|
290 | + /** |
|
291 | + * set the $_date_format property |
|
292 | + * |
|
293 | + * @access public |
|
294 | + * @param string $format a new date format (corresponding to formats accepted by PHP date() function) |
|
295 | + * @param bool $pretty Whether to set pretty format or not. |
|
296 | + * @return void |
|
297 | + */ |
|
298 | + public function set_date_format($format, $pretty = false) |
|
299 | + { |
|
300 | + if ($pretty) { |
|
301 | + $this->_pretty_date_format = $format; |
|
302 | + } else { |
|
303 | + $this->_date_format = $format; |
|
304 | + } |
|
305 | + } |
|
306 | + |
|
307 | + |
|
308 | + /** |
|
309 | + * return the $_date_format property value. |
|
310 | + * |
|
311 | + * @param bool $pretty Whether to get pretty format or not. |
|
312 | + * @return string |
|
313 | + */ |
|
314 | + public function get_date_format($pretty = false) |
|
315 | + { |
|
316 | + return $pretty ? $this->_pretty_date_format : $this->_date_format; |
|
317 | + } |
|
318 | + |
|
319 | + |
|
320 | + /** |
|
321 | + * set the $_time_format property |
|
322 | + * |
|
323 | + * @access public |
|
324 | + * @param string $format a new time format (corresponding to formats accepted by PHP date() function) |
|
325 | + * @param bool $pretty Whether to set pretty format or not. |
|
326 | + * @return void |
|
327 | + */ |
|
328 | + public function set_time_format($format, $pretty = false) |
|
329 | + { |
|
330 | + if ($pretty) { |
|
331 | + $this->_pretty_time_format = $format; |
|
332 | + } else { |
|
333 | + $this->_time_format = $format; |
|
334 | + } |
|
335 | + } |
|
336 | + |
|
337 | + |
|
338 | + /** |
|
339 | + * return the $_time_format property value. |
|
340 | + * |
|
341 | + * @param bool $pretty Whether to get pretty format or not. |
|
342 | + * @return string |
|
343 | + */ |
|
344 | + public function get_time_format($pretty = false) |
|
345 | + { |
|
346 | + return $pretty ? $this->_pretty_time_format : $this->_time_format; |
|
347 | + } |
|
348 | + |
|
349 | + |
|
350 | + /** |
|
351 | + * set the $_pretty_date_format property |
|
352 | + * |
|
353 | + * @access public |
|
354 | + * @param string $format a new pretty date format (corresponding to formats accepted by PHP date() function) |
|
355 | + * @return void |
|
356 | + */ |
|
357 | + public function set_pretty_date_format($format) |
|
358 | + { |
|
359 | + $this->_pretty_date_format = $format; |
|
360 | + } |
|
361 | + |
|
362 | + |
|
363 | + /** |
|
364 | + * set the $_pretty_time_format property |
|
365 | + * |
|
366 | + * @access public |
|
367 | + * @param string $format a new pretty time format (corresponding to formats accepted by PHP date() function) |
|
368 | + * @return void |
|
369 | + */ |
|
370 | + public function set_pretty_time_format($format) |
|
371 | + { |
|
372 | + $this->_pretty_time_format = $format; |
|
373 | + } |
|
374 | + |
|
375 | + |
|
376 | + /** |
|
377 | + * Only sets the time portion of the datetime. |
|
378 | + * |
|
379 | + * @param string|DateTime $time_to_set_string like 8am OR a DateTime object. |
|
380 | + * @param DateTime $current current DateTime object for the datetime field |
|
381 | + * @return DateTime |
|
382 | + */ |
|
383 | + public function prepare_for_set_with_new_time($time_to_set_string, DateTime $current) |
|
384 | + { |
|
385 | + // if $time_to_set_string is datetime object, then let's use it to set the parse array. |
|
386 | + // Otherwise parse the string. |
|
387 | + if ($time_to_set_string instanceof DateTime) { |
|
388 | + $parsed = array( |
|
389 | + 'hour' => $time_to_set_string->format('H'), |
|
390 | + 'minute' => $time_to_set_string->format('i'), |
|
391 | + 'second' => $time_to_set_string->format('s'), |
|
392 | + ); |
|
393 | + } else { |
|
394 | + // parse incoming string |
|
395 | + $parsed = date_parse_from_format($this->_time_format, $time_to_set_string); |
|
396 | + } |
|
397 | + EEH_DTT_Helper::setTimezone($current, $this->_DateTimeZone); |
|
398 | + return $current->setTime($parsed['hour'], $parsed['minute'], $parsed['second']); |
|
399 | + } |
|
400 | + |
|
401 | + |
|
402 | + /** |
|
403 | + * Only sets the date portion of the datetime. |
|
404 | + * |
|
405 | + * @param string|DateTime $date_to_set_string like Friday, January 8th or a DateTime object. |
|
406 | + * @param DateTime $current current DateTime object for the datetime field |
|
407 | + * @return DateTime |
|
408 | + */ |
|
409 | + public function prepare_for_set_with_new_date($date_to_set_string, DateTime $current) |
|
410 | + { |
|
411 | + // if $time_to_set_string is datetime object, then let's use it to set the parse array. |
|
412 | + // Otherwise parse the string. |
|
413 | + if ($date_to_set_string instanceof DateTime) { |
|
414 | + $parsed = array( |
|
415 | + 'year' => $date_to_set_string->format('Y'), |
|
416 | + 'month' => $date_to_set_string->format('m'), |
|
417 | + 'day' => $date_to_set_string->format('d'), |
|
418 | + ); |
|
419 | + } else { |
|
420 | + // parse incoming string |
|
421 | + $parsed = date_parse_from_format($this->_date_format, $date_to_set_string); |
|
422 | + } |
|
423 | + EEH_DTT_Helper::setTimezone($current, $this->_DateTimeZone); |
|
424 | + return $current->setDate($parsed['year'], $parsed['month'], $parsed['day']); |
|
425 | + } |
|
426 | + |
|
427 | + |
|
428 | + /** |
|
429 | + * This prepares the EE_DateTime value to be saved to the db as mysql timestamp (UTC +0 timezone). When the |
|
430 | + * datetime gets to this stage it should ALREADY be in UTC time |
|
431 | + * |
|
432 | + * @param DateTime $DateTime |
|
433 | + * @return string formatted date time for given timezone |
|
434 | + * @throws \EE_Error |
|
435 | + */ |
|
436 | + public function prepare_for_get($DateTime) |
|
437 | + { |
|
438 | + return $this->_prepare_for_display($DateTime); |
|
439 | + } |
|
440 | + |
|
441 | + |
|
442 | + /** |
|
443 | + * This differs from prepare_for_get in that it considers whether the internal $_timezone differs |
|
444 | + * from the set wp timezone. If so, then it returns the datetime string formatted via |
|
445 | + * _pretty_date_format, and _pretty_time_format. However, it also appends a timezone |
|
446 | + * abbreviation to the date_string. |
|
447 | + * |
|
448 | + * @param mixed $DateTime |
|
449 | + * @param null $schema |
|
450 | + * @return string |
|
451 | + * @throws \EE_Error |
|
452 | + */ |
|
453 | + public function prepare_for_pretty_echoing($DateTime, $schema = null) |
|
454 | + { |
|
455 | + return $this->_prepare_for_display($DateTime, $schema ? $schema : true); |
|
456 | + } |
|
457 | + |
|
458 | + |
|
459 | + /** |
|
460 | + * This prepares the EE_DateTime value to be saved to the db as mysql timestamp (UTC +0 |
|
461 | + * timezone). |
|
462 | + * |
|
463 | + * @param DateTime $DateTime |
|
464 | + * @param bool|string $schema |
|
465 | + * @return string |
|
466 | + * @throws \EE_Error |
|
467 | + */ |
|
468 | + protected function _prepare_for_display($DateTime, $schema = false) |
|
469 | + { |
|
470 | + if (! $DateTime instanceof DateTime) { |
|
471 | + if ($this->_nullable) { |
|
472 | + return ''; |
|
473 | + } else { |
|
474 | + if (WP_DEBUG) { |
|
475 | + throw new EE_Error( |
|
476 | + sprintf( |
|
477 | + __( |
|
478 | + 'EE_Datetime_Field::_prepare_for_display requires a DateTime class to be the value for the $DateTime argument because the %s field is not nullable.', |
|
479 | + 'event_espresso' |
|
480 | + ), |
|
481 | + $this->_nicename |
|
482 | + ) |
|
483 | + ); |
|
484 | + } else { |
|
485 | + $DateTime = new DbSafeDateTime(\EE_Datetime_Field::now); |
|
486 | + EE_Error::add_error( |
|
487 | + sprintf( |
|
488 | + __( |
|
489 | + 'EE_Datetime_Field::_prepare_for_display requires a DateTime class to be the value for the $DateTime argument because the %s field is not nullable. When WP_DEBUG is false, the value is set to "now" instead of throwing an exception.', |
|
490 | + 'event_espresso' |
|
491 | + ), |
|
492 | + $this->_nicename |
|
493 | + ) |
|
494 | + ); |
|
495 | + } |
|
496 | + } |
|
497 | + } |
|
498 | + $format_string = $this->_get_date_time_output($schema); |
|
499 | + EEH_DTT_Helper::setTimezone($DateTime, $this->_DateTimeZone); |
|
500 | + if ($schema) { |
|
501 | + if ($this->_display_timezone()) { |
|
502 | + // must be explicit because schema could equal true. |
|
503 | + if ($schema === 'no_html') { |
|
504 | + $timezone_string = ' (' . $DateTime->format('T') . ')'; |
|
505 | + } else { |
|
506 | + $timezone_string = ' <span class="ee_dtt_timezone_string">(' . $DateTime->format('T') . ')</span>'; |
|
507 | + } |
|
508 | + } else { |
|
509 | + $timezone_string = ''; |
|
510 | + } |
|
511 | + |
|
512 | + return $DateTime->format($format_string) . $timezone_string; |
|
513 | + } |
|
514 | + return $DateTime->format($format_string); |
|
515 | + } |
|
516 | + |
|
517 | + |
|
518 | + /** |
|
519 | + * This prepares the EE_DateTime value to be saved to the db as mysql timestamp (UTC +0 |
|
520 | + * timezone). |
|
521 | + * |
|
522 | + * @param mixed $datetime_value u |
|
523 | + * @return string mysql timestamp in UTC |
|
524 | + * @throws \EE_Error |
|
525 | + */ |
|
526 | + public function prepare_for_use_in_db($datetime_value) |
|
527 | + { |
|
528 | + // we allow an empty value or DateTime object, but nothing else. |
|
529 | + if (! empty($datetime_value) && ! $datetime_value instanceof DateTime) { |
|
530 | + throw new EE_Error( |
|
531 | + sprintf( |
|
532 | + __( |
|
533 | + 'The incoming value being prepared for setting in the database must either be empty or a php |
|
534 | 534 | DateTime object, instead of: %1$s %2$s', |
535 | - 'event_espresso' |
|
536 | - ), |
|
537 | - '<br />', |
|
538 | - print_r($datetime_value, true) |
|
539 | - ) |
|
540 | - ); |
|
541 | - } |
|
542 | - |
|
543 | - if ($datetime_value instanceof DateTime) { |
|
544 | - if (! $datetime_value instanceof DbSafeDateTime) { |
|
545 | - $datetime_value = DbSafeDateTime::createFromDateTime($datetime_value); |
|
546 | - } |
|
547 | - EEH_DTT_Helper::setTimezone($datetime_value, $this->get_UTC_DateTimeZone()); |
|
548 | - return $datetime_value->format( |
|
549 | - EE_Datetime_Field::mysql_timestamp_format |
|
550 | - ); |
|
551 | - } |
|
552 | - |
|
553 | - // if $datetime_value is empty, and ! $this->_nullable, use current_time() but set the GMT flag to true |
|
554 | - return ! $this->_nullable && empty($datetime_value) ? current_time('mysql', true) : null; |
|
555 | - } |
|
556 | - |
|
557 | - |
|
558 | - /** |
|
559 | - * This prepares the datetime for internal usage as a PHP DateTime object OR null (if nullable is |
|
560 | - * allowed) |
|
561 | - * |
|
562 | - * @param string $datetime_string mysql timestamp in UTC |
|
563 | - * @return mixed null | DateTime |
|
564 | - * @throws \EE_Error |
|
565 | - */ |
|
566 | - public function prepare_for_set_from_db($datetime_string) |
|
567 | - { |
|
568 | - // if $datetime_value is empty, and ! $this->_nullable, just use time() |
|
569 | - if (empty($datetime_string) && $this->_nullable) { |
|
570 | - return null; |
|
571 | - } |
|
572 | - // datetime strings from the db should ALWAYS be in UTC+0, so use UTC_DateTimeZone when creating |
|
573 | - if (empty($datetime_string)) { |
|
574 | - $DateTime = new DbSafeDateTime(\EE_Datetime_Field::now, $this->get_UTC_DateTimeZone()); |
|
575 | - } else { |
|
576 | - $DateTime = DbSafeDateTime::createFromFormat( |
|
577 | - EE_Datetime_Field::mysql_timestamp_format, |
|
578 | - $datetime_string, |
|
579 | - $this->get_UTC_DateTimeZone() |
|
580 | - ); |
|
581 | - } |
|
582 | - |
|
583 | - if (! $DateTime instanceof DbSafeDateTime) { |
|
584 | - // if still no datetime object, then let's just use now |
|
585 | - $DateTime = new DbSafeDateTime(\EE_Datetime_Field::now, $this->get_UTC_DateTimeZone()); |
|
586 | - } |
|
587 | - // THEN apply the field's set DateTimeZone |
|
588 | - EEH_DTT_Helper::setTimezone($DateTime, $this->_DateTimeZone); |
|
589 | - return $DateTime; |
|
590 | - } |
|
591 | - |
|
592 | - |
|
593 | - /** |
|
594 | - * All this method does is determine if we're going to display the timezone string or not on any output. |
|
595 | - * To determine this we check if the set timezone offset is different than the blog's set timezone offset. |
|
596 | - * If so, then true. |
|
597 | - * |
|
598 | - * @return bool true for yes false for no |
|
599 | - * @throws \EE_Error |
|
600 | - */ |
|
601 | - protected function _display_timezone() |
|
602 | - { |
|
603 | - |
|
604 | - // first let's do a comparison of timezone strings. |
|
605 | - // If they match then we can get out without any further calculations |
|
606 | - $blog_string = get_option('timezone_string'); |
|
607 | - if ($blog_string === $this->_timezone_string) { |
|
608 | - return false; |
|
609 | - } |
|
610 | - // now we need to calc the offset for the timezone string so we can compare with the blog offset. |
|
611 | - $this_offset = $this->get_timezone_offset($this->_DateTimeZone); |
|
612 | - $blog_offset = $this->get_timezone_offset($this->get_blog_DateTimeZone()); |
|
613 | - // now compare |
|
614 | - return $blog_offset !== $this_offset; |
|
615 | - } |
|
616 | - |
|
617 | - |
|
618 | - /** |
|
619 | - * This method returns a php DateTime object for setting on the EE_Base_Class model. |
|
620 | - * EE passes around DateTime objects because they are MUCH easier to manipulate and deal |
|
621 | - * with. |
|
622 | - * |
|
623 | - * @param int|string|DateTime $date_string This should be the incoming date string. It's assumed to be |
|
624 | - * in the format that is set on the date_field (or DateTime |
|
625 | - * object)! |
|
626 | - * @return DateTime |
|
627 | - */ |
|
628 | - protected function _get_date_object($date_string) |
|
629 | - { |
|
630 | - // first if this is an empty date_string and nullable is allowed, just return null. |
|
631 | - if ($this->_nullable && empty($date_string)) { |
|
632 | - return null; |
|
633 | - } |
|
634 | - |
|
635 | - // if incoming date |
|
636 | - if ($date_string instanceof DateTime) { |
|
637 | - EEH_DTT_Helper::setTimezone($date_string, $this->_DateTimeZone); |
|
638 | - return $date_string; |
|
639 | - } |
|
640 | - // if empty date_string and made it here. |
|
641 | - // Return a datetime object for now in the given timezone. |
|
642 | - if (empty($date_string)) { |
|
643 | - return new DbSafeDateTime(\EE_Datetime_Field::now, $this->_DateTimeZone); |
|
644 | - } |
|
645 | - // if $date_string is matches something that looks like a Unix timestamp let's just use it. |
|
646 | - if (preg_match(EE_Datetime_Field::unix_timestamp_regex, $date_string)) { |
|
647 | - try { |
|
648 | - // This is operating under the assumption that the incoming Unix timestamp |
|
649 | - // is an ACTUAL Unix timestamp and not the calculated one output by current_time('timestamp'); |
|
650 | - $DateTime = new DbSafeDateTime(\EE_Datetime_Field::now, $this->_DateTimeZone); |
|
651 | - $DateTime->setTimestamp($date_string); |
|
652 | - |
|
653 | - return $DateTime; |
|
654 | - } catch (Exception $e) { |
|
655 | - // should be rare, but if things got fooled then let's just continue |
|
656 | - } |
|
657 | - } |
|
658 | - // not a unix timestamp. So we will use the set format on this object and set timezone to |
|
659 | - // create the DateTime object. |
|
660 | - $format = $this->_date_format . ' ' . $this->_time_format; |
|
661 | - try { |
|
662 | - $DateTime = DbSafeDateTime::createFromFormat($format, $date_string, $this->_DateTimeZone); |
|
663 | - if (! $DateTime instanceof DbSafeDateTime) { |
|
664 | - throw new EE_Error( |
|
665 | - sprintf( |
|
666 | - __('"%1$s" does not represent a valid Date Time in the format "%2$s".', 'event_espresso'), |
|
667 | - $date_string, |
|
668 | - $format |
|
669 | - ) |
|
670 | - ); |
|
671 | - } |
|
672 | - } catch (Exception $e) { |
|
673 | - // if we made it here then likely then something went really wrong. |
|
674 | - // Instead of throwing an exception, let's just return a DateTime object for now, in the set timezone. |
|
675 | - $DateTime = new DbSafeDateTime(\EE_Datetime_Field::now, $this->_DateTimeZone); |
|
676 | - } |
|
677 | - |
|
678 | - return $DateTime; |
|
679 | - } |
|
680 | - |
|
681 | - |
|
682 | - |
|
683 | - /** |
|
684 | - * get_timezone_transitions |
|
685 | - * |
|
686 | - * @param \DateTimeZone $DateTimeZone |
|
687 | - * @param int $time |
|
688 | - * @param bool $first_only |
|
689 | - * @return mixed |
|
690 | - */ |
|
691 | - public function get_timezone_transitions(DateTimeZone $DateTimeZone, $time = null, $first_only = true) |
|
692 | - { |
|
693 | - return EEH_DTT_Helper::get_timezone_transitions($DateTimeZone, $time, $first_only); |
|
694 | - } |
|
695 | - |
|
696 | - |
|
697 | - |
|
698 | - /** |
|
699 | - * get_timezone_offset |
|
700 | - * |
|
701 | - * @param \DateTimeZone $DateTimeZone |
|
702 | - * @param int $time |
|
703 | - * @return mixed |
|
704 | - * @throws \DomainException |
|
705 | - */ |
|
706 | - public function get_timezone_offset(DateTimeZone $DateTimeZone, $time = null) |
|
707 | - { |
|
708 | - return EEH_DTT_Helper::get_timezone_offset($DateTimeZone, $time); |
|
709 | - } |
|
710 | - |
|
711 | - |
|
712 | - /** |
|
713 | - * This will take an incoming timezone string and return the abbreviation for that timezone |
|
714 | - * |
|
715 | - * @param string $timezone_string |
|
716 | - * @return string abbreviation |
|
717 | - * @throws \EE_Error |
|
718 | - */ |
|
719 | - public function get_timezone_abbrev($timezone_string) |
|
720 | - { |
|
721 | - $timezone_string = EEH_DTT_Helper::get_valid_timezone_string($timezone_string); |
|
722 | - $dateTime = new DateTime(\EE_Datetime_Field::now, new DateTimeZone($timezone_string)); |
|
723 | - |
|
724 | - return $dateTime->format('T'); |
|
725 | - } |
|
726 | - |
|
727 | - /** |
|
728 | - * Overrides the parent to allow for having a dynamic "now" value |
|
729 | - * |
|
730 | - * @return mixed |
|
731 | - */ |
|
732 | - public function get_default_value() |
|
733 | - { |
|
734 | - if ($this->_default_value === EE_Datetime_Field::now) { |
|
735 | - return time(); |
|
736 | - } else { |
|
737 | - return parent::get_default_value(); |
|
738 | - } |
|
739 | - } |
|
740 | - |
|
741 | - /** |
|
742 | - * Gets the default datetime object from the field's default time |
|
743 | - * @since 4.9.66.p |
|
744 | - * @return DbSafeDateTime|null |
|
745 | - * @throws InvalidArgumentException |
|
746 | - * @throws InvalidDataTypeException |
|
747 | - * @throws InvalidInterfaceException |
|
748 | - */ |
|
749 | - public function getDefaultDateTimeObj() |
|
750 | - { |
|
751 | - $default_raw = $this->get_default_value(); |
|
752 | - if ($default_raw instanceof DateTime) { |
|
753 | - return $default_raw; |
|
754 | - } elseif (is_null($default_raw)) { |
|
755 | - return $default_raw; |
|
756 | - } else { |
|
757 | - return new DbSafeDateTime( |
|
758 | - $this->get_default_value(), |
|
759 | - EEH_DTT_Helper::get_valid_timezone_string($this->get_timezone()) |
|
760 | - ); |
|
761 | - } |
|
762 | - } |
|
763 | - |
|
764 | - public function getSchemaDescription() |
|
765 | - { |
|
766 | - return sprintf( |
|
767 | - esc_html__('%s - the value for this field is in the timezone of the site.', 'event_espresso'), |
|
768 | - $this->get_nicename() |
|
769 | - ); |
|
770 | - } |
|
535 | + 'event_espresso' |
|
536 | + ), |
|
537 | + '<br />', |
|
538 | + print_r($datetime_value, true) |
|
539 | + ) |
|
540 | + ); |
|
541 | + } |
|
542 | + |
|
543 | + if ($datetime_value instanceof DateTime) { |
|
544 | + if (! $datetime_value instanceof DbSafeDateTime) { |
|
545 | + $datetime_value = DbSafeDateTime::createFromDateTime($datetime_value); |
|
546 | + } |
|
547 | + EEH_DTT_Helper::setTimezone($datetime_value, $this->get_UTC_DateTimeZone()); |
|
548 | + return $datetime_value->format( |
|
549 | + EE_Datetime_Field::mysql_timestamp_format |
|
550 | + ); |
|
551 | + } |
|
552 | + |
|
553 | + // if $datetime_value is empty, and ! $this->_nullable, use current_time() but set the GMT flag to true |
|
554 | + return ! $this->_nullable && empty($datetime_value) ? current_time('mysql', true) : null; |
|
555 | + } |
|
556 | + |
|
557 | + |
|
558 | + /** |
|
559 | + * This prepares the datetime for internal usage as a PHP DateTime object OR null (if nullable is |
|
560 | + * allowed) |
|
561 | + * |
|
562 | + * @param string $datetime_string mysql timestamp in UTC |
|
563 | + * @return mixed null | DateTime |
|
564 | + * @throws \EE_Error |
|
565 | + */ |
|
566 | + public function prepare_for_set_from_db($datetime_string) |
|
567 | + { |
|
568 | + // if $datetime_value is empty, and ! $this->_nullable, just use time() |
|
569 | + if (empty($datetime_string) && $this->_nullable) { |
|
570 | + return null; |
|
571 | + } |
|
572 | + // datetime strings from the db should ALWAYS be in UTC+0, so use UTC_DateTimeZone when creating |
|
573 | + if (empty($datetime_string)) { |
|
574 | + $DateTime = new DbSafeDateTime(\EE_Datetime_Field::now, $this->get_UTC_DateTimeZone()); |
|
575 | + } else { |
|
576 | + $DateTime = DbSafeDateTime::createFromFormat( |
|
577 | + EE_Datetime_Field::mysql_timestamp_format, |
|
578 | + $datetime_string, |
|
579 | + $this->get_UTC_DateTimeZone() |
|
580 | + ); |
|
581 | + } |
|
582 | + |
|
583 | + if (! $DateTime instanceof DbSafeDateTime) { |
|
584 | + // if still no datetime object, then let's just use now |
|
585 | + $DateTime = new DbSafeDateTime(\EE_Datetime_Field::now, $this->get_UTC_DateTimeZone()); |
|
586 | + } |
|
587 | + // THEN apply the field's set DateTimeZone |
|
588 | + EEH_DTT_Helper::setTimezone($DateTime, $this->_DateTimeZone); |
|
589 | + return $DateTime; |
|
590 | + } |
|
591 | + |
|
592 | + |
|
593 | + /** |
|
594 | + * All this method does is determine if we're going to display the timezone string or not on any output. |
|
595 | + * To determine this we check if the set timezone offset is different than the blog's set timezone offset. |
|
596 | + * If so, then true. |
|
597 | + * |
|
598 | + * @return bool true for yes false for no |
|
599 | + * @throws \EE_Error |
|
600 | + */ |
|
601 | + protected function _display_timezone() |
|
602 | + { |
|
603 | + |
|
604 | + // first let's do a comparison of timezone strings. |
|
605 | + // If they match then we can get out without any further calculations |
|
606 | + $blog_string = get_option('timezone_string'); |
|
607 | + if ($blog_string === $this->_timezone_string) { |
|
608 | + return false; |
|
609 | + } |
|
610 | + // now we need to calc the offset for the timezone string so we can compare with the blog offset. |
|
611 | + $this_offset = $this->get_timezone_offset($this->_DateTimeZone); |
|
612 | + $blog_offset = $this->get_timezone_offset($this->get_blog_DateTimeZone()); |
|
613 | + // now compare |
|
614 | + return $blog_offset !== $this_offset; |
|
615 | + } |
|
616 | + |
|
617 | + |
|
618 | + /** |
|
619 | + * This method returns a php DateTime object for setting on the EE_Base_Class model. |
|
620 | + * EE passes around DateTime objects because they are MUCH easier to manipulate and deal |
|
621 | + * with. |
|
622 | + * |
|
623 | + * @param int|string|DateTime $date_string This should be the incoming date string. It's assumed to be |
|
624 | + * in the format that is set on the date_field (or DateTime |
|
625 | + * object)! |
|
626 | + * @return DateTime |
|
627 | + */ |
|
628 | + protected function _get_date_object($date_string) |
|
629 | + { |
|
630 | + // first if this is an empty date_string and nullable is allowed, just return null. |
|
631 | + if ($this->_nullable && empty($date_string)) { |
|
632 | + return null; |
|
633 | + } |
|
634 | + |
|
635 | + // if incoming date |
|
636 | + if ($date_string instanceof DateTime) { |
|
637 | + EEH_DTT_Helper::setTimezone($date_string, $this->_DateTimeZone); |
|
638 | + return $date_string; |
|
639 | + } |
|
640 | + // if empty date_string and made it here. |
|
641 | + // Return a datetime object for now in the given timezone. |
|
642 | + if (empty($date_string)) { |
|
643 | + return new DbSafeDateTime(\EE_Datetime_Field::now, $this->_DateTimeZone); |
|
644 | + } |
|
645 | + // if $date_string is matches something that looks like a Unix timestamp let's just use it. |
|
646 | + if (preg_match(EE_Datetime_Field::unix_timestamp_regex, $date_string)) { |
|
647 | + try { |
|
648 | + // This is operating under the assumption that the incoming Unix timestamp |
|
649 | + // is an ACTUAL Unix timestamp and not the calculated one output by current_time('timestamp'); |
|
650 | + $DateTime = new DbSafeDateTime(\EE_Datetime_Field::now, $this->_DateTimeZone); |
|
651 | + $DateTime->setTimestamp($date_string); |
|
652 | + |
|
653 | + return $DateTime; |
|
654 | + } catch (Exception $e) { |
|
655 | + // should be rare, but if things got fooled then let's just continue |
|
656 | + } |
|
657 | + } |
|
658 | + // not a unix timestamp. So we will use the set format on this object and set timezone to |
|
659 | + // create the DateTime object. |
|
660 | + $format = $this->_date_format . ' ' . $this->_time_format; |
|
661 | + try { |
|
662 | + $DateTime = DbSafeDateTime::createFromFormat($format, $date_string, $this->_DateTimeZone); |
|
663 | + if (! $DateTime instanceof DbSafeDateTime) { |
|
664 | + throw new EE_Error( |
|
665 | + sprintf( |
|
666 | + __('"%1$s" does not represent a valid Date Time in the format "%2$s".', 'event_espresso'), |
|
667 | + $date_string, |
|
668 | + $format |
|
669 | + ) |
|
670 | + ); |
|
671 | + } |
|
672 | + } catch (Exception $e) { |
|
673 | + // if we made it here then likely then something went really wrong. |
|
674 | + // Instead of throwing an exception, let's just return a DateTime object for now, in the set timezone. |
|
675 | + $DateTime = new DbSafeDateTime(\EE_Datetime_Field::now, $this->_DateTimeZone); |
|
676 | + } |
|
677 | + |
|
678 | + return $DateTime; |
|
679 | + } |
|
680 | + |
|
681 | + |
|
682 | + |
|
683 | + /** |
|
684 | + * get_timezone_transitions |
|
685 | + * |
|
686 | + * @param \DateTimeZone $DateTimeZone |
|
687 | + * @param int $time |
|
688 | + * @param bool $first_only |
|
689 | + * @return mixed |
|
690 | + */ |
|
691 | + public function get_timezone_transitions(DateTimeZone $DateTimeZone, $time = null, $first_only = true) |
|
692 | + { |
|
693 | + return EEH_DTT_Helper::get_timezone_transitions($DateTimeZone, $time, $first_only); |
|
694 | + } |
|
695 | + |
|
696 | + |
|
697 | + |
|
698 | + /** |
|
699 | + * get_timezone_offset |
|
700 | + * |
|
701 | + * @param \DateTimeZone $DateTimeZone |
|
702 | + * @param int $time |
|
703 | + * @return mixed |
|
704 | + * @throws \DomainException |
|
705 | + */ |
|
706 | + public function get_timezone_offset(DateTimeZone $DateTimeZone, $time = null) |
|
707 | + { |
|
708 | + return EEH_DTT_Helper::get_timezone_offset($DateTimeZone, $time); |
|
709 | + } |
|
710 | + |
|
711 | + |
|
712 | + /** |
|
713 | + * This will take an incoming timezone string and return the abbreviation for that timezone |
|
714 | + * |
|
715 | + * @param string $timezone_string |
|
716 | + * @return string abbreviation |
|
717 | + * @throws \EE_Error |
|
718 | + */ |
|
719 | + public function get_timezone_abbrev($timezone_string) |
|
720 | + { |
|
721 | + $timezone_string = EEH_DTT_Helper::get_valid_timezone_string($timezone_string); |
|
722 | + $dateTime = new DateTime(\EE_Datetime_Field::now, new DateTimeZone($timezone_string)); |
|
723 | + |
|
724 | + return $dateTime->format('T'); |
|
725 | + } |
|
726 | + |
|
727 | + /** |
|
728 | + * Overrides the parent to allow for having a dynamic "now" value |
|
729 | + * |
|
730 | + * @return mixed |
|
731 | + */ |
|
732 | + public function get_default_value() |
|
733 | + { |
|
734 | + if ($this->_default_value === EE_Datetime_Field::now) { |
|
735 | + return time(); |
|
736 | + } else { |
|
737 | + return parent::get_default_value(); |
|
738 | + } |
|
739 | + } |
|
740 | + |
|
741 | + /** |
|
742 | + * Gets the default datetime object from the field's default time |
|
743 | + * @since 4.9.66.p |
|
744 | + * @return DbSafeDateTime|null |
|
745 | + * @throws InvalidArgumentException |
|
746 | + * @throws InvalidDataTypeException |
|
747 | + * @throws InvalidInterfaceException |
|
748 | + */ |
|
749 | + public function getDefaultDateTimeObj() |
|
750 | + { |
|
751 | + $default_raw = $this->get_default_value(); |
|
752 | + if ($default_raw instanceof DateTime) { |
|
753 | + return $default_raw; |
|
754 | + } elseif (is_null($default_raw)) { |
|
755 | + return $default_raw; |
|
756 | + } else { |
|
757 | + return new DbSafeDateTime( |
|
758 | + $this->get_default_value(), |
|
759 | + EEH_DTT_Helper::get_valid_timezone_string($this->get_timezone()) |
|
760 | + ); |
|
761 | + } |
|
762 | + } |
|
763 | + |
|
764 | + public function getSchemaDescription() |
|
765 | + { |
|
766 | + return sprintf( |
|
767 | + esc_html__('%s - the value for this field is in the timezone of the site.', 'event_espresso'), |
|
768 | + $this->get_nicename() |
|
769 | + ); |
|
770 | + } |
|
771 | 771 | } |
@@ -212,8 +212,8 @@ discard block |
||
212 | 212 | |
213 | 213 | default: |
214 | 214 | return $pretty |
215 | - ? $this->_pretty_date_format . ' ' . $this->_pretty_time_format |
|
216 | - : $this->_date_format . ' ' . $this->_time_format; |
|
215 | + ? $this->_pretty_date_format.' '.$this->_pretty_time_format |
|
216 | + : $this->_date_format.' '.$this->_time_format; |
|
217 | 217 | } |
218 | 218 | } |
219 | 219 | |
@@ -467,7 +467,7 @@ discard block |
||
467 | 467 | */ |
468 | 468 | protected function _prepare_for_display($DateTime, $schema = false) |
469 | 469 | { |
470 | - if (! $DateTime instanceof DateTime) { |
|
470 | + if ( ! $DateTime instanceof DateTime) { |
|
471 | 471 | if ($this->_nullable) { |
472 | 472 | return ''; |
473 | 473 | } else { |
@@ -501,15 +501,15 @@ discard block |
||
501 | 501 | if ($this->_display_timezone()) { |
502 | 502 | // must be explicit because schema could equal true. |
503 | 503 | if ($schema === 'no_html') { |
504 | - $timezone_string = ' (' . $DateTime->format('T') . ')'; |
|
504 | + $timezone_string = ' ('.$DateTime->format('T').')'; |
|
505 | 505 | } else { |
506 | - $timezone_string = ' <span class="ee_dtt_timezone_string">(' . $DateTime->format('T') . ')</span>'; |
|
506 | + $timezone_string = ' <span class="ee_dtt_timezone_string">('.$DateTime->format('T').')</span>'; |
|
507 | 507 | } |
508 | 508 | } else { |
509 | 509 | $timezone_string = ''; |
510 | 510 | } |
511 | 511 | |
512 | - return $DateTime->format($format_string) . $timezone_string; |
|
512 | + return $DateTime->format($format_string).$timezone_string; |
|
513 | 513 | } |
514 | 514 | return $DateTime->format($format_string); |
515 | 515 | } |
@@ -526,7 +526,7 @@ discard block |
||
526 | 526 | public function prepare_for_use_in_db($datetime_value) |
527 | 527 | { |
528 | 528 | // we allow an empty value or DateTime object, but nothing else. |
529 | - if (! empty($datetime_value) && ! $datetime_value instanceof DateTime) { |
|
529 | + if ( ! empty($datetime_value) && ! $datetime_value instanceof DateTime) { |
|
530 | 530 | throw new EE_Error( |
531 | 531 | sprintf( |
532 | 532 | __( |
@@ -541,7 +541,7 @@ discard block |
||
541 | 541 | } |
542 | 542 | |
543 | 543 | if ($datetime_value instanceof DateTime) { |
544 | - if (! $datetime_value instanceof DbSafeDateTime) { |
|
544 | + if ( ! $datetime_value instanceof DbSafeDateTime) { |
|
545 | 545 | $datetime_value = DbSafeDateTime::createFromDateTime($datetime_value); |
546 | 546 | } |
547 | 547 | EEH_DTT_Helper::setTimezone($datetime_value, $this->get_UTC_DateTimeZone()); |
@@ -580,7 +580,7 @@ discard block |
||
580 | 580 | ); |
581 | 581 | } |
582 | 582 | |
583 | - if (! $DateTime instanceof DbSafeDateTime) { |
|
583 | + if ( ! $DateTime instanceof DbSafeDateTime) { |
|
584 | 584 | // if still no datetime object, then let's just use now |
585 | 585 | $DateTime = new DbSafeDateTime(\EE_Datetime_Field::now, $this->get_UTC_DateTimeZone()); |
586 | 586 | } |
@@ -657,10 +657,10 @@ discard block |
||
657 | 657 | } |
658 | 658 | // not a unix timestamp. So we will use the set format on this object and set timezone to |
659 | 659 | // create the DateTime object. |
660 | - $format = $this->_date_format . ' ' . $this->_time_format; |
|
660 | + $format = $this->_date_format.' '.$this->_time_format; |
|
661 | 661 | try { |
662 | 662 | $DateTime = DbSafeDateTime::createFromFormat($format, $date_string, $this->_DateTimeZone); |
663 | - if (! $DateTime instanceof DbSafeDateTime) { |
|
663 | + if ( ! $DateTime instanceof DbSafeDateTime) { |
|
664 | 664 | throw new EE_Error( |
665 | 665 | sprintf( |
666 | 666 | __('"%1$s" does not represent a valid Date Time in the format "%2$s".', 'event_espresso'), |