@@ -24,79 +24,79 @@ |
||
24 | 24 | |
25 | 25 | |
26 | 26 | |
27 | - /** |
|
28 | - * the actual shortcode tag that gets registered with WordPress |
|
29 | - * |
|
30 | - * @return string |
|
31 | - */ |
|
32 | - public function getTag() |
|
33 | - { |
|
34 | - return 'ESPRESSO_CANCELLED'; |
|
35 | - } |
|
36 | - |
|
37 | - |
|
38 | - |
|
39 | - /** |
|
40 | - * the time in seconds to cache the results of the processShortcode() method |
|
41 | - * 0 means the processShortcode() results will NOT be cached at all |
|
42 | - * |
|
43 | - * @return int |
|
44 | - */ |
|
45 | - public function cacheExpiration() |
|
46 | - { |
|
47 | - return 0; |
|
48 | - } |
|
49 | - |
|
50 | - |
|
51 | - /** |
|
52 | - * a place for adding any initialization code that needs to run prior to wp_header(). |
|
53 | - * this may be required for shortcodes that utilize a corresponding module, |
|
54 | - * and need to enqueue assets for that module |
|
55 | - * |
|
56 | - * @return void |
|
57 | - */ |
|
58 | - public function initializeShortcode() |
|
59 | - { |
|
60 | - $this->shortcodeHasBeenInitialized(); |
|
61 | - } |
|
62 | - |
|
63 | - |
|
64 | - /** |
|
65 | - * callback that runs when the shortcode is encountered in post content. |
|
66 | - * IMPORTANT !!! |
|
67 | - * remember that shortcode content should be RETURNED and NOT echoed out |
|
68 | - * |
|
69 | - * @param array $attributes |
|
70 | - * @return string |
|
71 | - * @throws \EE_Error |
|
72 | - */ |
|
73 | - public function processShortcode($attributes = array()) |
|
74 | - { |
|
75 | - $transaction = EE_Registry::instance()->SSN->get_session_data('transaction'); |
|
76 | - if ($transaction instanceof EE_Transaction) { |
|
77 | - do_action('AHEE__EES_Espresso_Cancelled__process_shortcode__transaction', $transaction); |
|
78 | - $registrations = $transaction->registrations(); |
|
79 | - foreach ($registrations as $registration) { |
|
80 | - if ($registration instanceof EE_Registration) { |
|
81 | - do_action('AHEE__EES_Espresso_Cancelled__process_shortcode__registration', $registration); |
|
82 | - } |
|
83 | - } |
|
84 | - } |
|
85 | - do_action('AHEE__EES_Espresso_Cancelled__process_shortcode__clear_session'); |
|
86 | - // remove all unwanted records from the db |
|
87 | - if (EE_Registry::instance()->CART instanceof EE_Cart) { |
|
88 | - EE_Registry::instance()->CART->delete_cart(); |
|
89 | - } |
|
90 | - EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
91 | - return sprintf( |
|
92 | - __( |
|
93 | - '%sAll unsaved registration information entered during this session has been deleted.%s', |
|
94 | - 'event_espresso' |
|
95 | - ), |
|
96 | - '<p class="ee-registrations-cancelled-pg ee-attention">', |
|
97 | - '</p>' |
|
98 | - ); |
|
99 | - } |
|
27 | + /** |
|
28 | + * the actual shortcode tag that gets registered with WordPress |
|
29 | + * |
|
30 | + * @return string |
|
31 | + */ |
|
32 | + public function getTag() |
|
33 | + { |
|
34 | + return 'ESPRESSO_CANCELLED'; |
|
35 | + } |
|
36 | + |
|
37 | + |
|
38 | + |
|
39 | + /** |
|
40 | + * the time in seconds to cache the results of the processShortcode() method |
|
41 | + * 0 means the processShortcode() results will NOT be cached at all |
|
42 | + * |
|
43 | + * @return int |
|
44 | + */ |
|
45 | + public function cacheExpiration() |
|
46 | + { |
|
47 | + return 0; |
|
48 | + } |
|
49 | + |
|
50 | + |
|
51 | + /** |
|
52 | + * a place for adding any initialization code that needs to run prior to wp_header(). |
|
53 | + * this may be required for shortcodes that utilize a corresponding module, |
|
54 | + * and need to enqueue assets for that module |
|
55 | + * |
|
56 | + * @return void |
|
57 | + */ |
|
58 | + public function initializeShortcode() |
|
59 | + { |
|
60 | + $this->shortcodeHasBeenInitialized(); |
|
61 | + } |
|
62 | + |
|
63 | + |
|
64 | + /** |
|
65 | + * callback that runs when the shortcode is encountered in post content. |
|
66 | + * IMPORTANT !!! |
|
67 | + * remember that shortcode content should be RETURNED and NOT echoed out |
|
68 | + * |
|
69 | + * @param array $attributes |
|
70 | + * @return string |
|
71 | + * @throws \EE_Error |
|
72 | + */ |
|
73 | + public function processShortcode($attributes = array()) |
|
74 | + { |
|
75 | + $transaction = EE_Registry::instance()->SSN->get_session_data('transaction'); |
|
76 | + if ($transaction instanceof EE_Transaction) { |
|
77 | + do_action('AHEE__EES_Espresso_Cancelled__process_shortcode__transaction', $transaction); |
|
78 | + $registrations = $transaction->registrations(); |
|
79 | + foreach ($registrations as $registration) { |
|
80 | + if ($registration instanceof EE_Registration) { |
|
81 | + do_action('AHEE__EES_Espresso_Cancelled__process_shortcode__registration', $registration); |
|
82 | + } |
|
83 | + } |
|
84 | + } |
|
85 | + do_action('AHEE__EES_Espresso_Cancelled__process_shortcode__clear_session'); |
|
86 | + // remove all unwanted records from the db |
|
87 | + if (EE_Registry::instance()->CART instanceof EE_Cart) { |
|
88 | + EE_Registry::instance()->CART->delete_cart(); |
|
89 | + } |
|
90 | + EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
91 | + return sprintf( |
|
92 | + __( |
|
93 | + '%sAll unsaved registration information entered during this session has been deleted.%s', |
|
94 | + 'event_espresso' |
|
95 | + ), |
|
96 | + '<p class="ee-registrations-cancelled-pg ee-attention">', |
|
97 | + '</p>' |
|
98 | + ); |
|
99 | + } |
|
100 | 100 | |
101 | 101 | } |
102 | 102 | // End of file EspressoCancelled.php |
@@ -8,44 +8,44 @@ |
||
8 | 8 | interface ShortcodeInterface |
9 | 9 | { |
10 | 10 | |
11 | - /** |
|
12 | - * the actual shortcode tag that gets registered with WordPress |
|
13 | - * |
|
14 | - * @return string |
|
15 | - */ |
|
16 | - public function getTag(); |
|
17 | - |
|
18 | - /** |
|
19 | - * the length of time in seconds to cache the results of the processShortcode() method |
|
20 | - * 0 means the processShortcode() results will NOT be cached at all |
|
21 | - * |
|
22 | - * @return int |
|
23 | - */ |
|
24 | - public function cacheExpiration(); |
|
25 | - |
|
26 | - /** |
|
27 | - * a place for adding any initialization code that needs to run prior to wp_header(). |
|
28 | - * this may be required for shortcodes that utilize a corresponding module, |
|
29 | - * and need to enqueue assets for that module |
|
30 | - * |
|
31 | - * !!! IMPORTANT !!! |
|
32 | - * After performing any logic within this method required for initialization |
|
33 | - * $this->shortcodeHasBeenInitialized(); |
|
34 | - * should be called to ensure that the shortcode is setup correctly. |
|
35 | - * |
|
36 | - * @return void |
|
37 | - */ |
|
38 | - public function initializeShortcode(); |
|
39 | - |
|
40 | - /** |
|
41 | - * callback that runs when the shortcode is encountered in post content. |
|
42 | - * IMPORTANT !!! |
|
43 | - * remember that shortcode content should be RETURNED and NOT echoed out |
|
44 | - * |
|
45 | - * @param array $attributes |
|
46 | - * @return string |
|
47 | - */ |
|
48 | - public function processShortcode($attributes = array()); |
|
11 | + /** |
|
12 | + * the actual shortcode tag that gets registered with WordPress |
|
13 | + * |
|
14 | + * @return string |
|
15 | + */ |
|
16 | + public function getTag(); |
|
17 | + |
|
18 | + /** |
|
19 | + * the length of time in seconds to cache the results of the processShortcode() method |
|
20 | + * 0 means the processShortcode() results will NOT be cached at all |
|
21 | + * |
|
22 | + * @return int |
|
23 | + */ |
|
24 | + public function cacheExpiration(); |
|
25 | + |
|
26 | + /** |
|
27 | + * a place for adding any initialization code that needs to run prior to wp_header(). |
|
28 | + * this may be required for shortcodes that utilize a corresponding module, |
|
29 | + * and need to enqueue assets for that module |
|
30 | + * |
|
31 | + * !!! IMPORTANT !!! |
|
32 | + * After performing any logic within this method required for initialization |
|
33 | + * $this->shortcodeHasBeenInitialized(); |
|
34 | + * should be called to ensure that the shortcode is setup correctly. |
|
35 | + * |
|
36 | + * @return void |
|
37 | + */ |
|
38 | + public function initializeShortcode(); |
|
39 | + |
|
40 | + /** |
|
41 | + * callback that runs when the shortcode is encountered in post content. |
|
42 | + * IMPORTANT !!! |
|
43 | + * remember that shortcode content should be RETURNED and NOT echoed out |
|
44 | + * |
|
45 | + * @param array $attributes |
|
46 | + * @return string |
|
47 | + */ |
|
48 | + public function processShortcode($attributes = array()); |
|
49 | 49 | |
50 | 50 | } |
51 | 51 | // End of file ShortcodeInterface.php |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | } |
82 | 82 | } |
83 | 83 | return $this->shortcodeContent( |
84 | - $this->sanitizeAttributes((array)$attributes) |
|
84 | + $this->sanitizeAttributes((array) $attributes) |
|
85 | 85 | ); |
86 | 86 | } |
87 | 87 | |
@@ -109,8 +109,8 @@ discard block |
||
109 | 109 | // serialized attributes |
110 | 110 | wp_json_encode($attributes), |
111 | 111 | // Closure for generating content if cache is expired |
112 | - function () use ($shortcode, $attributes) { |
|
113 | - if($shortcode->initialized === false){ |
|
112 | + function() use ($shortcode, $attributes) { |
|
113 | + if ($shortcode->initialized === false) { |
|
114 | 114 | $shortcode->initializeShortcode(); |
115 | 115 | } |
116 | 116 | return $shortcode->processShortcode($attributes); |
@@ -21,219 +21,219 @@ |
||
21 | 21 | abstract class EspressoShortcode implements ShortcodeInterface |
22 | 22 | { |
23 | 23 | |
24 | - /** |
|
25 | - * transient prefix |
|
26 | - * |
|
27 | - * @type string |
|
28 | - */ |
|
29 | - const CACHE_TRANSIENT_PREFIX = 'ee_sc_'; |
|
30 | - |
|
31 | - /** |
|
32 | - * @var PostRelatedCacheManager $cache_manager |
|
33 | - */ |
|
34 | - private $cache_manager; |
|
35 | - |
|
36 | - /** |
|
37 | - * true if ShortcodeInterface::initializeShortcode() has been called |
|
38 | - * if false, then that will get called before processing |
|
39 | - * |
|
40 | - * @var boolean $initialized |
|
41 | - */ |
|
42 | - private $initialized = false; |
|
43 | - |
|
44 | - |
|
45 | - |
|
46 | - /** |
|
47 | - * EspressoShortcode constructor |
|
48 | - * |
|
49 | - * @param PostRelatedCacheManager $cache_manager |
|
50 | - */ |
|
51 | - public function __construct(PostRelatedCacheManager $cache_manager) |
|
52 | - { |
|
53 | - $this->cache_manager = $cache_manager; |
|
54 | - } |
|
55 | - |
|
56 | - |
|
57 | - |
|
58 | - /** |
|
59 | - * @return void |
|
60 | - */ |
|
61 | - public function shortcodeHasBeenInitialized() |
|
62 | - { |
|
63 | - $this->initialized = true; |
|
64 | - } |
|
65 | - |
|
66 | - |
|
67 | - |
|
68 | - /** |
|
69 | - * enqueues scripts then processes the shortcode |
|
70 | - * |
|
71 | - * @param array $attributes |
|
72 | - * @return string |
|
73 | - * @throws EE_Error |
|
74 | - */ |
|
75 | - final public function processShortcodeCallback($attributes = array()) |
|
76 | - { |
|
77 | - if ($this instanceof EnqueueAssetsInterface) { |
|
78 | - if (is_admin()) { |
|
79 | - $this->enqueueAdminScripts(); |
|
80 | - } else { |
|
81 | - $this->enqueueScripts(); |
|
82 | - } |
|
83 | - } |
|
84 | - return $this->shortcodeContent( |
|
85 | - $this->sanitizeAttributes((array)$attributes) |
|
86 | - ); |
|
87 | - } |
|
88 | - |
|
89 | - |
|
90 | - |
|
91 | - /** |
|
92 | - * If shortcode caching is enabled for the shortcode, |
|
93 | - * and cached results exist, then that will be returned |
|
94 | - * else new content will be generated. |
|
95 | - * If caching is enabled, then the new content will be cached for later. |
|
96 | - * |
|
97 | - * @param array $attributes |
|
98 | - * @return mixed|string |
|
99 | - * @throws EE_Error |
|
100 | - */ |
|
101 | - private function shortcodeContent(array $attributes) |
|
102 | - { |
|
103 | - $shortcode = $this; |
|
104 | - $post_ID = $this->currentPostID(); |
|
105 | - // something like "SC_EVENTS-123" |
|
106 | - $cache_ID = $this->shortcodeCacheID($post_ID); |
|
107 | - $this->cache_manager->clearPostRelatedCacheOnUpdate($post_ID, $cache_ID); |
|
108 | - return $this->cache_manager->get( |
|
109 | - $cache_ID, |
|
110 | - // serialized attributes |
|
111 | - wp_json_encode($attributes), |
|
112 | - // Closure for generating content if cache is expired |
|
113 | - function () use ($shortcode, $attributes) { |
|
114 | - if($shortcode->initialized === false){ |
|
115 | - $shortcode->initializeShortcode(); |
|
116 | - } |
|
117 | - return $shortcode->processShortcode($attributes); |
|
118 | - }, |
|
119 | - // filterable cache expiration set by each shortcode |
|
120 | - apply_filters( |
|
121 | - 'FHEE__EventEspresso_core_services_shortcodes_EspressoShortcode__shortcodeContent__cache_expiration', |
|
122 | - $this->cacheExpiration(), |
|
123 | - $this->getTag(), |
|
124 | - $this |
|
125 | - ) |
|
126 | - ); |
|
127 | - } |
|
128 | - |
|
129 | - |
|
130 | - |
|
131 | - /** |
|
132 | - * @return int |
|
133 | - * @throws EE_Error |
|
134 | - */ |
|
135 | - private function currentPostID() |
|
136 | - { |
|
137 | - // try to get EE_Event any way we can |
|
138 | - $event = EEH_Event_View::get_event(); |
|
139 | - // then get some kind of ID |
|
140 | - if ($event instanceof \EE_Event) { |
|
141 | - $post_ID = $event->ID(); |
|
142 | - } else { |
|
143 | - global $post; |
|
144 | - $post_ID = $post->ID; |
|
145 | - } |
|
146 | - return $post_ID; |
|
147 | - } |
|
148 | - |
|
149 | - |
|
150 | - |
|
151 | - /** |
|
152 | - * @param int $post_ID |
|
153 | - * @return string |
|
154 | - * @throws EE_Error |
|
155 | - */ |
|
156 | - private function shortcodeCacheID($post_ID) |
|
157 | - { |
|
158 | - $tag = str_replace('ESPRESSO_', '', $this->getTag()); |
|
159 | - return "SC_{$tag}-{$post_ID}"; |
|
160 | - } |
|
161 | - |
|
162 | - |
|
163 | - |
|
164 | - /** |
|
165 | - * array for defining custom attribute sanitization callbacks, |
|
166 | - * where keys match keys in your attributes array, |
|
167 | - * and values represent the sanitization function you wish to be applied to that attribute. |
|
168 | - * So for example, if you had an integer attribute named "event_id" |
|
169 | - * that you wanted to be sanitized using absint(), |
|
170 | - * then you would return the following: |
|
171 | - * array('event_id' => 'absint') |
|
172 | - * Entering 'skip_sanitization' for the callback value |
|
173 | - * means that no sanitization will be applied |
|
174 | - * on the assumption that the attribute |
|
175 | - * will be sanitized at some point... right? |
|
176 | - * You wouldn't pass around unsanitized attributes would you? |
|
177 | - * That would be very Tom Foolery of you!!! |
|
178 | - * |
|
179 | - * @return array |
|
180 | - */ |
|
181 | - protected function customAttributeSanitizationMap() |
|
182 | - { |
|
183 | - return array(); |
|
184 | - } |
|
185 | - |
|
186 | - |
|
187 | - |
|
188 | - /** |
|
189 | - * Performs basic sanitization on shortcode attributes |
|
190 | - * Since incoming attributes from the shortcode usage in the WP editor will all be strings, |
|
191 | - * most attributes will by default be sanitized using the sanitize_text_field() function. |
|
192 | - * This can be overridden using the customAttributeSanitizationMap() method (see above), |
|
193 | - * all other attributes would be sanitized using the defaults in the switch statement below |
|
194 | - * |
|
195 | - * @param array $attributes |
|
196 | - * @return array |
|
197 | - */ |
|
198 | - private function sanitizeAttributes(array $attributes) |
|
199 | - { |
|
200 | - $custom_sanitization = $this->customAttributeSanitizationMap(); |
|
201 | - foreach ($attributes as $key => $value) { |
|
202 | - // is a custom sanitization callback specified ? |
|
203 | - if (isset($custom_sanitization[$key])) { |
|
204 | - $callback = $custom_sanitization[$key]; |
|
205 | - if ($callback === 'skip_sanitization') { |
|
206 | - $attributes[$key] = $value; |
|
207 | - continue; |
|
208 | - } |
|
209 | - if (function_exists($callback)) { |
|
210 | - $attributes[$key] = $callback($value); |
|
211 | - continue; |
|
212 | - } |
|
213 | - } |
|
214 | - switch (true) { |
|
215 | - case $value === null : |
|
216 | - case is_int($value) : |
|
217 | - case is_float($value) : |
|
218 | - // typical booleans |
|
219 | - case in_array($value, array(true, 'true', '1', 'on', 'yes', false, 'false', '0', 'off', 'no'), true) : |
|
220 | - $attributes[$key] = $value; |
|
221 | - break; |
|
222 | - case is_string($value) : |
|
223 | - $attributes[$key] = sanitize_text_field($value); |
|
224 | - break; |
|
225 | - case is_array($value) : |
|
226 | - $attributes[$key] = $this->sanitizeAttributes($value); |
|
227 | - break; |
|
228 | - default : |
|
229 | - // only remaining data types are Object and Resource |
|
230 | - // which are not allowed as shortcode attributes |
|
231 | - $attributes[$key] = null; |
|
232 | - break; |
|
233 | - } |
|
234 | - } |
|
235 | - return $attributes; |
|
236 | - } |
|
24 | + /** |
|
25 | + * transient prefix |
|
26 | + * |
|
27 | + * @type string |
|
28 | + */ |
|
29 | + const CACHE_TRANSIENT_PREFIX = 'ee_sc_'; |
|
30 | + |
|
31 | + /** |
|
32 | + * @var PostRelatedCacheManager $cache_manager |
|
33 | + */ |
|
34 | + private $cache_manager; |
|
35 | + |
|
36 | + /** |
|
37 | + * true if ShortcodeInterface::initializeShortcode() has been called |
|
38 | + * if false, then that will get called before processing |
|
39 | + * |
|
40 | + * @var boolean $initialized |
|
41 | + */ |
|
42 | + private $initialized = false; |
|
43 | + |
|
44 | + |
|
45 | + |
|
46 | + /** |
|
47 | + * EspressoShortcode constructor |
|
48 | + * |
|
49 | + * @param PostRelatedCacheManager $cache_manager |
|
50 | + */ |
|
51 | + public function __construct(PostRelatedCacheManager $cache_manager) |
|
52 | + { |
|
53 | + $this->cache_manager = $cache_manager; |
|
54 | + } |
|
55 | + |
|
56 | + |
|
57 | + |
|
58 | + /** |
|
59 | + * @return void |
|
60 | + */ |
|
61 | + public function shortcodeHasBeenInitialized() |
|
62 | + { |
|
63 | + $this->initialized = true; |
|
64 | + } |
|
65 | + |
|
66 | + |
|
67 | + |
|
68 | + /** |
|
69 | + * enqueues scripts then processes the shortcode |
|
70 | + * |
|
71 | + * @param array $attributes |
|
72 | + * @return string |
|
73 | + * @throws EE_Error |
|
74 | + */ |
|
75 | + final public function processShortcodeCallback($attributes = array()) |
|
76 | + { |
|
77 | + if ($this instanceof EnqueueAssetsInterface) { |
|
78 | + if (is_admin()) { |
|
79 | + $this->enqueueAdminScripts(); |
|
80 | + } else { |
|
81 | + $this->enqueueScripts(); |
|
82 | + } |
|
83 | + } |
|
84 | + return $this->shortcodeContent( |
|
85 | + $this->sanitizeAttributes((array)$attributes) |
|
86 | + ); |
|
87 | + } |
|
88 | + |
|
89 | + |
|
90 | + |
|
91 | + /** |
|
92 | + * If shortcode caching is enabled for the shortcode, |
|
93 | + * and cached results exist, then that will be returned |
|
94 | + * else new content will be generated. |
|
95 | + * If caching is enabled, then the new content will be cached for later. |
|
96 | + * |
|
97 | + * @param array $attributes |
|
98 | + * @return mixed|string |
|
99 | + * @throws EE_Error |
|
100 | + */ |
|
101 | + private function shortcodeContent(array $attributes) |
|
102 | + { |
|
103 | + $shortcode = $this; |
|
104 | + $post_ID = $this->currentPostID(); |
|
105 | + // something like "SC_EVENTS-123" |
|
106 | + $cache_ID = $this->shortcodeCacheID($post_ID); |
|
107 | + $this->cache_manager->clearPostRelatedCacheOnUpdate($post_ID, $cache_ID); |
|
108 | + return $this->cache_manager->get( |
|
109 | + $cache_ID, |
|
110 | + // serialized attributes |
|
111 | + wp_json_encode($attributes), |
|
112 | + // Closure for generating content if cache is expired |
|
113 | + function () use ($shortcode, $attributes) { |
|
114 | + if($shortcode->initialized === false){ |
|
115 | + $shortcode->initializeShortcode(); |
|
116 | + } |
|
117 | + return $shortcode->processShortcode($attributes); |
|
118 | + }, |
|
119 | + // filterable cache expiration set by each shortcode |
|
120 | + apply_filters( |
|
121 | + 'FHEE__EventEspresso_core_services_shortcodes_EspressoShortcode__shortcodeContent__cache_expiration', |
|
122 | + $this->cacheExpiration(), |
|
123 | + $this->getTag(), |
|
124 | + $this |
|
125 | + ) |
|
126 | + ); |
|
127 | + } |
|
128 | + |
|
129 | + |
|
130 | + |
|
131 | + /** |
|
132 | + * @return int |
|
133 | + * @throws EE_Error |
|
134 | + */ |
|
135 | + private function currentPostID() |
|
136 | + { |
|
137 | + // try to get EE_Event any way we can |
|
138 | + $event = EEH_Event_View::get_event(); |
|
139 | + // then get some kind of ID |
|
140 | + if ($event instanceof \EE_Event) { |
|
141 | + $post_ID = $event->ID(); |
|
142 | + } else { |
|
143 | + global $post; |
|
144 | + $post_ID = $post->ID; |
|
145 | + } |
|
146 | + return $post_ID; |
|
147 | + } |
|
148 | + |
|
149 | + |
|
150 | + |
|
151 | + /** |
|
152 | + * @param int $post_ID |
|
153 | + * @return string |
|
154 | + * @throws EE_Error |
|
155 | + */ |
|
156 | + private function shortcodeCacheID($post_ID) |
|
157 | + { |
|
158 | + $tag = str_replace('ESPRESSO_', '', $this->getTag()); |
|
159 | + return "SC_{$tag}-{$post_ID}"; |
|
160 | + } |
|
161 | + |
|
162 | + |
|
163 | + |
|
164 | + /** |
|
165 | + * array for defining custom attribute sanitization callbacks, |
|
166 | + * where keys match keys in your attributes array, |
|
167 | + * and values represent the sanitization function you wish to be applied to that attribute. |
|
168 | + * So for example, if you had an integer attribute named "event_id" |
|
169 | + * that you wanted to be sanitized using absint(), |
|
170 | + * then you would return the following: |
|
171 | + * array('event_id' => 'absint') |
|
172 | + * Entering 'skip_sanitization' for the callback value |
|
173 | + * means that no sanitization will be applied |
|
174 | + * on the assumption that the attribute |
|
175 | + * will be sanitized at some point... right? |
|
176 | + * You wouldn't pass around unsanitized attributes would you? |
|
177 | + * That would be very Tom Foolery of you!!! |
|
178 | + * |
|
179 | + * @return array |
|
180 | + */ |
|
181 | + protected function customAttributeSanitizationMap() |
|
182 | + { |
|
183 | + return array(); |
|
184 | + } |
|
185 | + |
|
186 | + |
|
187 | + |
|
188 | + /** |
|
189 | + * Performs basic sanitization on shortcode attributes |
|
190 | + * Since incoming attributes from the shortcode usage in the WP editor will all be strings, |
|
191 | + * most attributes will by default be sanitized using the sanitize_text_field() function. |
|
192 | + * This can be overridden using the customAttributeSanitizationMap() method (see above), |
|
193 | + * all other attributes would be sanitized using the defaults in the switch statement below |
|
194 | + * |
|
195 | + * @param array $attributes |
|
196 | + * @return array |
|
197 | + */ |
|
198 | + private function sanitizeAttributes(array $attributes) |
|
199 | + { |
|
200 | + $custom_sanitization = $this->customAttributeSanitizationMap(); |
|
201 | + foreach ($attributes as $key => $value) { |
|
202 | + // is a custom sanitization callback specified ? |
|
203 | + if (isset($custom_sanitization[$key])) { |
|
204 | + $callback = $custom_sanitization[$key]; |
|
205 | + if ($callback === 'skip_sanitization') { |
|
206 | + $attributes[$key] = $value; |
|
207 | + continue; |
|
208 | + } |
|
209 | + if (function_exists($callback)) { |
|
210 | + $attributes[$key] = $callback($value); |
|
211 | + continue; |
|
212 | + } |
|
213 | + } |
|
214 | + switch (true) { |
|
215 | + case $value === null : |
|
216 | + case is_int($value) : |
|
217 | + case is_float($value) : |
|
218 | + // typical booleans |
|
219 | + case in_array($value, array(true, 'true', '1', 'on', 'yes', false, 'false', '0', 'off', 'no'), true) : |
|
220 | + $attributes[$key] = $value; |
|
221 | + break; |
|
222 | + case is_string($value) : |
|
223 | + $attributes[$key] = sanitize_text_field($value); |
|
224 | + break; |
|
225 | + case is_array($value) : |
|
226 | + $attributes[$key] = $this->sanitizeAttributes($value); |
|
227 | + break; |
|
228 | + default : |
|
229 | + // only remaining data types are Object and Resource |
|
230 | + // which are not allowed as shortcode attributes |
|
231 | + $attributes[$key] = null; |
|
232 | + break; |
|
233 | + } |
|
234 | + } |
|
235 | + return $attributes; |
|
236 | + } |
|
237 | 237 | |
238 | 238 | |
239 | 239 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
2 | - exit('No direct script access allowed'); |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | |
5 | 5 | |
@@ -15,117 +15,117 @@ discard block |
||
15 | 15 | class EE_Email_Validation_Strategy extends EE_Text_Validation_Strategy |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * @param null $validation_error_message |
|
20 | - */ |
|
21 | - public function __construct($validation_error_message = null) |
|
22 | - { |
|
23 | - if (! $validation_error_message) { |
|
24 | - $validation_error_message = __("Please enter a valid email address.", "event_espresso"); |
|
25 | - } |
|
26 | - parent::__construct($validation_error_message); |
|
27 | - } |
|
18 | + /** |
|
19 | + * @param null $validation_error_message |
|
20 | + */ |
|
21 | + public function __construct($validation_error_message = null) |
|
22 | + { |
|
23 | + if (! $validation_error_message) { |
|
24 | + $validation_error_message = __("Please enter a valid email address.", "event_espresso"); |
|
25 | + } |
|
26 | + parent::__construct($validation_error_message); |
|
27 | + } |
|
28 | 28 | |
29 | 29 | |
30 | 30 | |
31 | - /** |
|
32 | - * just checks the field isn't blank |
|
33 | - * |
|
34 | - * @param $normalized_value |
|
35 | - * @return bool |
|
36 | - * @throws \EE_Validation_Error |
|
37 | - */ |
|
38 | - public function validate($normalized_value) |
|
39 | - { |
|
40 | - if ($normalized_value && ! $this->_validate_email($normalized_value)) { |
|
41 | - throw new EE_Validation_Error($this->get_validation_error_message(), 'required'); |
|
42 | - } |
|
43 | - } |
|
31 | + /** |
|
32 | + * just checks the field isn't blank |
|
33 | + * |
|
34 | + * @param $normalized_value |
|
35 | + * @return bool |
|
36 | + * @throws \EE_Validation_Error |
|
37 | + */ |
|
38 | + public function validate($normalized_value) |
|
39 | + { |
|
40 | + if ($normalized_value && ! $this->_validate_email($normalized_value)) { |
|
41 | + throw new EE_Validation_Error($this->get_validation_error_message(), 'required'); |
|
42 | + } |
|
43 | + } |
|
44 | 44 | |
45 | 45 | |
46 | 46 | |
47 | - /** |
|
48 | - * @return array |
|
49 | - */ |
|
50 | - public function get_jquery_validation_rule_array() |
|
51 | - { |
|
52 | - return array('email' => true, 'messages' => array('email' => $this->get_validation_error_message())); |
|
53 | - } |
|
47 | + /** |
|
48 | + * @return array |
|
49 | + */ |
|
50 | + public function get_jquery_validation_rule_array() |
|
51 | + { |
|
52 | + return array('email' => true, 'messages' => array('email' => $this->get_validation_error_message())); |
|
53 | + } |
|
54 | 54 | |
55 | 55 | |
56 | 56 | |
57 | - /** |
|
58 | - * Validate an email address. |
|
59 | - * Provide email address (raw input) |
|
60 | - * |
|
61 | - * @param $email |
|
62 | - * @return bool of whether the email is valid or not |
|
63 | - * @throws \EE_Validation_Error |
|
64 | - */ |
|
65 | - private function _validate_email($email) |
|
66 | - { |
|
67 | - $validation_level = isset(EE_Registry::instance()->CFG->registration->email_validation_level) |
|
68 | - ? EE_Registry::instance()->CFG->registration->email_validation_level |
|
69 | - : 'wp_default'; |
|
70 | - if (! preg_match('/^.+\@\S+$/', $email)) { // \.\S+ |
|
71 | - // email not in correct {string}@{string} format |
|
72 | - return false; |
|
73 | - } else { |
|
74 | - $atIndex = strrpos($email, "@"); |
|
75 | - $domain = substr($email, $atIndex + 1); |
|
76 | - $local = substr($email, 0, $atIndex); |
|
77 | - $localLen = strlen($local); |
|
78 | - $domainLen = strlen($domain); |
|
79 | - if ($localLen < 1 || $localLen > 64) { |
|
80 | - // local part length exceeded |
|
81 | - return false; |
|
82 | - } else if ($domainLen < 1 || $domainLen > 255) { |
|
83 | - // domain part length exceeded |
|
84 | - return false; |
|
85 | - } else if ($local[0] === '.' || $local[$localLen - 1] === '.') { |
|
86 | - // local part starts or ends with '.' |
|
87 | - return false; |
|
88 | - } else if (preg_match('/\\.\\./', $local)) { |
|
89 | - // local part has two consecutive dots |
|
90 | - return false; |
|
91 | - } else if (preg_match('/\\.\\./', $domain)) { |
|
92 | - // domain part has two consecutive dots |
|
93 | - return false; |
|
94 | - } else if ($validation_level === 'wp_default') { |
|
95 | - return is_email($email); |
|
96 | - } else if ( |
|
97 | - ($validation_level === 'i18n' || $validation_level === 'i18n_dns') |
|
98 | - // plz see http://stackoverflow.com/a/24817336 re: the following regex |
|
99 | - && ! preg_match( |
|
100 | - '/^(?!\.)((?!.*\.{2})[a-zA-Z0-9\x{0080}-\x{00FF}\x{0100}-\x{017F}\x{0180}-\x{024F}\x{0250}-\x{02AF}\x{0300}-\x{036F}\x{0370}-\x{03FF}\x{0400}-\x{04FF}\x{0500}-\x{052F}\x{0530}-\x{058F}\x{0590}-\x{05FF}\x{0600}-\x{06FF}\x{0700}-\x{074F}\x{0750}-\x{077F}\x{0780}-\x{07BF}\x{07C0}-\x{07FF}\x{0900}-\x{097F}\x{0980}-\x{09FF}\x{0A00}-\x{0A7F}\x{0A80}-\x{0AFF}\x{0B00}-\x{0B7F}\x{0B80}-\x{0BFF}\x{0C00}-\x{0C7F}\x{0C80}-\x{0CFF}\x{0D00}-\x{0D7F}\x{0D80}-\x{0DFF}\x{0E00}-\x{0E7F}\x{0E80}-\x{0EFF}\x{0F00}-\x{0FFF}\x{1000}-\x{109F}\x{10A0}-\x{10FF}\x{1100}-\x{11FF}\x{1200}-\x{137F}\x{1380}-\x{139F}\x{13A0}-\x{13FF}\x{1400}-\x{167F}\x{1680}-\x{169F}\x{16A0}-\x{16FF}\x{1700}-\x{171F}\x{1720}-\x{173F}\x{1740}-\x{175F}\x{1760}-\x{177F}\x{1780}-\x{17FF}\x{1800}-\x{18AF}\x{1900}-\x{194F}\x{1950}-\x{197F}\x{1980}-\x{19DF}\x{19E0}-\x{19FF}\x{1A00}-\x{1A1F}\x{1B00}-\x{1B7F}\x{1D00}-\x{1D7F}\x{1D80}-\x{1DBF}\x{1DC0}-\x{1DFF}\x{1E00}-\x{1EFF}\x{1F00}-\x{1FFF}\x{20D0}-\x{20FF}\x{2100}-\x{214F}\x{2C00}-\x{2C5F}\x{2C60}-\x{2C7F}\x{2C80}-\x{2CFF}\x{2D00}-\x{2D2F}\x{2D30}-\x{2D7F}\x{2D80}-\x{2DDF}\x{2F00}-\x{2FDF}\x{2FF0}-\x{2FFF}\x{3040}-\x{309F}\x{30A0}-\x{30FF}\x{3100}-\x{312F}\x{3130}-\x{318F}\x{3190}-\x{319F}\x{31C0}-\x{31EF}\x{31F0}-\x{31FF}\x{3200}-\x{32FF}\x{3300}-\x{33FF}\x{3400}-\x{4DBF}\x{4DC0}-\x{4DFF}\x{4E00}-\x{9FFF}\x{A000}-\x{A48F}\x{A490}-\x{A4CF}\x{A700}-\x{A71F}\x{A800}-\x{A82F}\x{A840}-\x{A87F}\x{AC00}-\x{D7AF}\x{F900}-\x{FAFF}\.!#$%&\'*+-\/=?^_`{|}~\-\d]+)@(?!\.)([a-zA-Z0-9\x{0080}-\x{00FF}\x{0100}-\x{017F}\x{0180}-\x{024F}\x{0250}-\x{02AF}\x{0300}-\x{036F}\x{0370}-\x{03FF}\x{0400}-\x{04FF}\x{0500}-\x{052F}\x{0530}-\x{058F}\x{0590}-\x{05FF}\x{0600}-\x{06FF}\x{0700}-\x{074F}\x{0750}-\x{077F}\x{0780}-\x{07BF}\x{07C0}-\x{07FF}\x{0900}-\x{097F}\x{0980}-\x{09FF}\x{0A00}-\x{0A7F}\x{0A80}-\x{0AFF}\x{0B00}-\x{0B7F}\x{0B80}-\x{0BFF}\x{0C00}-\x{0C7F}\x{0C80}-\x{0CFF}\x{0D00}-\x{0D7F}\x{0D80}-\x{0DFF}\x{0E00}-\x{0E7F}\x{0E80}-\x{0EFF}\x{0F00}-\x{0FFF}\x{1000}-\x{109F}\x{10A0}-\x{10FF}\x{1100}-\x{11FF}\x{1200}-\x{137F}\x{1380}-\x{139F}\x{13A0}-\x{13FF}\x{1400}-\x{167F}\x{1680}-\x{169F}\x{16A0}-\x{16FF}\x{1700}-\x{171F}\x{1720}-\x{173F}\x{1740}-\x{175F}\x{1760}-\x{177F}\x{1780}-\x{17FF}\x{1800}-\x{18AF}\x{1900}-\x{194F}\x{1950}-\x{197F}\x{1980}-\x{19DF}\x{19E0}-\x{19FF}\x{1A00}-\x{1A1F}\x{1B00}-\x{1B7F}\x{1D00}-\x{1D7F}\x{1D80}-\x{1DBF}\x{1DC0}-\x{1DFF}\x{1E00}-\x{1EFF}\x{1F00}-\x{1FFF}\x{20D0}-\x{20FF}\x{2100}-\x{214F}\x{2C00}-\x{2C5F}\x{2C60}-\x{2C7F}\x{2C80}-\x{2CFF}\x{2D00}-\x{2D2F}\x{2D30}-\x{2D7F}\x{2D80}-\x{2DDF}\x{2F00}-\x{2FDF}\x{2FF0}-\x{2FFF}\x{3040}-\x{309F}\x{30A0}-\x{30FF}\x{3100}-\x{312F}\x{3130}-\x{318F}\x{3190}-\x{319F}\x{31C0}-\x{31EF}\x{31F0}-\x{31FF}\x{3200}-\x{32FF}\x{3300}-\x{33FF}\x{3400}-\x{4DBF}\x{4DC0}-\x{4DFF}\x{4E00}-\x{9FFF}\x{A000}-\x{A48F}\x{A490}-\x{A4CF}\x{A700}-\x{A71F}\x{A800}-\x{A82F}\x{A840}-\x{A87F}\x{AC00}-\x{D7AF}\x{F900}-\x{FAFF}\-\.\d]+)((\.([a-zA-Z\x{0080}-\x{00FF}\x{0100}-\x{017F}\x{0180}-\x{024F}\x{0250}-\x{02AF}\x{0300}-\x{036F}\x{0370}-\x{03FF}\x{0400}-\x{04FF}\x{0500}-\x{052F}\x{0530}-\x{058F}\x{0590}-\x{05FF}\x{0600}-\x{06FF}\x{0700}-\x{074F}\x{0750}-\x{077F}\x{0780}-\x{07BF}\x{07C0}-\x{07FF}\x{0900}-\x{097F}\x{0980}-\x{09FF}\x{0A00}-\x{0A7F}\x{0A80}-\x{0AFF}\x{0B00}-\x{0B7F}\x{0B80}-\x{0BFF}\x{0C00}-\x{0C7F}\x{0C80}-\x{0CFF}\x{0D00}-\x{0D7F}\x{0D80}-\x{0DFF}\x{0E00}-\x{0E7F}\x{0E80}-\x{0EFF}\x{0F00}-\x{0FFF}\x{1000}-\x{109F}\x{10A0}-\x{10FF}\x{1100}-\x{11FF}\x{1200}-\x{137F}\x{1380}-\x{139F}\x{13A0}-\x{13FF}\x{1400}-\x{167F}\x{1680}-\x{169F}\x{16A0}-\x{16FF}\x{1700}-\x{171F}\x{1720}-\x{173F}\x{1740}-\x{175F}\x{1760}-\x{177F}\x{1780}-\x{17FF}\x{1800}-\x{18AF}\x{1900}-\x{194F}\x{1950}-\x{197F}\x{1980}-\x{19DF}\x{19E0}-\x{19FF}\x{1A00}-\x{1A1F}\x{1B00}-\x{1B7F}\x{1D00}-\x{1D7F}\x{1D80}-\x{1DBF}\x{1DC0}-\x{1DFF}\x{1E00}-\x{1EFF}\x{1F00}-\x{1FFF}\x{20D0}-\x{20FF}\x{2100}-\x{214F}\x{2C00}-\x{2C5F}\x{2C60}-\x{2C7F}\x{2C80}-\x{2CFF}\x{2D00}-\x{2D2F}\x{2D30}-\x{2D7F}\x{2D80}-\x{2DDF}\x{2F00}-\x{2FDF}\x{2FF0}-\x{2FFF}\x{3040}-\x{309F}\x{30A0}-\x{30FF}\x{3100}-\x{312F}\x{3130}-\x{318F}\x{3190}-\x{319F}\x{31C0}-\x{31EF}\x{31F0}-\x{31FF}\x{3200}-\x{32FF}\x{3300}-\x{33FF}\x{3400}-\x{4DBF}\x{4DC0}-\x{4DFF}\x{4E00}-\x{9FFF}\x{A000}-\x{A48F}\x{A490}-\x{A4CF}\x{A700}-\x{A71F}\x{A800}-\x{A82F}\x{A840}-\x{A87F}\x{AC00}-\x{D7AF}\x{F900}-\x{FAFF}]){2,63})+)$/u', |
|
101 | ||
102 | - ) |
|
103 | - ) { |
|
104 | - return false; |
|
105 | - } |
|
106 | - if ($validation_level === 'i18n_dns') { |
|
107 | - if (! checkdnsrr($domain, "MX")) { |
|
108 | - // domain not found in MX records |
|
109 | - throw new EE_Validation_Error( |
|
110 | - __( |
|
111 | - 'Although the email address provided is formatted correctly, a valid "MX record" could not be located for that address and domain. Please enter a valid email address.', |
|
112 | - 'event_espresso' |
|
113 | - ) |
|
114 | - ); |
|
115 | - } else if (! checkdnsrr($domain, "A")) { |
|
116 | - // domain not found in A records |
|
117 | - throw new EE_Validation_Error( |
|
118 | - __( |
|
119 | - 'Although the email address provided is formatted correctly, a valid "A record" could not be located for that address and domain. Please enter a valid email address.', |
|
120 | - 'event_espresso' |
|
121 | - ) |
|
122 | - ); |
|
123 | - } |
|
124 | - } |
|
125 | - } |
|
126 | - // you have successfully run the gauntlet young Padawan |
|
127 | - return true; |
|
128 | - } |
|
57 | + /** |
|
58 | + * Validate an email address. |
|
59 | + * Provide email address (raw input) |
|
60 | + * |
|
61 | + * @param $email |
|
62 | + * @return bool of whether the email is valid or not |
|
63 | + * @throws \EE_Validation_Error |
|
64 | + */ |
|
65 | + private function _validate_email($email) |
|
66 | + { |
|
67 | + $validation_level = isset(EE_Registry::instance()->CFG->registration->email_validation_level) |
|
68 | + ? EE_Registry::instance()->CFG->registration->email_validation_level |
|
69 | + : 'wp_default'; |
|
70 | + if (! preg_match('/^.+\@\S+$/', $email)) { // \.\S+ |
|
71 | + // email not in correct {string}@{string} format |
|
72 | + return false; |
|
73 | + } else { |
|
74 | + $atIndex = strrpos($email, "@"); |
|
75 | + $domain = substr($email, $atIndex + 1); |
|
76 | + $local = substr($email, 0, $atIndex); |
|
77 | + $localLen = strlen($local); |
|
78 | + $domainLen = strlen($domain); |
|
79 | + if ($localLen < 1 || $localLen > 64) { |
|
80 | + // local part length exceeded |
|
81 | + return false; |
|
82 | + } else if ($domainLen < 1 || $domainLen > 255) { |
|
83 | + // domain part length exceeded |
|
84 | + return false; |
|
85 | + } else if ($local[0] === '.' || $local[$localLen - 1] === '.') { |
|
86 | + // local part starts or ends with '.' |
|
87 | + return false; |
|
88 | + } else if (preg_match('/\\.\\./', $local)) { |
|
89 | + // local part has two consecutive dots |
|
90 | + return false; |
|
91 | + } else if (preg_match('/\\.\\./', $domain)) { |
|
92 | + // domain part has two consecutive dots |
|
93 | + return false; |
|
94 | + } else if ($validation_level === 'wp_default') { |
|
95 | + return is_email($email); |
|
96 | + } else if ( |
|
97 | + ($validation_level === 'i18n' || $validation_level === 'i18n_dns') |
|
98 | + // plz see http://stackoverflow.com/a/24817336 re: the following regex |
|
99 | + && ! preg_match( |
|
100 | + '/^(?!\.)((?!.*\.{2})[a-zA-Z0-9\x{0080}-\x{00FF}\x{0100}-\x{017F}\x{0180}-\x{024F}\x{0250}-\x{02AF}\x{0300}-\x{036F}\x{0370}-\x{03FF}\x{0400}-\x{04FF}\x{0500}-\x{052F}\x{0530}-\x{058F}\x{0590}-\x{05FF}\x{0600}-\x{06FF}\x{0700}-\x{074F}\x{0750}-\x{077F}\x{0780}-\x{07BF}\x{07C0}-\x{07FF}\x{0900}-\x{097F}\x{0980}-\x{09FF}\x{0A00}-\x{0A7F}\x{0A80}-\x{0AFF}\x{0B00}-\x{0B7F}\x{0B80}-\x{0BFF}\x{0C00}-\x{0C7F}\x{0C80}-\x{0CFF}\x{0D00}-\x{0D7F}\x{0D80}-\x{0DFF}\x{0E00}-\x{0E7F}\x{0E80}-\x{0EFF}\x{0F00}-\x{0FFF}\x{1000}-\x{109F}\x{10A0}-\x{10FF}\x{1100}-\x{11FF}\x{1200}-\x{137F}\x{1380}-\x{139F}\x{13A0}-\x{13FF}\x{1400}-\x{167F}\x{1680}-\x{169F}\x{16A0}-\x{16FF}\x{1700}-\x{171F}\x{1720}-\x{173F}\x{1740}-\x{175F}\x{1760}-\x{177F}\x{1780}-\x{17FF}\x{1800}-\x{18AF}\x{1900}-\x{194F}\x{1950}-\x{197F}\x{1980}-\x{19DF}\x{19E0}-\x{19FF}\x{1A00}-\x{1A1F}\x{1B00}-\x{1B7F}\x{1D00}-\x{1D7F}\x{1D80}-\x{1DBF}\x{1DC0}-\x{1DFF}\x{1E00}-\x{1EFF}\x{1F00}-\x{1FFF}\x{20D0}-\x{20FF}\x{2100}-\x{214F}\x{2C00}-\x{2C5F}\x{2C60}-\x{2C7F}\x{2C80}-\x{2CFF}\x{2D00}-\x{2D2F}\x{2D30}-\x{2D7F}\x{2D80}-\x{2DDF}\x{2F00}-\x{2FDF}\x{2FF0}-\x{2FFF}\x{3040}-\x{309F}\x{30A0}-\x{30FF}\x{3100}-\x{312F}\x{3130}-\x{318F}\x{3190}-\x{319F}\x{31C0}-\x{31EF}\x{31F0}-\x{31FF}\x{3200}-\x{32FF}\x{3300}-\x{33FF}\x{3400}-\x{4DBF}\x{4DC0}-\x{4DFF}\x{4E00}-\x{9FFF}\x{A000}-\x{A48F}\x{A490}-\x{A4CF}\x{A700}-\x{A71F}\x{A800}-\x{A82F}\x{A840}-\x{A87F}\x{AC00}-\x{D7AF}\x{F900}-\x{FAFF}\.!#$%&\'*+-\/=?^_`{|}~\-\d]+)@(?!\.)([a-zA-Z0-9\x{0080}-\x{00FF}\x{0100}-\x{017F}\x{0180}-\x{024F}\x{0250}-\x{02AF}\x{0300}-\x{036F}\x{0370}-\x{03FF}\x{0400}-\x{04FF}\x{0500}-\x{052F}\x{0530}-\x{058F}\x{0590}-\x{05FF}\x{0600}-\x{06FF}\x{0700}-\x{074F}\x{0750}-\x{077F}\x{0780}-\x{07BF}\x{07C0}-\x{07FF}\x{0900}-\x{097F}\x{0980}-\x{09FF}\x{0A00}-\x{0A7F}\x{0A80}-\x{0AFF}\x{0B00}-\x{0B7F}\x{0B80}-\x{0BFF}\x{0C00}-\x{0C7F}\x{0C80}-\x{0CFF}\x{0D00}-\x{0D7F}\x{0D80}-\x{0DFF}\x{0E00}-\x{0E7F}\x{0E80}-\x{0EFF}\x{0F00}-\x{0FFF}\x{1000}-\x{109F}\x{10A0}-\x{10FF}\x{1100}-\x{11FF}\x{1200}-\x{137F}\x{1380}-\x{139F}\x{13A0}-\x{13FF}\x{1400}-\x{167F}\x{1680}-\x{169F}\x{16A0}-\x{16FF}\x{1700}-\x{171F}\x{1720}-\x{173F}\x{1740}-\x{175F}\x{1760}-\x{177F}\x{1780}-\x{17FF}\x{1800}-\x{18AF}\x{1900}-\x{194F}\x{1950}-\x{197F}\x{1980}-\x{19DF}\x{19E0}-\x{19FF}\x{1A00}-\x{1A1F}\x{1B00}-\x{1B7F}\x{1D00}-\x{1D7F}\x{1D80}-\x{1DBF}\x{1DC0}-\x{1DFF}\x{1E00}-\x{1EFF}\x{1F00}-\x{1FFF}\x{20D0}-\x{20FF}\x{2100}-\x{214F}\x{2C00}-\x{2C5F}\x{2C60}-\x{2C7F}\x{2C80}-\x{2CFF}\x{2D00}-\x{2D2F}\x{2D30}-\x{2D7F}\x{2D80}-\x{2DDF}\x{2F00}-\x{2FDF}\x{2FF0}-\x{2FFF}\x{3040}-\x{309F}\x{30A0}-\x{30FF}\x{3100}-\x{312F}\x{3130}-\x{318F}\x{3190}-\x{319F}\x{31C0}-\x{31EF}\x{31F0}-\x{31FF}\x{3200}-\x{32FF}\x{3300}-\x{33FF}\x{3400}-\x{4DBF}\x{4DC0}-\x{4DFF}\x{4E00}-\x{9FFF}\x{A000}-\x{A48F}\x{A490}-\x{A4CF}\x{A700}-\x{A71F}\x{A800}-\x{A82F}\x{A840}-\x{A87F}\x{AC00}-\x{D7AF}\x{F900}-\x{FAFF}\-\.\d]+)((\.([a-zA-Z\x{0080}-\x{00FF}\x{0100}-\x{017F}\x{0180}-\x{024F}\x{0250}-\x{02AF}\x{0300}-\x{036F}\x{0370}-\x{03FF}\x{0400}-\x{04FF}\x{0500}-\x{052F}\x{0530}-\x{058F}\x{0590}-\x{05FF}\x{0600}-\x{06FF}\x{0700}-\x{074F}\x{0750}-\x{077F}\x{0780}-\x{07BF}\x{07C0}-\x{07FF}\x{0900}-\x{097F}\x{0980}-\x{09FF}\x{0A00}-\x{0A7F}\x{0A80}-\x{0AFF}\x{0B00}-\x{0B7F}\x{0B80}-\x{0BFF}\x{0C00}-\x{0C7F}\x{0C80}-\x{0CFF}\x{0D00}-\x{0D7F}\x{0D80}-\x{0DFF}\x{0E00}-\x{0E7F}\x{0E80}-\x{0EFF}\x{0F00}-\x{0FFF}\x{1000}-\x{109F}\x{10A0}-\x{10FF}\x{1100}-\x{11FF}\x{1200}-\x{137F}\x{1380}-\x{139F}\x{13A0}-\x{13FF}\x{1400}-\x{167F}\x{1680}-\x{169F}\x{16A0}-\x{16FF}\x{1700}-\x{171F}\x{1720}-\x{173F}\x{1740}-\x{175F}\x{1760}-\x{177F}\x{1780}-\x{17FF}\x{1800}-\x{18AF}\x{1900}-\x{194F}\x{1950}-\x{197F}\x{1980}-\x{19DF}\x{19E0}-\x{19FF}\x{1A00}-\x{1A1F}\x{1B00}-\x{1B7F}\x{1D00}-\x{1D7F}\x{1D80}-\x{1DBF}\x{1DC0}-\x{1DFF}\x{1E00}-\x{1EFF}\x{1F00}-\x{1FFF}\x{20D0}-\x{20FF}\x{2100}-\x{214F}\x{2C00}-\x{2C5F}\x{2C60}-\x{2C7F}\x{2C80}-\x{2CFF}\x{2D00}-\x{2D2F}\x{2D30}-\x{2D7F}\x{2D80}-\x{2DDF}\x{2F00}-\x{2FDF}\x{2FF0}-\x{2FFF}\x{3040}-\x{309F}\x{30A0}-\x{30FF}\x{3100}-\x{312F}\x{3130}-\x{318F}\x{3190}-\x{319F}\x{31C0}-\x{31EF}\x{31F0}-\x{31FF}\x{3200}-\x{32FF}\x{3300}-\x{33FF}\x{3400}-\x{4DBF}\x{4DC0}-\x{4DFF}\x{4E00}-\x{9FFF}\x{A000}-\x{A48F}\x{A490}-\x{A4CF}\x{A700}-\x{A71F}\x{A800}-\x{A82F}\x{A840}-\x{A87F}\x{AC00}-\x{D7AF}\x{F900}-\x{FAFF}]){2,63})+)$/u', |
|
101 | ||
102 | + ) |
|
103 | + ) { |
|
104 | + return false; |
|
105 | + } |
|
106 | + if ($validation_level === 'i18n_dns') { |
|
107 | + if (! checkdnsrr($domain, "MX")) { |
|
108 | + // domain not found in MX records |
|
109 | + throw new EE_Validation_Error( |
|
110 | + __( |
|
111 | + 'Although the email address provided is formatted correctly, a valid "MX record" could not be located for that address and domain. Please enter a valid email address.', |
|
112 | + 'event_espresso' |
|
113 | + ) |
|
114 | + ); |
|
115 | + } else if (! checkdnsrr($domain, "A")) { |
|
116 | + // domain not found in A records |
|
117 | + throw new EE_Validation_Error( |
|
118 | + __( |
|
119 | + 'Although the email address provided is formatted correctly, a valid "A record" could not be located for that address and domain. Please enter a valid email address.', |
|
120 | + 'event_espresso' |
|
121 | + ) |
|
122 | + ); |
|
123 | + } |
|
124 | + } |
|
125 | + } |
|
126 | + // you have successfully run the gauntlet young Padawan |
|
127 | + return true; |
|
128 | + } |
|
129 | 129 | |
130 | 130 | |
131 | 131 | } |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | 2 | exit('No direct script access allowed'); |
3 | 3 | } |
4 | 4 | |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | */ |
21 | 21 | public function __construct($validation_error_message = null) |
22 | 22 | { |
23 | - if (! $validation_error_message) { |
|
23 | + if ( ! $validation_error_message) { |
|
24 | 24 | $validation_error_message = __("Please enter a valid email address.", "event_espresso"); |
25 | 25 | } |
26 | 26 | parent::__construct($validation_error_message); |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | $validation_level = isset(EE_Registry::instance()->CFG->registration->email_validation_level) |
68 | 68 | ? EE_Registry::instance()->CFG->registration->email_validation_level |
69 | 69 | : 'wp_default'; |
70 | - if (! preg_match('/^.+\@\S+$/', $email)) { // \.\S+ |
|
70 | + if ( ! preg_match('/^.+\@\S+$/', $email)) { // \.\S+ |
|
71 | 71 | // email not in correct {string}@{string} format |
72 | 72 | return false; |
73 | 73 | } else { |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | return false; |
105 | 105 | } |
106 | 106 | if ($validation_level === 'i18n_dns') { |
107 | - if (! checkdnsrr($domain, "MX")) { |
|
107 | + if ( ! checkdnsrr($domain, "MX")) { |
|
108 | 108 | // domain not found in MX records |
109 | 109 | throw new EE_Validation_Error( |
110 | 110 | __( |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | 'event_espresso' |
113 | 113 | ) |
114 | 114 | ); |
115 | - } else if (! checkdnsrr($domain, "A")) { |
|
115 | + } else if ( ! checkdnsrr($domain, "A")) { |
|
116 | 116 | // domain not found in A records |
117 | 117 | throw new EE_Validation_Error( |
118 | 118 | __( |
@@ -47,7 +47,7 @@ |
||
47 | 47 | /** |
48 | 48 | * This retrieves any EE_Message_Template_Group in the repo by its ID. |
49 | 49 | * |
50 | - * @param $GRP_ID |
|
50 | + * @param integer $GRP_ID |
|
51 | 51 | * @return EE_Message_Template_Group | null |
52 | 52 | */ |
53 | 53 | public function get_by_ID($GRP_ID) |
@@ -14,115 +14,115 @@ |
||
14 | 14 | { |
15 | 15 | |
16 | 16 | |
17 | - /** |
|
18 | - * EE_Message_Template_Group_Collection constructor. |
|
19 | - */ |
|
20 | - public function __construct() |
|
21 | - { |
|
22 | - $this->interface = 'EE_Message_Template_Group'; |
|
23 | - } |
|
17 | + /** |
|
18 | + * EE_Message_Template_Group_Collection constructor. |
|
19 | + */ |
|
20 | + public function __construct() |
|
21 | + { |
|
22 | + $this->interface = 'EE_Message_Template_Group'; |
|
23 | + } |
|
24 | 24 | |
25 | 25 | |
26 | - /** |
|
27 | - * Adds the Message Template Group object to the repository. |
|
28 | - * |
|
29 | - * @param $message_template_group |
|
30 | - * @param array|int $EVT_ID Some templates are specific to EVT, so this is provided as a way of |
|
31 | - * indexing the template by key. If this template is shared among multiple events then |
|
32 | - * include the events as an array. |
|
33 | - * @return bool |
|
34 | - */ |
|
35 | - public function add($message_template_group, $EVT_ID = array()) |
|
36 | - { |
|
37 | - $EVT_ID = is_array($EVT_ID) ? $EVT_ID : (array) $EVT_ID; |
|
38 | - if ($message_template_group instanceof $this->interface) { |
|
39 | - $data['key'] = $this->getKey( |
|
40 | - $message_template_group->messenger(), |
|
41 | - $message_template_group->message_type(), |
|
42 | - $EVT_ID |
|
43 | - ); |
|
44 | - return parent::add($message_template_group, $data); |
|
45 | - } |
|
46 | - return false; |
|
47 | - } |
|
26 | + /** |
|
27 | + * Adds the Message Template Group object to the repository. |
|
28 | + * |
|
29 | + * @param $message_template_group |
|
30 | + * @param array|int $EVT_ID Some templates are specific to EVT, so this is provided as a way of |
|
31 | + * indexing the template by key. If this template is shared among multiple events then |
|
32 | + * include the events as an array. |
|
33 | + * @return bool |
|
34 | + */ |
|
35 | + public function add($message_template_group, $EVT_ID = array()) |
|
36 | + { |
|
37 | + $EVT_ID = is_array($EVT_ID) ? $EVT_ID : (array) $EVT_ID; |
|
38 | + if ($message_template_group instanceof $this->interface) { |
|
39 | + $data['key'] = $this->getKey( |
|
40 | + $message_template_group->messenger(), |
|
41 | + $message_template_group->message_type(), |
|
42 | + $EVT_ID |
|
43 | + ); |
|
44 | + return parent::add($message_template_group, $data); |
|
45 | + } |
|
46 | + return false; |
|
47 | + } |
|
48 | 48 | |
49 | 49 | |
50 | - /** |
|
51 | - * This retrieves any EE_Message_Template_Group in the repo by its ID. |
|
52 | - * |
|
53 | - * @param $GRP_ID |
|
54 | - * @return EE_Message_Template_Group | null |
|
55 | - */ |
|
56 | - public function get_by_ID($GRP_ID) |
|
57 | - { |
|
58 | - $this->rewind(); |
|
59 | - while ($this->valid()) { |
|
60 | - if ($this->current()->ID() === $GRP_ID) { |
|
61 | - /** @var EE_Message_Template_Group $message_template_group */ |
|
62 | - $message_template_group = $this->current(); |
|
63 | - $this->rewind(); |
|
64 | - return $message_template_group; |
|
65 | - } |
|
66 | - $this->next(); |
|
67 | - } |
|
68 | - return null; |
|
69 | - } |
|
50 | + /** |
|
51 | + * This retrieves any EE_Message_Template_Group in the repo by its ID. |
|
52 | + * |
|
53 | + * @param $GRP_ID |
|
54 | + * @return EE_Message_Template_Group | null |
|
55 | + */ |
|
56 | + public function get_by_ID($GRP_ID) |
|
57 | + { |
|
58 | + $this->rewind(); |
|
59 | + while ($this->valid()) { |
|
60 | + if ($this->current()->ID() === $GRP_ID) { |
|
61 | + /** @var EE_Message_Template_Group $message_template_group */ |
|
62 | + $message_template_group = $this->current(); |
|
63 | + $this->rewind(); |
|
64 | + return $message_template_group; |
|
65 | + } |
|
66 | + $this->next(); |
|
67 | + } |
|
68 | + return null; |
|
69 | + } |
|
70 | 70 | |
71 | 71 | |
72 | - /** |
|
73 | - * Generates a hash used to identify a given Message Template Group. |
|
74 | - * |
|
75 | - * @param string $messenger The EE_messenger->name |
|
76 | - * @param string $message_type The EE_message_type->name |
|
77 | - * @param int $EVT_ID Optional. If the template is for a specific EVT then that should be included. |
|
78 | - * @deprecated 4.9.40.rc.017 Use getKey instead. |
|
79 | - * @return string |
|
80 | - */ |
|
81 | - public function get_key($messenger, $message_type, $EVT_ID = 0) |
|
82 | - { |
|
83 | - $EVT_ID = (array) $EVT_ID; |
|
84 | - return $this->getKey($messenger, $message_type, $EVT_ID); |
|
85 | - } |
|
72 | + /** |
|
73 | + * Generates a hash used to identify a given Message Template Group. |
|
74 | + * |
|
75 | + * @param string $messenger The EE_messenger->name |
|
76 | + * @param string $message_type The EE_message_type->name |
|
77 | + * @param int $EVT_ID Optional. If the template is for a specific EVT then that should be included. |
|
78 | + * @deprecated 4.9.40.rc.017 Use getKey instead. |
|
79 | + * @return string |
|
80 | + */ |
|
81 | + public function get_key($messenger, $message_type, $EVT_ID = 0) |
|
82 | + { |
|
83 | + $EVT_ID = (array) $EVT_ID; |
|
84 | + return $this->getKey($messenger, $message_type, $EVT_ID); |
|
85 | + } |
|
86 | 86 | |
87 | 87 | |
88 | - /** |
|
89 | - * Generates a hash used to identify a given Message Template Group |
|
90 | - * @param string $messenger The EE_messenger->name |
|
91 | - * @param string $message_type The EE_message_type->name |
|
92 | - * @param array $EVT_ID Optional. If the template is for a specific EVT_ID (or events) then that should |
|
93 | - * be included. |
|
94 | - * @since 4.9.40.rc.017 |
|
95 | - * @return string |
|
96 | - */ |
|
97 | - public function getKey($messenger, $message_type, array $EVT_ID = array()) |
|
98 | - { |
|
99 | - sort($EVT_ID); |
|
100 | - $EVT_ID = implode(',', array_unique($EVT_ID)); |
|
101 | - return md5($messenger . $message_type . $EVT_ID); |
|
102 | - } |
|
88 | + /** |
|
89 | + * Generates a hash used to identify a given Message Template Group |
|
90 | + * @param string $messenger The EE_messenger->name |
|
91 | + * @param string $message_type The EE_message_type->name |
|
92 | + * @param array $EVT_ID Optional. If the template is for a specific EVT_ID (or events) then that should |
|
93 | + * be included. |
|
94 | + * @since 4.9.40.rc.017 |
|
95 | + * @return string |
|
96 | + */ |
|
97 | + public function getKey($messenger, $message_type, array $EVT_ID = array()) |
|
98 | + { |
|
99 | + sort($EVT_ID); |
|
100 | + $EVT_ID = implode(',', array_unique($EVT_ID)); |
|
101 | + return md5($messenger . $message_type . $EVT_ID); |
|
102 | + } |
|
103 | 103 | |
104 | 104 | |
105 | - /** |
|
106 | - * This returns a saved EE_Message_Template_Group object if there is one in the repository indexed by a key matching |
|
107 | - * the given string. |
|
108 | - * |
|
109 | - * @param string $key @see EE_Message_Template_Group::get_key() to setup a key formatted for searching. |
|
110 | - * @return null|EE_Message_Template_Group |
|
111 | - */ |
|
112 | - public function get_by_key($key) |
|
113 | - { |
|
114 | - $this->rewind(); |
|
115 | - while ($this->valid()) { |
|
116 | - $data = $this->getInfo(); |
|
117 | - if (isset($data['key']) && $data['key'] === $key) { |
|
118 | - /** @var EE_Message_Template_Group $message_template_group */ |
|
119 | - $message_template_group = $this->current(); |
|
120 | - $this->rewind(); |
|
121 | - return $message_template_group; |
|
122 | - } |
|
123 | - $this->next(); |
|
124 | - } |
|
125 | - return null; |
|
126 | - } |
|
105 | + /** |
|
106 | + * This returns a saved EE_Message_Template_Group object if there is one in the repository indexed by a key matching |
|
107 | + * the given string. |
|
108 | + * |
|
109 | + * @param string $key @see EE_Message_Template_Group::get_key() to setup a key formatted for searching. |
|
110 | + * @return null|EE_Message_Template_Group |
|
111 | + */ |
|
112 | + public function get_by_key($key) |
|
113 | + { |
|
114 | + $this->rewind(); |
|
115 | + while ($this->valid()) { |
|
116 | + $data = $this->getInfo(); |
|
117 | + if (isset($data['key']) && $data['key'] === $key) { |
|
118 | + /** @var EE_Message_Template_Group $message_template_group */ |
|
119 | + $message_template_group = $this->current(); |
|
120 | + $this->rewind(); |
|
121 | + return $message_template_group; |
|
122 | + } |
|
123 | + $this->next(); |
|
124 | + } |
|
125 | + return null; |
|
126 | + } |
|
127 | 127 | |
128 | 128 | } |
@@ -98,7 +98,7 @@ |
||
98 | 98 | { |
99 | 99 | sort($EVT_ID); |
100 | 100 | $EVT_ID = implode(',', array_unique($EVT_ID)); |
101 | - return md5($messenger . $message_type . $EVT_ID); |
|
101 | + return md5($messenger.$message_type.$EVT_ID); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 |
@@ -77,7 +77,7 @@ |
||
77 | 77 | extract($attributes, EXTR_OVERWRITE); |
78 | 78 | $event_id = isset($event_id) ? $event_id : 0; |
79 | 79 | $event = EE_Registry::instance()->load_model('Event')->get_one_by_ID($event_id); |
80 | - if (! $event instanceof EE_Event) { |
|
80 | + if ( ! $event instanceof EE_Event) { |
|
81 | 81 | new ExceptionStackTraceDisplay( |
82 | 82 | new InvalidArgumentException( |
83 | 83 | sprintf( |
@@ -24,82 +24,82 @@ |
||
24 | 24 | |
25 | 25 | |
26 | 26 | |
27 | - /** |
|
28 | - * the actual shortcode tag that gets registered with WordPress |
|
29 | - * |
|
30 | - * @return string |
|
31 | - */ |
|
32 | - public function getTag() |
|
33 | - { |
|
34 | - return 'ESPRESSO_TICKET_SELECTOR'; |
|
35 | - } |
|
36 | - |
|
37 | - |
|
38 | - |
|
39 | - /** |
|
40 | - * the time in seconds to cache the results of the processShortcode() method |
|
41 | - * 0 means the processShortcode() results will NOT be cached at all |
|
42 | - * |
|
43 | - * @return int |
|
44 | - */ |
|
45 | - public function cacheExpiration() |
|
46 | - { |
|
47 | - return 0; |
|
48 | - } |
|
49 | - |
|
50 | - |
|
51 | - /** |
|
52 | - * a place for adding any initialization code that needs to run prior to wp_header(). |
|
53 | - * this may be required for shortcodes that utilize a corresponding module, |
|
54 | - * and need to enqueue assets for that module |
|
55 | - * |
|
56 | - * @return void |
|
57 | - */ |
|
58 | - public function initializeShortcode() |
|
59 | - { |
|
60 | - add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true'); |
|
61 | - $this->shortcodeHasBeenInitialized(); |
|
62 | - } |
|
63 | - |
|
64 | - |
|
65 | - |
|
66 | - /** |
|
67 | - * callback that runs when the shortcode is encountered in post content. |
|
68 | - * IMPORTANT !!! |
|
69 | - * remember that shortcode content should be RETURNED and NOT echoed out |
|
70 | - * |
|
71 | - * @param array $attributes |
|
72 | - * @return string |
|
73 | - * @throws InvalidArgumentException |
|
74 | - */ |
|
75 | - public function processShortcode($attributes = array()) |
|
76 | - { |
|
77 | - extract($attributes, EXTR_OVERWRITE); |
|
78 | - $event_id = isset($event_id) ? $event_id : 0; |
|
79 | - $event = EE_Registry::instance()->load_model('Event')->get_one_by_ID($event_id); |
|
80 | - if (! $event instanceof EE_Event) { |
|
81 | - new ExceptionStackTraceDisplay( |
|
82 | - new InvalidArgumentException( |
|
83 | - sprintf( |
|
84 | - esc_html__( |
|
85 | - 'A valid Event ID is required to use the "%1$s" shortcode.%4$sAn Event with an ID of "%2$s" could not be found.%4$sPlease verify that the shortcode added to this post\'s content includes an "%3$s" argument and that it\'s value corresponds to a valid Event ID.', |
|
86 | - 'event_espresso' |
|
87 | - ), |
|
88 | - $this->getTag(), |
|
89 | - $event_id, |
|
90 | - 'event_id', |
|
91 | - '<br />' |
|
92 | - ) |
|
93 | - ) |
|
94 | - ); |
|
95 | - return ''; |
|
96 | - } |
|
97 | - ob_start(); |
|
98 | - do_action('AHEE_event_details_before_post', $event_id); |
|
99 | - espresso_ticket_selector($event); |
|
100 | - do_action('AHEE_event_details_after_post'); |
|
101 | - return ob_get_clean(); |
|
102 | - } |
|
27 | + /** |
|
28 | + * the actual shortcode tag that gets registered with WordPress |
|
29 | + * |
|
30 | + * @return string |
|
31 | + */ |
|
32 | + public function getTag() |
|
33 | + { |
|
34 | + return 'ESPRESSO_TICKET_SELECTOR'; |
|
35 | + } |
|
36 | + |
|
37 | + |
|
38 | + |
|
39 | + /** |
|
40 | + * the time in seconds to cache the results of the processShortcode() method |
|
41 | + * 0 means the processShortcode() results will NOT be cached at all |
|
42 | + * |
|
43 | + * @return int |
|
44 | + */ |
|
45 | + public function cacheExpiration() |
|
46 | + { |
|
47 | + return 0; |
|
48 | + } |
|
49 | + |
|
50 | + |
|
51 | + /** |
|
52 | + * a place for adding any initialization code that needs to run prior to wp_header(). |
|
53 | + * this may be required for shortcodes that utilize a corresponding module, |
|
54 | + * and need to enqueue assets for that module |
|
55 | + * |
|
56 | + * @return void |
|
57 | + */ |
|
58 | + public function initializeShortcode() |
|
59 | + { |
|
60 | + add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true'); |
|
61 | + $this->shortcodeHasBeenInitialized(); |
|
62 | + } |
|
63 | + |
|
64 | + |
|
65 | + |
|
66 | + /** |
|
67 | + * callback that runs when the shortcode is encountered in post content. |
|
68 | + * IMPORTANT !!! |
|
69 | + * remember that shortcode content should be RETURNED and NOT echoed out |
|
70 | + * |
|
71 | + * @param array $attributes |
|
72 | + * @return string |
|
73 | + * @throws InvalidArgumentException |
|
74 | + */ |
|
75 | + public function processShortcode($attributes = array()) |
|
76 | + { |
|
77 | + extract($attributes, EXTR_OVERWRITE); |
|
78 | + $event_id = isset($event_id) ? $event_id : 0; |
|
79 | + $event = EE_Registry::instance()->load_model('Event')->get_one_by_ID($event_id); |
|
80 | + if (! $event instanceof EE_Event) { |
|
81 | + new ExceptionStackTraceDisplay( |
|
82 | + new InvalidArgumentException( |
|
83 | + sprintf( |
|
84 | + esc_html__( |
|
85 | + 'A valid Event ID is required to use the "%1$s" shortcode.%4$sAn Event with an ID of "%2$s" could not be found.%4$sPlease verify that the shortcode added to this post\'s content includes an "%3$s" argument and that it\'s value corresponds to a valid Event ID.', |
|
86 | + 'event_espresso' |
|
87 | + ), |
|
88 | + $this->getTag(), |
|
89 | + $event_id, |
|
90 | + 'event_id', |
|
91 | + '<br />' |
|
92 | + ) |
|
93 | + ) |
|
94 | + ); |
|
95 | + return ''; |
|
96 | + } |
|
97 | + ob_start(); |
|
98 | + do_action('AHEE_event_details_before_post', $event_id); |
|
99 | + espresso_ticket_selector($event); |
|
100 | + do_action('AHEE_event_details_after_post'); |
|
101 | + return ob_get_clean(); |
|
102 | + } |
|
103 | 103 | |
104 | 104 | |
105 | 105 | } |
@@ -5,9 +5,9 @@ |
||
5 | 5 | interface SessionIdentifierInterface |
6 | 6 | { |
7 | 7 | |
8 | - /** |
|
9 | - * @return string |
|
10 | - */ |
|
11 | - public function id(); |
|
8 | + /** |
|
9 | + * @return string |
|
10 | + */ |
|
11 | + public function id(); |
|
12 | 12 | |
13 | 13 | } |
14 | 14 | \ No newline at end of file |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | // with these parameters |
141 | 141 | $cache_id .= filter_input(INPUT_SERVER, 'QUERY_STRING', FILTER_SANITIZE_URL); |
142 | 142 | // then md5 the above to control it's length, add all of our prefixes, and truncate |
143 | - return substr($this->cachePrefix() . $id_prefix . '-' . md5($cache_id), 0, 182); |
|
143 | + return substr($this->cachePrefix().$id_prefix.'-'.md5($cache_id), 0, 182); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | |
@@ -170,9 +170,9 @@ discard block |
||
170 | 170 | return ' |
171 | 171 | <div class="ee-cached-content-notice" style="position:fixed; bottom:0; left: 0;"> |
172 | 172 | <p style="font-size:9px;font-weight:normal;color:#666;line-height: 12px;margin:0 0 3px 5px"> |
173 | - <b>' . $type . '</b><span style="color:#999"> : </span> |
|
174 | - <span>' . $cache_id . '</span> |
|
175 | - <span style="margin-left:2em;">' . __FILE__ . '</span> |
|
173 | + <b>' . $type.'</b><span style="color:#999"> : </span> |
|
174 | + <span>' . $cache_id.'</span> |
|
175 | + <span style="margin-left:2em;">' . __FILE__.'</span> |
|
176 | 176 | </p> |
177 | 177 | </div>'; |
178 | 178 | } |
@@ -19,140 +19,140 @@ discard block |
||
19 | 19 | class BasicCacheManager implements CacheManagerInterface |
20 | 20 | { |
21 | 21 | |
22 | - /** |
|
23 | - * @type string |
|
24 | - */ |
|
25 | - const CACHE_PREFIX = 'ee_cache_'; |
|
26 | - |
|
27 | - |
|
28 | - /** |
|
29 | - * @var CacheStorageInterface $cache_storage |
|
30 | - */ |
|
31 | - private $cache_storage; |
|
32 | - |
|
33 | - |
|
34 | - |
|
35 | - /** |
|
36 | - * BasicCacheManager constructor. |
|
37 | - * |
|
38 | - * @param CacheStorageInterface $cache_storage [required] |
|
39 | - */ |
|
40 | - public function __construct(CacheStorageInterface $cache_storage) |
|
41 | - { |
|
42 | - $this->cache_storage = $cache_storage; |
|
43 | - } |
|
44 | - |
|
45 | - |
|
46 | - |
|
47 | - /** |
|
48 | - * returns a string that will be prepended to all cache identifiers |
|
49 | - * |
|
50 | - * @return string |
|
51 | - */ |
|
52 | - public function cachePrefix() |
|
53 | - { |
|
54 | - return BasicCacheManager::CACHE_PREFIX; |
|
55 | - } |
|
56 | - |
|
57 | - |
|
58 | - |
|
59 | - /** |
|
60 | - * @param string $id_prefix [required] Prepended to all cache IDs. Can be helpful in finding specific cache types. |
|
61 | - * May also be helpful to include an additional specific identifier, |
|
62 | - * such as a post ID as part of the $id_prefix so that individual caches |
|
63 | - * can be found and/or cleared. ex: "venue-28", or "shortcode-156". |
|
64 | - * BasicCacheManager::CACHE_PREFIX will also be prepended to the cache id. |
|
65 | - * @param string $cache_id [required] Additional identifying details that make this cache unique. |
|
66 | - * It is advisable to use some of the actual data |
|
67 | - * that is used to generate the content being cached, |
|
68 | - * in order to guarantee that the cache id is unique for that content. |
|
69 | - * The cache id will be md5'd before usage to make it more db friendly, |
|
70 | - * and the entire cache id string will be truncated to 190 characters. |
|
71 | - * @param Closure $callback [required] since the point of caching is to avoid generating content when not |
|
72 | - * necessary, |
|
73 | - * we wrap our content creation in a Closure so that it is not executed until needed. |
|
74 | - * @param int $expiration |
|
75 | - * @return Closure|mixed |
|
76 | - */ |
|
77 | - public function get($id_prefix, $cache_id, Closure $callback, $expiration = HOUR_IN_SECONDS) |
|
78 | - { |
|
79 | - $content = ''; |
|
80 | - $expiration = absint( |
|
81 | - apply_filters( |
|
82 | - 'FHEE__CacheManager__get__cache_expiration', |
|
83 | - $expiration, |
|
84 | - $id_prefix, |
|
85 | - $cache_id |
|
86 | - ) |
|
87 | - ); |
|
88 | - $cache_id = $this->generateCacheIdentifier($id_prefix, $cache_id); |
|
89 | - // is caching enabled for this content ? |
|
90 | - if ($expiration) { |
|
91 | - $content = $this->cache_storage->get($cache_id); |
|
92 | - } |
|
93 | - // any existing content ? |
|
94 | - if (empty($content)) { |
|
95 | - // nope! let's generate some new stuff |
|
96 | - $content = $callback(); |
|
97 | - // save the new content if caching is enabled |
|
98 | - if ($expiration) { |
|
99 | - $this->cache_storage->add($cache_id, $content, $expiration); |
|
100 | - if (EE_DEBUG) { |
|
101 | - $content .= $this->displayCacheNotice($cache_id, 'REFRESH CACHE'); |
|
102 | - } |
|
103 | - } |
|
104 | - } else { |
|
105 | - if (EE_DEBUG) { |
|
106 | - $content .= $this->displayCacheNotice($cache_id, 'CACHED CONTENT'); |
|
107 | - } |
|
108 | - } |
|
109 | - return $content; |
|
110 | - } |
|
111 | - |
|
112 | - |
|
113 | - |
|
114 | - /** |
|
115 | - * Generates a unique identifier string for the cache |
|
116 | - * |
|
117 | - * @param string $id_prefix [required] see BasicCacheManager::get() |
|
118 | - * @param string $cache_id [required] see BasicCacheManager::get() |
|
119 | - * @return string |
|
120 | - */ |
|
121 | - private function generateCacheIdentifier($id_prefix, $cache_id) |
|
122 | - { |
|
123 | - // let's make the cached content unique for this "page" |
|
124 | - $cache_id .= filter_input(INPUT_SERVER, 'REQUEST_URI', FILTER_SANITIZE_URL); |
|
125 | - // with these parameters |
|
126 | - $cache_id .= filter_input(INPUT_SERVER, 'QUERY_STRING', FILTER_SANITIZE_URL); |
|
127 | - // then md5 the above to control it's length, add all of our prefixes, and truncate |
|
128 | - return substr($this->cachePrefix() . $id_prefix . '-' . md5($cache_id), 0, 182); |
|
129 | - } |
|
130 | - |
|
131 | - |
|
132 | - |
|
133 | - /** |
|
134 | - * @param array|string $cache_id [required] Could be an ID prefix affecting many caches |
|
135 | - * or a specific ID targeting a single cache item |
|
136 | - * @return void |
|
137 | - */ |
|
138 | - public function clear($cache_id) |
|
139 | - { |
|
140 | - // ensure incoming arg is in an array |
|
141 | - $cache_id = is_array($cache_id) ? $cache_id : array($cache_id); |
|
142 | - // delete corresponding transients for the supplied id prefix |
|
143 | - $this->cache_storage->deleteMany($cache_id); |
|
144 | - } |
|
145 | - |
|
146 | - |
|
147 | - |
|
148 | - /** |
|
149 | - * @param array|string $cache_id [required] Could be an ID prefix affecting many caches |
|
150 | - * or a specific ID targeting a single cache item |
|
151 | - * @param string $type |
|
152 | - * @return string |
|
153 | - */ |
|
154 | - private function displayCacheNotice($cache_id, $type) { |
|
155 | - return ' |
|
22 | + /** |
|
23 | + * @type string |
|
24 | + */ |
|
25 | + const CACHE_PREFIX = 'ee_cache_'; |
|
26 | + |
|
27 | + |
|
28 | + /** |
|
29 | + * @var CacheStorageInterface $cache_storage |
|
30 | + */ |
|
31 | + private $cache_storage; |
|
32 | + |
|
33 | + |
|
34 | + |
|
35 | + /** |
|
36 | + * BasicCacheManager constructor. |
|
37 | + * |
|
38 | + * @param CacheStorageInterface $cache_storage [required] |
|
39 | + */ |
|
40 | + public function __construct(CacheStorageInterface $cache_storage) |
|
41 | + { |
|
42 | + $this->cache_storage = $cache_storage; |
|
43 | + } |
|
44 | + |
|
45 | + |
|
46 | + |
|
47 | + /** |
|
48 | + * returns a string that will be prepended to all cache identifiers |
|
49 | + * |
|
50 | + * @return string |
|
51 | + */ |
|
52 | + public function cachePrefix() |
|
53 | + { |
|
54 | + return BasicCacheManager::CACHE_PREFIX; |
|
55 | + } |
|
56 | + |
|
57 | + |
|
58 | + |
|
59 | + /** |
|
60 | + * @param string $id_prefix [required] Prepended to all cache IDs. Can be helpful in finding specific cache types. |
|
61 | + * May also be helpful to include an additional specific identifier, |
|
62 | + * such as a post ID as part of the $id_prefix so that individual caches |
|
63 | + * can be found and/or cleared. ex: "venue-28", or "shortcode-156". |
|
64 | + * BasicCacheManager::CACHE_PREFIX will also be prepended to the cache id. |
|
65 | + * @param string $cache_id [required] Additional identifying details that make this cache unique. |
|
66 | + * It is advisable to use some of the actual data |
|
67 | + * that is used to generate the content being cached, |
|
68 | + * in order to guarantee that the cache id is unique for that content. |
|
69 | + * The cache id will be md5'd before usage to make it more db friendly, |
|
70 | + * and the entire cache id string will be truncated to 190 characters. |
|
71 | + * @param Closure $callback [required] since the point of caching is to avoid generating content when not |
|
72 | + * necessary, |
|
73 | + * we wrap our content creation in a Closure so that it is not executed until needed. |
|
74 | + * @param int $expiration |
|
75 | + * @return Closure|mixed |
|
76 | + */ |
|
77 | + public function get($id_prefix, $cache_id, Closure $callback, $expiration = HOUR_IN_SECONDS) |
|
78 | + { |
|
79 | + $content = ''; |
|
80 | + $expiration = absint( |
|
81 | + apply_filters( |
|
82 | + 'FHEE__CacheManager__get__cache_expiration', |
|
83 | + $expiration, |
|
84 | + $id_prefix, |
|
85 | + $cache_id |
|
86 | + ) |
|
87 | + ); |
|
88 | + $cache_id = $this->generateCacheIdentifier($id_prefix, $cache_id); |
|
89 | + // is caching enabled for this content ? |
|
90 | + if ($expiration) { |
|
91 | + $content = $this->cache_storage->get($cache_id); |
|
92 | + } |
|
93 | + // any existing content ? |
|
94 | + if (empty($content)) { |
|
95 | + // nope! let's generate some new stuff |
|
96 | + $content = $callback(); |
|
97 | + // save the new content if caching is enabled |
|
98 | + if ($expiration) { |
|
99 | + $this->cache_storage->add($cache_id, $content, $expiration); |
|
100 | + if (EE_DEBUG) { |
|
101 | + $content .= $this->displayCacheNotice($cache_id, 'REFRESH CACHE'); |
|
102 | + } |
|
103 | + } |
|
104 | + } else { |
|
105 | + if (EE_DEBUG) { |
|
106 | + $content .= $this->displayCacheNotice($cache_id, 'CACHED CONTENT'); |
|
107 | + } |
|
108 | + } |
|
109 | + return $content; |
|
110 | + } |
|
111 | + |
|
112 | + |
|
113 | + |
|
114 | + /** |
|
115 | + * Generates a unique identifier string for the cache |
|
116 | + * |
|
117 | + * @param string $id_prefix [required] see BasicCacheManager::get() |
|
118 | + * @param string $cache_id [required] see BasicCacheManager::get() |
|
119 | + * @return string |
|
120 | + */ |
|
121 | + private function generateCacheIdentifier($id_prefix, $cache_id) |
|
122 | + { |
|
123 | + // let's make the cached content unique for this "page" |
|
124 | + $cache_id .= filter_input(INPUT_SERVER, 'REQUEST_URI', FILTER_SANITIZE_URL); |
|
125 | + // with these parameters |
|
126 | + $cache_id .= filter_input(INPUT_SERVER, 'QUERY_STRING', FILTER_SANITIZE_URL); |
|
127 | + // then md5 the above to control it's length, add all of our prefixes, and truncate |
|
128 | + return substr($this->cachePrefix() . $id_prefix . '-' . md5($cache_id), 0, 182); |
|
129 | + } |
|
130 | + |
|
131 | + |
|
132 | + |
|
133 | + /** |
|
134 | + * @param array|string $cache_id [required] Could be an ID prefix affecting many caches |
|
135 | + * or a specific ID targeting a single cache item |
|
136 | + * @return void |
|
137 | + */ |
|
138 | + public function clear($cache_id) |
|
139 | + { |
|
140 | + // ensure incoming arg is in an array |
|
141 | + $cache_id = is_array($cache_id) ? $cache_id : array($cache_id); |
|
142 | + // delete corresponding transients for the supplied id prefix |
|
143 | + $this->cache_storage->deleteMany($cache_id); |
|
144 | + } |
|
145 | + |
|
146 | + |
|
147 | + |
|
148 | + /** |
|
149 | + * @param array|string $cache_id [required] Could be an ID prefix affecting many caches |
|
150 | + * or a specific ID targeting a single cache item |
|
151 | + * @param string $type |
|
152 | + * @return string |
|
153 | + */ |
|
154 | + private function displayCacheNotice($cache_id, $type) { |
|
155 | + return ' |
|
156 | 156 | <div class="ee-cached-content-notice" style="position:fixed; bottom:0; left: 0;"> |
157 | 157 | <p style="font-size:9px;font-weight:normal;color:#666;line-height: 12px;margin:0 0 3px 5px"> |
158 | 158 | <b>' . $type . '</b><span style="color:#999"> : </span> |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | <span style="margin-left:2em;">' . __FILE__ . '</span> |
161 | 161 | </p> |
162 | 162 | </div>'; |
163 | - } |
|
163 | + } |
|
164 | 164 | |
165 | 165 | } |
166 | 166 | // End of file BasicCacheManager.php |
@@ -120,7 +120,7 @@ |
||
120 | 120 | |
121 | 121 | /** |
122 | 122 | * Wrapper for getting the selector for a given field and given display row of a ticket in the event editor. |
123 | - * @param $field_name |
|
123 | + * @param string $field_name |
|
124 | 124 | * @param int $row_number |
125 | 125 | * @return string |
126 | 126 | */ |
@@ -14,231 +14,231 @@ |
||
14 | 14 | class EventsAdmin extends CoreAdmin |
15 | 15 | { |
16 | 16 | |
17 | - /** |
|
18 | - * Selector for the Add new Event button in the admin. |
|
19 | - * @var string |
|
20 | - */ |
|
21 | - const ADD_NEW_EVENT_BUTTON_SELECTOR = '#add-new-event'; |
|
22 | - |
|
23 | - |
|
24 | - /** |
|
25 | - * Selector for the Event Title field in the event editor |
|
26 | - * @var string |
|
27 | - */ |
|
28 | - const EVENT_EDITOR_TITLE_FIELD_SELECTOR = "//input[@id='title']"; |
|
29 | - |
|
30 | - /** |
|
31 | - * Selector for the publish submit button in the event editor. |
|
32 | - * @var string |
|
33 | - */ |
|
34 | - const EVENT_EDITOR_PUBLISH_BUTTON_SELECTOR = "#publish"; |
|
35 | - |
|
36 | - |
|
37 | - /** |
|
38 | - * Selector for the save button in the event editor |
|
39 | - */ |
|
40 | - const EVENT_EDITOR_SAVE_BUTTON_SELECTOR = "#save-post"; |
|
41 | - |
|
42 | - |
|
43 | - /** |
|
44 | - * @var string |
|
45 | - */ |
|
46 | - const EVENT_EDITOR_DEFAULT_REGISTRATION_STATUS_FIELD_SELECTOR = '#EVT_default_registration_status'; |
|
17 | + /** |
|
18 | + * Selector for the Add new Event button in the admin. |
|
19 | + * @var string |
|
20 | + */ |
|
21 | + const ADD_NEW_EVENT_BUTTON_SELECTOR = '#add-new-event'; |
|
22 | + |
|
23 | + |
|
24 | + /** |
|
25 | + * Selector for the Event Title field in the event editor |
|
26 | + * @var string |
|
27 | + */ |
|
28 | + const EVENT_EDITOR_TITLE_FIELD_SELECTOR = "//input[@id='title']"; |
|
29 | + |
|
30 | + /** |
|
31 | + * Selector for the publish submit button in the event editor. |
|
32 | + * @var string |
|
33 | + */ |
|
34 | + const EVENT_EDITOR_PUBLISH_BUTTON_SELECTOR = "#publish"; |
|
35 | + |
|
36 | + |
|
37 | + /** |
|
38 | + * Selector for the save button in the event editor |
|
39 | + */ |
|
40 | + const EVENT_EDITOR_SAVE_BUTTON_SELECTOR = "#save-post"; |
|
41 | + |
|
42 | + |
|
43 | + /** |
|
44 | + * @var string |
|
45 | + */ |
|
46 | + const EVENT_EDITOR_DEFAULT_REGISTRATION_STATUS_FIELD_SELECTOR = '#EVT_default_registration_status'; |
|
47 | 47 | |
48 | - /** |
|
49 | - * Selector for the view link after publishing an event. |
|
50 | - * @var string |
|
51 | - */ |
|
52 | - const EVENT_EDITOR_VIEW_LINK_AFTER_PUBLISH_SELECTOR = "//div[@id='message']/p/a"; |
|
48 | + /** |
|
49 | + * Selector for the view link after publishing an event. |
|
50 | + * @var string |
|
51 | + */ |
|
52 | + const EVENT_EDITOR_VIEW_LINK_AFTER_PUBLISH_SELECTOR = "//div[@id='message']/p/a"; |
|
53 | 53 | |
54 | 54 | |
55 | - /** |
|
56 | - * Selector for the ID of the event in the event editor |
|
57 | - * @var string |
|
58 | - */ |
|
59 | - const EVENT_EDITOR_EVT_ID_SELECTOR = "//input[@id='post_ID']"; |
|
55 | + /** |
|
56 | + * Selector for the ID of the event in the event editor |
|
57 | + * @var string |
|
58 | + */ |
|
59 | + const EVENT_EDITOR_EVT_ID_SELECTOR = "//input[@id='post_ID']"; |
|
60 | 60 | |
61 | 61 | |
62 | - /** |
|
63 | - * Selector for the search input on the event list table page. |
|
64 | - * @var string |
|
65 | - */ |
|
66 | - const EVENT_LIST_TABLE_SEARCH_INPUT_SELECTOR = '#toplevel_page_espresso_events-search-input'; |
|
67 | - |
|
68 | - |
|
69 | - |
|
70 | - |
|
71 | - /** |
|
72 | - * @param string $additional_params |
|
73 | - * @return string |
|
74 | - */ |
|
75 | - public static function defaultEventsListTableUrl($additional_params = '') |
|
76 | - { |
|
77 | - return self::adminUrl('espresso_events', 'default', $additional_params); |
|
78 | - } |
|
79 | - |
|
80 | - |
|
81 | - /** |
|
82 | - * The selector for the DTTname field for the given row in the event editor. |
|
83 | - * @param int $row_number |
|
84 | - * @return string |
|
85 | - */ |
|
86 | - public static function eventEditorDatetimeNameFieldSelector($row_number = 1) |
|
87 | - { |
|
88 | - return self::eventEditorDatetimeFieldSelectorForField('DTT_name', $row_number); |
|
89 | - } |
|
90 | - |
|
91 | - |
|
92 | - /** |
|
93 | - * The selector for the DTT_EVT_start field for the given row in the event editor.d |
|
94 | - * @param int $row_number |
|
95 | - * @return string |
|
96 | - */ |
|
97 | - public static function eventEditorDatetimeStartDateFieldSelector($row_number = 1) |
|
98 | - { |
|
99 | - return self::eventEditorDatetimeFieldSelectorForField('DTT_EVT_start', $row_number); |
|
100 | - } |
|
101 | - |
|
102 | - |
|
103 | - /** |
|
104 | - * Wrapper for getting the selector for a given field and given row of a datetime in the event editor. |
|
105 | - * |
|
106 | - * @param string $field_name |
|
107 | - * @param int $row_number |
|
108 | - * @return string |
|
109 | - */ |
|
110 | - public static function eventEditorDatetimeFieldSelectorForField($field_name, $row_number = 1) |
|
111 | - { |
|
112 | - return "//input[@id='event-datetime-$field_name-$row_number']"; |
|
113 | - } |
|
114 | - |
|
115 | - |
|
116 | - /** |
|
117 | - * The selector for the TKT_name field for the given display row in the event editor. |
|
118 | - * @param int $row_number |
|
119 | - * @return string |
|
120 | - */ |
|
121 | - public static function eventEditorTicketNameFieldSelector($row_number = 1) |
|
122 | - { |
|
123 | - return self::eventEditorTicketFieldSelectorForFieldInDisplayRow('TKT_name', $row_number); |
|
124 | - } |
|
125 | - |
|
126 | - |
|
127 | - public static function eventEditorTicketPriceFieldSelector($row_number = 1) |
|
128 | - { |
|
129 | - return self::eventEditorTicketFieldSelectorForFieldInDisplayRow('TKT_base_price', $row_number); |
|
130 | - } |
|
131 | - |
|
132 | - |
|
133 | - public static function eventEditorTicketAdvancedDetailsSelector($row_number = 1) |
|
134 | - { |
|
135 | - return "//tr[@id='display-ticketrow-$row_number']//span[contains(@class, 'gear-icon')]"; |
|
136 | - } |
|
137 | - |
|
138 | - |
|
139 | - public static function eventEditorTicketAdvancedDetailsSubtotalSelector($row_number = 1) |
|
140 | - { |
|
141 | - return "//span[@id='price-total-amount-$row_number']"; |
|
142 | - } |
|
143 | - |
|
144 | - |
|
145 | - public static function eventEditorTicketAdvancedDetailsTotalSelector($row_number = 1) |
|
146 | - { |
|
147 | - return "//span[@id='price-total-amount-$row_number']"; |
|
148 | - } |
|
149 | - |
|
150 | - |
|
151 | - public static function eventEditorTicketTaxableCheckboxSelector($row_number = 1) |
|
152 | - { |
|
153 | - return "//input[@id='edit-ticket-TKT_taxable-$row_number']"; |
|
154 | - } |
|
155 | - |
|
156 | - |
|
157 | - /** |
|
158 | - * This returns the xpath locater for the Tax amount display container within the advanced settings view for the |
|
159 | - * given ticket (row) and the given tax id (PRC_ID). |
|
160 | - * |
|
161 | - * @param int $tax_id The PRC_ID for the tax you want the locater for. Note, this defaults to the default tax |
|
162 | - * setup on a fresh install. |
|
163 | - * @param int $row_number What row representing the ticket you want the locator for. |
|
164 | - * @return string |
|
165 | - */ |
|
166 | - public static function eventEditorTicketTaxAmountDisplayForTaxIdAndTicketRowSelector($tax_id = 2, $row_number = 1) |
|
167 | - { |
|
168 | - return "//span[@id='TKT-tax-amount-display-$tax_id-$row_number']"; |
|
169 | - } |
|
170 | - |
|
171 | - |
|
172 | - /** |
|
173 | - * Wrapper for getting the selector for a given field and given display row of a ticket in the event editor. |
|
174 | - * @param $field_name |
|
175 | - * @param int $row_number |
|
176 | - * @return string |
|
177 | - */ |
|
178 | - public static function eventEditorTicketFieldSelectorForFieldInDisplayRow($field_name, $row_number = 1) |
|
179 | - { |
|
180 | - return "//tr[@id='display-ticketrow-$row_number']//input[contains(@class, 'edit-ticket-$field_name')]"; |
|
181 | - } |
|
182 | - |
|
183 | - |
|
184 | - /** |
|
185 | - * Returns the selector for the event title edit link in the events list table for the given Event Title. |
|
186 | - * @param string $event_title |
|
187 | - * @return string |
|
188 | - */ |
|
189 | - public static function eventListTableEventTitleEditLinkSelectorForTitle($event_title) |
|
190 | - { |
|
191 | - return "//td[contains(@class, 'column-name')]/strong/a[text()='$event_title']"; |
|
192 | - } |
|
193 | - |
|
194 | - |
|
195 | - /** |
|
196 | - * Locator for for the ID column in the event list table for a given event title. |
|
197 | - * @param string $event_title |
|
198 | - * @return string |
|
199 | - */ |
|
200 | - public static function eventListTableEventIdSelectorForTitle($event_title) |
|
201 | - { |
|
202 | - return "//td[contains(@class, 'column-name')]/strong/a[text()='$event_title']" |
|
203 | - . "//ancestor::tr/th[contains(@class, 'check-column')]/input"; |
|
204 | - } |
|
205 | - |
|
206 | - |
|
207 | - /** |
|
208 | - * Locator for the view link in the row of an event list table for the given event title. |
|
209 | - * @param string $event_title |
|
210 | - * @return string |
|
211 | - */ |
|
212 | - public static function eventListTableEventTitleViewLinkSelectorForTitle($event_title) |
|
213 | - { |
|
214 | - return "//td[contains(@class, 'column-name')]/strong/a[text()='$event_title']" |
|
215 | - . "//ancestor::td//span[@class='view']/a"; |
|
216 | - } |
|
217 | - |
|
218 | - |
|
219 | - /** |
|
220 | - * Locator for the messenger tab in the Notifications metabox in the event editor. |
|
221 | - * @param string $messenger_slug The slug for the messenger (it's reference slug). |
|
222 | - * @return string |
|
223 | - */ |
|
224 | - public static function eventEditorNotificationsMetaBoxMessengerTabSelector($messenger_slug) |
|
225 | - { |
|
226 | - return "//div[@id='espresso_events_Messages_Hooks_Extend_messages_metabox_metabox']" |
|
227 | - . "//a[@rel='ee-tab-$messenger_slug']"; |
|
228 | - } |
|
229 | - |
|
230 | - |
|
231 | - /** |
|
232 | - * Locator for the select input within the notifications metabox. |
|
233 | - * Note, this assumes the tab content for the related messenger is already visible. |
|
234 | - * @param string $message_type_label The message type label (visible string in the table) you want the selector for. |
|
235 | - * @return string |
|
236 | - */ |
|
237 | - public static function eventEditorNotificationsMetaBoxSelectSelectorForMessageType($message_type_label) |
|
238 | - { |
|
239 | - return "//div[@id='espresso_events_Messages_Hooks_Extend_messages_metabox_metabox']" |
|
240 | - . "//table[@class='messages-custom-template-switcher']" |
|
241 | - . "//tr/td[contains(.,'Registration Approved')]" |
|
242 | - . "//ancestor::tr//select[contains(@class,'message-template-selector')]"; |
|
243 | - } |
|
62 | + /** |
|
63 | + * Selector for the search input on the event list table page. |
|
64 | + * @var string |
|
65 | + */ |
|
66 | + const EVENT_LIST_TABLE_SEARCH_INPUT_SELECTOR = '#toplevel_page_espresso_events-search-input'; |
|
67 | + |
|
68 | + |
|
69 | + |
|
70 | + |
|
71 | + /** |
|
72 | + * @param string $additional_params |
|
73 | + * @return string |
|
74 | + */ |
|
75 | + public static function defaultEventsListTableUrl($additional_params = '') |
|
76 | + { |
|
77 | + return self::adminUrl('espresso_events', 'default', $additional_params); |
|
78 | + } |
|
79 | + |
|
80 | + |
|
81 | + /** |
|
82 | + * The selector for the DTTname field for the given row in the event editor. |
|
83 | + * @param int $row_number |
|
84 | + * @return string |
|
85 | + */ |
|
86 | + public static function eventEditorDatetimeNameFieldSelector($row_number = 1) |
|
87 | + { |
|
88 | + return self::eventEditorDatetimeFieldSelectorForField('DTT_name', $row_number); |
|
89 | + } |
|
90 | + |
|
91 | + |
|
92 | + /** |
|
93 | + * The selector for the DTT_EVT_start field for the given row in the event editor.d |
|
94 | + * @param int $row_number |
|
95 | + * @return string |
|
96 | + */ |
|
97 | + public static function eventEditorDatetimeStartDateFieldSelector($row_number = 1) |
|
98 | + { |
|
99 | + return self::eventEditorDatetimeFieldSelectorForField('DTT_EVT_start', $row_number); |
|
100 | + } |
|
101 | + |
|
102 | + |
|
103 | + /** |
|
104 | + * Wrapper for getting the selector for a given field and given row of a datetime in the event editor. |
|
105 | + * |
|
106 | + * @param string $field_name |
|
107 | + * @param int $row_number |
|
108 | + * @return string |
|
109 | + */ |
|
110 | + public static function eventEditorDatetimeFieldSelectorForField($field_name, $row_number = 1) |
|
111 | + { |
|
112 | + return "//input[@id='event-datetime-$field_name-$row_number']"; |
|
113 | + } |
|
114 | + |
|
115 | + |
|
116 | + /** |
|
117 | + * The selector for the TKT_name field for the given display row in the event editor. |
|
118 | + * @param int $row_number |
|
119 | + * @return string |
|
120 | + */ |
|
121 | + public static function eventEditorTicketNameFieldSelector($row_number = 1) |
|
122 | + { |
|
123 | + return self::eventEditorTicketFieldSelectorForFieldInDisplayRow('TKT_name', $row_number); |
|
124 | + } |
|
125 | + |
|
126 | + |
|
127 | + public static function eventEditorTicketPriceFieldSelector($row_number = 1) |
|
128 | + { |
|
129 | + return self::eventEditorTicketFieldSelectorForFieldInDisplayRow('TKT_base_price', $row_number); |
|
130 | + } |
|
131 | + |
|
132 | + |
|
133 | + public static function eventEditorTicketAdvancedDetailsSelector($row_number = 1) |
|
134 | + { |
|
135 | + return "//tr[@id='display-ticketrow-$row_number']//span[contains(@class, 'gear-icon')]"; |
|
136 | + } |
|
137 | + |
|
138 | + |
|
139 | + public static function eventEditorTicketAdvancedDetailsSubtotalSelector($row_number = 1) |
|
140 | + { |
|
141 | + return "//span[@id='price-total-amount-$row_number']"; |
|
142 | + } |
|
143 | + |
|
144 | + |
|
145 | + public static function eventEditorTicketAdvancedDetailsTotalSelector($row_number = 1) |
|
146 | + { |
|
147 | + return "//span[@id='price-total-amount-$row_number']"; |
|
148 | + } |
|
149 | + |
|
150 | + |
|
151 | + public static function eventEditorTicketTaxableCheckboxSelector($row_number = 1) |
|
152 | + { |
|
153 | + return "//input[@id='edit-ticket-TKT_taxable-$row_number']"; |
|
154 | + } |
|
155 | + |
|
156 | + |
|
157 | + /** |
|
158 | + * This returns the xpath locater for the Tax amount display container within the advanced settings view for the |
|
159 | + * given ticket (row) and the given tax id (PRC_ID). |
|
160 | + * |
|
161 | + * @param int $tax_id The PRC_ID for the tax you want the locater for. Note, this defaults to the default tax |
|
162 | + * setup on a fresh install. |
|
163 | + * @param int $row_number What row representing the ticket you want the locator for. |
|
164 | + * @return string |
|
165 | + */ |
|
166 | + public static function eventEditorTicketTaxAmountDisplayForTaxIdAndTicketRowSelector($tax_id = 2, $row_number = 1) |
|
167 | + { |
|
168 | + return "//span[@id='TKT-tax-amount-display-$tax_id-$row_number']"; |
|
169 | + } |
|
170 | + |
|
171 | + |
|
172 | + /** |
|
173 | + * Wrapper for getting the selector for a given field and given display row of a ticket in the event editor. |
|
174 | + * @param $field_name |
|
175 | + * @param int $row_number |
|
176 | + * @return string |
|
177 | + */ |
|
178 | + public static function eventEditorTicketFieldSelectorForFieldInDisplayRow($field_name, $row_number = 1) |
|
179 | + { |
|
180 | + return "//tr[@id='display-ticketrow-$row_number']//input[contains(@class, 'edit-ticket-$field_name')]"; |
|
181 | + } |
|
182 | + |
|
183 | + |
|
184 | + /** |
|
185 | + * Returns the selector for the event title edit link in the events list table for the given Event Title. |
|
186 | + * @param string $event_title |
|
187 | + * @return string |
|
188 | + */ |
|
189 | + public static function eventListTableEventTitleEditLinkSelectorForTitle($event_title) |
|
190 | + { |
|
191 | + return "//td[contains(@class, 'column-name')]/strong/a[text()='$event_title']"; |
|
192 | + } |
|
193 | + |
|
194 | + |
|
195 | + /** |
|
196 | + * Locator for for the ID column in the event list table for a given event title. |
|
197 | + * @param string $event_title |
|
198 | + * @return string |
|
199 | + */ |
|
200 | + public static function eventListTableEventIdSelectorForTitle($event_title) |
|
201 | + { |
|
202 | + return "//td[contains(@class, 'column-name')]/strong/a[text()='$event_title']" |
|
203 | + . "//ancestor::tr/th[contains(@class, 'check-column')]/input"; |
|
204 | + } |
|
205 | + |
|
206 | + |
|
207 | + /** |
|
208 | + * Locator for the view link in the row of an event list table for the given event title. |
|
209 | + * @param string $event_title |
|
210 | + * @return string |
|
211 | + */ |
|
212 | + public static function eventListTableEventTitleViewLinkSelectorForTitle($event_title) |
|
213 | + { |
|
214 | + return "//td[contains(@class, 'column-name')]/strong/a[text()='$event_title']" |
|
215 | + . "//ancestor::td//span[@class='view']/a"; |
|
216 | + } |
|
217 | + |
|
218 | + |
|
219 | + /** |
|
220 | + * Locator for the messenger tab in the Notifications metabox in the event editor. |
|
221 | + * @param string $messenger_slug The slug for the messenger (it's reference slug). |
|
222 | + * @return string |
|
223 | + */ |
|
224 | + public static function eventEditorNotificationsMetaBoxMessengerTabSelector($messenger_slug) |
|
225 | + { |
|
226 | + return "//div[@id='espresso_events_Messages_Hooks_Extend_messages_metabox_metabox']" |
|
227 | + . "//a[@rel='ee-tab-$messenger_slug']"; |
|
228 | + } |
|
229 | + |
|
230 | + |
|
231 | + /** |
|
232 | + * Locator for the select input within the notifications metabox. |
|
233 | + * Note, this assumes the tab content for the related messenger is already visible. |
|
234 | + * @param string $message_type_label The message type label (visible string in the table) you want the selector for. |
|
235 | + * @return string |
|
236 | + */ |
|
237 | + public static function eventEditorNotificationsMetaBoxSelectSelectorForMessageType($message_type_label) |
|
238 | + { |
|
239 | + return "//div[@id='espresso_events_Messages_Hooks_Extend_messages_metabox_metabox']" |
|
240 | + . "//table[@class='messages-custom-template-switcher']" |
|
241 | + . "//tr/td[contains(.,'Registration Approved')]" |
|
242 | + . "//ancestor::tr//select[contains(@class,'message-template-selector')]"; |
|
243 | + } |
|
244 | 244 | } |