Completed
Branch FET/messages_do_shortcode_on_e... (87f291)
by
unknown
53:06 queued 44:52
created
core/libraries/shortcodes/EE_Event_Shortcodes.lib.php 2 patches
Indentation   +291 added lines, -291 removed lines patch added patch discarded remove patch
@@ -19,295 +19,295 @@
 block discarded – undo
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
-            $shortcode = str_replace('[EVENT_META_*', '', $shortcode);
240
-            $shortcode = trim(str_replace(']', '', $shortcode));
241
-            // Get any attributes set on this shortcode.
242
-            $attrs = $this->_get_shortcode_attrs($shortcode);
243
-            // The meta_key set on the shortcode should always be the first value in the array.
244
-            $meta_key = $attrs[0];
245
-            // Pull the meta value from the event post.
246
-            $event_meta = $this->_event->get_post_meta($meta_key, true);
247
-            // If we have no event_meta, just return an empty string.
248
-            if (empty($event_meta)) {
249
-                return '';
250
-            }
251
-            // Add a filter to allow all instances of EVENT_META_* to run through do_shortcode, default to false.
252
-            // Check if a do_shortcode attribute was set to true and if so run $event_meta through that function.
253
-            if (apply_filters('FHEE__EventEspresso_core_libraries_shortcodes_EE_Event_Shortcodes___parser__event_meta_do_shortcode', false)
254
-                || !empty($attrs['do_shortcode']) && filter_var($attrs['do_shortcode'], FILTER_VALIDATE_BOOLEAN)
255
-            ) {
256
-                return do_shortcode($event_meta);
257
-            }
258
-            // Still here? We just need to return the event_meta value as is.
259
-            return $event_meta;
260
-        }
261
-
262
-        if (strpos($shortcode, '[EVENT_TOTAL_AVAILABLE_SPACES_*') !== false) {
263
-            $attrs = $this->_get_shortcode_attrs($shortcode);
264
-            $method = empty($attrs['method']) ? 'current' : $attrs['method'];
265
-            $method = $method === 'current';
266
-            $available = $this->_event->total_available_spaces($method);
267
-            return $available === EE_INF ? '&infin;' : $available;
268
-        }
269
-
270
-        if (strpos($shortcode, '[EVENT_IMAGE_*') !== false) {
271
-            $attrs = $this->_get_shortcode_attrs($shortcode);
272
-            $width = empty($attrs['width']) ? '' : ' width="' . $attrs['width'] . '"';
273
-            $height = empty($attrs['height']) ? '' : ' height="' . $attrs['height'] . '"';
274
-
275
-            // Size may be set to a string such as 'tumbnail' or "width, height" eg - '200,200'
276
-            if (! empty($attrs['size'])) {
277
-                $size = explode(',', $attrs['size']);
278
-                if (count($size) === 1) {
279
-                    $size = $size[0];
280
-                }
281
-            } else {
282
-                $size = 'thumbnail';
283
-            }
284
-
285
-            $image = $this->_event->feature_image_url($size);
286
-
287
-            return ! empty($image)
288
-                ? '<img src="' . $image . '" alt="'
289
-                  . sprintf(
290
-                      esc_attr__('%s Feature Image', 'event_espresso'),
291
-                      $this->_event->get('EVT_name')
292
-                  ) . '"' . $width . $height . '/>'
293
-                : '';
294
-        }
295
-
296
-        return '';
297
-    }
298
-
299
-
300
-    /**
301
-     * returns the link to the event
302
-     *
303
-     * @param  boolean $full_link if TRUE (default) we return the html for the name of the event linked to the event.
304
-     *                            Otherwise we just return the url of the event.
305
-     * @return string
306
-     */
307
-    private function _get_event_link($event, $full_link = true)
308
-    {
309
-        $url = get_permalink($event->ID());
310
-
311
-        return $full_link ? '<a href="' . $url . '">' . $event->get('EVT_name') . '</a>' : $url;
312
-    }
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
+			$shortcode = str_replace('[EVENT_META_*', '', $shortcode);
240
+			$shortcode = trim(str_replace(']', '', $shortcode));
241
+			// Get any attributes set on this shortcode.
242
+			$attrs = $this->_get_shortcode_attrs($shortcode);
243
+			// The meta_key set on the shortcode should always be the first value in the array.
244
+			$meta_key = $attrs[0];
245
+			// Pull the meta value from the event post.
246
+			$event_meta = $this->_event->get_post_meta($meta_key, true);
247
+			// If we have no event_meta, just return an empty string.
248
+			if (empty($event_meta)) {
249
+				return '';
250
+			}
251
+			// Add a filter to allow all instances of EVENT_META_* to run through do_shortcode, default to false.
252
+			// Check if a do_shortcode attribute was set to true and if so run $event_meta through that function.
253
+			if (apply_filters('FHEE__EventEspresso_core_libraries_shortcodes_EE_Event_Shortcodes___parser__event_meta_do_shortcode', false)
254
+				|| !empty($attrs['do_shortcode']) && filter_var($attrs['do_shortcode'], FILTER_VALIDATE_BOOLEAN)
255
+			) {
256
+				return do_shortcode($event_meta);
257
+			}
258
+			// Still here? We just need to return the event_meta value as is.
259
+			return $event_meta;
260
+		}
261
+
262
+		if (strpos($shortcode, '[EVENT_TOTAL_AVAILABLE_SPACES_*') !== false) {
263
+			$attrs = $this->_get_shortcode_attrs($shortcode);
264
+			$method = empty($attrs['method']) ? 'current' : $attrs['method'];
265
+			$method = $method === 'current';
266
+			$available = $this->_event->total_available_spaces($method);
267
+			return $available === EE_INF ? '&infin;' : $available;
268
+		}
269
+
270
+		if (strpos($shortcode, '[EVENT_IMAGE_*') !== false) {
271
+			$attrs = $this->_get_shortcode_attrs($shortcode);
272
+			$width = empty($attrs['width']) ? '' : ' width="' . $attrs['width'] . '"';
273
+			$height = empty($attrs['height']) ? '' : ' height="' . $attrs['height'] . '"';
274
+
275
+			// Size may be set to a string such as 'tumbnail' or "width, height" eg - '200,200'
276
+			if (! empty($attrs['size'])) {
277
+				$size = explode(',', $attrs['size']);
278
+				if (count($size) === 1) {
279
+					$size = $size[0];
280
+				}
281
+			} else {
282
+				$size = 'thumbnail';
283
+			}
284
+
285
+			$image = $this->_event->feature_image_url($size);
286
+
287
+			return ! empty($image)
288
+				? '<img src="' . $image . '" alt="'
289
+				  . sprintf(
290
+					  esc_attr__('%s Feature Image', 'event_espresso'),
291
+					  $this->_event->get('EVT_name')
292
+				  ) . '"' . $width . $height . '/>'
293
+				: '';
294
+		}
295
+
296
+		return '';
297
+	}
298
+
299
+
300
+	/**
301
+	 * returns the link to the event
302
+	 *
303
+	 * @param  boolean $full_link if TRUE (default) we return the html for the name of the event linked to the event.
304
+	 *                            Otherwise we just return the url of the event.
305
+	 * @return string
306
+	 */
307
+	private function _get_event_link($event, $full_link = true)
308
+	{
309
+		$url = get_permalink($event->ID());
310
+
311
+		return $full_link ? '<a href="' . $url . '">' . $event->get('EVT_name') . '</a>' : $url;
312
+	}
313 313
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 
135 135
 
136 136
         // If there is no event objecdt by now then get out.
137
-        if (! $this->_event instanceof EE_Event) {
137
+        if ( ! $this->_event instanceof EE_Event) {
138 138
             return '';
139 139
         }
140 140
 
@@ -187,11 +187,11 @@  discard block
 block discarded – undo
187 187
                 $image = $this->_event->feature_image_url(array(600, 300));
188 188
                 // @todo: eventually we should make this an attribute shortcode so that em can send along what size they want returned.
189 189
                 return ! empty($image)
190
-                    ? '<img src="' . $image . '" alt="'
190
+                    ? '<img src="'.$image.'" alt="'
191 191
                       . sprintf(
192 192
                           esc_attr__('%s Feature Image', 'event_espresso'),
193 193
                           $this->_event->get('EVT_name')
194
-                      ) . '" />'
194
+                      ).'" />'
195 195
                     : '';
196 196
                 break;
197 197
 
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
             // Add a filter to allow all instances of EVENT_META_* to run through do_shortcode, default to false.
252 252
             // Check if a do_shortcode attribute was set to true and if so run $event_meta through that function.
253 253
             if (apply_filters('FHEE__EventEspresso_core_libraries_shortcodes_EE_Event_Shortcodes___parser__event_meta_do_shortcode', false)
254
-                || !empty($attrs['do_shortcode']) && filter_var($attrs['do_shortcode'], FILTER_VALIDATE_BOOLEAN)
254
+                || ! empty($attrs['do_shortcode']) && filter_var($attrs['do_shortcode'], FILTER_VALIDATE_BOOLEAN)
255 255
             ) {
256 256
                 return do_shortcode($event_meta);
257 257
             }
@@ -269,11 +269,11 @@  discard block
 block discarded – undo
269 269
 
270 270
         if (strpos($shortcode, '[EVENT_IMAGE_*') !== false) {
271 271
             $attrs = $this->_get_shortcode_attrs($shortcode);
272
-            $width = empty($attrs['width']) ? '' : ' width="' . $attrs['width'] . '"';
273
-            $height = empty($attrs['height']) ? '' : ' height="' . $attrs['height'] . '"';
272
+            $width = empty($attrs['width']) ? '' : ' width="'.$attrs['width'].'"';
273
+            $height = empty($attrs['height']) ? '' : ' height="'.$attrs['height'].'"';
274 274
 
275 275
             // Size may be set to a string such as 'tumbnail' or "width, height" eg - '200,200'
276
-            if (! empty($attrs['size'])) {
276
+            if ( ! empty($attrs['size'])) {
277 277
                 $size = explode(',', $attrs['size']);
278 278
                 if (count($size) === 1) {
279 279
                     $size = $size[0];
@@ -285,11 +285,11 @@  discard block
 block discarded – undo
285 285
             $image = $this->_event->feature_image_url($size);
286 286
 
287 287
             return ! empty($image)
288
-                ? '<img src="' . $image . '" alt="'
288
+                ? '<img src="'.$image.'" alt="'
289 289
                   . sprintf(
290 290
                       esc_attr__('%s Feature Image', 'event_espresso'),
291 291
                       $this->_event->get('EVT_name')
292
-                  ) . '"' . $width . $height . '/>'
292
+                  ).'"'.$width.$height.'/>'
293 293
                 : '';
294 294
         }
295 295
 
@@ -308,6 +308,6 @@  discard block
 block discarded – undo
308 308
     {
309 309
         $url = get_permalink($event->ID());
310 310
 
311
-        return $full_link ? '<a href="' . $url . '">' . $event->get('EVT_name') . '</a>' : $url;
311
+        return $full_link ? '<a href="'.$url.'">'.$event->get('EVT_name').'</a>' : $url;
312 312
     }
313 313
 }
Please login to merge, or discard this patch.