@@ -19,296 +19,296 @@ |
||
19 | 19 | { |
20 | 20 | |
21 | 21 | |
22 | - /** |
|
23 | - * Will hold the EE_Event if available |
|
24 | - * |
|
25 | - * @var EE_Event |
|
26 | - */ |
|
27 | - protected $_event; |
|
28 | - |
|
29 | - |
|
30 | - public function __construct() |
|
31 | - { |
|
32 | - parent::__construct(); |
|
33 | - } |
|
34 | - |
|
35 | - |
|
36 | - protected function _init_props() |
|
37 | - { |
|
38 | - $this->label = __('Event Shortcodes', 'event_espresso'); |
|
39 | - $this->description = __('All shortcodes specific to event related data', 'event_espresso'); |
|
40 | - $this->_shortcodes = array( |
|
41 | - '[EVENT_ID]' => __( |
|
42 | - 'Will be replaced by the event ID of an event', |
|
43 | - 'event_espresso' |
|
44 | - ), |
|
45 | - '[EVENT]' => __('The name of the event', 'event_espresso'), |
|
46 | - '[EVENT_NAME]' => __( |
|
47 | - "This also can be used for the name of the event", |
|
48 | - 'event_espresso' |
|
49 | - ), |
|
50 | - '[EVENT_PHONE]' => __( |
|
51 | - 'The phone number for the event (usually an info number)', |
|
52 | - 'event_espresso' |
|
53 | - ), |
|
54 | - '[EVENT_DESCRIPTION]' => __('The description of the event', 'event_espresso'), |
|
55 | - '[EVENT_EXCERPT]' => __( |
|
56 | - 'This gets parsed to the value for the excerpt field in the event or blank if there is no excerpt.', |
|
57 | - 'event_espresso' |
|
58 | - ), |
|
59 | - '[EVENT_LINK]' => __('A link associated with the event', 'event_espresso'), |
|
60 | - '[EVENT_URL]' => __( |
|
61 | - 'A link to the event set up on the host site.', |
|
62 | - 'event_espresso' |
|
63 | - ), |
|
64 | - '[VIRTUAL_URL]' => __( |
|
65 | - 'What was used for the "URL of Event" field in the Venue settings', |
|
66 | - 'event_espresso' |
|
67 | - ), |
|
68 | - '[VIRTUAL_PHONE]' => __( |
|
69 | - 'An alternate phone number for the event. Typically used as a "call-in" number', |
|
70 | - 'event_espresso' |
|
71 | - ), |
|
72 | - '[EVENT_IMAGE]' => __( |
|
73 | - 'This will parse to the Feature image for the event.', |
|
74 | - 'event_espresso' |
|
75 | - ), |
|
76 | - '[EVENT_IMAGE_*]' => sprintf( |
|
77 | - __( |
|
78 | - 'This will parse to the Feature image for the event, %1$ssize%2$s can be set to determine the size of the image loaded by the shortcode. The %1$swidth%2$s and/or %1$sheight%2$s can also be set to determine the width and height of the image when output. By default the shortcode will load the %1$sthumbnail%2$s image size.', |
|
79 | - 'event_espresso' |
|
80 | - ), |
|
81 | - '<code>', |
|
82 | - '</code>' |
|
83 | - ), |
|
84 | - '[EVENT_TOTAL_AVAILABLE_SPACES_*]' => sprintf( |
|
85 | - __( |
|
86 | - 'This will parse to the total available spaces for an event. Calculating total spaces is approximate because it is dependent on the complexity of limits on your event. There are two methods of calculation (which can be indicated by the %1$smethod%2$s param on the shortcode). %1$scurrent%2$s which will do a more accurate calculation of total available spaces based on current sales, and %1$sfull%2$s which will be the maximum total available spaces that is on the event in optimal conditions. The shortcode will default to current.', |
|
87 | - 'event_espresso' |
|
88 | - ), |
|
89 | - '<code>', |
|
90 | - '</code>' |
|
91 | - ), |
|
92 | - '[EVENT_TOTAL_SPOTS_TAKEN]' => __( |
|
93 | - 'This shortcode will parse to the output the total approved registrations for this event', |
|
94 | - 'event_espresso' |
|
95 | - ), |
|
96 | - '[EVENT_FACEBOOK_URL]' => __( |
|
97 | - 'This will return the Facebook URL for the event if you have it set via custom field in your event, otherwise it will use the Facebook URL set in "Your Organization Settings". To set the facebook url in your event, add a custom field with the key as <code>event_facebook</code> and the value as your facebook url.', |
|
98 | - 'event_espresso' |
|
99 | - ), |
|
100 | - '[EVENT_TWITTER_URL]' => __( |
|
101 | - 'This will return the Twitter URL for the event if you have it set via custom field in your event, otherwise it will use the Twitter URL set in "Your Organization Settings". To set the facebook url in your event, add a custom field with the key as <code>event_twitter</code> and the value as your facebook url', |
|
102 | - 'event_espresso' |
|
103 | - ), |
|
104 | - '[EVENT_META_*]' => sprintf( |
|
105 | - __( |
|
106 | - 'This is a special dynamic shortcode. After the "*", add the exact name for your custom field, if there is a value set for that custom field within the event then it will be output in place of this shortcode. If you use shortcodes within your custom fields set %1$sdo_shortcode=true%2$s at the end of the shortcode to run the value through the do_shortcode function. ', |
|
107 | - 'event_espresso' |
|
108 | - ), |
|
109 | - '<code>', |
|
110 | - '</code>' |
|
111 | - ), |
|
112 | - '[REGISTRATION_LIST_TABLE_FOR_EVENT_URL]' => __( |
|
113 | - 'This parses to the url for the registration list table filtered by registrations for this event.', |
|
114 | - 'event_espresso' |
|
115 | - ), |
|
116 | - ); |
|
117 | - } |
|
118 | - |
|
119 | - |
|
120 | - protected function _parser($shortcode) |
|
121 | - { |
|
122 | - |
|
123 | - |
|
124 | - $this->_event = $this->_data instanceof EE_Event ? $this->_data : null; |
|
125 | - |
|
126 | - // if no event, then let's see if there is a reg_obj. If there IS, then we'll try and grab the event from the reg_obj instead. |
|
127 | - if (empty($this->_event)) { |
|
128 | - $aee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null; |
|
129 | - $aee = $this->_extra_data instanceof EE_Messages_Addressee ? $this->_extra_data : $aee; |
|
130 | - |
|
131 | - $this->_event = $aee instanceof EE_Messages_Addressee && $aee->reg_obj instanceof EE_Registration |
|
132 | - ? $aee->reg_obj->event() : null; |
|
133 | - } |
|
134 | - |
|
135 | - |
|
136 | - // If there is no event objecdt by now then get out. |
|
137 | - if (! $this->_event instanceof EE_Event) { |
|
138 | - return ''; |
|
139 | - } |
|
140 | - |
|
141 | - switch ($shortcode) { |
|
142 | - case '[EVENT_ID]': |
|
143 | - return $this->_event->ID(); |
|
144 | - break; |
|
145 | - |
|
146 | - case '[EVENT]': |
|
147 | - case '[EVENT_NAME]': |
|
148 | - return $this->_event->get('EVT_name'); |
|
149 | - break; |
|
150 | - |
|
151 | - case '[EVENT_PHONE]': |
|
152 | - return $this->_event->get('EVT_phone'); |
|
153 | - break; |
|
154 | - |
|
155 | - case '[EVENT_DESCRIPTION]': |
|
156 | - return $this->_event->get('EVT_desc'); |
|
157 | - break; |
|
158 | - |
|
159 | - case '[EVENT_EXCERPT]': |
|
160 | - return $this->_event->get('EVT_short_desc'); |
|
161 | - break; |
|
162 | - |
|
163 | - case '[EVENT_LINK]': |
|
164 | - return $this->_get_event_link($this->_event); |
|
165 | - break; |
|
166 | - |
|
167 | - case '[EVENT_URL]': |
|
168 | - return $this->_get_event_link($this->_event, false); |
|
169 | - break; |
|
170 | - |
|
171 | - case '[VIRTUAL_URL]': |
|
172 | - $venue = $this->_event->get_first_related('Venue'); |
|
173 | - if (empty($venue)) { |
|
174 | - return ''; |
|
175 | - } |
|
176 | - return $venue->get('VNU_virtual_url'); |
|
177 | - |
|
178 | - case '[VIRTUAL_PHONE]': |
|
179 | - $venue = $this->_event->get_first_related('Venue'); |
|
180 | - if (empty($venue)) { |
|
181 | - return ''; |
|
182 | - } |
|
183 | - return $venue->get('VNU_virtual_phone'); |
|
184 | - break; |
|
185 | - |
|
186 | - case '[EVENT_IMAGE]': |
|
187 | - $image = $this->_event->feature_image_url(array(600, 300)); |
|
188 | - // @todo: eventually we should make this an attribute shortcode so that em can send along what size they want returned. |
|
189 | - return ! empty($image) |
|
190 | - ? '<img src="' . $image . '" alt="' |
|
191 | - . sprintf( |
|
192 | - esc_attr__('%s Feature Image', 'event_espresso'), |
|
193 | - $this->_event->get('EVT_name') |
|
194 | - ) . '" />' |
|
195 | - : ''; |
|
196 | - break; |
|
197 | - |
|
198 | - case '[EVENT_FACEBOOK_URL]': |
|
199 | - $facebook_url = $this->_event->get_post_meta('event_facebook', true); |
|
200 | - return empty($facebook_url) ? EE_Registry::instance()->CFG->organization->get_pretty('facebook') |
|
201 | - : $facebook_url; |
|
202 | - break; |
|
203 | - |
|
204 | - case '[EVENT_TWITTER_URL]': |
|
205 | - $twitter_url = $this->_event->get_post_meta('event_twitter', true); |
|
206 | - return empty($twitter_url) ? EE_Registry::instance()->CFG->organization->get_pretty('twitter') |
|
207 | - : $twitter_url; |
|
208 | - break; |
|
209 | - |
|
210 | - case '[EVENT_AUTHOR_EMAIL]': |
|
211 | - $author_id = $this->_event->get('EVT_wp_user'); |
|
212 | - $user_data = get_userdata((int) $author_id); |
|
213 | - return $user_data->user_email; |
|
214 | - break; |
|
215 | - |
|
216 | - case '[EVENT_TOTAL_SPOTS_TAKEN]': |
|
217 | - return EEM_Registration::instance()->count( |
|
218 | - array(array('EVT_ID' => $this->_event->ID(), 'STS_ID' => EEM_Registration::status_id_approved)), |
|
219 | - 'REG_ID', |
|
220 | - true |
|
221 | - ); |
|
222 | - break; |
|
223 | - |
|
224 | - case '[REGISTRATION_LIST_TABLE_FOR_EVENT_URL]': |
|
225 | - return EEH_URL::add_query_args_and_nonce( |
|
226 | - array( |
|
227 | - 'event_id' => $this->_event->ID(), |
|
228 | - 'page' => 'espresso_registrations', |
|
229 | - 'action' => 'default', |
|
230 | - ), |
|
231 | - admin_url('admin.php'), |
|
232 | - true |
|
233 | - ); |
|
234 | - break; |
|
235 | - } |
|
236 | - |
|
237 | - if (strpos($shortcode, '[EVENT_META_*') !== false) { |
|
238 | - // Strip the shortcode itself from $shortcode leaving any attributes set. |
|
239 | - // Removing the * is correct here as _* is used to indiciate a dynamic shortcode. |
|
240 | - $shortcode = str_replace('[EVENT_META_*', '', $shortcode); |
|
241 | - $shortcode = trim(str_replace(']', '', $shortcode)); |
|
242 | - // Get any attributes set on this shortcode. |
|
243 | - $attrs = $this->_get_shortcode_attrs($shortcode); |
|
244 | - // The meta_key set on the shortcode should always be the first value in the array. |
|
245 | - $meta_key = $attrs[0]; |
|
246 | - // Pull the meta value from the event post. |
|
247 | - $event_meta = $this->_event->get_post_meta($meta_key, true); |
|
248 | - // If we have no event_meta, just return an empty string. |
|
249 | - if (empty($event_meta)) { |
|
250 | - return ''; |
|
251 | - } |
|
252 | - // Add a filter to allow all instances of EVENT_META_* to run through do_shortcode, default to false. |
|
253 | - // Check if a do_shortcode attribute was set to true and if so run $event_meta through that function. |
|
254 | - if (apply_filters('FHEE__EventEspresso_core_libraries_shortcodes_EE_Event_Shortcodes___parser__event_meta_do_shortcode', false) |
|
255 | - || !empty($attrs['do_shortcode']) && filter_var($attrs['do_shortcode'], FILTER_VALIDATE_BOOLEAN) |
|
256 | - ) { |
|
257 | - return do_shortcode($event_meta); |
|
258 | - } |
|
259 | - // Still here? We just need to return the event_meta value as is. |
|
260 | - return $event_meta; |
|
261 | - } |
|
262 | - |
|
263 | - if (strpos($shortcode, '[EVENT_TOTAL_AVAILABLE_SPACES_*') !== false) { |
|
264 | - $attrs = $this->_get_shortcode_attrs($shortcode); |
|
265 | - $method = empty($attrs['method']) ? 'current' : $attrs['method']; |
|
266 | - $method = $method === 'current'; |
|
267 | - $available = $this->_event->total_available_spaces($method); |
|
268 | - return $available === EE_INF ? '∞' : $available; |
|
269 | - } |
|
270 | - |
|
271 | - if (strpos($shortcode, '[EVENT_IMAGE_*') !== false) { |
|
272 | - $attrs = $this->_get_shortcode_attrs($shortcode); |
|
273 | - $width = empty($attrs['width']) ? '' : ' width="' . $attrs['width'] . '"'; |
|
274 | - $height = empty($attrs['height']) ? '' : ' height="' . $attrs['height'] . '"'; |
|
275 | - |
|
276 | - // Size may be set to a string such as 'tumbnail' or "width, height" eg - '200,200' |
|
277 | - if (! empty($attrs['size'])) { |
|
278 | - $size = explode(',', $attrs['size']); |
|
279 | - if (count($size) === 1) { |
|
280 | - $size = $size[0]; |
|
281 | - } |
|
282 | - } else { |
|
283 | - $size = 'thumbnail'; |
|
284 | - } |
|
285 | - |
|
286 | - $image = $this->_event->feature_image_url($size); |
|
287 | - |
|
288 | - return ! empty($image) |
|
289 | - ? '<img src="' . $image . '" alt="' |
|
290 | - . sprintf( |
|
291 | - esc_attr__('%s Feature Image', 'event_espresso'), |
|
292 | - $this->_event->get('EVT_name') |
|
293 | - ) . '"' . $width . $height . '/>' |
|
294 | - : ''; |
|
295 | - } |
|
296 | - |
|
297 | - return ''; |
|
298 | - } |
|
299 | - |
|
300 | - |
|
301 | - /** |
|
302 | - * returns the link to the event |
|
303 | - * |
|
304 | - * @param boolean $full_link if TRUE (default) we return the html for the name of the event linked to the event. |
|
305 | - * Otherwise we just return the url of the event. |
|
306 | - * @return string |
|
307 | - */ |
|
308 | - private function _get_event_link($event, $full_link = true) |
|
309 | - { |
|
310 | - $url = get_permalink($event->ID()); |
|
311 | - |
|
312 | - return $full_link ? '<a href="' . $url . '">' . $event->get('EVT_name') . '</a>' : $url; |
|
313 | - } |
|
22 | + /** |
|
23 | + * Will hold the EE_Event if available |
|
24 | + * |
|
25 | + * @var EE_Event |
|
26 | + */ |
|
27 | + protected $_event; |
|
28 | + |
|
29 | + |
|
30 | + public function __construct() |
|
31 | + { |
|
32 | + parent::__construct(); |
|
33 | + } |
|
34 | + |
|
35 | + |
|
36 | + protected function _init_props() |
|
37 | + { |
|
38 | + $this->label = __('Event Shortcodes', 'event_espresso'); |
|
39 | + $this->description = __('All shortcodes specific to event related data', 'event_espresso'); |
|
40 | + $this->_shortcodes = array( |
|
41 | + '[EVENT_ID]' => __( |
|
42 | + 'Will be replaced by the event ID of an event', |
|
43 | + 'event_espresso' |
|
44 | + ), |
|
45 | + '[EVENT]' => __('The name of the event', 'event_espresso'), |
|
46 | + '[EVENT_NAME]' => __( |
|
47 | + "This also can be used for the name of the event", |
|
48 | + 'event_espresso' |
|
49 | + ), |
|
50 | + '[EVENT_PHONE]' => __( |
|
51 | + 'The phone number for the event (usually an info number)', |
|
52 | + 'event_espresso' |
|
53 | + ), |
|
54 | + '[EVENT_DESCRIPTION]' => __('The description of the event', 'event_espresso'), |
|
55 | + '[EVENT_EXCERPT]' => __( |
|
56 | + 'This gets parsed to the value for the excerpt field in the event or blank if there is no excerpt.', |
|
57 | + 'event_espresso' |
|
58 | + ), |
|
59 | + '[EVENT_LINK]' => __('A link associated with the event', 'event_espresso'), |
|
60 | + '[EVENT_URL]' => __( |
|
61 | + 'A link to the event set up on the host site.', |
|
62 | + 'event_espresso' |
|
63 | + ), |
|
64 | + '[VIRTUAL_URL]' => __( |
|
65 | + 'What was used for the "URL of Event" field in the Venue settings', |
|
66 | + 'event_espresso' |
|
67 | + ), |
|
68 | + '[VIRTUAL_PHONE]' => __( |
|
69 | + 'An alternate phone number for the event. Typically used as a "call-in" number', |
|
70 | + 'event_espresso' |
|
71 | + ), |
|
72 | + '[EVENT_IMAGE]' => __( |
|
73 | + 'This will parse to the Feature image for the event.', |
|
74 | + 'event_espresso' |
|
75 | + ), |
|
76 | + '[EVENT_IMAGE_*]' => sprintf( |
|
77 | + __( |
|
78 | + 'This will parse to the Feature image for the event, %1$ssize%2$s can be set to determine the size of the image loaded by the shortcode. The %1$swidth%2$s and/or %1$sheight%2$s can also be set to determine the width and height of the image when output. By default the shortcode will load the %1$sthumbnail%2$s image size.', |
|
79 | + 'event_espresso' |
|
80 | + ), |
|
81 | + '<code>', |
|
82 | + '</code>' |
|
83 | + ), |
|
84 | + '[EVENT_TOTAL_AVAILABLE_SPACES_*]' => sprintf( |
|
85 | + __( |
|
86 | + 'This will parse to the total available spaces for an event. Calculating total spaces is approximate because it is dependent on the complexity of limits on your event. There are two methods of calculation (which can be indicated by the %1$smethod%2$s param on the shortcode). %1$scurrent%2$s which will do a more accurate calculation of total available spaces based on current sales, and %1$sfull%2$s which will be the maximum total available spaces that is on the event in optimal conditions. The shortcode will default to current.', |
|
87 | + 'event_espresso' |
|
88 | + ), |
|
89 | + '<code>', |
|
90 | + '</code>' |
|
91 | + ), |
|
92 | + '[EVENT_TOTAL_SPOTS_TAKEN]' => __( |
|
93 | + 'This shortcode will parse to the output the total approved registrations for this event', |
|
94 | + 'event_espresso' |
|
95 | + ), |
|
96 | + '[EVENT_FACEBOOK_URL]' => __( |
|
97 | + 'This will return the Facebook URL for the event if you have it set via custom field in your event, otherwise it will use the Facebook URL set in "Your Organization Settings". To set the facebook url in your event, add a custom field with the key as <code>event_facebook</code> and the value as your facebook url.', |
|
98 | + 'event_espresso' |
|
99 | + ), |
|
100 | + '[EVENT_TWITTER_URL]' => __( |
|
101 | + 'This will return the Twitter URL for the event if you have it set via custom field in your event, otherwise it will use the Twitter URL set in "Your Organization Settings". To set the facebook url in your event, add a custom field with the key as <code>event_twitter</code> and the value as your facebook url', |
|
102 | + 'event_espresso' |
|
103 | + ), |
|
104 | + '[EVENT_META_*]' => sprintf( |
|
105 | + __( |
|
106 | + 'This is a special dynamic shortcode. After the "*", add the exact name for your custom field, if there is a value set for that custom field within the event then it will be output in place of this shortcode. If you use shortcodes within your custom fields set %1$sdo_shortcode=true%2$s at the end of the shortcode to run the value through the do_shortcode function. ', |
|
107 | + 'event_espresso' |
|
108 | + ), |
|
109 | + '<code>', |
|
110 | + '</code>' |
|
111 | + ), |
|
112 | + '[REGISTRATION_LIST_TABLE_FOR_EVENT_URL]' => __( |
|
113 | + 'This parses to the url for the registration list table filtered by registrations for this event.', |
|
114 | + 'event_espresso' |
|
115 | + ), |
|
116 | + ); |
|
117 | + } |
|
118 | + |
|
119 | + |
|
120 | + protected function _parser($shortcode) |
|
121 | + { |
|
122 | + |
|
123 | + |
|
124 | + $this->_event = $this->_data instanceof EE_Event ? $this->_data : null; |
|
125 | + |
|
126 | + // if no event, then let's see if there is a reg_obj. If there IS, then we'll try and grab the event from the reg_obj instead. |
|
127 | + if (empty($this->_event)) { |
|
128 | + $aee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null; |
|
129 | + $aee = $this->_extra_data instanceof EE_Messages_Addressee ? $this->_extra_data : $aee; |
|
130 | + |
|
131 | + $this->_event = $aee instanceof EE_Messages_Addressee && $aee->reg_obj instanceof EE_Registration |
|
132 | + ? $aee->reg_obj->event() : null; |
|
133 | + } |
|
134 | + |
|
135 | + |
|
136 | + // If there is no event objecdt by now then get out. |
|
137 | + if (! $this->_event instanceof EE_Event) { |
|
138 | + return ''; |
|
139 | + } |
|
140 | + |
|
141 | + switch ($shortcode) { |
|
142 | + case '[EVENT_ID]': |
|
143 | + return $this->_event->ID(); |
|
144 | + break; |
|
145 | + |
|
146 | + case '[EVENT]': |
|
147 | + case '[EVENT_NAME]': |
|
148 | + return $this->_event->get('EVT_name'); |
|
149 | + break; |
|
150 | + |
|
151 | + case '[EVENT_PHONE]': |
|
152 | + return $this->_event->get('EVT_phone'); |
|
153 | + break; |
|
154 | + |
|
155 | + case '[EVENT_DESCRIPTION]': |
|
156 | + return $this->_event->get('EVT_desc'); |
|
157 | + break; |
|
158 | + |
|
159 | + case '[EVENT_EXCERPT]': |
|
160 | + return $this->_event->get('EVT_short_desc'); |
|
161 | + break; |
|
162 | + |
|
163 | + case '[EVENT_LINK]': |
|
164 | + return $this->_get_event_link($this->_event); |
|
165 | + break; |
|
166 | + |
|
167 | + case '[EVENT_URL]': |
|
168 | + return $this->_get_event_link($this->_event, false); |
|
169 | + break; |
|
170 | + |
|
171 | + case '[VIRTUAL_URL]': |
|
172 | + $venue = $this->_event->get_first_related('Venue'); |
|
173 | + if (empty($venue)) { |
|
174 | + return ''; |
|
175 | + } |
|
176 | + return $venue->get('VNU_virtual_url'); |
|
177 | + |
|
178 | + case '[VIRTUAL_PHONE]': |
|
179 | + $venue = $this->_event->get_first_related('Venue'); |
|
180 | + if (empty($venue)) { |
|
181 | + return ''; |
|
182 | + } |
|
183 | + return $venue->get('VNU_virtual_phone'); |
|
184 | + break; |
|
185 | + |
|
186 | + case '[EVENT_IMAGE]': |
|
187 | + $image = $this->_event->feature_image_url(array(600, 300)); |
|
188 | + // @todo: eventually we should make this an attribute shortcode so that em can send along what size they want returned. |
|
189 | + return ! empty($image) |
|
190 | + ? '<img src="' . $image . '" alt="' |
|
191 | + . sprintf( |
|
192 | + esc_attr__('%s Feature Image', 'event_espresso'), |
|
193 | + $this->_event->get('EVT_name') |
|
194 | + ) . '" />' |
|
195 | + : ''; |
|
196 | + break; |
|
197 | + |
|
198 | + case '[EVENT_FACEBOOK_URL]': |
|
199 | + $facebook_url = $this->_event->get_post_meta('event_facebook', true); |
|
200 | + return empty($facebook_url) ? EE_Registry::instance()->CFG->organization->get_pretty('facebook') |
|
201 | + : $facebook_url; |
|
202 | + break; |
|
203 | + |
|
204 | + case '[EVENT_TWITTER_URL]': |
|
205 | + $twitter_url = $this->_event->get_post_meta('event_twitter', true); |
|
206 | + return empty($twitter_url) ? EE_Registry::instance()->CFG->organization->get_pretty('twitter') |
|
207 | + : $twitter_url; |
|
208 | + break; |
|
209 | + |
|
210 | + case '[EVENT_AUTHOR_EMAIL]': |
|
211 | + $author_id = $this->_event->get('EVT_wp_user'); |
|
212 | + $user_data = get_userdata((int) $author_id); |
|
213 | + return $user_data->user_email; |
|
214 | + break; |
|
215 | + |
|
216 | + case '[EVENT_TOTAL_SPOTS_TAKEN]': |
|
217 | + return EEM_Registration::instance()->count( |
|
218 | + array(array('EVT_ID' => $this->_event->ID(), 'STS_ID' => EEM_Registration::status_id_approved)), |
|
219 | + 'REG_ID', |
|
220 | + true |
|
221 | + ); |
|
222 | + break; |
|
223 | + |
|
224 | + case '[REGISTRATION_LIST_TABLE_FOR_EVENT_URL]': |
|
225 | + return EEH_URL::add_query_args_and_nonce( |
|
226 | + array( |
|
227 | + 'event_id' => $this->_event->ID(), |
|
228 | + 'page' => 'espresso_registrations', |
|
229 | + 'action' => 'default', |
|
230 | + ), |
|
231 | + admin_url('admin.php'), |
|
232 | + true |
|
233 | + ); |
|
234 | + break; |
|
235 | + } |
|
236 | + |
|
237 | + if (strpos($shortcode, '[EVENT_META_*') !== false) { |
|
238 | + // Strip the shortcode itself from $shortcode leaving any attributes set. |
|
239 | + // Removing the * is correct here as _* is used to indiciate a dynamic shortcode. |
|
240 | + $shortcode = str_replace('[EVENT_META_*', '', $shortcode); |
|
241 | + $shortcode = trim(str_replace(']', '', $shortcode)); |
|
242 | + // Get any attributes set on this shortcode. |
|
243 | + $attrs = $this->_get_shortcode_attrs($shortcode); |
|
244 | + // The meta_key set on the shortcode should always be the first value in the array. |
|
245 | + $meta_key = $attrs[0]; |
|
246 | + // Pull the meta value from the event post. |
|
247 | + $event_meta = $this->_event->get_post_meta($meta_key, true); |
|
248 | + // If we have no event_meta, just return an empty string. |
|
249 | + if (empty($event_meta)) { |
|
250 | + return ''; |
|
251 | + } |
|
252 | + // Add a filter to allow all instances of EVENT_META_* to run through do_shortcode, default to false. |
|
253 | + // Check if a do_shortcode attribute was set to true and if so run $event_meta through that function. |
|
254 | + if (apply_filters('FHEE__EventEspresso_core_libraries_shortcodes_EE_Event_Shortcodes___parser__event_meta_do_shortcode', false) |
|
255 | + || !empty($attrs['do_shortcode']) && filter_var($attrs['do_shortcode'], FILTER_VALIDATE_BOOLEAN) |
|
256 | + ) { |
|
257 | + return do_shortcode($event_meta); |
|
258 | + } |
|
259 | + // Still here? We just need to return the event_meta value as is. |
|
260 | + return $event_meta; |
|
261 | + } |
|
262 | + |
|
263 | + if (strpos($shortcode, '[EVENT_TOTAL_AVAILABLE_SPACES_*') !== false) { |
|
264 | + $attrs = $this->_get_shortcode_attrs($shortcode); |
|
265 | + $method = empty($attrs['method']) ? 'current' : $attrs['method']; |
|
266 | + $method = $method === 'current'; |
|
267 | + $available = $this->_event->total_available_spaces($method); |
|
268 | + return $available === EE_INF ? '∞' : $available; |
|
269 | + } |
|
270 | + |
|
271 | + if (strpos($shortcode, '[EVENT_IMAGE_*') !== false) { |
|
272 | + $attrs = $this->_get_shortcode_attrs($shortcode); |
|
273 | + $width = empty($attrs['width']) ? '' : ' width="' . $attrs['width'] . '"'; |
|
274 | + $height = empty($attrs['height']) ? '' : ' height="' . $attrs['height'] . '"'; |
|
275 | + |
|
276 | + // Size may be set to a string such as 'tumbnail' or "width, height" eg - '200,200' |
|
277 | + if (! empty($attrs['size'])) { |
|
278 | + $size = explode(',', $attrs['size']); |
|
279 | + if (count($size) === 1) { |
|
280 | + $size = $size[0]; |
|
281 | + } |
|
282 | + } else { |
|
283 | + $size = 'thumbnail'; |
|
284 | + } |
|
285 | + |
|
286 | + $image = $this->_event->feature_image_url($size); |
|
287 | + |
|
288 | + return ! empty($image) |
|
289 | + ? '<img src="' . $image . '" alt="' |
|
290 | + . sprintf( |
|
291 | + esc_attr__('%s Feature Image', 'event_espresso'), |
|
292 | + $this->_event->get('EVT_name') |
|
293 | + ) . '"' . $width . $height . '/>' |
|
294 | + : ''; |
|
295 | + } |
|
296 | + |
|
297 | + return ''; |
|
298 | + } |
|
299 | + |
|
300 | + |
|
301 | + /** |
|
302 | + * returns the link to the event |
|
303 | + * |
|
304 | + * @param boolean $full_link if TRUE (default) we return the html for the name of the event linked to the event. |
|
305 | + * Otherwise we just return the url of the event. |
|
306 | + * @return string |
|
307 | + */ |
|
308 | + private function _get_event_link($event, $full_link = true) |
|
309 | + { |
|
310 | + $url = get_permalink($event->ID()); |
|
311 | + |
|
312 | + return $full_link ? '<a href="' . $url . '">' . $event->get('EVT_name') . '</a>' : $url; |
|
313 | + } |
|
314 | 314 | } |