@@ -16,16 +16,16 @@ |
||
16 | 16 | */ |
17 | 17 | class URLValidator |
18 | 18 | { |
19 | - /** |
|
20 | - * Returns whether or not the URL is valid |
|
21 | - * @since 4.9.68.p |
|
22 | - * @param $url |
|
23 | - * @return boolean |
|
24 | - */ |
|
25 | - public function isValid($url) |
|
26 | - { |
|
27 | - return esc_url_raw($url) === $url; |
|
28 | - } |
|
19 | + /** |
|
20 | + * Returns whether or not the URL is valid |
|
21 | + * @since 4.9.68.p |
|
22 | + * @param $url |
|
23 | + * @return boolean |
|
24 | + */ |
|
25 | + public function isValid($url) |
|
26 | + { |
|
27 | + return esc_url_raw($url) === $url; |
|
28 | + } |
|
29 | 29 | } |
30 | 30 | // End of file URLValidator.php |
31 | 31 | // Location: ${NAMESPACE}/URLValidator.php |
@@ -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 | } |
@@ -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 = esc_html__('Term', 'event_espresso'); |
|
30 | - $this->plural_item = esc_html__('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', esc_html__('Term ID', 'event_espresso')), |
|
37 | - 'name' => new EE_Plain_Text_Field('name', esc_html__('Term Name', 'event_espresso'), false, ''), |
|
38 | - 'slug' => new EE_Slug_Field('slug', esc_html__('Term Slug', 'event_espresso'), false), |
|
39 | - 'term_group' => new EE_Integer_Field('term_group', esc_html__("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 = esc_html__('Term', 'event_espresso'); |
|
30 | + $this->plural_item = esc_html__('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', esc_html__('Term ID', 'event_espresso')), |
|
37 | + 'name' => new EE_Plain_Text_Field('name', esc_html__('Term Name', 'event_espresso'), false, ''), |
|
38 | + 'slug' => new EE_Slug_Field('slug', esc_html__('Term Slug', 'event_espresso'), false), |
|
39 | + 'term_group' => new EE_Integer_Field('term_group', esc_html__("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' => esc_html__('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' => esc_html__('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 | } |
@@ -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 | } |
@@ -18,41 +18,41 @@ |
||
18 | 18 | class SetRequestTypeContextChecker extends Middleware |
19 | 19 | { |
20 | 20 | |
21 | - /** |
|
22 | - * converts a Request to a Response |
|
23 | - * |
|
24 | - * @param RequestInterface $request |
|
25 | - * @param ResponseInterface $response |
|
26 | - * @return ResponseInterface |
|
27 | - * @throws InvalidArgumentException |
|
28 | - */ |
|
29 | - public function handleRequest(RequestInterface $request, ResponseInterface $response) |
|
30 | - { |
|
31 | - $this->request = $request; |
|
32 | - $this->response = $response; |
|
33 | - /** @var RequestTypeContextDetector $request_type_context_detector */ |
|
34 | - $request_type_context_detector = $this->loader->getShared( |
|
35 | - 'EventEspresso\core\domain\services\contexts\RequestTypeContextDetector', |
|
36 | - array( |
|
37 | - $this->request, |
|
38 | - $this->loader->getShared( |
|
39 | - 'EventEspresso\core\domain\services\contexts\RequestTypeContextFactory', |
|
40 | - array($this->loader) |
|
41 | - ), |
|
42 | - array( |
|
43 | - 'DOING_AJAX' => defined('DOING_AJAX') && DOING_AJAX, |
|
44 | - 'WP_CLI' => defined('WP_CLI') && WP_CLI, |
|
45 | - 'is_admin' => is_admin(), |
|
46 | - ) |
|
47 | - ) |
|
48 | - ); |
|
49 | - $request_type_context = $request_type_context_detector->detectRequestTypeContext(); |
|
50 | - $request_type_context_checker = $this->loader->getShared( |
|
51 | - 'EventEspresso\core\domain\services\contexts\RequestTypeContextChecker', |
|
52 | - array($request_type_context) |
|
53 | - ); |
|
54 | - $this->request->setRequestTypeContextChecker($request_type_context_checker); |
|
55 | - $this->response = $this->processRequestStack($this->request, $this->response); |
|
56 | - return $this->response; |
|
57 | - } |
|
21 | + /** |
|
22 | + * converts a Request to a Response |
|
23 | + * |
|
24 | + * @param RequestInterface $request |
|
25 | + * @param ResponseInterface $response |
|
26 | + * @return ResponseInterface |
|
27 | + * @throws InvalidArgumentException |
|
28 | + */ |
|
29 | + public function handleRequest(RequestInterface $request, ResponseInterface $response) |
|
30 | + { |
|
31 | + $this->request = $request; |
|
32 | + $this->response = $response; |
|
33 | + /** @var RequestTypeContextDetector $request_type_context_detector */ |
|
34 | + $request_type_context_detector = $this->loader->getShared( |
|
35 | + 'EventEspresso\core\domain\services\contexts\RequestTypeContextDetector', |
|
36 | + array( |
|
37 | + $this->request, |
|
38 | + $this->loader->getShared( |
|
39 | + 'EventEspresso\core\domain\services\contexts\RequestTypeContextFactory', |
|
40 | + array($this->loader) |
|
41 | + ), |
|
42 | + array( |
|
43 | + 'DOING_AJAX' => defined('DOING_AJAX') && DOING_AJAX, |
|
44 | + 'WP_CLI' => defined('WP_CLI') && WP_CLI, |
|
45 | + 'is_admin' => is_admin(), |
|
46 | + ) |
|
47 | + ) |
|
48 | + ); |
|
49 | + $request_type_context = $request_type_context_detector->detectRequestTypeContext(); |
|
50 | + $request_type_context_checker = $this->loader->getShared( |
|
51 | + 'EventEspresso\core\domain\services\contexts\RequestTypeContextChecker', |
|
52 | + array($request_type_context) |
|
53 | + ); |
|
54 | + $this->request->setRequestTypeContextChecker($request_type_context_checker); |
|
55 | + $this->response = $this->processRequestStack($this->request, $this->response); |
|
56 | + return $this->response; |
|
57 | + } |
|
58 | 58 | } |
@@ -14,80 +14,80 @@ |
||
14 | 14 | */ |
15 | 15 | class EE_Country_Select_Input extends EE_Select_Input |
16 | 16 | { |
17 | - /** |
|
18 | - * $input_settings key used for detecting the "get" option |
|
19 | - */ |
|
20 | - const OPTION_GET_KEY = 'get'; |
|
17 | + /** |
|
18 | + * $input_settings key used for detecting the "get" option |
|
19 | + */ |
|
20 | + const OPTION_GET_KEY = 'get'; |
|
21 | 21 | |
22 | - /** |
|
23 | - * indicates that ALL countries should be retrieved from the db for the input |
|
24 | - */ |
|
25 | - const OPTION_GET_ALL = 'all'; |
|
22 | + /** |
|
23 | + * indicates that ALL countries should be retrieved from the db for the input |
|
24 | + */ |
|
25 | + const OPTION_GET_ALL = 'all'; |
|
26 | 26 | |
27 | - /** |
|
28 | - * indicates that only ACTIVE countries should be retrieved from the db for the input |
|
29 | - */ |
|
30 | - const OPTION_GET_ACTIVE = 'active'; |
|
27 | + /** |
|
28 | + * indicates that only ACTIVE countries should be retrieved from the db for the input |
|
29 | + */ |
|
30 | + const OPTION_GET_ACTIVE = 'active'; |
|
31 | 31 | |
32 | 32 | |
33 | - /** |
|
34 | - * @param array $country_options |
|
35 | - * @param array $input_settings |
|
36 | - * @throws EE_Error |
|
37 | - * @throws InvalidArgumentException |
|
38 | - * @throws InvalidDataTypeException |
|
39 | - * @throws InvalidInterfaceException |
|
40 | - * @throws ReflectionException |
|
41 | - */ |
|
42 | - public function __construct($country_options = null, $input_settings = array()) |
|
43 | - { |
|
44 | - $get = isset($input_settings[ self::OPTION_GET_KEY ]) |
|
45 | - ? $input_settings[ self::OPTION_GET_KEY ] |
|
46 | - : self::OPTION_GET_ACTIVE; |
|
47 | - $country_options = apply_filters( |
|
48 | - 'FHEE__EE_Country_Select_Input____construct__country_options', |
|
49 | - $this->get_country_answer_options($country_options, $get), |
|
50 | - $this, |
|
51 | - $get |
|
52 | - ); |
|
53 | - $input_settings['html_class'] = isset($input_settings['html_class']) |
|
54 | - ? $input_settings['html_class'] . ' ee-country-select-js' |
|
55 | - : 'ee-country-select-js'; |
|
56 | - parent::__construct($country_options, $input_settings); |
|
57 | - } |
|
33 | + /** |
|
34 | + * @param array $country_options |
|
35 | + * @param array $input_settings |
|
36 | + * @throws EE_Error |
|
37 | + * @throws InvalidArgumentException |
|
38 | + * @throws InvalidDataTypeException |
|
39 | + * @throws InvalidInterfaceException |
|
40 | + * @throws ReflectionException |
|
41 | + */ |
|
42 | + public function __construct($country_options = null, $input_settings = array()) |
|
43 | + { |
|
44 | + $get = isset($input_settings[ self::OPTION_GET_KEY ]) |
|
45 | + ? $input_settings[ self::OPTION_GET_KEY ] |
|
46 | + : self::OPTION_GET_ACTIVE; |
|
47 | + $country_options = apply_filters( |
|
48 | + 'FHEE__EE_Country_Select_Input____construct__country_options', |
|
49 | + $this->get_country_answer_options($country_options, $get), |
|
50 | + $this, |
|
51 | + $get |
|
52 | + ); |
|
53 | + $input_settings['html_class'] = isset($input_settings['html_class']) |
|
54 | + ? $input_settings['html_class'] . ' ee-country-select-js' |
|
55 | + : 'ee-country-select-js'; |
|
56 | + parent::__construct($country_options, $input_settings); |
|
57 | + } |
|
58 | 58 | |
59 | 59 | |
60 | - /** |
|
61 | - * get_country_answer_options |
|
62 | - * |
|
63 | - * @param array $country_options |
|
64 | - * @param string $get |
|
65 | - * @return array |
|
66 | - * @throws EE_Error |
|
67 | - * @throws InvalidArgumentException |
|
68 | - * @throws ReflectionException |
|
69 | - * @throws InvalidDataTypeException |
|
70 | - * @throws InvalidInterfaceException |
|
71 | - */ |
|
72 | - public function get_country_answer_options($country_options = null, $get = self::OPTION_GET_ACTIVE) |
|
73 | - { |
|
74 | - // if passed something that is NOT an array |
|
75 | - if (! is_array($country_options)) { |
|
76 | - // get possibly cached list of countries |
|
77 | - $countries = $get === self::OPTION_GET_ALL |
|
78 | - ? EEM_Country::instance()->get_all_countries() |
|
79 | - : EEM_Country::instance()->get_all_active_countries(); |
|
80 | - if (! empty($countries)) { |
|
81 | - $country_options[''] = ''; |
|
82 | - foreach ($countries as $country) { |
|
83 | - if ($country instanceof EE_Country) { |
|
84 | - $country_options[ $country->ID() ] = $country->name(); |
|
85 | - } |
|
86 | - } |
|
87 | - } else { |
|
88 | - $country_options = array(); |
|
89 | - } |
|
90 | - } |
|
91 | - return $country_options; |
|
92 | - } |
|
60 | + /** |
|
61 | + * get_country_answer_options |
|
62 | + * |
|
63 | + * @param array $country_options |
|
64 | + * @param string $get |
|
65 | + * @return array |
|
66 | + * @throws EE_Error |
|
67 | + * @throws InvalidArgumentException |
|
68 | + * @throws ReflectionException |
|
69 | + * @throws InvalidDataTypeException |
|
70 | + * @throws InvalidInterfaceException |
|
71 | + */ |
|
72 | + public function get_country_answer_options($country_options = null, $get = self::OPTION_GET_ACTIVE) |
|
73 | + { |
|
74 | + // if passed something that is NOT an array |
|
75 | + if (! is_array($country_options)) { |
|
76 | + // get possibly cached list of countries |
|
77 | + $countries = $get === self::OPTION_GET_ALL |
|
78 | + ? EEM_Country::instance()->get_all_countries() |
|
79 | + : EEM_Country::instance()->get_all_active_countries(); |
|
80 | + if (! empty($countries)) { |
|
81 | + $country_options[''] = ''; |
|
82 | + foreach ($countries as $country) { |
|
83 | + if ($country instanceof EE_Country) { |
|
84 | + $country_options[ $country->ID() ] = $country->name(); |
|
85 | + } |
|
86 | + } |
|
87 | + } else { |
|
88 | + $country_options = array(); |
|
89 | + } |
|
90 | + } |
|
91 | + return $country_options; |
|
92 | + } |
|
93 | 93 | } |
@@ -41,8 +41,8 @@ discard block |
||
41 | 41 | */ |
42 | 42 | public function __construct($country_options = null, $input_settings = array()) |
43 | 43 | { |
44 | - $get = isset($input_settings[ self::OPTION_GET_KEY ]) |
|
45 | - ? $input_settings[ self::OPTION_GET_KEY ] |
|
44 | + $get = isset($input_settings[self::OPTION_GET_KEY]) |
|
45 | + ? $input_settings[self::OPTION_GET_KEY] |
|
46 | 46 | : self::OPTION_GET_ACTIVE; |
47 | 47 | $country_options = apply_filters( |
48 | 48 | 'FHEE__EE_Country_Select_Input____construct__country_options', |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | $get |
52 | 52 | ); |
53 | 53 | $input_settings['html_class'] = isset($input_settings['html_class']) |
54 | - ? $input_settings['html_class'] . ' ee-country-select-js' |
|
54 | + ? $input_settings['html_class'].' ee-country-select-js' |
|
55 | 55 | : 'ee-country-select-js'; |
56 | 56 | parent::__construct($country_options, $input_settings); |
57 | 57 | } |
@@ -72,16 +72,16 @@ discard block |
||
72 | 72 | public function get_country_answer_options($country_options = null, $get = self::OPTION_GET_ACTIVE) |
73 | 73 | { |
74 | 74 | // if passed something that is NOT an array |
75 | - if (! is_array($country_options)) { |
|
75 | + if ( ! is_array($country_options)) { |
|
76 | 76 | // get possibly cached list of countries |
77 | 77 | $countries = $get === self::OPTION_GET_ALL |
78 | 78 | ? EEM_Country::instance()->get_all_countries() |
79 | 79 | : EEM_Country::instance()->get_all_active_countries(); |
80 | - if (! empty($countries)) { |
|
80 | + if ( ! empty($countries)) { |
|
81 | 81 | $country_options[''] = ''; |
82 | 82 | foreach ($countries as $country) { |
83 | 83 | if ($country instanceof EE_Country) { |
84 | - $country_options[ $country->ID() ] = $country->name(); |
|
84 | + $country_options[$country->ID()] = $country->name(); |
|
85 | 85 | } |
86 | 86 | } |
87 | 87 | } else { |
@@ -14,8 +14,8 @@ |
||
14 | 14 | */ |
15 | 15 | class AnyFrontendRequest extends RouteMatchSpecification |
16 | 16 | { |
17 | - public function isMatchingRoute() |
|
18 | - { |
|
19 | - return $this->request->isFrontend(); |
|
20 | - } |
|
17 | + public function isMatchingRoute() |
|
18 | + { |
|
19 | + return $this->request->isFrontend(); |
|
20 | + } |
|
21 | 21 | } |
@@ -32,19 +32,19 @@ discard block |
||
32 | 32 | */ |
33 | 33 | public function isValid($file, $func, $line) |
34 | 34 | { |
35 | - if (! defined('JSON_ERROR_RECURSION')) { |
|
35 | + if ( ! defined('JSON_ERROR_RECURSION')) { |
|
36 | 36 | define('JSON_ERROR_RECURSION', 6); |
37 | 37 | } |
38 | - if (! defined('JSON_ERROR_INF_OR_NAN')) { |
|
38 | + if ( ! defined('JSON_ERROR_INF_OR_NAN')) { |
|
39 | 39 | define('JSON_ERROR_INF_OR_NAN', 7); |
40 | 40 | } |
41 | - if (! defined('JSON_ERROR_UNSUPPORTED_TYPE')) { |
|
41 | + if ( ! defined('JSON_ERROR_UNSUPPORTED_TYPE')) { |
|
42 | 42 | define('JSON_ERROR_UNSUPPORTED_TYPE', 8); |
43 | 43 | } |
44 | - if (! defined('JSON_ERROR_INVALID_PROPERTY_NAME')) { |
|
44 | + if ( ! defined('JSON_ERROR_INVALID_PROPERTY_NAME')) { |
|
45 | 45 | define('JSON_ERROR_INVALID_PROPERTY_NAME', 9); |
46 | 46 | } |
47 | - if (! defined('JSON_ERROR_UTF16')) { |
|
47 | + if ( ! defined('JSON_ERROR_UTF16')) { |
|
48 | 48 | define('JSON_ERROR_UTF16', 10); |
49 | 49 | } |
50 | 50 | switch (json_last_error()) { |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | $error = ': Unknown error'; |
85 | 85 | break; |
86 | 86 | } |
87 | - EE_Error::add_error('JSON decoding failed' . $error, $file, $func, $line); |
|
87 | + EE_Error::add_error('JSON decoding failed'.$error, $file, $func, $line); |
|
88 | 88 | return false; |
89 | 89 | } |
90 | 90 | } |
@@ -18,76 +18,76 @@ |
||
18 | 18 | class JsonValidator |
19 | 19 | { |
20 | 20 | |
21 | - /** |
|
22 | - * Call this method IMMEDIATELY after json_decode() and |
|
23 | - * it will will return true if the decoded JSON was valid, |
|
24 | - * or return false after adding an error if not valid. |
|
25 | - * The actual JSON file does not need to be supplied, |
|
26 | - * but details re: code execution location are required. |
|
27 | - * ex: |
|
28 | - * JsonValidator::isValid(__FILE__, __METHOD__, __LINE__) |
|
29 | - * |
|
30 | - * @param string $file |
|
31 | - * @param string $func |
|
32 | - * @param string $line |
|
33 | - * @return boolean |
|
34 | - * @since 4.9.70.p |
|
35 | - */ |
|
36 | - public function isValid($file, $func, $line) |
|
37 | - { |
|
38 | - if (! defined('JSON_ERROR_RECURSION')) { |
|
39 | - define('JSON_ERROR_RECURSION', 6); |
|
40 | - } |
|
41 | - if (! defined('JSON_ERROR_INF_OR_NAN')) { |
|
42 | - define('JSON_ERROR_INF_OR_NAN', 7); |
|
43 | - } |
|
44 | - if (! defined('JSON_ERROR_UNSUPPORTED_TYPE')) { |
|
45 | - define('JSON_ERROR_UNSUPPORTED_TYPE', 8); |
|
46 | - } |
|
47 | - if (! defined('JSON_ERROR_INVALID_PROPERTY_NAME')) { |
|
48 | - define('JSON_ERROR_INVALID_PROPERTY_NAME', 9); |
|
49 | - } |
|
50 | - if (! defined('JSON_ERROR_UTF16')) { |
|
51 | - define('JSON_ERROR_UTF16', 10); |
|
52 | - } |
|
53 | - switch (json_last_error()) { |
|
54 | - case JSON_ERROR_NONE: |
|
55 | - return true; |
|
56 | - case JSON_ERROR_DEPTH: |
|
57 | - $error = ': Maximum stack depth exceeded'; |
|
58 | - break; |
|
59 | - case JSON_ERROR_STATE_MISMATCH: |
|
60 | - $error = ': Invalid or malformed JSON'; |
|
61 | - break; |
|
62 | - case JSON_ERROR_CTRL_CHAR: |
|
63 | - $error = ': Control character error, possible malformed JSON'; |
|
64 | - break; |
|
65 | - case JSON_ERROR_SYNTAX: |
|
66 | - $error = ': Syntax error, malformed JSON'; |
|
67 | - break; |
|
68 | - case JSON_ERROR_UTF8: |
|
69 | - $error = ': Malformed UTF-8 characters, possible malformed JSON'; |
|
70 | - break; |
|
71 | - case JSON_ERROR_RECURSION: |
|
72 | - $error = ': One or more recursive references in the value to be encoded'; |
|
73 | - break; |
|
74 | - case JSON_ERROR_INF_OR_NAN: |
|
75 | - $error = ': One or more NAN or INF values in the value to be encoded'; |
|
76 | - break; |
|
77 | - case JSON_ERROR_UNSUPPORTED_TYPE: |
|
78 | - $error = ': A value of a type that cannot be encoded was given'; |
|
79 | - break; |
|
80 | - case JSON_ERROR_INVALID_PROPERTY_NAME: |
|
81 | - $error = ': A property name that cannot be encoded was given'; |
|
82 | - break; |
|
83 | - case JSON_ERROR_UTF16: |
|
84 | - $error = ': Malformed UTF-16 characters, possibly incorrectly encoded'; |
|
85 | - break; |
|
86 | - default: |
|
87 | - $error = ': Unknown error'; |
|
88 | - break; |
|
89 | - } |
|
90 | - EE_Error::add_error('JSON decoding failed' . $error, $file, $func, $line); |
|
91 | - return false; |
|
92 | - } |
|
21 | + /** |
|
22 | + * Call this method IMMEDIATELY after json_decode() and |
|
23 | + * it will will return true if the decoded JSON was valid, |
|
24 | + * or return false after adding an error if not valid. |
|
25 | + * The actual JSON file does not need to be supplied, |
|
26 | + * but details re: code execution location are required. |
|
27 | + * ex: |
|
28 | + * JsonValidator::isValid(__FILE__, __METHOD__, __LINE__) |
|
29 | + * |
|
30 | + * @param string $file |
|
31 | + * @param string $func |
|
32 | + * @param string $line |
|
33 | + * @return boolean |
|
34 | + * @since 4.9.70.p |
|
35 | + */ |
|
36 | + public function isValid($file, $func, $line) |
|
37 | + { |
|
38 | + if (! defined('JSON_ERROR_RECURSION')) { |
|
39 | + define('JSON_ERROR_RECURSION', 6); |
|
40 | + } |
|
41 | + if (! defined('JSON_ERROR_INF_OR_NAN')) { |
|
42 | + define('JSON_ERROR_INF_OR_NAN', 7); |
|
43 | + } |
|
44 | + if (! defined('JSON_ERROR_UNSUPPORTED_TYPE')) { |
|
45 | + define('JSON_ERROR_UNSUPPORTED_TYPE', 8); |
|
46 | + } |
|
47 | + if (! defined('JSON_ERROR_INVALID_PROPERTY_NAME')) { |
|
48 | + define('JSON_ERROR_INVALID_PROPERTY_NAME', 9); |
|
49 | + } |
|
50 | + if (! defined('JSON_ERROR_UTF16')) { |
|
51 | + define('JSON_ERROR_UTF16', 10); |
|
52 | + } |
|
53 | + switch (json_last_error()) { |
|
54 | + case JSON_ERROR_NONE: |
|
55 | + return true; |
|
56 | + case JSON_ERROR_DEPTH: |
|
57 | + $error = ': Maximum stack depth exceeded'; |
|
58 | + break; |
|
59 | + case JSON_ERROR_STATE_MISMATCH: |
|
60 | + $error = ': Invalid or malformed JSON'; |
|
61 | + break; |
|
62 | + case JSON_ERROR_CTRL_CHAR: |
|
63 | + $error = ': Control character error, possible malformed JSON'; |
|
64 | + break; |
|
65 | + case JSON_ERROR_SYNTAX: |
|
66 | + $error = ': Syntax error, malformed JSON'; |
|
67 | + break; |
|
68 | + case JSON_ERROR_UTF8: |
|
69 | + $error = ': Malformed UTF-8 characters, possible malformed JSON'; |
|
70 | + break; |
|
71 | + case JSON_ERROR_RECURSION: |
|
72 | + $error = ': One or more recursive references in the value to be encoded'; |
|
73 | + break; |
|
74 | + case JSON_ERROR_INF_OR_NAN: |
|
75 | + $error = ': One or more NAN or INF values in the value to be encoded'; |
|
76 | + break; |
|
77 | + case JSON_ERROR_UNSUPPORTED_TYPE: |
|
78 | + $error = ': A value of a type that cannot be encoded was given'; |
|
79 | + break; |
|
80 | + case JSON_ERROR_INVALID_PROPERTY_NAME: |
|
81 | + $error = ': A property name that cannot be encoded was given'; |
|
82 | + break; |
|
83 | + case JSON_ERROR_UTF16: |
|
84 | + $error = ': Malformed UTF-16 characters, possibly incorrectly encoded'; |
|
85 | + break; |
|
86 | + default: |
|
87 | + $error = ': Unknown error'; |
|
88 | + break; |
|
89 | + } |
|
90 | + EE_Error::add_error('JSON decoding failed' . $error, $file, $func, $line); |
|
91 | + return false; |
|
92 | + } |
|
93 | 93 | } |
@@ -20,104 +20,104 @@ |
||
20 | 20 | class EventAttendeesBlockRenderer extends BlockRenderer |
21 | 21 | { |
22 | 22 | |
23 | - /** |
|
24 | - * @var EEM_Attendee |
|
25 | - */ |
|
26 | - private $attendee_model; |
|
23 | + /** |
|
24 | + * @var EEM_Attendee |
|
25 | + */ |
|
26 | + private $attendee_model; |
|
27 | 27 | |
28 | - public function __construct(DomainInterface $domain, EEM_Attendee $attendee_model) |
|
29 | - { |
|
30 | - $this->attendee_model = $attendee_model; |
|
31 | - parent::__construct($domain); |
|
32 | - } |
|
28 | + public function __construct(DomainInterface $domain, EEM_Attendee $attendee_model) |
|
29 | + { |
|
30 | + $this->attendee_model = $attendee_model; |
|
31 | + parent::__construct($domain); |
|
32 | + } |
|
33 | 33 | |
34 | 34 | |
35 | - /** |
|
36 | - * Renders the block. |
|
37 | - * |
|
38 | - * @param array $attributes Expect already validated and sanitized array of attributes for use in generating the |
|
39 | - * query and the template output. |
|
40 | - * @return string |
|
41 | - * @throws DomainException |
|
42 | - * @throws EE_Error |
|
43 | - */ |
|
44 | - public function render(array $attributes) |
|
45 | - { |
|
46 | - $template_args['attributes'] = $attributes; |
|
47 | - $template_args['attendees'] = $this->attendee_model->get_all($this->getQueryParams($attributes)); |
|
48 | - return EEH_Template::display_template( |
|
49 | - $this->templateRootPath() . 'event-attendees.php', |
|
50 | - $template_args, |
|
51 | - true |
|
52 | - ); |
|
53 | - } |
|
35 | + /** |
|
36 | + * Renders the block. |
|
37 | + * |
|
38 | + * @param array $attributes Expect already validated and sanitized array of attributes for use in generating the |
|
39 | + * query and the template output. |
|
40 | + * @return string |
|
41 | + * @throws DomainException |
|
42 | + * @throws EE_Error |
|
43 | + */ |
|
44 | + public function render(array $attributes) |
|
45 | + { |
|
46 | + $template_args['attributes'] = $attributes; |
|
47 | + $template_args['attendees'] = $this->attendee_model->get_all($this->getQueryParams($attributes)); |
|
48 | + return EEH_Template::display_template( |
|
49 | + $this->templateRootPath() . 'event-attendees.php', |
|
50 | + $template_args, |
|
51 | + true |
|
52 | + ); |
|
53 | + } |
|
54 | 54 | |
55 | 55 | |
56 | - /** |
|
57 | - * Get query parameters for model query. |
|
58 | - * |
|
59 | - * @param array $attributes |
|
60 | - * @return array |
|
61 | - */ |
|
62 | - private function getQueryParams(array $attributes) |
|
63 | - { |
|
64 | - return array( |
|
65 | - 0 => $this->getWhereQueryPart($attributes), |
|
66 | - 'default_where_conditions' => 'this_model_only', |
|
67 | - 'limit' => $attributes['limit'], |
|
68 | - 'group_by' => array('ATT_ID'), |
|
69 | - 'order_by' => $this->getOrderByQueryPart($attributes) |
|
70 | - ); |
|
71 | - } |
|
56 | + /** |
|
57 | + * Get query parameters for model query. |
|
58 | + * |
|
59 | + * @param array $attributes |
|
60 | + * @return array |
|
61 | + */ |
|
62 | + private function getQueryParams(array $attributes) |
|
63 | + { |
|
64 | + return array( |
|
65 | + 0 => $this->getWhereQueryPart($attributes), |
|
66 | + 'default_where_conditions' => 'this_model_only', |
|
67 | + 'limit' => $attributes['limit'], |
|
68 | + 'group_by' => array('ATT_ID'), |
|
69 | + 'order_by' => $this->getOrderByQueryPart($attributes) |
|
70 | + ); |
|
71 | + } |
|
72 | 72 | |
73 | 73 | |
74 | - /** |
|
75 | - * Get where query part for query parameters for model query. |
|
76 | - * |
|
77 | - * @param array $attributes |
|
78 | - * @return array |
|
79 | - */ |
|
80 | - private function getWhereQueryPart(array $attributes) |
|
81 | - { |
|
82 | - $where = array(); |
|
83 | - if ($attributes['ticketId'] > 0) { |
|
84 | - $where['Registration.TKT_ID'] = $attributes['ticketId']; |
|
85 | - } elseif ($attributes['datetimeId'] > 0) { |
|
86 | - $where['Registration.Ticket.Datetime.DTT_ID'] = $attributes['datetimeId']; |
|
87 | - } else { |
|
88 | - $where['Registration.EVT_ID'] = $attributes['eventId']; |
|
89 | - } |
|
90 | - $where['Registration.STS_ID'] = $attributes['status']; |
|
91 | - return $where; |
|
92 | - } |
|
74 | + /** |
|
75 | + * Get where query part for query parameters for model query. |
|
76 | + * |
|
77 | + * @param array $attributes |
|
78 | + * @return array |
|
79 | + */ |
|
80 | + private function getWhereQueryPart(array $attributes) |
|
81 | + { |
|
82 | + $where = array(); |
|
83 | + if ($attributes['ticketId'] > 0) { |
|
84 | + $where['Registration.TKT_ID'] = $attributes['ticketId']; |
|
85 | + } elseif ($attributes['datetimeId'] > 0) { |
|
86 | + $where['Registration.Ticket.Datetime.DTT_ID'] = $attributes['datetimeId']; |
|
87 | + } else { |
|
88 | + $where['Registration.EVT_ID'] = $attributes['eventId']; |
|
89 | + } |
|
90 | + $where['Registration.STS_ID'] = $attributes['status']; |
|
91 | + return $where; |
|
92 | + } |
|
93 | 93 | |
94 | 94 | |
95 | - /** |
|
96 | - * Get order by query part for query parameters for model query. |
|
97 | - * |
|
98 | - * @param array $attributes |
|
99 | - * @return array |
|
100 | - */ |
|
101 | - private function getOrderByQueryPart(array $attributes) |
|
102 | - { |
|
103 | - $order = $attributes['order']; |
|
104 | - switch ($attributes['orderBy']) { |
|
105 | - case 'id': |
|
106 | - $order_by = array('ATT_ID' => $order); |
|
107 | - break; |
|
108 | - case 'lastNameOnly': |
|
109 | - $order_by = array('ATT_lname' => $order); |
|
110 | - break; |
|
111 | - case 'firstNameOnly': |
|
112 | - $order_by = array('ATT_fname' => $order); |
|
113 | - break; |
|
114 | - case 'firstThenLastName': |
|
115 | - $order_by = array('ATT_fname' => $order, 'ATT_lname' => $order); |
|
116 | - break; |
|
117 | - default: |
|
118 | - $order_by = array('ATT_lname' => $order, 'ATT_fname' => $order); |
|
119 | - break; |
|
120 | - } |
|
121 | - return $order_by; |
|
122 | - } |
|
95 | + /** |
|
96 | + * Get order by query part for query parameters for model query. |
|
97 | + * |
|
98 | + * @param array $attributes |
|
99 | + * @return array |
|
100 | + */ |
|
101 | + private function getOrderByQueryPart(array $attributes) |
|
102 | + { |
|
103 | + $order = $attributes['order']; |
|
104 | + switch ($attributes['orderBy']) { |
|
105 | + case 'id': |
|
106 | + $order_by = array('ATT_ID' => $order); |
|
107 | + break; |
|
108 | + case 'lastNameOnly': |
|
109 | + $order_by = array('ATT_lname' => $order); |
|
110 | + break; |
|
111 | + case 'firstNameOnly': |
|
112 | + $order_by = array('ATT_fname' => $order); |
|
113 | + break; |
|
114 | + case 'firstThenLastName': |
|
115 | + $order_by = array('ATT_fname' => $order, 'ATT_lname' => $order); |
|
116 | + break; |
|
117 | + default: |
|
118 | + $order_by = array('ATT_lname' => $order, 'ATT_fname' => $order); |
|
119 | + break; |
|
120 | + } |
|
121 | + return $order_by; |
|
122 | + } |
|
123 | 123 | } |
@@ -46,7 +46,7 @@ |
||
46 | 46 | $template_args['attributes'] = $attributes; |
47 | 47 | $template_args['attendees'] = $this->attendee_model->get_all($this->getQueryParams($attributes)); |
48 | 48 | return EEH_Template::display_template( |
49 | - $this->templateRootPath() . 'event-attendees.php', |
|
49 | + $this->templateRootPath().'event-attendees.php', |
|
50 | 50 | $template_args, |
51 | 51 | true |
52 | 52 | ); |
@@ -14,11 +14,11 @@ |
||
14 | 14 | interface BlockRendererInterface |
15 | 15 | { |
16 | 16 | |
17 | - /** |
|
18 | - * This receives an array of attributes and returns rendered content for the block using those attributes. |
|
19 | - * |
|
20 | - * @param array $attributes |
|
21 | - * @return string Rendered Content |
|
22 | - */ |
|
23 | - public function render(array $attributes); |
|
17 | + /** |
|
18 | + * This receives an array of attributes and returns rendered content for the block using those attributes. |
|
19 | + * |
|
20 | + * @param array $attributes |
|
21 | + * @return string Rendered Content |
|
22 | + */ |
|
23 | + public function render(array $attributes); |
|
24 | 24 | } |