@@ -16,180 +16,180 @@ |
||
16 | 16 | class RegisterCustomTaxonomyTerms |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * @var array[] $custom_taxonomy_terms |
|
21 | - */ |
|
22 | - public $custom_taxonomy_terms = array(); |
|
23 | - |
|
24 | - |
|
25 | - /** |
|
26 | - * RegisterCustomTaxonomyTerms constructor. |
|
27 | - */ |
|
28 | - public function __construct() |
|
29 | - { |
|
30 | - // hook into save_post so that we can make sure that the default terms get saved on publish of registered cpts |
|
31 | - // IF they don't have a term for that taxonomy set. |
|
32 | - add_action('save_post', array($this, 'saveDefaultTerm'), 100, 2); |
|
33 | - do_action( |
|
34 | - 'AHEE__EventEspresso_core_domain_services_custom_post_types_RegisterCustomTaxonomyTerms__construct_end', |
|
35 | - $this |
|
36 | - ); |
|
37 | - } |
|
38 | - |
|
39 | - |
|
40 | - public function registerCustomTaxonomyTerms() |
|
41 | - { |
|
42 | - // setup default terms in any of our taxonomies (but only if we're in admin). |
|
43 | - // Why not added via register_activation_hook? |
|
44 | - // Because it's possible that in future iterations of EE we may add new defaults for specialized taxonomies |
|
45 | - // (think event_types) and register_activation_hook only reliably runs when a user manually activates the plugin. |
|
46 | - // Keep in mind that this will READ these terms if they are deleted by the user. Hence MUST use terms. |
|
47 | - // if ( is_admin() ) { |
|
48 | - // $this->set_must_use_event_types(); |
|
49 | - // } |
|
50 | - // set default terms |
|
51 | - $this->registerCustomTaxonomyTerm( |
|
52 | - 'espresso_event_type', |
|
53 | - 'single-event', |
|
54 | - array('espresso_events') |
|
55 | - ); |
|
56 | - } |
|
57 | - |
|
58 | - |
|
59 | - /** |
|
60 | - * Allows us to set what the default will be for terms when a cpt is PUBLISHED. |
|
61 | - * |
|
62 | - * @param string $taxonomy The taxonomy we're using for the default term |
|
63 | - * @param string $term_slug The slug of the term that will be the default. |
|
64 | - * @param array $cpt_slugs An array of custom post types we want the default assigned to |
|
65 | - */ |
|
66 | - public function registerCustomTaxonomyTerm($taxonomy, $term_slug, array $cpt_slugs = array()) |
|
67 | - { |
|
68 | - $this->custom_taxonomy_terms[][$term_slug] = new CustomTaxonomyTerm( |
|
69 | - $taxonomy, |
|
70 | - $term_slug, |
|
71 | - $cpt_slugs |
|
72 | - ); |
|
73 | - } |
|
74 | - |
|
75 | - |
|
76 | - /** |
|
77 | - * hooked into the wp 'save_post' action hook for setting our default terms found in the $_default_terms property |
|
78 | - * |
|
79 | - * @param int $post_id ID of CPT being saved |
|
80 | - * @param WP_Post $post Post object |
|
81 | - * @return void |
|
82 | - */ |
|
83 | - public function saveDefaultTerm($post_id, WP_Post $post) |
|
84 | - { |
|
85 | - if (empty($this->custom_taxonomy_terms)) { |
|
86 | - return; |
|
87 | - } |
|
88 | - // no default terms set so lets just exit. |
|
89 | - foreach ($this->custom_taxonomy_terms as $custom_taxonomy_terms) { |
|
90 | - foreach ($custom_taxonomy_terms as $custom_taxonomy_term) { |
|
91 | - if ($post->post_status === 'publish' |
|
92 | - && $custom_taxonomy_term instanceof CustomTaxonomyTerm |
|
93 | - && in_array($post->post_type, $custom_taxonomy_term->customPostTypeSlugs(), true) |
|
94 | - ) { |
|
95 | - // note some error proofing going on here to save unnecessary db queries |
|
96 | - $taxonomies = get_object_taxonomies($post->post_type); |
|
97 | - foreach ($taxonomies as $taxonomy) { |
|
98 | - $terms = wp_get_post_terms($post_id, $taxonomy); |
|
99 | - if (empty($terms) && $taxonomy === $custom_taxonomy_term->taxonomySlug()) { |
|
100 | - wp_set_object_terms( |
|
101 | - $post_id, |
|
102 | - array($custom_taxonomy_term->termSlug()), |
|
103 | - $taxonomy |
|
104 | - ); |
|
105 | - } |
|
106 | - } |
|
107 | - } |
|
108 | - } |
|
109 | - } |
|
110 | - } |
|
111 | - |
|
112 | - |
|
113 | - /** |
|
114 | - * @return void |
|
115 | - */ |
|
116 | - public function setMustUseEventTypes() |
|
117 | - { |
|
118 | - $term_details = array( |
|
119 | - // Attendee's register for the first date-time only |
|
120 | - 'single-event' => array( |
|
121 | - 'term' => esc_html__('Single Event', 'event_espresso'), |
|
122 | - 'desc' => esc_html__( |
|
123 | - 'A single event that spans one or more consecutive days.', |
|
124 | - 'event_espresso' |
|
125 | - ), |
|
126 | - ), |
|
127 | - // example: a party or two-day long workshop |
|
128 | - // Attendee's can register for any of the date-times |
|
129 | - 'multi-event' => array( |
|
130 | - 'term' => esc_html__('Multi Event', 'event_espresso'), |
|
131 | - 'desc' => esc_html__( |
|
132 | - 'Multiple, separate, but related events that occur on consecutive days.', |
|
133 | - 'event_espresso' |
|
134 | - ), |
|
135 | - ), |
|
136 | - // example: a three day music festival or week long conference |
|
137 | - // Attendee's register for the first date-time only |
|
138 | - 'event-series' => array( |
|
139 | - 'term' => esc_html__('Event Series', 'event_espresso'), |
|
140 | - 'desc' => esc_html__( |
|
141 | - ' Multiple events that occur over multiple non-consecutive days.', |
|
142 | - 'event_espresso' |
|
143 | - ), |
|
144 | - ), |
|
145 | - // example: an 8 week introduction to basket weaving course |
|
146 | - // Attendee's can register for any of the date-times. |
|
147 | - 'recurring-event' => array( |
|
148 | - 'term' => esc_html__('Recurring Event', 'event_espresso'), |
|
149 | - 'desc' => esc_html__( |
|
150 | - 'Multiple events that occur over multiple non-consecutive days.', |
|
151 | - 'event_espresso' |
|
152 | - ), |
|
153 | - ), |
|
154 | - // example: a yoga class |
|
155 | - 'ongoing' => array( |
|
156 | - 'term' => esc_html__('Ongoing Event', 'event_espresso'), |
|
157 | - 'desc' => esc_html__( |
|
158 | - 'An "event" that people can purchase tickets to gain access for anytime for this event regardless of date times on the event', |
|
159 | - 'event_espresso' |
|
160 | - ), |
|
161 | - ) |
|
162 | - // example: access to a museum |
|
163 | - // 'walk-in' => array( esc_html__('Walk In', 'event_espresso'), esc_html__('Single datetime and single entry recurring events. Attendees register for one or multiple datetimes individually.', 'event_espresso') ), |
|
164 | - // 'reservation' => array( esc_html__('Reservation', 'event_espresso'), esc_html__('Reservations are created by specifying available datetimes and quantities. Attendees choose from the available datetimes and specify the quantity available (if the maximum is greater than 1)') ), //@TODO to avoid confusion we'll implement this in a later iteration > EE4.1 |
|
165 | - // 'multiple-session' => array( esc_html__('Multiple Session', 'event_espresso'), esc_html__('Multiple event, multiple datetime, hierarchically organized, custom entry events. Attendees may be required to register for a parent event before being allowed to register for child events. Attendees can register for any combination of child events as long as the datetimes do not conflict. Parent and child events may have additional fees or registration questions.') ), //@TODO to avoid confusion we'll implement this in a later iteration > EE4.1 |
|
166 | - // 'appointment' => array( esc_html__('Appointments', 'event_espresso'), esc_html__('Time slotted events where datetimes are generally in hours or minutes. For example, attendees can register for a single 15 minute or 1 hour time slot and this type of availability frequently reoccurs.', 'event_espresso') ) |
|
167 | - ); |
|
168 | - $this->setMustUseTerms('espresso_event_type', $term_details); |
|
169 | - } |
|
170 | - |
|
171 | - |
|
172 | - /** |
|
173 | - * wrapper method for handling the setting up of initial terms in the db (if they don't already exist). |
|
174 | - * Note this should ONLY be used for terms that always must be present. Be aware that if an initial term is |
|
175 | - * deleted then it WILL be recreated. |
|
176 | - * |
|
177 | - * @param string $taxonomy The name of the taxonomy |
|
178 | - * @param array $term_details An array of term details indexed by slug and containing Name of term, and |
|
179 | - * description as the elements in the array |
|
180 | - * @return void |
|
181 | - */ |
|
182 | - public function setMustUseTerms($taxonomy, $term_details) |
|
183 | - { |
|
184 | - $term_details = (array)$term_details; |
|
185 | - foreach ($term_details as $slug => $details) { |
|
186 | - if (isset($details['term'], $details['desc']) && ! term_exists($slug, $taxonomy)) { |
|
187 | - $insert_arr = array( |
|
188 | - 'slug' => $slug, |
|
189 | - 'description' => $details['desc'], |
|
190 | - ); |
|
191 | - wp_insert_term($details['term'], $taxonomy, $insert_arr); |
|
192 | - } |
|
193 | - } |
|
194 | - } |
|
19 | + /** |
|
20 | + * @var array[] $custom_taxonomy_terms |
|
21 | + */ |
|
22 | + public $custom_taxonomy_terms = array(); |
|
23 | + |
|
24 | + |
|
25 | + /** |
|
26 | + * RegisterCustomTaxonomyTerms constructor. |
|
27 | + */ |
|
28 | + public function __construct() |
|
29 | + { |
|
30 | + // hook into save_post so that we can make sure that the default terms get saved on publish of registered cpts |
|
31 | + // IF they don't have a term for that taxonomy set. |
|
32 | + add_action('save_post', array($this, 'saveDefaultTerm'), 100, 2); |
|
33 | + do_action( |
|
34 | + 'AHEE__EventEspresso_core_domain_services_custom_post_types_RegisterCustomTaxonomyTerms__construct_end', |
|
35 | + $this |
|
36 | + ); |
|
37 | + } |
|
38 | + |
|
39 | + |
|
40 | + public function registerCustomTaxonomyTerms() |
|
41 | + { |
|
42 | + // setup default terms in any of our taxonomies (but only if we're in admin). |
|
43 | + // Why not added via register_activation_hook? |
|
44 | + // Because it's possible that in future iterations of EE we may add new defaults for specialized taxonomies |
|
45 | + // (think event_types) and register_activation_hook only reliably runs when a user manually activates the plugin. |
|
46 | + // Keep in mind that this will READ these terms if they are deleted by the user. Hence MUST use terms. |
|
47 | + // if ( is_admin() ) { |
|
48 | + // $this->set_must_use_event_types(); |
|
49 | + // } |
|
50 | + // set default terms |
|
51 | + $this->registerCustomTaxonomyTerm( |
|
52 | + 'espresso_event_type', |
|
53 | + 'single-event', |
|
54 | + array('espresso_events') |
|
55 | + ); |
|
56 | + } |
|
57 | + |
|
58 | + |
|
59 | + /** |
|
60 | + * Allows us to set what the default will be for terms when a cpt is PUBLISHED. |
|
61 | + * |
|
62 | + * @param string $taxonomy The taxonomy we're using for the default term |
|
63 | + * @param string $term_slug The slug of the term that will be the default. |
|
64 | + * @param array $cpt_slugs An array of custom post types we want the default assigned to |
|
65 | + */ |
|
66 | + public function registerCustomTaxonomyTerm($taxonomy, $term_slug, array $cpt_slugs = array()) |
|
67 | + { |
|
68 | + $this->custom_taxonomy_terms[][$term_slug] = new CustomTaxonomyTerm( |
|
69 | + $taxonomy, |
|
70 | + $term_slug, |
|
71 | + $cpt_slugs |
|
72 | + ); |
|
73 | + } |
|
74 | + |
|
75 | + |
|
76 | + /** |
|
77 | + * hooked into the wp 'save_post' action hook for setting our default terms found in the $_default_terms property |
|
78 | + * |
|
79 | + * @param int $post_id ID of CPT being saved |
|
80 | + * @param WP_Post $post Post object |
|
81 | + * @return void |
|
82 | + */ |
|
83 | + public function saveDefaultTerm($post_id, WP_Post $post) |
|
84 | + { |
|
85 | + if (empty($this->custom_taxonomy_terms)) { |
|
86 | + return; |
|
87 | + } |
|
88 | + // no default terms set so lets just exit. |
|
89 | + foreach ($this->custom_taxonomy_terms as $custom_taxonomy_terms) { |
|
90 | + foreach ($custom_taxonomy_terms as $custom_taxonomy_term) { |
|
91 | + if ($post->post_status === 'publish' |
|
92 | + && $custom_taxonomy_term instanceof CustomTaxonomyTerm |
|
93 | + && in_array($post->post_type, $custom_taxonomy_term->customPostTypeSlugs(), true) |
|
94 | + ) { |
|
95 | + // note some error proofing going on here to save unnecessary db queries |
|
96 | + $taxonomies = get_object_taxonomies($post->post_type); |
|
97 | + foreach ($taxonomies as $taxonomy) { |
|
98 | + $terms = wp_get_post_terms($post_id, $taxonomy); |
|
99 | + if (empty($terms) && $taxonomy === $custom_taxonomy_term->taxonomySlug()) { |
|
100 | + wp_set_object_terms( |
|
101 | + $post_id, |
|
102 | + array($custom_taxonomy_term->termSlug()), |
|
103 | + $taxonomy |
|
104 | + ); |
|
105 | + } |
|
106 | + } |
|
107 | + } |
|
108 | + } |
|
109 | + } |
|
110 | + } |
|
111 | + |
|
112 | + |
|
113 | + /** |
|
114 | + * @return void |
|
115 | + */ |
|
116 | + public function setMustUseEventTypes() |
|
117 | + { |
|
118 | + $term_details = array( |
|
119 | + // Attendee's register for the first date-time only |
|
120 | + 'single-event' => array( |
|
121 | + 'term' => esc_html__('Single Event', 'event_espresso'), |
|
122 | + 'desc' => esc_html__( |
|
123 | + 'A single event that spans one or more consecutive days.', |
|
124 | + 'event_espresso' |
|
125 | + ), |
|
126 | + ), |
|
127 | + // example: a party or two-day long workshop |
|
128 | + // Attendee's can register for any of the date-times |
|
129 | + 'multi-event' => array( |
|
130 | + 'term' => esc_html__('Multi Event', 'event_espresso'), |
|
131 | + 'desc' => esc_html__( |
|
132 | + 'Multiple, separate, but related events that occur on consecutive days.', |
|
133 | + 'event_espresso' |
|
134 | + ), |
|
135 | + ), |
|
136 | + // example: a three day music festival or week long conference |
|
137 | + // Attendee's register for the first date-time only |
|
138 | + 'event-series' => array( |
|
139 | + 'term' => esc_html__('Event Series', 'event_espresso'), |
|
140 | + 'desc' => esc_html__( |
|
141 | + ' Multiple events that occur over multiple non-consecutive days.', |
|
142 | + 'event_espresso' |
|
143 | + ), |
|
144 | + ), |
|
145 | + // example: an 8 week introduction to basket weaving course |
|
146 | + // Attendee's can register for any of the date-times. |
|
147 | + 'recurring-event' => array( |
|
148 | + 'term' => esc_html__('Recurring Event', 'event_espresso'), |
|
149 | + 'desc' => esc_html__( |
|
150 | + 'Multiple events that occur over multiple non-consecutive days.', |
|
151 | + 'event_espresso' |
|
152 | + ), |
|
153 | + ), |
|
154 | + // example: a yoga class |
|
155 | + 'ongoing' => array( |
|
156 | + 'term' => esc_html__('Ongoing Event', 'event_espresso'), |
|
157 | + 'desc' => esc_html__( |
|
158 | + 'An "event" that people can purchase tickets to gain access for anytime for this event regardless of date times on the event', |
|
159 | + 'event_espresso' |
|
160 | + ), |
|
161 | + ) |
|
162 | + // example: access to a museum |
|
163 | + // 'walk-in' => array( esc_html__('Walk In', 'event_espresso'), esc_html__('Single datetime and single entry recurring events. Attendees register for one or multiple datetimes individually.', 'event_espresso') ), |
|
164 | + // 'reservation' => array( esc_html__('Reservation', 'event_espresso'), esc_html__('Reservations are created by specifying available datetimes and quantities. Attendees choose from the available datetimes and specify the quantity available (if the maximum is greater than 1)') ), //@TODO to avoid confusion we'll implement this in a later iteration > EE4.1 |
|
165 | + // 'multiple-session' => array( esc_html__('Multiple Session', 'event_espresso'), esc_html__('Multiple event, multiple datetime, hierarchically organized, custom entry events. Attendees may be required to register for a parent event before being allowed to register for child events. Attendees can register for any combination of child events as long as the datetimes do not conflict. Parent and child events may have additional fees or registration questions.') ), //@TODO to avoid confusion we'll implement this in a later iteration > EE4.1 |
|
166 | + // 'appointment' => array( esc_html__('Appointments', 'event_espresso'), esc_html__('Time slotted events where datetimes are generally in hours or minutes. For example, attendees can register for a single 15 minute or 1 hour time slot and this type of availability frequently reoccurs.', 'event_espresso') ) |
|
167 | + ); |
|
168 | + $this->setMustUseTerms('espresso_event_type', $term_details); |
|
169 | + } |
|
170 | + |
|
171 | + |
|
172 | + /** |
|
173 | + * wrapper method for handling the setting up of initial terms in the db (if they don't already exist). |
|
174 | + * Note this should ONLY be used for terms that always must be present. Be aware that if an initial term is |
|
175 | + * deleted then it WILL be recreated. |
|
176 | + * |
|
177 | + * @param string $taxonomy The name of the taxonomy |
|
178 | + * @param array $term_details An array of term details indexed by slug and containing Name of term, and |
|
179 | + * description as the elements in the array |
|
180 | + * @return void |
|
181 | + */ |
|
182 | + public function setMustUseTerms($taxonomy, $term_details) |
|
183 | + { |
|
184 | + $term_details = (array)$term_details; |
|
185 | + foreach ($term_details as $slug => $details) { |
|
186 | + if (isset($details['term'], $details['desc']) && ! term_exists($slug, $taxonomy)) { |
|
187 | + $insert_arr = array( |
|
188 | + 'slug' => $slug, |
|
189 | + 'description' => $details['desc'], |
|
190 | + ); |
|
191 | + wp_insert_term($details['term'], $taxonomy, $insert_arr); |
|
192 | + } |
|
193 | + } |
|
194 | + } |
|
195 | 195 | } |
@@ -181,7 +181,7 @@ |
||
181 | 181 | */ |
182 | 182 | public function setMustUseTerms($taxonomy, $term_details) |
183 | 183 | { |
184 | - $term_details = (array)$term_details; |
|
184 | + $term_details = (array) $term_details; |
|
185 | 185 | foreach ($term_details as $slug => $details) { |
186 | 186 | if (isset($details['term'], $details['desc']) && ! term_exists($slug, $taxonomy)) { |
187 | 187 | $insert_arr = array( |
@@ -13,30 +13,30 @@ |
||
13 | 13 | class RewriteRules |
14 | 14 | { |
15 | 15 | |
16 | - const OPTION_KEY_FLUSH_REWRITE_RULES = 'ee_flush_rewrite_rules'; |
|
16 | + const OPTION_KEY_FLUSH_REWRITE_RULES = 'ee_flush_rewrite_rules'; |
|
17 | 17 | |
18 | 18 | |
19 | - /** |
|
20 | - * This will flush rewrite rules on demand. This actually gets called around wp init priority level 100. |
|
21 | - * |
|
22 | - * @return void |
|
23 | - */ |
|
24 | - public function flush() |
|
25 | - { |
|
26 | - update_option(RewriteRules::OPTION_KEY_FLUSH_REWRITE_RULES, true); |
|
27 | - } |
|
19 | + /** |
|
20 | + * This will flush rewrite rules on demand. This actually gets called around wp init priority level 100. |
|
21 | + * |
|
22 | + * @return void |
|
23 | + */ |
|
24 | + public function flush() |
|
25 | + { |
|
26 | + update_option(RewriteRules::OPTION_KEY_FLUSH_REWRITE_RULES, true); |
|
27 | + } |
|
28 | 28 | |
29 | 29 | |
30 | - /** |
|
31 | - * This will flush rewrite rules on demand. This actually gets called around wp init priority level 100. |
|
32 | - * |
|
33 | - * @return void |
|
34 | - */ |
|
35 | - public function flushRewriteRules() |
|
36 | - { |
|
37 | - if (get_option(RewriteRules::OPTION_KEY_FLUSH_REWRITE_RULES, true)) { |
|
38 | - flush_rewrite_rules(); |
|
39 | - update_option(RewriteRules::OPTION_KEY_FLUSH_REWRITE_RULES, false); |
|
40 | - } |
|
41 | - } |
|
30 | + /** |
|
31 | + * This will flush rewrite rules on demand. This actually gets called around wp init priority level 100. |
|
32 | + * |
|
33 | + * @return void |
|
34 | + */ |
|
35 | + public function flushRewriteRules() |
|
36 | + { |
|
37 | + if (get_option(RewriteRules::OPTION_KEY_FLUSH_REWRITE_RULES, true)) { |
|
38 | + flush_rewrite_rules(); |
|
39 | + update_option(RewriteRules::OPTION_KEY_FLUSH_REWRITE_RULES, false); |
|
40 | + } |
|
41 | + } |
|
42 | 42 | } |
@@ -16,197 +16,197 @@ |
||
16 | 16 | class EventListQuery extends WP_Query |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * @var string $title |
|
21 | - */ |
|
22 | - private $title; |
|
23 | - |
|
24 | - /** |
|
25 | - * @var integer $limit |
|
26 | - */ |
|
27 | - private $limit = 10; |
|
28 | - |
|
29 | - /** |
|
30 | - * @var string $css_class |
|
31 | - */ |
|
32 | - private $css_class; |
|
33 | - |
|
34 | - /** |
|
35 | - * @var boolean $show_expired |
|
36 | - */ |
|
37 | - private $show_expired = false; |
|
38 | - |
|
39 | - /** |
|
40 | - * @var string $month |
|
41 | - */ |
|
42 | - private $month; |
|
43 | - |
|
44 | - /** |
|
45 | - * @var string $category_slug |
|
46 | - */ |
|
47 | - private $category_slug; |
|
48 | - |
|
49 | - /** |
|
50 | - * @var string $order_by |
|
51 | - */ |
|
52 | - private $order_by; |
|
53 | - |
|
54 | - /** |
|
55 | - * @var string $sort |
|
56 | - */ |
|
57 | - private $sort; |
|
58 | - |
|
59 | - /** |
|
60 | - * @var boolean $show_title |
|
61 | - */ |
|
62 | - private $show_title = true; |
|
63 | - |
|
64 | - |
|
65 | - /** |
|
66 | - * EE_Event_List_Query Constructor * |
|
67 | - * |
|
68 | - * @param array $args |
|
69 | - */ |
|
70 | - public function __construct($args = array()) |
|
71 | - { |
|
72 | - $args = $this->parseArgs((array)$args); |
|
73 | - $this->setupEventQueryHelper(); |
|
74 | - $this->setupFilters(); |
|
75 | - $args = $this->getQueryArgs($args); |
|
76 | - // run the query |
|
77 | - parent::__construct($args); |
|
78 | - } |
|
79 | - |
|
80 | - |
|
81 | - /** |
|
82 | - * @param array $args |
|
83 | - * @return array |
|
84 | - */ |
|
85 | - private function parseArgs(array $args) |
|
86 | - { |
|
87 | - // incoming args could be a mix of WP query args + EE shortcode args |
|
88 | - foreach ($args as $property => $value) { |
|
89 | - // if the arg is a property of this class, then it's an EE shortcode arg |
|
90 | - if (property_exists($this, $property) && ! property_exists('WP_Query', $property)) { |
|
91 | - // set the property value |
|
92 | - $this->{$property} = $value; |
|
93 | - // then remove it from the array of args that will later be passed to WP_Query() |
|
94 | - unset($args[$property]); |
|
95 | - } |
|
96 | - } |
|
97 | - return $args; |
|
98 | - } |
|
99 | - |
|
100 | - |
|
101 | - private function setupEventQueryHelper() |
|
102 | - { |
|
103 | - // add query filters |
|
104 | - EEH_Event_Query::add_query_filters(); |
|
105 | - // set params that will get used by the filters |
|
106 | - EEH_Event_Query::set_query_params( |
|
107 | - $this->month, |
|
108 | - $this->category_slug, |
|
109 | - $this->show_expired, |
|
110 | - $this->order_by, |
|
111 | - $this->sort |
|
112 | - ); |
|
113 | - } |
|
114 | - |
|
115 | - |
|
116 | - private function setupFilters() |
|
117 | - { |
|
118 | - // first off, let's remove any filters from previous queries |
|
119 | - remove_filter( |
|
120 | - 'FHEE__archive_espresso_events_template__show_header', |
|
121 | - array($this, 'show_event_list_title') |
|
122 | - ); |
|
123 | - remove_filter( |
|
124 | - 'FHEE__archive_espresso_events_template__upcoming_events_h1', |
|
125 | - array($this, 'event_list_title') |
|
126 | - ); |
|
127 | - remove_all_filters('FHEE__content_espresso_events__event_class'); |
|
128 | - // Event List Title ? |
|
129 | - add_filter( |
|
130 | - 'FHEE__archive_espresso_events_template__show_header', |
|
131 | - array($this, 'show_event_list_title') |
|
132 | - ); |
|
133 | - add_filter( |
|
134 | - 'FHEE__archive_espresso_events_template__upcoming_events_h1', |
|
135 | - array($this, 'event_list_title'), |
|
136 | - 10, |
|
137 | - 1 |
|
138 | - ); |
|
139 | - // add the css class |
|
140 | - add_filter( |
|
141 | - 'FHEE__content_espresso_events__event_class', |
|
142 | - array($this, 'event_list_css'), |
|
143 | - 10, |
|
144 | - 1 |
|
145 | - ); |
|
146 | - } |
|
147 | - |
|
148 | - |
|
149 | - private function getQueryArgs(array $args) |
|
150 | - { |
|
151 | - // the current "page" we are viewing |
|
152 | - $paged = max(1, get_query_var('paged')); |
|
153 | - // Force these args |
|
154 | - return array_merge( |
|
155 | - $args, |
|
156 | - array( |
|
157 | - 'post_type' => 'espresso_events', |
|
158 | - 'posts_per_page' => $this->limit, |
|
159 | - 'update_post_term_cache' => false, |
|
160 | - 'update_post_meta_cache' => false, |
|
161 | - 'paged' => $paged, |
|
162 | - 'offset' => ($paged - 1) * $this->limit, |
|
163 | - ) |
|
164 | - ); |
|
165 | - } |
|
166 | - |
|
167 | - // phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
168 | - /** |
|
169 | - * show_event_list_title |
|
170 | - * |
|
171 | - * @return boolean |
|
172 | - */ |
|
173 | - public function show_event_list_title() |
|
174 | - { |
|
175 | - return filter_var( |
|
176 | - $this->show_title, |
|
177 | - FILTER_VALIDATE_BOOLEAN |
|
178 | - ); |
|
179 | - } |
|
180 | - |
|
181 | - |
|
182 | - /** |
|
183 | - * callback for FHEE__archive_espresso_events_template__upcoming_events_h1 filter |
|
184 | - * |
|
185 | - * @param string $event_list_title |
|
186 | - * @return string |
|
187 | - */ |
|
188 | - public function event_list_title($event_list_title = '') |
|
189 | - { |
|
190 | - if (! empty($this->title)) { |
|
191 | - return $this->title; |
|
192 | - } |
|
193 | - return $event_list_title; |
|
194 | - } |
|
195 | - |
|
196 | - |
|
197 | - /** |
|
198 | - * callback for FHEE__content_espresso_events__event_class filter |
|
199 | - * |
|
200 | - * @param string $event_list_css |
|
201 | - * @return string |
|
202 | - */ |
|
203 | - public function event_list_css($event_list_css = '') |
|
204 | - { |
|
205 | - $event_list_css .= ! empty($event_list_css) ? ' ' : ''; |
|
206 | - $event_list_css .= ! empty($this->css_class) ? $this->css_class : ''; |
|
207 | - $event_list_css .= ! empty($event_list_css) ? ' ' : ''; |
|
208 | - $event_list_css .= ! empty($this->category_slug) ? $this->category_slug : ''; |
|
209 | - return $event_list_css; |
|
210 | - } |
|
211 | - // phpcs:enable |
|
19 | + /** |
|
20 | + * @var string $title |
|
21 | + */ |
|
22 | + private $title; |
|
23 | + |
|
24 | + /** |
|
25 | + * @var integer $limit |
|
26 | + */ |
|
27 | + private $limit = 10; |
|
28 | + |
|
29 | + /** |
|
30 | + * @var string $css_class |
|
31 | + */ |
|
32 | + private $css_class; |
|
33 | + |
|
34 | + /** |
|
35 | + * @var boolean $show_expired |
|
36 | + */ |
|
37 | + private $show_expired = false; |
|
38 | + |
|
39 | + /** |
|
40 | + * @var string $month |
|
41 | + */ |
|
42 | + private $month; |
|
43 | + |
|
44 | + /** |
|
45 | + * @var string $category_slug |
|
46 | + */ |
|
47 | + private $category_slug; |
|
48 | + |
|
49 | + /** |
|
50 | + * @var string $order_by |
|
51 | + */ |
|
52 | + private $order_by; |
|
53 | + |
|
54 | + /** |
|
55 | + * @var string $sort |
|
56 | + */ |
|
57 | + private $sort; |
|
58 | + |
|
59 | + /** |
|
60 | + * @var boolean $show_title |
|
61 | + */ |
|
62 | + private $show_title = true; |
|
63 | + |
|
64 | + |
|
65 | + /** |
|
66 | + * EE_Event_List_Query Constructor * |
|
67 | + * |
|
68 | + * @param array $args |
|
69 | + */ |
|
70 | + public function __construct($args = array()) |
|
71 | + { |
|
72 | + $args = $this->parseArgs((array)$args); |
|
73 | + $this->setupEventQueryHelper(); |
|
74 | + $this->setupFilters(); |
|
75 | + $args = $this->getQueryArgs($args); |
|
76 | + // run the query |
|
77 | + parent::__construct($args); |
|
78 | + } |
|
79 | + |
|
80 | + |
|
81 | + /** |
|
82 | + * @param array $args |
|
83 | + * @return array |
|
84 | + */ |
|
85 | + private function parseArgs(array $args) |
|
86 | + { |
|
87 | + // incoming args could be a mix of WP query args + EE shortcode args |
|
88 | + foreach ($args as $property => $value) { |
|
89 | + // if the arg is a property of this class, then it's an EE shortcode arg |
|
90 | + if (property_exists($this, $property) && ! property_exists('WP_Query', $property)) { |
|
91 | + // set the property value |
|
92 | + $this->{$property} = $value; |
|
93 | + // then remove it from the array of args that will later be passed to WP_Query() |
|
94 | + unset($args[$property]); |
|
95 | + } |
|
96 | + } |
|
97 | + return $args; |
|
98 | + } |
|
99 | + |
|
100 | + |
|
101 | + private function setupEventQueryHelper() |
|
102 | + { |
|
103 | + // add query filters |
|
104 | + EEH_Event_Query::add_query_filters(); |
|
105 | + // set params that will get used by the filters |
|
106 | + EEH_Event_Query::set_query_params( |
|
107 | + $this->month, |
|
108 | + $this->category_slug, |
|
109 | + $this->show_expired, |
|
110 | + $this->order_by, |
|
111 | + $this->sort |
|
112 | + ); |
|
113 | + } |
|
114 | + |
|
115 | + |
|
116 | + private function setupFilters() |
|
117 | + { |
|
118 | + // first off, let's remove any filters from previous queries |
|
119 | + remove_filter( |
|
120 | + 'FHEE__archive_espresso_events_template__show_header', |
|
121 | + array($this, 'show_event_list_title') |
|
122 | + ); |
|
123 | + remove_filter( |
|
124 | + 'FHEE__archive_espresso_events_template__upcoming_events_h1', |
|
125 | + array($this, 'event_list_title') |
|
126 | + ); |
|
127 | + remove_all_filters('FHEE__content_espresso_events__event_class'); |
|
128 | + // Event List Title ? |
|
129 | + add_filter( |
|
130 | + 'FHEE__archive_espresso_events_template__show_header', |
|
131 | + array($this, 'show_event_list_title') |
|
132 | + ); |
|
133 | + add_filter( |
|
134 | + 'FHEE__archive_espresso_events_template__upcoming_events_h1', |
|
135 | + array($this, 'event_list_title'), |
|
136 | + 10, |
|
137 | + 1 |
|
138 | + ); |
|
139 | + // add the css class |
|
140 | + add_filter( |
|
141 | + 'FHEE__content_espresso_events__event_class', |
|
142 | + array($this, 'event_list_css'), |
|
143 | + 10, |
|
144 | + 1 |
|
145 | + ); |
|
146 | + } |
|
147 | + |
|
148 | + |
|
149 | + private function getQueryArgs(array $args) |
|
150 | + { |
|
151 | + // the current "page" we are viewing |
|
152 | + $paged = max(1, get_query_var('paged')); |
|
153 | + // Force these args |
|
154 | + return array_merge( |
|
155 | + $args, |
|
156 | + array( |
|
157 | + 'post_type' => 'espresso_events', |
|
158 | + 'posts_per_page' => $this->limit, |
|
159 | + 'update_post_term_cache' => false, |
|
160 | + 'update_post_meta_cache' => false, |
|
161 | + 'paged' => $paged, |
|
162 | + 'offset' => ($paged - 1) * $this->limit, |
|
163 | + ) |
|
164 | + ); |
|
165 | + } |
|
166 | + |
|
167 | + // phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
168 | + /** |
|
169 | + * show_event_list_title |
|
170 | + * |
|
171 | + * @return boolean |
|
172 | + */ |
|
173 | + public function show_event_list_title() |
|
174 | + { |
|
175 | + return filter_var( |
|
176 | + $this->show_title, |
|
177 | + FILTER_VALIDATE_BOOLEAN |
|
178 | + ); |
|
179 | + } |
|
180 | + |
|
181 | + |
|
182 | + /** |
|
183 | + * callback for FHEE__archive_espresso_events_template__upcoming_events_h1 filter |
|
184 | + * |
|
185 | + * @param string $event_list_title |
|
186 | + * @return string |
|
187 | + */ |
|
188 | + public function event_list_title($event_list_title = '') |
|
189 | + { |
|
190 | + if (! empty($this->title)) { |
|
191 | + return $this->title; |
|
192 | + } |
|
193 | + return $event_list_title; |
|
194 | + } |
|
195 | + |
|
196 | + |
|
197 | + /** |
|
198 | + * callback for FHEE__content_espresso_events__event_class filter |
|
199 | + * |
|
200 | + * @param string $event_list_css |
|
201 | + * @return string |
|
202 | + */ |
|
203 | + public function event_list_css($event_list_css = '') |
|
204 | + { |
|
205 | + $event_list_css .= ! empty($event_list_css) ? ' ' : ''; |
|
206 | + $event_list_css .= ! empty($this->css_class) ? $this->css_class : ''; |
|
207 | + $event_list_css .= ! empty($event_list_css) ? ' ' : ''; |
|
208 | + $event_list_css .= ! empty($this->category_slug) ? $this->category_slug : ''; |
|
209 | + return $event_list_css; |
|
210 | + } |
|
211 | + // phpcs:enable |
|
212 | 212 | } |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | */ |
70 | 70 | public function __construct($args = array()) |
71 | 71 | { |
72 | - $args = $this->parseArgs((array)$args); |
|
72 | + $args = $this->parseArgs((array) $args); |
|
73 | 73 | $this->setupEventQueryHelper(); |
74 | 74 | $this->setupFilters(); |
75 | 75 | $args = $this->getQueryArgs($args); |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | */ |
188 | 188 | public function event_list_title($event_list_title = '') |
189 | 189 | { |
190 | - if (! empty($this->title)) { |
|
190 | + if ( ! empty($this->title)) { |
|
191 | 191 | return $this->title; |
192 | 192 | } |
193 | 193 | return $event_list_title; |
@@ -17,88 +17,88 @@ |
||
17 | 17 | class CapabilitiesChecker implements CapabilitiesCheckerInterface |
18 | 18 | { |
19 | 19 | |
20 | - /** |
|
21 | - * @type EE_Capabilities $capabilities |
|
22 | - */ |
|
23 | - private $capabilities; |
|
20 | + /** |
|
21 | + * @type EE_Capabilities $capabilities |
|
22 | + */ |
|
23 | + private $capabilities; |
|
24 | 24 | |
25 | 25 | |
26 | 26 | |
27 | - /** |
|
28 | - * CapabilitiesChecker constructor |
|
29 | - * |
|
30 | - * @param EE_Capabilities $capabilities |
|
31 | - */ |
|
32 | - public function __construct(EE_Capabilities $capabilities) |
|
33 | - { |
|
34 | - $this->capabilities = $capabilities; |
|
35 | - } |
|
27 | + /** |
|
28 | + * CapabilitiesChecker constructor |
|
29 | + * |
|
30 | + * @param EE_Capabilities $capabilities |
|
31 | + */ |
|
32 | + public function __construct(EE_Capabilities $capabilities) |
|
33 | + { |
|
34 | + $this->capabilities = $capabilities; |
|
35 | + } |
|
36 | 36 | |
37 | 37 | |
38 | 38 | |
39 | - /** |
|
40 | - * @return EE_Capabilities |
|
41 | - */ |
|
42 | - protected function capabilities() |
|
43 | - { |
|
44 | - return $this->capabilities; |
|
45 | - } |
|
39 | + /** |
|
40 | + * @return EE_Capabilities |
|
41 | + */ |
|
42 | + protected function capabilities() |
|
43 | + { |
|
44 | + return $this->capabilities; |
|
45 | + } |
|
46 | 46 | |
47 | 47 | |
48 | 48 | |
49 | - /** |
|
50 | - * Verifies that the current user has ALL of the capabilities listed in the CapCheck DTO. |
|
51 | - * If any of the individual capability checks fails, then the command will NOT be executed. |
|
52 | - * |
|
53 | - * @param CapCheckInterface|CapCheckInterface[] $cap_check |
|
54 | - * @return bool |
|
55 | - * @throws InvalidClassException |
|
56 | - * @throws InsufficientPermissionsException |
|
57 | - */ |
|
58 | - public function processCapCheck($cap_check) |
|
59 | - { |
|
60 | - if (is_array($cap_check)) { |
|
61 | - foreach ($cap_check as $check) { |
|
62 | - $this->processCapCheck($check); |
|
63 | - } |
|
64 | - return true; |
|
65 | - } |
|
66 | - // at this point, $cap_check should be an individual instance of CapCheck |
|
67 | - if (! $cap_check instanceof CapCheckInterface) { |
|
68 | - throw new InvalidClassException( |
|
69 | - '\EventEspresso\core\domain\services\capabilities\CapCheckInterface' |
|
70 | - ); |
|
71 | - } |
|
72 | - // sometimes cap checks are conditional, and no capabilities are required |
|
73 | - if ($cap_check instanceof PublicCapabilities) { |
|
74 | - return true; |
|
75 | - } |
|
76 | - $capabilities = (array)$cap_check->capability(); |
|
77 | - foreach ($capabilities as $capability) { |
|
78 | - if (! $this->capabilities()->current_user_can( |
|
79 | - $capability, |
|
80 | - $cap_check->context(), |
|
81 | - $cap_check->ID() |
|
82 | - )) { |
|
83 | - throw new InsufficientPermissionsException($cap_check->context()); |
|
84 | - } |
|
85 | - } |
|
86 | - return true; |
|
87 | - } |
|
49 | + /** |
|
50 | + * Verifies that the current user has ALL of the capabilities listed in the CapCheck DTO. |
|
51 | + * If any of the individual capability checks fails, then the command will NOT be executed. |
|
52 | + * |
|
53 | + * @param CapCheckInterface|CapCheckInterface[] $cap_check |
|
54 | + * @return bool |
|
55 | + * @throws InvalidClassException |
|
56 | + * @throws InsufficientPermissionsException |
|
57 | + */ |
|
58 | + public function processCapCheck($cap_check) |
|
59 | + { |
|
60 | + if (is_array($cap_check)) { |
|
61 | + foreach ($cap_check as $check) { |
|
62 | + $this->processCapCheck($check); |
|
63 | + } |
|
64 | + return true; |
|
65 | + } |
|
66 | + // at this point, $cap_check should be an individual instance of CapCheck |
|
67 | + if (! $cap_check instanceof CapCheckInterface) { |
|
68 | + throw new InvalidClassException( |
|
69 | + '\EventEspresso\core\domain\services\capabilities\CapCheckInterface' |
|
70 | + ); |
|
71 | + } |
|
72 | + // sometimes cap checks are conditional, and no capabilities are required |
|
73 | + if ($cap_check instanceof PublicCapabilities) { |
|
74 | + return true; |
|
75 | + } |
|
76 | + $capabilities = (array)$cap_check->capability(); |
|
77 | + foreach ($capabilities as $capability) { |
|
78 | + if (! $this->capabilities()->current_user_can( |
|
79 | + $capability, |
|
80 | + $cap_check->context(), |
|
81 | + $cap_check->ID() |
|
82 | + )) { |
|
83 | + throw new InsufficientPermissionsException($cap_check->context()); |
|
84 | + } |
|
85 | + } |
|
86 | + return true; |
|
87 | + } |
|
88 | 88 | |
89 | 89 | |
90 | 90 | |
91 | - /** |
|
92 | - * @param string $capability - the capability to be checked, like: 'ee_edit_registrations' |
|
93 | - * @param string $context - what the user is attempting to do, like: 'Edit Registration' |
|
94 | - * @param int $ID - (optional) ID for item where current_user_can is being called from |
|
95 | - * @return bool |
|
96 | - * @throws InvalidDataTypeException |
|
97 | - * @throws InsufficientPermissionsException |
|
98 | - * @throws InvalidClassException |
|
99 | - */ |
|
100 | - public function process($capability, $context, $ID = 0) |
|
101 | - { |
|
102 | - return $this->processCapCheck(new CapCheck($capability, $context, $ID)); |
|
103 | - } |
|
91 | + /** |
|
92 | + * @param string $capability - the capability to be checked, like: 'ee_edit_registrations' |
|
93 | + * @param string $context - what the user is attempting to do, like: 'Edit Registration' |
|
94 | + * @param int $ID - (optional) ID for item where current_user_can is being called from |
|
95 | + * @return bool |
|
96 | + * @throws InvalidDataTypeException |
|
97 | + * @throws InsufficientPermissionsException |
|
98 | + * @throws InvalidClassException |
|
99 | + */ |
|
100 | + public function process($capability, $context, $ID = 0) |
|
101 | + { |
|
102 | + return $this->processCapCheck(new CapCheck($capability, $context, $ID)); |
|
103 | + } |
|
104 | 104 | } |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | return true; |
65 | 65 | } |
66 | 66 | // at this point, $cap_check should be an individual instance of CapCheck |
67 | - if (! $cap_check instanceof CapCheckInterface) { |
|
67 | + if ( ! $cap_check instanceof CapCheckInterface) { |
|
68 | 68 | throw new InvalidClassException( |
69 | 69 | '\EventEspresso\core\domain\services\capabilities\CapCheckInterface' |
70 | 70 | ); |
@@ -73,9 +73,9 @@ discard block |
||
73 | 73 | if ($cap_check instanceof PublicCapabilities) { |
74 | 74 | return true; |
75 | 75 | } |
76 | - $capabilities = (array)$cap_check->capability(); |
|
76 | + $capabilities = (array) $cap_check->capability(); |
|
77 | 77 | foreach ($capabilities as $capability) { |
78 | - if (! $this->capabilities()->current_user_can( |
|
78 | + if ( ! $this->capabilities()->current_user_can( |
|
79 | 79 | $capability, |
80 | 80 | $cap_check->context(), |
81 | 81 | $cap_check->ID() |
@@ -16,25 +16,25 @@ |
||
16 | 16 | interface CapabilitiesCheckerInterface |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * Verifies that the current user has ALL of the capabilities listed in the CapCheck DTO. |
|
21 | - * If any of the individual capability checks fails, then the command will NOT be executed. |
|
22 | - * |
|
23 | - * @param CapCheckInterface|CapCheckInterface[] $cap_check |
|
24 | - * @return bool |
|
25 | - * @throws InvalidClassException |
|
26 | - * @throws InsufficientPermissionsException |
|
27 | - */ |
|
28 | - public function processCapCheck($cap_check); |
|
19 | + /** |
|
20 | + * Verifies that the current user has ALL of the capabilities listed in the CapCheck DTO. |
|
21 | + * If any of the individual capability checks fails, then the command will NOT be executed. |
|
22 | + * |
|
23 | + * @param CapCheckInterface|CapCheckInterface[] $cap_check |
|
24 | + * @return bool |
|
25 | + * @throws InvalidClassException |
|
26 | + * @throws InsufficientPermissionsException |
|
27 | + */ |
|
28 | + public function processCapCheck($cap_check); |
|
29 | 29 | |
30 | 30 | |
31 | - /** |
|
32 | - * @param string $capability - the capability to be checked, like: 'ee_edit_registrations' |
|
33 | - * @param string $context - what the user is attempting to do, like: 'Edit Registration' |
|
34 | - * @param int $ID - (optional) ID for item where current_user_can is being called from |
|
35 | - * @return bool |
|
36 | - * @throws InsufficientPermissionsException |
|
37 | - * @throws InvalidClassException |
|
38 | - */ |
|
39 | - public function process($capability, $context, $ID = 0); |
|
31 | + /** |
|
32 | + * @param string $capability - the capability to be checked, like: 'ee_edit_registrations' |
|
33 | + * @param string $context - what the user is attempting to do, like: 'Edit Registration' |
|
34 | + * @param int $ID - (optional) ID for item where current_user_can is being called from |
|
35 | + * @return bool |
|
36 | + * @throws InsufficientPermissionsException |
|
37 | + * @throws InvalidClassException |
|
38 | + */ |
|
39 | + public function process($capability, $context, $ID = 0); |
|
40 | 40 | } |
@@ -11,8 +11,8 @@ |
||
11 | 11 | interface RequiresCapCheckInterface |
12 | 12 | { |
13 | 13 | |
14 | - /** |
|
15 | - * @return CapCheckInterface |
|
16 | - */ |
|
17 | - public function getCapCheck(); |
|
14 | + /** |
|
15 | + * @return CapCheckInterface |
|
16 | + */ |
|
17 | + public function getCapCheck(); |
|
18 | 18 | } |
@@ -12,18 +12,18 @@ |
||
12 | 12 | interface CapCheckInterface |
13 | 13 | { |
14 | 14 | |
15 | - /** |
|
16 | - * @return string |
|
17 | - */ |
|
18 | - public function capability(); |
|
15 | + /** |
|
16 | + * @return string |
|
17 | + */ |
|
18 | + public function capability(); |
|
19 | 19 | |
20 | - /** |
|
21 | - * @return string |
|
22 | - */ |
|
23 | - public function context(); |
|
20 | + /** |
|
21 | + * @return string |
|
22 | + */ |
|
23 | + public function context(); |
|
24 | 24 | |
25 | - /** |
|
26 | - * @return int|string |
|
27 | - */ |
|
28 | - public function ID(); |
|
25 | + /** |
|
26 | + * @return int|string |
|
27 | + */ |
|
28 | + public function ID(); |
|
29 | 29 | } |
@@ -15,66 +15,66 @@ |
||
15 | 15 | class CapCheck implements CapCheckInterface |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * @var string|array $capability |
|
20 | - */ |
|
21 | - private $capability; |
|
18 | + /** |
|
19 | + * @var string|array $capability |
|
20 | + */ |
|
21 | + private $capability; |
|
22 | 22 | |
23 | - /** |
|
24 | - * @var string $context |
|
25 | - */ |
|
26 | - private $context; |
|
23 | + /** |
|
24 | + * @var string $context |
|
25 | + */ |
|
26 | + private $context; |
|
27 | 27 | |
28 | - /** |
|
29 | - * @var int|string $ID |
|
30 | - */ |
|
31 | - private $ID; |
|
28 | + /** |
|
29 | + * @var int|string $ID |
|
30 | + */ |
|
31 | + private $ID; |
|
32 | 32 | |
33 | 33 | |
34 | - /** |
|
35 | - * @param string|array $capability - the capability to be checked, like: 'ee_edit_registrations', |
|
36 | - * or an array of capability strings |
|
37 | - * @param string $context - what the user is attempting to do, like: 'Edit Registration' |
|
38 | - * @param int $ID - (optional) ID for item where current_user_can is being called from |
|
39 | - * @throws InvalidDataTypeException |
|
40 | - */ |
|
41 | - public function __construct($capability, $context, $ID = 0) |
|
42 | - { |
|
43 | - if (! (is_string($capability) || is_array($capability))) { |
|
44 | - throw new InvalidDataTypeException('$capability', $capability, 'string or array'); |
|
45 | - } |
|
46 | - if (! is_string($context)) { |
|
47 | - throw new InvalidDataTypeException('$context', $context, 'string'); |
|
48 | - } |
|
49 | - $this->capability = $capability; |
|
50 | - $this->context = strtolower(str_replace(' ', '_', $context)); |
|
51 | - $this->ID = $ID; |
|
52 | - } |
|
34 | + /** |
|
35 | + * @param string|array $capability - the capability to be checked, like: 'ee_edit_registrations', |
|
36 | + * or an array of capability strings |
|
37 | + * @param string $context - what the user is attempting to do, like: 'Edit Registration' |
|
38 | + * @param int $ID - (optional) ID for item where current_user_can is being called from |
|
39 | + * @throws InvalidDataTypeException |
|
40 | + */ |
|
41 | + public function __construct($capability, $context, $ID = 0) |
|
42 | + { |
|
43 | + if (! (is_string($capability) || is_array($capability))) { |
|
44 | + throw new InvalidDataTypeException('$capability', $capability, 'string or array'); |
|
45 | + } |
|
46 | + if (! is_string($context)) { |
|
47 | + throw new InvalidDataTypeException('$context', $context, 'string'); |
|
48 | + } |
|
49 | + $this->capability = $capability; |
|
50 | + $this->context = strtolower(str_replace(' ', '_', $context)); |
|
51 | + $this->ID = $ID; |
|
52 | + } |
|
53 | 53 | |
54 | 54 | |
55 | - /** |
|
56 | - * @return string|array |
|
57 | - */ |
|
58 | - public function capability() |
|
59 | - { |
|
60 | - return $this->capability; |
|
61 | - } |
|
55 | + /** |
|
56 | + * @return string|array |
|
57 | + */ |
|
58 | + public function capability() |
|
59 | + { |
|
60 | + return $this->capability; |
|
61 | + } |
|
62 | 62 | |
63 | 63 | |
64 | - /** |
|
65 | - * @return string |
|
66 | - */ |
|
67 | - public function context() |
|
68 | - { |
|
69 | - return $this->context; |
|
70 | - } |
|
64 | + /** |
|
65 | + * @return string |
|
66 | + */ |
|
67 | + public function context() |
|
68 | + { |
|
69 | + return $this->context; |
|
70 | + } |
|
71 | 71 | |
72 | 72 | |
73 | - /** |
|
74 | - * @return int|string |
|
75 | - */ |
|
76 | - public function ID() |
|
77 | - { |
|
78 | - return $this->ID; |
|
79 | - } |
|
73 | + /** |
|
74 | + * @return int|string |
|
75 | + */ |
|
76 | + public function ID() |
|
77 | + { |
|
78 | + return $this->ID; |
|
79 | + } |
|
80 | 80 | } |
@@ -40,10 +40,10 @@ |
||
40 | 40 | */ |
41 | 41 | public function __construct($capability, $context, $ID = 0) |
42 | 42 | { |
43 | - if (! (is_string($capability) || is_array($capability))) { |
|
43 | + if ( ! (is_string($capability) || is_array($capability))) { |
|
44 | 44 | throw new InvalidDataTypeException('$capability', $capability, 'string or array'); |
45 | 45 | } |
46 | - if (! is_string($context)) { |
|
46 | + if ( ! is_string($context)) { |
|
47 | 47 | throw new InvalidDataTypeException('$context', $context, 'string'); |
48 | 48 | } |
49 | 49 | $this->capability = $capability; |
@@ -19,19 +19,19 @@ |
||
19 | 19 | class EmailAddressFactory implements FactoryInterface |
20 | 20 | { |
21 | 21 | |
22 | - /** |
|
23 | - * @param string $email_address |
|
24 | - * @return EmailAddress |
|
25 | - * @throws EmailValidationException |
|
26 | - * @throws InvalidDataTypeException |
|
27 | - * @throws InvalidInterfaceException |
|
28 | - * @throws InvalidArgumentException |
|
29 | - */ |
|
30 | - public static function create($email_address) |
|
31 | - { |
|
32 | - return LoaderFactory::getLoader()->getNew( |
|
33 | - 'EventEspresso\core\domain\values\EmailAddress', |
|
34 | - array($email_address) |
|
35 | - ); |
|
36 | - } |
|
22 | + /** |
|
23 | + * @param string $email_address |
|
24 | + * @return EmailAddress |
|
25 | + * @throws EmailValidationException |
|
26 | + * @throws InvalidDataTypeException |
|
27 | + * @throws InvalidInterfaceException |
|
28 | + * @throws InvalidArgumentException |
|
29 | + */ |
|
30 | + public static function create($email_address) |
|
31 | + { |
|
32 | + return LoaderFactory::getLoader()->getNew( |
|
33 | + 'EventEspresso\core\domain\values\EmailAddress', |
|
34 | + array($email_address) |
|
35 | + ); |
|
36 | + } |
|
37 | 37 | } |