Completed
Branch master (03f360)
by
unknown
13:33 queued 11:19
created
core/helpers/EEH_Event_View.helper.php 1 patch
Indentation   +614 added lines, -614 removed lines patch added patch discarded remove patch
@@ -10,364 +10,364 @@  discard block
 block discarded – undo
10 10
 class EEH_Event_View extends EEH_Base
11 11
 {
12 12
 
13
-    /**
14
-     * @var EE_Event $_event
15
-     */
16
-    private static $_event = null;
17
-
18
-
19
-    /**
20
-     * get_event
21
-     * attempts to retrieve an EE_Event object any way it can
22
-     *
23
-     * @param int|WP_Post $EVT_ID
24
-     * @return EE_Event|null
25
-     * @throws EE_Error
26
-     * @throws ReflectionException
27
-     */
28
-    public static function get_event($EVT_ID = 0)
29
-    {
30
-        // international newspaper?
31
-        global $post;
32
-        $EVT_ID = $EVT_ID instanceof WP_Post && $EVT_ID->post_type === 'espresso_events'
33
-            ? $EVT_ID->ID
34
-            : absint($EVT_ID);
35
-        // do we already have the Event  you are looking for?
36
-        if (EEH_Event_View::$_event instanceof EE_Event && $EVT_ID && EEH_Event_View::$_event->ID() === $EVT_ID) {
37
-            return EEH_Event_View::$_event;
38
-        }
39
-        // reset property so that the new event is cached.
40
-        EEH_Event_View::$_event = null;
41
-        if (! $EVT_ID && $post instanceof EE_Event) {
42
-            EEH_Event_View::$_event = $post;
43
-            return EEH_Event_View::$_event;
44
-        }
45
-        // if the post type is for an event and it has a cached event and we don't have a different incoming $EVT_ID
46
-        // then let's just use that cached event on the $post object.
47
-        if (
48
-            $post instanceof WP_Post
49
-            && $post->post_type === 'espresso_events'
50
-            && isset($post->EE_Event)
51
-            && (
52
-                $EVT_ID === 0
53
-                || $EVT_ID === $post->ID
54
-            )
55
-        ) {
56
-            EEH_Event_View::$_event = $post->EE_Event;
57
-            return EEH_Event_View::$_event;
58
-        }
59
-        // If the event we have isn't an event but we do have an EVT_ID, let's try getting the event using the ID.
60
-        if (! EEH_Event_View::$_event instanceof EE_Event && $EVT_ID) {
61
-            EEH_Event_View::$_event = EEM_Event::instance()->get_one_by_ID($EVT_ID);
62
-        }
63
-        return EEH_Event_View::$_event;
64
-    }
65
-
66
-
67
-    /**
68
-     *    display_ticket_selector
69
-     *
70
-     * @param int $EVT_ID
71
-     * @return    boolean
72
-     * @throws EE_Error
73
-     * @throws EE_Error
74
-     * @throws ReflectionException
75
-     */
76
-    public static function display_ticket_selector($EVT_ID = 0)
77
-    {
78
-        $event = EEH_Event_View::get_event($EVT_ID);
79
-        return $event instanceof EE_Event && $event->display_ticket_selector();
80
-    }
81
-
82
-
83
-    /**
84
-     *    event_status
85
-     *
86
-     * @param int $EVT_ID
87
-     * @return    string
88
-     * @throws EE_Error
89
-     * @throws EE_Error
90
-     * @throws ReflectionException
91
-     */
92
-    public static function event_status($EVT_ID = 0)
93
-    {
94
-        $event = EEH_Event_View::get_event($EVT_ID);
95
-        return $event instanceof EE_Event ? $event->pretty_active_status(false) : '';
96
-    }
97
-
98
-
99
-    /**
100
-     *  event_active_status
101
-     *
102
-     * @param int $EVT_ID
103
-     * @return     string
104
-     * @throws EE_Error
105
-     * @throws EE_Error
106
-     * @throws ReflectionException
107
-     */
108
-    public static function event_active_status($EVT_ID = 0, $echo = true)
109
-    {
110
-        $event = EEH_Event_View::get_event($EVT_ID);
111
-        return $event instanceof EE_Event ? $event->pretty_active_status($echo) : 'inactive';
112
-    }
113
-
114
-
115
-    /**
116
-     *  event_has_content_or_excerpt
117
-     *
118
-     * @param int $EVT_ID
119
-     * @return     bool
120
-     * @throws EE_Error
121
-     * @throws EE_Error
122
-     * @throws ReflectionException
123
-     */
124
-    public static function event_has_content_or_excerpt($EVT_ID = 0)
125
-    {
126
-        $event                  = EEH_Event_View::get_event($EVT_ID);
127
-        $has_content_or_excerpt = false;
128
-        if ($event instanceof EE_Event) {
129
-            $has_content_or_excerpt = $event->description() != '' || $event->short_description(null, null, true) != '';
130
-        }
131
-        if (
132
-            is_archive()
133
-            && ! (espresso_display_full_description_in_event_list()
134
-                  || espresso_display_excerpt_in_event_list())
135
-        ) {
136
-            $has_content_or_excerpt = false;
137
-        }
138
-        return $has_content_or_excerpt;
139
-    }
140
-
141
-
142
-    /**
143
-     *    event_active_status
144
-     *
145
-     * @param null $num_words
146
-     * @param null $more
147
-     * @return    string
148
-     */
149
-    public static function event_content_or_excerpt($num_words = null, $more = null)
150
-    {
151
-        global $post;
152
-        ob_start();
153
-        if ((is_single()) || (is_archive() && espresso_display_full_description_in_event_list())) {
154
-            // admin has chosen "full description"
155
-            // for the "Event Espresso - Events > Templates > Display Description" option
156
-            the_content();
157
-        } elseif ((is_archive() && espresso_display_excerpt_in_event_list())) {
158
-            if (has_excerpt($post->ID)) {
159
-                // admin has chosen "excerpt (short desc)"
160
-                // for the "Event Espresso - Events > Templates > Display Description" option
161
-                // AND an excerpt actually exists
162
-                the_excerpt();
163
-            } else {
164
-                // admin has chosen "excerpt (short desc)"
165
-                // for the "Event Espresso - Events > Templates > Display Description" option
166
-                // but NO excerpt actually exists, so we need to create one
167
-                if (! empty($num_words)) {
168
-                    if (empty($more)) {
169
-                        $more_link_text = esc_html__('(more…)', 'event_espresso');
170
-                        $more           = ' <a href="' . get_permalink() . '"';
171
-                        $more           .= ' class="more-link"';
172
-                        $more           .= EED_Events_Archive::link_target();
173
-                        $more           .= '>' . $more_link_text . '</a>';
174
-                        $more           = apply_filters('the_content_more_link', $more, $more_link_text);
175
-                    }
176
-                    $content = str_replace('NOMORELINK', '', get_the_content('NOMORELINK'));
177
-
178
-                    $content = wp_trim_words($content, $num_words, ' ') . $more;
179
-                } else {
180
-                    $content = get_the_content();
181
-                }
182
-                global $allowedtags;
183
-                // make sure links are allowed
184
-                $allowedtags['a'] = isset($allowedtags['a'])
185
-                    ? $allowedtags['a']
186
-                    : [];
187
-                // as well as target attribute
188
-                $allowedtags['a']['target'] = isset($allowedtags['a']['target'])
189
-                    ? $allowedtags['a']['target']
190
-                    : false;
191
-                // but get previous value so we can reset it
192
-                $prev_value                 = $allowedtags['a']['target'];
193
-                $allowedtags['a']['target'] = true;
194
-                $content                    = wp_kses($content, $allowedtags);
195
-                $content                    = strip_shortcodes($content);
196
-                echo apply_filters('the_content', $content);
197
-                $allowedtags['a']['target'] = $prev_value;
198
-            }
199
-        } else {
200
-            // admin has chosen "none"
201
-            // for the "Event Espresso - Events > Templates > Display Description" option
202
-            echo apply_filters('the_content', '');
203
-        }
204
-        return ob_get_clean();
205
-    }
206
-
207
-
208
-    /**
209
-     *  event_tickets_available
210
-     *
211
-     * @param int $EVT_ID
212
-     * @return     EE_Ticket[]
213
-     * @throws EE_Error
214
-     * @throws ReflectionException
215
-     */
216
-    public static function event_tickets_available($EVT_ID = 0)
217
-    {
218
-        $event                          = EEH_Event_View::get_event($EVT_ID);
219
-        $tickets_available_for_purchase = [];
220
-        if ($event instanceof EE_Event) {
221
-            $datetimes = EEH_Event_View::get_all_date_obj($EVT_ID, false);
222
-            foreach ($datetimes as $datetime) {
223
-                $tickets_available_for_purchase =
224
-                    array_merge($tickets_available_for_purchase, $datetime->ticket_types_available_for_purchase());
225
-            }
226
-        }
227
-        return $tickets_available_for_purchase;
228
-    }
229
-
230
-
231
-    /**
232
-     *    the_event_date
233
-     *
234
-     * @param int  $EVT_ID
235
-     * @param bool $hide_uncategorized
236
-     * @return    string
237
-     * @throws EE_Error
238
-     * @throws ReflectionException
239
-     */
240
-    public static function event_categories($EVT_ID = 0, $hide_uncategorized = true)
241
-    {
242
-        $category_links = [];
243
-        $event          = EEH_Event_View::get_event($EVT_ID);
244
-        if ($event instanceof EE_Event) {
245
-            $event_categories = get_the_terms($event->ID(), 'espresso_event_categories');
246
-            if ($event_categories) {
247
-                // loop thru terms and create links
248
-                foreach ($event_categories as $term) {
249
-                    $url = get_term_link($term, 'espresso_venue_categories');
250
-                    if (
251
-                        ! is_wp_error($url)
252
-                        && (
253
-                            (
254
-                                $hide_uncategorized
255
-                                && strtolower($term->name) != esc_html__('uncategorized', 'event_espresso')
256
-                            )
257
-                            || ! $hide_uncategorized
258
-                        )
259
-                    ) {
260
-                        $category_links[] = '<a href="' . esc_url_raw($url) . '" '
261
-                                            . 'rel="tag" ' . EED_Events_Archive::link_target() . '>'
262
-                                            . esc_html($term->name)
263
-                                            . '</a>';
264
-                    }
265
-                }
266
-            }
267
-        }
268
-        return implode(', ', $category_links);
269
-    }
270
-
271
-
272
-    /**
273
-     *    the_event_date - first date by date order
274
-     *
275
-     * @param string $date_format
276
-     * @param string $time_format
277
-     * @param int    $EVT_ID
278
-     * @return    string
279
-     * @throws EE_Error
280
-     * @throws ReflectionException
281
-     */
282
-    public static function the_event_date($date_format = 'D M jS', $time_format = 'g:i a', $EVT_ID = 0)
283
-    {
284
-        $datetime = EEH_Event_View::get_primary_date_obj($EVT_ID);
285
-        $format   = ! empty($date_format) && ! empty($time_format)
286
-                ? $date_format . ' ' . $time_format
287
-                : $date_format . $time_format;
288
-        return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime('DTT_EVT_start', $format) : '';
289
-    }
290
-
291
-
292
-    /**
293
-     *    the_event_end_date - last date by date order
294
-     *
295
-     * @param string $date_format
296
-     * @param string $time_format
297
-     * @param int    $EVT_ID
298
-     * @return    string
299
-     * @throws EE_Error
300
-     * @throws ReflectionException
301
-     */
302
-    public static function the_event_end_date($date_format = 'D M jS', $time_format = 'g:i a', $EVT_ID = 0)
303
-    {
304
-        $datetime = EEH_Event_View::get_last_date_obj($EVT_ID);
305
-        $format   =
306
-            ! empty($date_format) && ! empty($time_format)
307
-                ? $date_format . ' ' . $time_format
308
-                : $date_format
309
-                  . $time_format;
310
-        return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime('DTT_EVT_end', $format) : '';
311
-    }
312
-
313
-
314
-    /**
315
-     *    the_earliest_event_date - first date chronologically
316
-     *
317
-     * @param string $date_format
318
-     * @param string $time_format
319
-     * @param int    $EVT_ID
320
-     * @return    string
321
-     * @throws EE_Error
322
-     * @throws ReflectionException
323
-     */
324
-    public static function the_earliest_event_date($date_format = 'D M jS', $time_format = 'g:i a', $EVT_ID = 0)
325
-    {
326
-        $datetime = EEH_Event_View::get_earliest_date_obj($EVT_ID);
327
-        $format   =
328
-            ! empty($date_format) && ! empty($time_format)
329
-                ? $date_format . ' ' . $time_format
330
-                : $date_format
331
-                  . $time_format;
332
-        return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime('DTT_EVT_start', $format) : '';
333
-    }
334
-
335
-
336
-    /**
337
-     *    the_latest_event_date - latest date chronologically
338
-     *
339
-     * @param string $date_format
340
-     * @param string $time_format
341
-     * @param int    $EVT_ID
342
-     * @return    string
343
-     * @throws EE_Error
344
-     * @throws ReflectionException
345
-     */
346
-    public static function the_latest_event_date($date_format = 'D M jS', $time_format = 'g:i a', $EVT_ID = 0)
347
-    {
348
-        $datetime = EEH_Event_View::get_latest_date_obj($EVT_ID);
349
-        $format   =
350
-            ! empty($date_format) && ! empty($time_format)
351
-                ? $date_format . ' ' . $time_format
352
-                : $date_format
353
-                  . $time_format;
354
-        return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime('DTT_EVT_end', $format) : '';
355
-    }
356
-
357
-
358
-    /**
359
-     *    event_date_as_calendar_page
360
-     *
361
-     * @param int $EVT_ID
362
-     * @return    void
363
-     * @throws EE_Error
364
-     * @throws ReflectionException
365
-     */
366
-    public static function event_date_as_calendar_page($EVT_ID = 0)
367
-    {
368
-        $datetime = EEH_Event_View::get_primary_date_obj($EVT_ID);
369
-        if ($datetime instanceof EE_Datetime) {
370
-            ?>
13
+	/**
14
+	 * @var EE_Event $_event
15
+	 */
16
+	private static $_event = null;
17
+
18
+
19
+	/**
20
+	 * get_event
21
+	 * attempts to retrieve an EE_Event object any way it can
22
+	 *
23
+	 * @param int|WP_Post $EVT_ID
24
+	 * @return EE_Event|null
25
+	 * @throws EE_Error
26
+	 * @throws ReflectionException
27
+	 */
28
+	public static function get_event($EVT_ID = 0)
29
+	{
30
+		// international newspaper?
31
+		global $post;
32
+		$EVT_ID = $EVT_ID instanceof WP_Post && $EVT_ID->post_type === 'espresso_events'
33
+			? $EVT_ID->ID
34
+			: absint($EVT_ID);
35
+		// do we already have the Event  you are looking for?
36
+		if (EEH_Event_View::$_event instanceof EE_Event && $EVT_ID && EEH_Event_View::$_event->ID() === $EVT_ID) {
37
+			return EEH_Event_View::$_event;
38
+		}
39
+		// reset property so that the new event is cached.
40
+		EEH_Event_View::$_event = null;
41
+		if (! $EVT_ID && $post instanceof EE_Event) {
42
+			EEH_Event_View::$_event = $post;
43
+			return EEH_Event_View::$_event;
44
+		}
45
+		// if the post type is for an event and it has a cached event and we don't have a different incoming $EVT_ID
46
+		// then let's just use that cached event on the $post object.
47
+		if (
48
+			$post instanceof WP_Post
49
+			&& $post->post_type === 'espresso_events'
50
+			&& isset($post->EE_Event)
51
+			&& (
52
+				$EVT_ID === 0
53
+				|| $EVT_ID === $post->ID
54
+			)
55
+		) {
56
+			EEH_Event_View::$_event = $post->EE_Event;
57
+			return EEH_Event_View::$_event;
58
+		}
59
+		// If the event we have isn't an event but we do have an EVT_ID, let's try getting the event using the ID.
60
+		if (! EEH_Event_View::$_event instanceof EE_Event && $EVT_ID) {
61
+			EEH_Event_View::$_event = EEM_Event::instance()->get_one_by_ID($EVT_ID);
62
+		}
63
+		return EEH_Event_View::$_event;
64
+	}
65
+
66
+
67
+	/**
68
+	 *    display_ticket_selector
69
+	 *
70
+	 * @param int $EVT_ID
71
+	 * @return    boolean
72
+	 * @throws EE_Error
73
+	 * @throws EE_Error
74
+	 * @throws ReflectionException
75
+	 */
76
+	public static function display_ticket_selector($EVT_ID = 0)
77
+	{
78
+		$event = EEH_Event_View::get_event($EVT_ID);
79
+		return $event instanceof EE_Event && $event->display_ticket_selector();
80
+	}
81
+
82
+
83
+	/**
84
+	 *    event_status
85
+	 *
86
+	 * @param int $EVT_ID
87
+	 * @return    string
88
+	 * @throws EE_Error
89
+	 * @throws EE_Error
90
+	 * @throws ReflectionException
91
+	 */
92
+	public static function event_status($EVT_ID = 0)
93
+	{
94
+		$event = EEH_Event_View::get_event($EVT_ID);
95
+		return $event instanceof EE_Event ? $event->pretty_active_status(false) : '';
96
+	}
97
+
98
+
99
+	/**
100
+	 *  event_active_status
101
+	 *
102
+	 * @param int $EVT_ID
103
+	 * @return     string
104
+	 * @throws EE_Error
105
+	 * @throws EE_Error
106
+	 * @throws ReflectionException
107
+	 */
108
+	public static function event_active_status($EVT_ID = 0, $echo = true)
109
+	{
110
+		$event = EEH_Event_View::get_event($EVT_ID);
111
+		return $event instanceof EE_Event ? $event->pretty_active_status($echo) : 'inactive';
112
+	}
113
+
114
+
115
+	/**
116
+	 *  event_has_content_or_excerpt
117
+	 *
118
+	 * @param int $EVT_ID
119
+	 * @return     bool
120
+	 * @throws EE_Error
121
+	 * @throws EE_Error
122
+	 * @throws ReflectionException
123
+	 */
124
+	public static function event_has_content_or_excerpt($EVT_ID = 0)
125
+	{
126
+		$event                  = EEH_Event_View::get_event($EVT_ID);
127
+		$has_content_or_excerpt = false;
128
+		if ($event instanceof EE_Event) {
129
+			$has_content_or_excerpt = $event->description() != '' || $event->short_description(null, null, true) != '';
130
+		}
131
+		if (
132
+			is_archive()
133
+			&& ! (espresso_display_full_description_in_event_list()
134
+				  || espresso_display_excerpt_in_event_list())
135
+		) {
136
+			$has_content_or_excerpt = false;
137
+		}
138
+		return $has_content_or_excerpt;
139
+	}
140
+
141
+
142
+	/**
143
+	 *    event_active_status
144
+	 *
145
+	 * @param null $num_words
146
+	 * @param null $more
147
+	 * @return    string
148
+	 */
149
+	public static function event_content_or_excerpt($num_words = null, $more = null)
150
+	{
151
+		global $post;
152
+		ob_start();
153
+		if ((is_single()) || (is_archive() && espresso_display_full_description_in_event_list())) {
154
+			// admin has chosen "full description"
155
+			// for the "Event Espresso - Events > Templates > Display Description" option
156
+			the_content();
157
+		} elseif ((is_archive() && espresso_display_excerpt_in_event_list())) {
158
+			if (has_excerpt($post->ID)) {
159
+				// admin has chosen "excerpt (short desc)"
160
+				// for the "Event Espresso - Events > Templates > Display Description" option
161
+				// AND an excerpt actually exists
162
+				the_excerpt();
163
+			} else {
164
+				// admin has chosen "excerpt (short desc)"
165
+				// for the "Event Espresso - Events > Templates > Display Description" option
166
+				// but NO excerpt actually exists, so we need to create one
167
+				if (! empty($num_words)) {
168
+					if (empty($more)) {
169
+						$more_link_text = esc_html__('(more&hellip;)', 'event_espresso');
170
+						$more           = ' <a href="' . get_permalink() . '"';
171
+						$more           .= ' class="more-link"';
172
+						$more           .= EED_Events_Archive::link_target();
173
+						$more           .= '>' . $more_link_text . '</a>';
174
+						$more           = apply_filters('the_content_more_link', $more, $more_link_text);
175
+					}
176
+					$content = str_replace('NOMORELINK', '', get_the_content('NOMORELINK'));
177
+
178
+					$content = wp_trim_words($content, $num_words, ' ') . $more;
179
+				} else {
180
+					$content = get_the_content();
181
+				}
182
+				global $allowedtags;
183
+				// make sure links are allowed
184
+				$allowedtags['a'] = isset($allowedtags['a'])
185
+					? $allowedtags['a']
186
+					: [];
187
+				// as well as target attribute
188
+				$allowedtags['a']['target'] = isset($allowedtags['a']['target'])
189
+					? $allowedtags['a']['target']
190
+					: false;
191
+				// but get previous value so we can reset it
192
+				$prev_value                 = $allowedtags['a']['target'];
193
+				$allowedtags['a']['target'] = true;
194
+				$content                    = wp_kses($content, $allowedtags);
195
+				$content                    = strip_shortcodes($content);
196
+				echo apply_filters('the_content', $content);
197
+				$allowedtags['a']['target'] = $prev_value;
198
+			}
199
+		} else {
200
+			// admin has chosen "none"
201
+			// for the "Event Espresso - Events > Templates > Display Description" option
202
+			echo apply_filters('the_content', '');
203
+		}
204
+		return ob_get_clean();
205
+	}
206
+
207
+
208
+	/**
209
+	 *  event_tickets_available
210
+	 *
211
+	 * @param int $EVT_ID
212
+	 * @return     EE_Ticket[]
213
+	 * @throws EE_Error
214
+	 * @throws ReflectionException
215
+	 */
216
+	public static function event_tickets_available($EVT_ID = 0)
217
+	{
218
+		$event                          = EEH_Event_View::get_event($EVT_ID);
219
+		$tickets_available_for_purchase = [];
220
+		if ($event instanceof EE_Event) {
221
+			$datetimes = EEH_Event_View::get_all_date_obj($EVT_ID, false);
222
+			foreach ($datetimes as $datetime) {
223
+				$tickets_available_for_purchase =
224
+					array_merge($tickets_available_for_purchase, $datetime->ticket_types_available_for_purchase());
225
+			}
226
+		}
227
+		return $tickets_available_for_purchase;
228
+	}
229
+
230
+
231
+	/**
232
+	 *    the_event_date
233
+	 *
234
+	 * @param int  $EVT_ID
235
+	 * @param bool $hide_uncategorized
236
+	 * @return    string
237
+	 * @throws EE_Error
238
+	 * @throws ReflectionException
239
+	 */
240
+	public static function event_categories($EVT_ID = 0, $hide_uncategorized = true)
241
+	{
242
+		$category_links = [];
243
+		$event          = EEH_Event_View::get_event($EVT_ID);
244
+		if ($event instanceof EE_Event) {
245
+			$event_categories = get_the_terms($event->ID(), 'espresso_event_categories');
246
+			if ($event_categories) {
247
+				// loop thru terms and create links
248
+				foreach ($event_categories as $term) {
249
+					$url = get_term_link($term, 'espresso_venue_categories');
250
+					if (
251
+						! is_wp_error($url)
252
+						&& (
253
+							(
254
+								$hide_uncategorized
255
+								&& strtolower($term->name) != esc_html__('uncategorized', 'event_espresso')
256
+							)
257
+							|| ! $hide_uncategorized
258
+						)
259
+					) {
260
+						$category_links[] = '<a href="' . esc_url_raw($url) . '" '
261
+											. 'rel="tag" ' . EED_Events_Archive::link_target() . '>'
262
+											. esc_html($term->name)
263
+											. '</a>';
264
+					}
265
+				}
266
+			}
267
+		}
268
+		return implode(', ', $category_links);
269
+	}
270
+
271
+
272
+	/**
273
+	 *    the_event_date - first date by date order
274
+	 *
275
+	 * @param string $date_format
276
+	 * @param string $time_format
277
+	 * @param int    $EVT_ID
278
+	 * @return    string
279
+	 * @throws EE_Error
280
+	 * @throws ReflectionException
281
+	 */
282
+	public static function the_event_date($date_format = 'D M jS', $time_format = 'g:i a', $EVT_ID = 0)
283
+	{
284
+		$datetime = EEH_Event_View::get_primary_date_obj($EVT_ID);
285
+		$format   = ! empty($date_format) && ! empty($time_format)
286
+				? $date_format . ' ' . $time_format
287
+				: $date_format . $time_format;
288
+		return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime('DTT_EVT_start', $format) : '';
289
+	}
290
+
291
+
292
+	/**
293
+	 *    the_event_end_date - last date by date order
294
+	 *
295
+	 * @param string $date_format
296
+	 * @param string $time_format
297
+	 * @param int    $EVT_ID
298
+	 * @return    string
299
+	 * @throws EE_Error
300
+	 * @throws ReflectionException
301
+	 */
302
+	public static function the_event_end_date($date_format = 'D M jS', $time_format = 'g:i a', $EVT_ID = 0)
303
+	{
304
+		$datetime = EEH_Event_View::get_last_date_obj($EVT_ID);
305
+		$format   =
306
+			! empty($date_format) && ! empty($time_format)
307
+				? $date_format . ' ' . $time_format
308
+				: $date_format
309
+				  . $time_format;
310
+		return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime('DTT_EVT_end', $format) : '';
311
+	}
312
+
313
+
314
+	/**
315
+	 *    the_earliest_event_date - first date chronologically
316
+	 *
317
+	 * @param string $date_format
318
+	 * @param string $time_format
319
+	 * @param int    $EVT_ID
320
+	 * @return    string
321
+	 * @throws EE_Error
322
+	 * @throws ReflectionException
323
+	 */
324
+	public static function the_earliest_event_date($date_format = 'D M jS', $time_format = 'g:i a', $EVT_ID = 0)
325
+	{
326
+		$datetime = EEH_Event_View::get_earliest_date_obj($EVT_ID);
327
+		$format   =
328
+			! empty($date_format) && ! empty($time_format)
329
+				? $date_format . ' ' . $time_format
330
+				: $date_format
331
+				  . $time_format;
332
+		return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime('DTT_EVT_start', $format) : '';
333
+	}
334
+
335
+
336
+	/**
337
+	 *    the_latest_event_date - latest date chronologically
338
+	 *
339
+	 * @param string $date_format
340
+	 * @param string $time_format
341
+	 * @param int    $EVT_ID
342
+	 * @return    string
343
+	 * @throws EE_Error
344
+	 * @throws ReflectionException
345
+	 */
346
+	public static function the_latest_event_date($date_format = 'D M jS', $time_format = 'g:i a', $EVT_ID = 0)
347
+	{
348
+		$datetime = EEH_Event_View::get_latest_date_obj($EVT_ID);
349
+		$format   =
350
+			! empty($date_format) && ! empty($time_format)
351
+				? $date_format . ' ' . $time_format
352
+				: $date_format
353
+				  . $time_format;
354
+		return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime('DTT_EVT_end', $format) : '';
355
+	}
356
+
357
+
358
+	/**
359
+	 *    event_date_as_calendar_page
360
+	 *
361
+	 * @param int $EVT_ID
362
+	 * @return    void
363
+	 * @throws EE_Error
364
+	 * @throws ReflectionException
365
+	 */
366
+	public static function event_date_as_calendar_page($EVT_ID = 0)
367
+	{
368
+		$datetime = EEH_Event_View::get_primary_date_obj($EVT_ID);
369
+		if ($datetime instanceof EE_Datetime) {
370
+			?>
371 371
             <div class="event-date-calendar-page-dv">
372 372
                 <div class="event-date-calendar-page-month-dv">
373 373
                     <?php echo esc_html($datetime->get_i18n_datetime('DTT_EVT_start', 'M')); ?>
@@ -377,260 +377,260 @@  discard block
 block discarded – undo
377 377
                 </div>
378 378
             </div>
379 379
             <?php
380
-        }
381
-    }
382
-
383
-
384
-    /**
385
-     *    get_primary_date_obj - orders date by DTT_order
386
-     *
387
-     * @param int $EVT_ID
388
-     * @return EE_Datetime
389
-     * @throws EE_Error
390
-     * @throws ReflectionException
391
-     */
392
-    public static function get_primary_date_obj($EVT_ID = 0)
393
-    {
394
-        $event = EEH_Event_View::get_event($EVT_ID);
395
-        if ($event instanceof EE_Event) {
396
-            $datetimes = $event->get_many_related(
397
-                'Datetime',
398
-                [
399
-                    'limit'    => 1,
400
-                    'order_by' => ['DTT_order' => 'ASC'],
401
-                ]
402
-            );
403
-            return reset($datetimes);
404
-        }
405
-        return null;
406
-    }
407
-
408
-
409
-    /**
410
-     *    get_last_date_obj - orders date by DTT_order
411
-     *
412
-     * @param int $EVT_ID
413
-     * @return EE_Datetime
414
-     * @throws EE_Error
415
-     * @throws ReflectionException
416
-     */
417
-    public static function get_last_date_obj($EVT_ID = 0)
418
-    {
419
-        $event = EEH_Event_View::get_event($EVT_ID);
420
-        if ($event instanceof EE_Event) {
421
-            $datetimes = $event->get_many_related(
422
-                'Datetime',
423
-                [
424
-                    'limit'    => 1,
425
-                    'order_by' => ['DTT_order' => 'DESC'],
426
-                ]
427
-            );
428
-            return end($datetimes);
429
-        }
430
-        return null;
431
-    }
432
-
433
-
434
-    /**
435
-     *    get_earliest_date_obj - orders date chronologically
436
-     *
437
-     * @param int $EVT_ID
438
-     * @return EE_Datetime
439
-     * @throws EE_Error
440
-     * @throws ReflectionException
441
-     */
442
-    public static function get_earliest_date_obj($EVT_ID = 0)
443
-    {
444
-        $event = EEH_Event_View::get_event($EVT_ID);
445
-        if ($event instanceof EE_Event) {
446
-            $datetimes = $event->get_many_related(
447
-                'Datetime',
448
-                [
449
-                    'limit'    => 1,
450
-                    'order_by' => ['DTT_EVT_start' => 'ASC'],
451
-                ]
452
-            );
453
-            return reset($datetimes);
454
-        }
455
-        return null;
456
-    }
457
-
458
-
459
-    /**
460
-     *    get_latest_date_obj - orders date chronologically
461
-     *
462
-     * @param int $EVT_ID
463
-     * @return EE_Datetime
464
-     * @throws EE_Error
465
-     * @throws ReflectionException
466
-     */
467
-    public static function get_latest_date_obj($EVT_ID = 0)
468
-    {
469
-        $event = EEH_Event_View::get_event($EVT_ID);
470
-        if ($event instanceof EE_Event) {
471
-            $datetimes = $event->get_many_related(
472
-                'Datetime',
473
-                [
474
-                    'limit'    => 1,
475
-                    'order_by' => ['DTT_EVT_start' => 'DESC'],
476
-                ]
477
-            );
478
-            return end($datetimes);
479
-        }
480
-        return null;
481
-    }
482
-
483
-
484
-    /**
485
-     *    get_next_upcoming_date_obj - return the next upcoming datetime
486
-     *
487
-     * @param int $EVT_ID
488
-     * @return    EE_Datetime|null
489
-     * @throws EE_Error
490
-     * @throws EE_Error
491
-     */
492
-    public static function get_next_upcoming_date_obj($EVT_ID = 0)
493
-    {
494
-        $datetime = EEM_Datetime::instance()->get_one(
495
-            [
496
-                [
497
-                    'Event.EVT_ID'  => $EVT_ID,
498
-                    'DTT_EVT_start' => ['>=', current_time('mysql', true)],
499
-                ],
500
-                'order_by' => ['DTT_EVT_start' => 'asc'],
501
-            ]
502
-        );
503
-        return $datetime instanceof EE_Datetime ? $datetime : null;
504
-    }
505
-
506
-
507
-    /**
508
-     *    get_all_date_obj
509
-     *
510
-     * @param int  $EVT_ID
511
-     * @param null $include_expired
512
-     * @param bool $include_deleted
513
-     * @param null $limit
514
-     * @return EE_Datetime[]
515
-     * @throws EE_Error
516
-     * @throws EE_Error
517
-     * @throws ReflectionException
518
-     */
519
-    public static function get_all_date_obj(
520
-        $EVT_ID = 0,
521
-        $include_expired = null,
522
-        $include_deleted = false,
523
-        $limit = null
524
-    ) {
525
-        $event = EEH_Event_View::get_event($EVT_ID);
526
-        if ($include_expired === null) {
527
-            if ($event instanceof EE_Event && $event->is_expired()) {
528
-                $include_expired = true;
529
-            } else {
530
-                $include_expired = false;
531
-            }
532
-        }
533
-
534
-        if ($event instanceof EE_Event) {
535
-            return $event->datetimes_ordered($include_expired, $include_deleted, $limit);
536
-        }
537
-        return [];
538
-    }
539
-
540
-
541
-    /**
542
-     *    event_link_url
543
-     *
544
-     * @param int $EVT_ID
545
-     * @return string
546
-     * @throws EE_Error
547
-     * @throws ReflectionException
548
-     */
549
-    public static function event_link_url($EVT_ID = 0)
550
-    {
551
-        $event = EEH_Event_View::get_event($EVT_ID);
552
-        if ($event instanceof EE_Event) {
553
-            $url = $event->external_url() !== null && $event->external_url() !== ''
554
-                ? $event->external_url()
555
-                : get_permalink($event->ID());
556
-            $url = preg_match("~^(?:f|ht)tps?://~i", $url) ? $url : 'https://' . $url;
557
-            return esc_url_raw($url);
558
-        }
559
-        return '';
560
-    }
561
-
562
-
563
-    /**
564
-     *    event_phone
565
-     *
566
-     * @param int $EVT_ID
567
-     * @return    string
568
-     * @throws EE_Error
569
-     * @throws EE_Error
570
-     * @throws ReflectionException
571
-     */
572
-    public static function event_phone($EVT_ID = 0)
573
-    {
574
-        $event = EEH_Event_View::get_event($EVT_ID);
575
-        if ($event instanceof EE_Event) {
576
-            return EEH_Schema::telephone($event->phone());
577
-        }
578
-        return null;
579
-    }
580
-
581
-
582
-    /**
583
-     *    edit_event_link
584
-     *
585
-     * @param int    $EVT_ID
586
-     * @param string $link
587
-     * @param string $before
588
-     * @param string $after
589
-     * @return    string
590
-     * @throws EE_Error
591
-     * @throws ReflectionException
592
-     */
593
-    public static function edit_event_link($EVT_ID = 0, $link = '', $before = '', $after = '')
594
-    {
595
-        $event = EEH_Event_View::get_event($EVT_ID);
596
-        if ($event instanceof EE_Event) {
597
-            // can the user edit this post ?
598
-            if (current_user_can('edit_post', $event->ID())) {
599
-                // set link text
600
-                $link_text = ! empty($link) ? $link : esc_html__('edit this event', 'event_espresso');
601
-                // generate nonce
602
-                $nonce = wp_create_nonce('edit_nonce');
603
-                // generate url to event editor for this event
604
-                $url =
605
-                    add_query_arg(
606
-                        [
607
-                            'page'       => 'espresso_events',
608
-                            'action'     => 'edit',
609
-                            'post'       => $event->ID(),
610
-                            'edit_nonce' => $nonce,
611
-                        ],
612
-                        admin_url()
613
-                    );
614
-                // get edit CPT text
615
-                $post_type_obj = get_post_type_object('espresso_events');
616
-                // build final link html
617
-                $link = '<a class="post-edit-link" href="' . $url . '" ';
618
-                $link .= ' title="' . esc_attr($post_type_obj->labels->edit_item) . '"';
619
-                $link .= EED_Events_Archive::link_target();
620
-                $link .= '>' . $link_text . '</a>';
621
-                // put it all together
622
-                return $before . apply_filters('edit_post_link', $link, $event->ID()) . $after;
623
-            }
624
-        }
625
-        return '';
626
-    }
627
-
628
-
629
-    /**
630
-     * @return string
631
-     */
632
-    public static function event_archive_url()
633
-    {
634
-        return get_post_type_archive_link('espresso_events');
635
-    }
380
+		}
381
+	}
382
+
383
+
384
+	/**
385
+	 *    get_primary_date_obj - orders date by DTT_order
386
+	 *
387
+	 * @param int $EVT_ID
388
+	 * @return EE_Datetime
389
+	 * @throws EE_Error
390
+	 * @throws ReflectionException
391
+	 */
392
+	public static function get_primary_date_obj($EVT_ID = 0)
393
+	{
394
+		$event = EEH_Event_View::get_event($EVT_ID);
395
+		if ($event instanceof EE_Event) {
396
+			$datetimes = $event->get_many_related(
397
+				'Datetime',
398
+				[
399
+					'limit'    => 1,
400
+					'order_by' => ['DTT_order' => 'ASC'],
401
+				]
402
+			);
403
+			return reset($datetimes);
404
+		}
405
+		return null;
406
+	}
407
+
408
+
409
+	/**
410
+	 *    get_last_date_obj - orders date by DTT_order
411
+	 *
412
+	 * @param int $EVT_ID
413
+	 * @return EE_Datetime
414
+	 * @throws EE_Error
415
+	 * @throws ReflectionException
416
+	 */
417
+	public static function get_last_date_obj($EVT_ID = 0)
418
+	{
419
+		$event = EEH_Event_View::get_event($EVT_ID);
420
+		if ($event instanceof EE_Event) {
421
+			$datetimes = $event->get_many_related(
422
+				'Datetime',
423
+				[
424
+					'limit'    => 1,
425
+					'order_by' => ['DTT_order' => 'DESC'],
426
+				]
427
+			);
428
+			return end($datetimes);
429
+		}
430
+		return null;
431
+	}
432
+
433
+
434
+	/**
435
+	 *    get_earliest_date_obj - orders date chronologically
436
+	 *
437
+	 * @param int $EVT_ID
438
+	 * @return EE_Datetime
439
+	 * @throws EE_Error
440
+	 * @throws ReflectionException
441
+	 */
442
+	public static function get_earliest_date_obj($EVT_ID = 0)
443
+	{
444
+		$event = EEH_Event_View::get_event($EVT_ID);
445
+		if ($event instanceof EE_Event) {
446
+			$datetimes = $event->get_many_related(
447
+				'Datetime',
448
+				[
449
+					'limit'    => 1,
450
+					'order_by' => ['DTT_EVT_start' => 'ASC'],
451
+				]
452
+			);
453
+			return reset($datetimes);
454
+		}
455
+		return null;
456
+	}
457
+
458
+
459
+	/**
460
+	 *    get_latest_date_obj - orders date chronologically
461
+	 *
462
+	 * @param int $EVT_ID
463
+	 * @return EE_Datetime
464
+	 * @throws EE_Error
465
+	 * @throws ReflectionException
466
+	 */
467
+	public static function get_latest_date_obj($EVT_ID = 0)
468
+	{
469
+		$event = EEH_Event_View::get_event($EVT_ID);
470
+		if ($event instanceof EE_Event) {
471
+			$datetimes = $event->get_many_related(
472
+				'Datetime',
473
+				[
474
+					'limit'    => 1,
475
+					'order_by' => ['DTT_EVT_start' => 'DESC'],
476
+				]
477
+			);
478
+			return end($datetimes);
479
+		}
480
+		return null;
481
+	}
482
+
483
+
484
+	/**
485
+	 *    get_next_upcoming_date_obj - return the next upcoming datetime
486
+	 *
487
+	 * @param int $EVT_ID
488
+	 * @return    EE_Datetime|null
489
+	 * @throws EE_Error
490
+	 * @throws EE_Error
491
+	 */
492
+	public static function get_next_upcoming_date_obj($EVT_ID = 0)
493
+	{
494
+		$datetime = EEM_Datetime::instance()->get_one(
495
+			[
496
+				[
497
+					'Event.EVT_ID'  => $EVT_ID,
498
+					'DTT_EVT_start' => ['>=', current_time('mysql', true)],
499
+				],
500
+				'order_by' => ['DTT_EVT_start' => 'asc'],
501
+			]
502
+		);
503
+		return $datetime instanceof EE_Datetime ? $datetime : null;
504
+	}
505
+
506
+
507
+	/**
508
+	 *    get_all_date_obj
509
+	 *
510
+	 * @param int  $EVT_ID
511
+	 * @param null $include_expired
512
+	 * @param bool $include_deleted
513
+	 * @param null $limit
514
+	 * @return EE_Datetime[]
515
+	 * @throws EE_Error
516
+	 * @throws EE_Error
517
+	 * @throws ReflectionException
518
+	 */
519
+	public static function get_all_date_obj(
520
+		$EVT_ID = 0,
521
+		$include_expired = null,
522
+		$include_deleted = false,
523
+		$limit = null
524
+	) {
525
+		$event = EEH_Event_View::get_event($EVT_ID);
526
+		if ($include_expired === null) {
527
+			if ($event instanceof EE_Event && $event->is_expired()) {
528
+				$include_expired = true;
529
+			} else {
530
+				$include_expired = false;
531
+			}
532
+		}
533
+
534
+		if ($event instanceof EE_Event) {
535
+			return $event->datetimes_ordered($include_expired, $include_deleted, $limit);
536
+		}
537
+		return [];
538
+	}
539
+
540
+
541
+	/**
542
+	 *    event_link_url
543
+	 *
544
+	 * @param int $EVT_ID
545
+	 * @return string
546
+	 * @throws EE_Error
547
+	 * @throws ReflectionException
548
+	 */
549
+	public static function event_link_url($EVT_ID = 0)
550
+	{
551
+		$event = EEH_Event_View::get_event($EVT_ID);
552
+		if ($event instanceof EE_Event) {
553
+			$url = $event->external_url() !== null && $event->external_url() !== ''
554
+				? $event->external_url()
555
+				: get_permalink($event->ID());
556
+			$url = preg_match("~^(?:f|ht)tps?://~i", $url) ? $url : 'https://' . $url;
557
+			return esc_url_raw($url);
558
+		}
559
+		return '';
560
+	}
561
+
562
+
563
+	/**
564
+	 *    event_phone
565
+	 *
566
+	 * @param int $EVT_ID
567
+	 * @return    string
568
+	 * @throws EE_Error
569
+	 * @throws EE_Error
570
+	 * @throws ReflectionException
571
+	 */
572
+	public static function event_phone($EVT_ID = 0)
573
+	{
574
+		$event = EEH_Event_View::get_event($EVT_ID);
575
+		if ($event instanceof EE_Event) {
576
+			return EEH_Schema::telephone($event->phone());
577
+		}
578
+		return null;
579
+	}
580
+
581
+
582
+	/**
583
+	 *    edit_event_link
584
+	 *
585
+	 * @param int    $EVT_ID
586
+	 * @param string $link
587
+	 * @param string $before
588
+	 * @param string $after
589
+	 * @return    string
590
+	 * @throws EE_Error
591
+	 * @throws ReflectionException
592
+	 */
593
+	public static function edit_event_link($EVT_ID = 0, $link = '', $before = '', $after = '')
594
+	{
595
+		$event = EEH_Event_View::get_event($EVT_ID);
596
+		if ($event instanceof EE_Event) {
597
+			// can the user edit this post ?
598
+			if (current_user_can('edit_post', $event->ID())) {
599
+				// set link text
600
+				$link_text = ! empty($link) ? $link : esc_html__('edit this event', 'event_espresso');
601
+				// generate nonce
602
+				$nonce = wp_create_nonce('edit_nonce');
603
+				// generate url to event editor for this event
604
+				$url =
605
+					add_query_arg(
606
+						[
607
+							'page'       => 'espresso_events',
608
+							'action'     => 'edit',
609
+							'post'       => $event->ID(),
610
+							'edit_nonce' => $nonce,
611
+						],
612
+						admin_url()
613
+					);
614
+				// get edit CPT text
615
+				$post_type_obj = get_post_type_object('espresso_events');
616
+				// build final link html
617
+				$link = '<a class="post-edit-link" href="' . $url . '" ';
618
+				$link .= ' title="' . esc_attr($post_type_obj->labels->edit_item) . '"';
619
+				$link .= EED_Events_Archive::link_target();
620
+				$link .= '>' . $link_text . '</a>';
621
+				// put it all together
622
+				return $before . apply_filters('edit_post_link', $link, $event->ID()) . $after;
623
+			}
624
+		}
625
+		return '';
626
+	}
627
+
628
+
629
+	/**
630
+	 * @return string
631
+	 */
632
+	public static function event_archive_url()
633
+	{
634
+		return get_post_type_archive_link('espresso_events');
635
+	}
636 636
 }
Please login to merge, or discard this patch.
registration_form/templates/question_groups_main_meta_box.template.php 1 patch
Indentation   +84 added lines, -84 removed lines patch added patch discarded remove patch
@@ -13,8 +13,8 @@  discard block
 block discarded – undo
13 13
 /* @var EE_Question[] $all_questions */
14 14
 assert(isset($all_questions) && (empty($all_questions) || is_array($all_questions)));// list of unused questions
15 15
 foreach ($all_questions as $unused_question) {
16
-    assert($unused_question);
17
-    assert($unused_question instanceof EE_Question);
16
+	assert($unused_question);
17
+	assert($unused_question instanceof EE_Question);
18 18
 }
19 19
 /* @var array $values . Array of arrays, where each sub-array contains 2 keys: 'id' (internal value) and 'name' (label for displaying) */
20 20
 assert(is_array($values));
@@ -33,8 +33,8 @@  discard block
 block discarded – undo
33 33
             <th>
34 34
                 <label for="QSG_name">
35 35
                     <?php esc_html_e('Group Name', 'event_espresso'); ?><?php echo EEH_Template::get_help_tab_link(
36
-                        'group_name_info'
37
-                    ); ?>
36
+						'group_name_info'
37
+					); ?>
38 38
                 </label>
39 39
             </th>
40 40
             <td>
@@ -48,8 +48,8 @@  discard block
 block discarded – undo
48 48
             <th>
49 49
                 <label for="QSG_identifier">
50 50
                     <?php esc_html_e('Group Identifier', 'event_espresso'); ?><?php echo EEH_Template::get_help_tab_link(
51
-                        'group_identifier_info'
52
-                    ); ?>
51
+						'group_identifier_info'
52
+					); ?>
53 53
                 </label>
54 54
             </th>
55 55
             <td>
@@ -68,8 +68,8 @@  discard block
 block discarded – undo
68 68
             <th>
69 69
                 <label for="QSG_desc">
70 70
                     <?php esc_html_e('Description', 'event_espresso'); ?><?php echo EEH_Template::get_help_tab_link(
71
-                        'group_description_info'
72
-                    ); ?>
71
+						'group_description_info'
72
+					); ?>
73 73
                 </label>
74 74
             </th>
75 75
             <td>
@@ -82,8 +82,8 @@  discard block
 block discarded – undo
82 82
             <th>
83 83
                 <label for="QSG_order">
84 84
                     <?php esc_html_e('Question Group Order', 'event_espresso'); ?><?php echo EEH_Template::get_help_tab_link(
85
-                        'group_order_info'
86
-                    ); ?>
85
+						'group_order_info'
86
+					); ?>
87 87
                 </label>
88 88
             </th>
89 89
             <td>
@@ -96,17 +96,17 @@  discard block
 block discarded – undo
96 96
             <th>
97 97
                 <label>
98 98
                     <?php esc_html_e('Show Name', 'event_espresso'); ?><?php echo EEH_Template::get_help_tab_link(
99
-                        'show_group_name_info'
100
-                    ); ?>
99
+						'show_group_name_info'
100
+					); ?>
101 101
                 </label>
102 102
             </th>
103 103
             <td>
104 104
                 <label for="QSG_show_group_name">
105 105
                     <?php echo EEH_Form_Fields::select_input(
106
-                        'QSG_show_group_name',
107
-                        $values,
108
-                        $question_group->show_group_name()
109
-                    ); ?>
106
+						'QSG_show_group_name',
107
+						$values,
108
+						$question_group->show_group_name()
109
+					); ?>
110 110
                     <p class="description"><?php esc_html_e('Show Group Name on Registration Page?', 'event_espresso'); ?></p>
111 111
                 </label>
112 112
             </td>
@@ -116,20 +116,20 @@  discard block
 block discarded – undo
116 116
             <th>
117 117
                 <label>
118 118
                     <?php esc_html_e(' Show Description', 'event_espresso'); ?><?php echo EEH_Template::get_help_tab_link(
119
-                        'show_group_description_info'
120
-                    ); ?>
119
+						'show_group_description_info'
120
+					); ?>
121 121
                 </label>
122 122
             </th>
123 123
             <td>
124 124
                 <label for="QSG_show_group_order">
125 125
                     <?php echo EEH_Form_Fields::select_input(
126
-                        'QSG_show_group_desc',
127
-                        $values,
128
-                        $question_group->show_group_desc()
129
-                    ); ?>
126
+						'QSG_show_group_desc',
127
+						$values,
128
+						$question_group->show_group_desc()
129
+					); ?>
130 130
                     <p class="description"><?php
131
-                        esc_html_e(' Show Group Description on Registration Page?', 'event_espresso');
132
-                    ?></p>
131
+						esc_html_e(' Show Group Description on Registration Page?', 'event_espresso');
132
+					?></p>
133 133
                 </label>
134 134
                 <input type="hidden" name="QSG_system" value="<?php echo esc_attr($question_group->system_group()); ?>">
135 135
             </td>
@@ -145,85 +145,85 @@  discard block
 block discarded – undo
145 145
     <div class="form-table question-group-questions inside">
146 146
         <div class="padding">
147 147
             <p><span class="description"><?php
148
-                    esc_html_e(
149
-                        'Select which questions should be shown in this group by checking or unchecking boxes. You can drag and drop questions to reorder them. Your changes will be updated when you save.',
150
-                        'event_espresso'
151
-                    ); ?></span></p>
148
+					esc_html_e(
149
+						'Select which questions should be shown in this group by checking or unchecking boxes. You can drag and drop questions to reorder them. Your changes will be updated when you save.',
150
+						'event_espresso'
151
+					); ?></span></p>
152 152
             <div>
153 153
                 <ul class="question-list-sortable">
154 154
                     <?php
155
-                    $question_order = 0;
156
-                    $question_group_questions = $question_group->questions();
157
-                    foreach ($all_questions as $question_ID => $question) {
158
-                        if ($question instanceof EE_Question) {
159
-                            /*@var $question EE_Question*/
160
-                            $checked = isset($question_group_questions[ $question_ID ]) ? 'checked' : '';
161
-                            // disable questions from the personal information question group
162
-                            // is it required in the current question group? if so don't allow admins to remove it
163
-                            $disabled = in_array(
164
-                                $question->system_ID(),
165
-                                EEM_Question::instance()->required_system_questions_in_system_question_group(
166
-                                    $QSG_system
167
-                                )
168
-                            ) ? 'disabled' : '';
169
-                            // limit where system questions can appear
170
-                            if (
171
-                                $question->system_ID() &&
172
-                                ! in_array(
173
-                                    $question->system_ID(),
174
-                                    EEM_Question::instance()->allowed_system_questions_in_system_question_group(
175
-                                        $QSG_system
176
-                                    )
177
-                                )
178
-                            ) {
179
-                                continue; // skip over system question not assigned to this group except for the address system group cause we want the address questions to display even if they aren't selected (but still not show the personal system questions).  The third condition checks if we're displaying a non system question group and the question is a system question, then we skip because for non-system question groups we only want to show non-system questions.
180
-                            }
181
-                            ?>
155
+					$question_order = 0;
156
+					$question_group_questions = $question_group->questions();
157
+					foreach ($all_questions as $question_ID => $question) {
158
+						if ($question instanceof EE_Question) {
159
+							/*@var $question EE_Question*/
160
+							$checked = isset($question_group_questions[ $question_ID ]) ? 'checked' : '';
161
+							// disable questions from the personal information question group
162
+							// is it required in the current question group? if so don't allow admins to remove it
163
+							$disabled = in_array(
164
+								$question->system_ID(),
165
+								EEM_Question::instance()->required_system_questions_in_system_question_group(
166
+									$QSG_system
167
+								)
168
+							) ? 'disabled' : '';
169
+							// limit where system questions can appear
170
+							if (
171
+								$question->system_ID() &&
172
+								! in_array(
173
+									$question->system_ID(),
174
+									EEM_Question::instance()->allowed_system_questions_in_system_question_group(
175
+										$QSG_system
176
+									)
177
+								)
178
+							) {
179
+								continue; // skip over system question not assigned to this group except for the address system group cause we want the address questions to display even if they aren't selected (but still not show the personal system questions).  The third condition checks if we're displaying a non system question group and the question is a system question, then we skip because for non-system question groups we only want to show non-system questions.
180
+							}
181
+							?>
182 182
                             <li class="ee-question-sortable">
183 183
                                 <label for="question-<?php echo absint($question_ID); ?>">
184 184
                                     <input type="checkbox" name="questions[<?php echo absint($question_ID); ?>]"
185 185
                                            id="question-<?php echo absint($question_ID); ?>"
186 186
                                            value="<?php echo absint($question_ID); ?>" <?php echo esc_attr($disabled); ?> <?php echo esc_attr($checked); ?>>
187 187
                                     <span class="question-text"><?php
188
-                                        echo trim($question->display_text())
189
-                                             . (95 <= strlen(trim($question->display_text()))
190
-                                                ? "&hellip;"
191
-                                                : '');
192
-                                                                ?>
188
+										echo trim($question->display_text())
189
+											 . (95 <= strlen(trim($question->display_text()))
190
+												? "&hellip;"
191
+												: '');
192
+																?>
193 193
                                     </span>
194 194
                                     <input class="question-group-QGQ_order" type="hidden"
195 195
                                            name="question_orders[<?php echo absint($question_ID); ?>]"
196 196
                                            value="<?php echo esc_attr($question_order); ?>">
197 197
                                 </label>
198 198
                                 <?php
199
-                                if (
200
-                                    EE_Registry::instance()->CAP->current_user_can(
201
-                                        'ee_edit_question',
202
-                                        'espresso_registration_form_edit_question',
203
-                                        $question->ID()
204
-                                    )
205
-                                ) {
206
-                                    $edit_query_args = array(
207
-                                        'action' => 'edit_question',
208
-                                        'QST_ID' => $question->ID(),
209
-                                    );
210
-                                    $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EE_FORMS_ADMIN_URL);
199
+								if (
200
+									EE_Registry::instance()->CAP->current_user_can(
201
+										'ee_edit_question',
202
+										'espresso_registration_form_edit_question',
203
+										$question->ID()
204
+									)
205
+								) {
206
+									$edit_query_args = array(
207
+										'action' => 'edit_question',
208
+										'QST_ID' => $question->ID(),
209
+									);
210
+									$edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EE_FORMS_ADMIN_URL);
211 211
 
212
-                                    echo '<a href="' . $edit_link . '" target="_blank" title="' .
213
-                                        sprintf(
214
-                                            esc_attr__('Edit %s', 'event_espresso'),
215
-                                            $question->admin_label()
216
-                                        )
217
-                                        . '"><span class="dashicons dashicons-edit"></span>
212
+									echo '<a href="' . $edit_link . '" target="_blank" title="' .
213
+										sprintf(
214
+											esc_attr__('Edit %s', 'event_espresso'),
215
+											$question->admin_label()
216
+										)
217
+										. '"><span class="dashicons dashicons-edit"></span>
218 218
                                         </a>';
219
-                                }
220
-                                ?>
219
+								}
220
+								?>
221 221
                             </li>
222 222
                             <?php
223
-                            $question_order++;
224
-                        }
225
-                    }
226
-                    ?>
223
+							$question_order++;
224
+						}
225
+					}
226
+					?>
227 227
                 </ul>
228 228
             </div>
229 229
         </div>
Please login to merge, or discard this patch.
espresso.php 1 patch
Indentation   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -38,103 +38,103 @@
 block discarded – undo
38 38
  * @since           4.0
39 39
  */
40 40
 if (function_exists('espresso_version')) {
41
-    if (! function_exists('espresso_duplicate_plugin_error')) {
42
-        /**
43
-         *    espresso_duplicate_plugin_error
44
-         *    displays if more than one version of EE is activated at the same time
45
-         */
46
-        function espresso_duplicate_plugin_error()
47
-        {
48
-            ?>
41
+	if (! function_exists('espresso_duplicate_plugin_error')) {
42
+		/**
43
+		 *    espresso_duplicate_plugin_error
44
+		 *    displays if more than one version of EE is activated at the same time
45
+		 */
46
+		function espresso_duplicate_plugin_error()
47
+		{
48
+			?>
49 49
             <div class="error">
50 50
                 <p>
51 51
                     <?php
52
-                    echo esc_html__(
53
-                        'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
-                        'event_espresso'
55
-                    ); ?>
52
+					echo esc_html__(
53
+						'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
+						'event_espresso'
55
+					); ?>
56 56
                 </p>
57 57
             </div>
58 58
             <?php
59
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
60
-        }
61
-    }
62
-    add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
59
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
60
+		}
61
+	}
62
+	add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
63 63
 } else {
64
-    define('EE_MIN_PHP_VER_REQUIRED', '5.6.2');
65
-    if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
-        /**
67
-         * espresso_minimum_php_version_error
68
-         *
69
-         * @return void
70
-         */
71
-        function espresso_minimum_php_version_error()
72
-        {
73
-            ?>
64
+	define('EE_MIN_PHP_VER_REQUIRED', '5.6.2');
65
+	if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
+		/**
67
+		 * espresso_minimum_php_version_error
68
+		 *
69
+		 * @return void
70
+		 */
71
+		function espresso_minimum_php_version_error()
72
+		{
73
+			?>
74 74
             <div class="error">
75 75
                 <p>
76 76
                     <?php
77
-                    printf(
78
-                        esc_html__(
79
-                            'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
-                            'event_espresso'
81
-                        ),
82
-                        EE_MIN_PHP_VER_REQUIRED,
83
-                        PHP_VERSION,
84
-                        '<br/>',
85
-                        '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
-                    );
87
-                    ?>
77
+					printf(
78
+						esc_html__(
79
+							'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
+							'event_espresso'
81
+						),
82
+						EE_MIN_PHP_VER_REQUIRED,
83
+						PHP_VERSION,
84
+						'<br/>',
85
+						'<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
+					);
87
+					?>
88 88
                 </p>
89 89
             </div>
90 90
             <?php
91
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
92
-        }
91
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
92
+		}
93 93
 
94
-        add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
-    } else {
96
-        define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
97
-        /**
98
-         * espresso_version
99
-         * Returns the plugin version
100
-         *
101
-         * @return string
102
-         */
103
-        function espresso_version()
104
-        {
105
-            return apply_filters('FHEE__espresso__espresso_version', '4.10.30.rc.017');
106
-        }
94
+		add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
+	} else {
96
+		define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
97
+		/**
98
+		 * espresso_version
99
+		 * Returns the plugin version
100
+		 *
101
+		 * @return string
102
+		 */
103
+		function espresso_version()
104
+		{
105
+			return apply_filters('FHEE__espresso__espresso_version', '4.10.30.rc.017');
106
+		}
107 107
 
108
-        /**
109
-         * espresso_plugin_activation
110
-         * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
111
-         */
112
-        function espresso_plugin_activation()
113
-        {
114
-            update_option('ee_espresso_activation', true);
115
-        }
108
+		/**
109
+		 * espresso_plugin_activation
110
+		 * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
111
+		 */
112
+		function espresso_plugin_activation()
113
+		{
114
+			update_option('ee_espresso_activation', true);
115
+		}
116 116
 
117
-        register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
117
+		register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
118 118
 
119
-        require_once __DIR__ . '/core/bootstrap_espresso.php';
120
-        bootstrap_espresso();
121
-    }
119
+		require_once __DIR__ . '/core/bootstrap_espresso.php';
120
+		bootstrap_espresso();
121
+	}
122 122
 }
123 123
 if (! function_exists('espresso_deactivate_plugin')) {
124
-    /**
125
-     *    deactivate_plugin
126
-     * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
127
-     *
128
-     * @access public
129
-     * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
130
-     * @return    void
131
-     */
132
-    function espresso_deactivate_plugin($plugin_basename = '')
133
-    {
134
-        if (! function_exists('deactivate_plugins')) {
135
-            require_once ABSPATH . 'wp-admin/includes/plugin.php';
136
-        }
137
-        unset($_GET['activate'], $_REQUEST['activate']);
138
-        deactivate_plugins($plugin_basename);
139
-    }
124
+	/**
125
+	 *    deactivate_plugin
126
+	 * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
127
+	 *
128
+	 * @access public
129
+	 * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
130
+	 * @return    void
131
+	 */
132
+	function espresso_deactivate_plugin($plugin_basename = '')
133
+	{
134
+		if (! function_exists('deactivate_plugins')) {
135
+			require_once ABSPATH . 'wp-admin/includes/plugin.php';
136
+		}
137
+		unset($_GET['activate'], $_REQUEST['activate']);
138
+		deactivate_plugins($plugin_basename);
139
+	}
140 140
 }
141 141
\ No newline at end of file
Please login to merge, or discard this patch.