@@ -51,8 +51,11 @@ discard block |
||
51 | 51 | <?php echo do_shortcode( $venue_description ); ?> |
52 | 52 | </p> |
53 | 53 | <?php endif; ?> |
54 | - <?php else : ?> |
|
55 | - <?php $venue_excerpt = espresso_venue_excerpt( $VNU_ID, FALSE ); ?> |
|
54 | + <?php else { |
|
55 | + : ?> |
|
56 | + <?php $venue_excerpt = espresso_venue_excerpt( $VNU_ID, FALSE ); |
|
57 | +} |
|
58 | +?> |
|
56 | 59 | <?php if ( $venue_excerpt ) : ?> |
57 | 60 | <p> |
58 | 61 | <strong><?php esc_html_e( 'Description:', 'event_espresso' ); ?></strong><br/> |
@@ -64,12 +67,15 @@ discard block |
||
64 | 67 | <!-- .espresso-venue-dv --> |
65 | 68 | <?php |
66 | 69 | do_action( 'AHEE_event_details_after_venue_details', $post ); |
67 | -else : |
|
70 | +else { |
|
71 | + : |
|
68 | 72 | if ( espresso_venue_is_password_protected() ) : |
69 | 73 | ?> |
70 | 74 | <div class="espresso-venue-dv espresso-password-protected-venue-dv" > |
71 | 75 | <h3 class="event-venues-h3 ee-event-h3"> |
72 | - <?php esc_html_e( 'Location', 'event_espresso' );?> |
|
76 | + <?php esc_html_e( 'Location', 'event_espresso' ); |
|
77 | +} |
|
78 | +?> |
|
73 | 79 | </h3> |
74 | 80 | <?php echo espresso_password_protected_venue_form(); ?> |
75 | 81 | </div> |
@@ -3,75 +3,75 @@ |
||
3 | 3 | use EventEspresso\core\services\request\sanitizers\AllowedTags; |
4 | 4 | |
5 | 5 | if ( |
6 | - ( is_single() && espresso_display_venue_in_event_details() ) |
|
7 | - || ( is_archive() && espresso_display_venue_in_event_list() ) |
|
6 | + (is_single() && espresso_display_venue_in_event_details()) |
|
7 | + || (is_archive() && espresso_display_venue_in_event_list()) |
|
8 | 8 | ) : |
9 | 9 | global $post; |
10 | - do_action( 'AHEE_event_details_before_venue_details', $post ); |
|
11 | - $venue_name = espresso_venue_name( 0, 'details', FALSE ); |
|
12 | - if ( empty( $venue_name ) && espresso_is_venue_private() ) { |
|
13 | - do_action( 'AHEE_event_details_after_venue_details', $post ); |
|
10 | + do_action('AHEE_event_details_before_venue_details', $post); |
|
11 | + $venue_name = espresso_venue_name(0, 'details', FALSE); |
|
12 | + if (empty($venue_name) && espresso_is_venue_private()) { |
|
13 | + do_action('AHEE_event_details_after_venue_details', $post); |
|
14 | 14 | return ''; |
15 | 15 | } |
16 | 16 | ?> |
17 | 17 | |
18 | 18 | <div class="espresso-venue-dv<?php echo espresso_is_venue_private() ? ' espresso-private-venue-dv' : ''; ?>"> |
19 | 19 | <h4> |
20 | - <strong><?php esc_html_e( 'Venue:', 'event_espresso' ); ?></strong> |
|
20 | + <strong><?php esc_html_e('Venue:', 'event_espresso'); ?></strong> |
|
21 | 21 | <strong> <?php echo wp_kses($venue_name, AllowedTags::getAllowedTags()); ?></strong> |
22 | 22 | </h4> |
23 | 23 | <p><span class="smaller-text tags-links"><?php echo espresso_venue_categories(); ?></span></p> |
24 | -<?php if ( $venue_phone = espresso_venue_phone( $post->ID, FALSE )) : ?> |
|
24 | +<?php if ($venue_phone = espresso_venue_phone($post->ID, FALSE)) : ?> |
|
25 | 25 | <p> |
26 | 26 | <span class="small-text"> |
27 | - <strong><?php esc_html_e( 'Venue Phone:', 'event_espresso' ); ?></strong> |
|
27 | + <strong><?php esc_html_e('Venue Phone:', 'event_espresso'); ?></strong> |
|
28 | 28 | </span> |
29 | 29 | <?php echo wp_kses($venue_phone, AllowedTags::getAllowedTags()); ?> |
30 | 30 | </p> |
31 | -<?php endif; ?> |
|
32 | -<?php if ( $venue_website = espresso_venue_website( $post->ID, FALSE )) : ?> |
|
31 | +<?php endif; ?> |
|
32 | +<?php if ($venue_website = espresso_venue_website($post->ID, FALSE)) : ?> |
|
33 | 33 | <p> |
34 | 34 | <span class="small-text"> |
35 | - <strong><?php esc_html_e( 'Venue Website:', 'event_espresso' ); ?></strong> |
|
35 | + <strong><?php esc_html_e('Venue Website:', 'event_espresso'); ?></strong> |
|
36 | 36 | </span> |
37 | 37 | <?php echo wp_kses($venue_website, AllowedTags::getAllowedTags()); ?> |
38 | 38 | </p> |
39 | 39 | <?php endif; ?> |
40 | -<?php if ( espresso_venue_has_address( $post->ID )) : ?> |
|
41 | - <strong><span class="dashicons dashicons-location-alt"></span><?php esc_html_e( 'Address:', 'event_espresso' ); ?></strong> |
|
42 | - <?php espresso_venue_address( 'inline' ); // already escaped ?> |
|
43 | - <?php espresso_venue_gmap( $post->ID ); // already escaped ?> |
|
40 | +<?php if (espresso_venue_has_address($post->ID)) : ?> |
|
41 | + <strong><span class="dashicons dashicons-location-alt"></span><?php esc_html_e('Address:', 'event_espresso'); ?></strong> |
|
42 | + <?php espresso_venue_address('inline'); // already escaped ?> |
|
43 | + <?php espresso_venue_gmap($post->ID); // already escaped ?> |
|
44 | 44 | <div class="clear"><br/></div> |
45 | -<?php endif; ?> |
|
45 | +<?php endif; ?> |
|
46 | 46 | |
47 | - <?php $VNU_ID = espresso_venue_id( $post->ID ); ?> |
|
48 | - <?php if ( is_single() ) : ?> |
|
49 | - <?php $venue_description = espresso_venue_description( $VNU_ID, FALSE ); ?> |
|
50 | - <?php if ( $venue_description ) : ?> |
|
47 | + <?php $VNU_ID = espresso_venue_id($post->ID); ?> |
|
48 | + <?php if (is_single()) : ?> |
|
49 | + <?php $venue_description = espresso_venue_description($VNU_ID, FALSE); ?> |
|
50 | + <?php if ($venue_description) : ?> |
|
51 | 51 | <p> |
52 | - <strong><?php esc_html_e( 'Description:', 'event_espresso' ); ?></strong><br/> |
|
53 | - <?php echo do_shortcode( $venue_description ); ?> |
|
52 | + <strong><?php esc_html_e('Description:', 'event_espresso'); ?></strong><br/> |
|
53 | + <?php echo do_shortcode($venue_description); ?> |
|
54 | 54 | </p> |
55 | - <?php endif; ?> |
|
55 | + <?php endif; ?> |
|
56 | 56 | <?php else : ?> |
57 | - <?php $venue_excerpt = espresso_venue_excerpt( $VNU_ID, FALSE ); ?> |
|
58 | - <?php if ( $venue_excerpt ) : ?> |
|
57 | + <?php $venue_excerpt = espresso_venue_excerpt($VNU_ID, FALSE); ?> |
|
58 | + <?php if ($venue_excerpt) : ?> |
|
59 | 59 | <p> |
60 | - <strong><?php esc_html_e( 'Description:', 'event_espresso' ); ?></strong><br/> |
|
60 | + <strong><?php esc_html_e('Description:', 'event_espresso'); ?></strong><br/> |
|
61 | 61 | <?php echo wp_kses($venue_excerpt, AllowedTags::getAllowedTags()); ?> |
62 | 62 | </p> |
63 | - <?php endif; ?> |
|
64 | - <?php endif; ?> |
|
63 | + <?php endif; ?> |
|
64 | + <?php endif; ?> |
|
65 | 65 | </div> |
66 | 66 | <!-- .espresso-venue-dv --> |
67 | 67 | <?php |
68 | -do_action( 'AHEE_event_details_after_venue_details', $post ); |
|
68 | +do_action('AHEE_event_details_after_venue_details', $post); |
|
69 | 69 | else : |
70 | - if ( espresso_venue_is_password_protected() ) : |
|
70 | + if (espresso_venue_is_password_protected()) : |
|
71 | 71 | ?> |
72 | 72 | <div class="espresso-venue-dv espresso-password-protected-venue-dv" > |
73 | 73 | <h3 class="event-venues-h3 ee-event-h3"> |
74 | - <?php esc_html_e( 'Location', 'event_espresso' );?> |
|
74 | + <?php esc_html_e('Location', 'event_espresso'); ?> |
|
75 | 75 | </h3> |
76 | 76 | <?php echo espresso_password_protected_venue_form(); ?> |
77 | 77 | </div> |
@@ -7,10 +7,10 @@ |
||
7 | 7 | <?php echo "<{$tag} id=\"event-details-{$tag}-{$post->ID}\" class=\"entry-title\">"; ?> |
8 | 8 | <a class="ee-event-header-lnk" |
9 | 9 | href="<?php the_permalink(); ?>" |
10 | - <?php echo \EED_Events_Archive::link_target();?> |
|
10 | + <?php echo \EED_Events_Archive::link_target(); ?> |
|
11 | 11 | > |
12 | 12 | <?php the_title(); ?> |
13 | 13 | </a> |
14 | 14 | <?php echo "</{$tag}>"; ?> |
15 | - <?php if ( ! is_archive() && has_excerpt( $post->ID )): the_excerpt(); endif;?> |
|
15 | + <?php if ( ! is_archive() && has_excerpt($post->ID)): the_excerpt(); endif; ?> |
|
16 | 16 | </header> |
@@ -13,25 +13,25 @@ discard block |
||
13 | 13 | <div id="ee-block-event-attendees" class="ee-core-blocks event-espresso-blocks event-attendees"> |
14 | 14 | <ul> |
15 | 15 | <?php |
16 | - foreach ($attendees as $attendee) { |
|
17 | - $attendee_name = esc_html($attendee->full_name()); |
|
16 | + foreach ($attendees as $attendee) { |
|
17 | + $attendee_name = esc_html($attendee->full_name()); |
|
18 | 18 | |
19 | - $gravatar = $attributes['showGravatar'] |
|
20 | - ? get_avatar_url( |
|
21 | - $attendee->email(), |
|
22 | - array( |
|
23 | - 'width' => $attributes['avatarSize'], |
|
24 | - 'height' => $attributes['avatarSize'] |
|
25 | - ) |
|
26 | - ) |
|
27 | - : ''; |
|
19 | + $gravatar = $attributes['showGravatar'] |
|
20 | + ? get_avatar_url( |
|
21 | + $attendee->email(), |
|
22 | + array( |
|
23 | + 'width' => $attributes['avatarSize'], |
|
24 | + 'height' => $attributes['avatarSize'] |
|
25 | + ) |
|
26 | + ) |
|
27 | + : ''; |
|
28 | 28 | |
29 | - $gravatar_class = $attributes['avatarClass'] |
|
30 | - ? $attributes['avatarClass'] . ' contact-avatar-img avatar' |
|
31 | - : 'contact-avatar-img avatar'; |
|
29 | + $gravatar_class = $attributes['avatarClass'] |
|
30 | + ? $attributes['avatarClass'] . ' contact-avatar-img avatar' |
|
31 | + : 'contact-avatar-img avatar'; |
|
32 | 32 | |
33 | - $gravatar = $gravatar !== '' |
|
34 | - ? ' |
|
33 | + $gravatar = $gravatar !== '' |
|
34 | + ? ' |
|
35 | 35 | <div class="contact-image-wrap-div"> |
36 | 36 | <img class="' . esc_attr($gravatar_class) . '" |
37 | 37 | width="' . esc_attr($attributes['avatarSize']) . '" |
@@ -40,13 +40,13 @@ discard block |
||
40 | 40 | alt="contact avatar" |
41 | 41 | > |
42 | 42 | </div>' |
43 | - : ''; |
|
43 | + : ''; |
|
44 | 44 | |
45 | - echo " |
|
45 | + echo " |
|
46 | 46 | <li> |
47 | 47 | {$gravatar}<span>{$attendee_name}</span> |
48 | 48 | </li>"; |
49 | - } |
|
50 | - ?> |
|
49 | + } |
|
50 | + ?> |
|
51 | 51 | </ul> |
52 | 52 | </div> |
@@ -27,16 +27,16 @@ |
||
27 | 27 | : ''; |
28 | 28 | |
29 | 29 | $gravatar_class = $attributes['avatarClass'] |
30 | - ? $attributes['avatarClass'] . ' contact-avatar-img avatar' |
|
30 | + ? $attributes['avatarClass'].' contact-avatar-img avatar' |
|
31 | 31 | : 'contact-avatar-img avatar'; |
32 | 32 | |
33 | 33 | $gravatar = $gravatar !== '' |
34 | 34 | ? ' |
35 | 35 | <div class="contact-image-wrap-div"> |
36 | - <img class="' . esc_attr($gravatar_class) . '" |
|
37 | - width="' . esc_attr($attributes['avatarSize']) . '" |
|
38 | - height="' . esc_attr($attributes['avatarSize']) . '" |
|
39 | - src="' . esc_url_raw($gravatar) . '" |
|
36 | + <img class="' . esc_attr($gravatar_class).'" |
|
37 | + width="' . esc_attr($attributes['avatarSize']).'" |
|
38 | + height="' . esc_attr($attributes['avatarSize']).'" |
|
39 | + src="' . esc_url_raw($gravatar).'" |
|
40 | 40 | alt="contact avatar" |
41 | 41 | > |
42 | 42 | </div>' |
@@ -1,9 +1,9 @@ |
||
1 | 1 | <div id="espresso-ajax-loading" style="display:none;"> |
2 | 2 | <span class="ee-spinner ee-spin"></span><span style="display:none;"> |
3 | 3 | <?php esc_html_e( |
4 | - 'loading...', |
|
5 | - 'event_espresso' |
|
6 | - ); ?></span> |
|
4 | + 'loading...', |
|
5 | + 'event_espresso' |
|
6 | + ); ?></span> |
|
7 | 7 | </div> |
8 | 8 | |
9 | 9 | <div id="espresso-ajax-notices"> |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | } |
100 | 100 | } |
101 | 101 | // now if we STILL do NOT have an EE_Venue model object, BUT we have a Venue ID... |
102 | - if (! EEH_Venue_View::$_venue instanceof EE_Venue && $VNU_ID) { |
|
102 | + if ( ! EEH_Venue_View::$_venue instanceof EE_Venue && $VNU_ID) { |
|
103 | 103 | // sigh... pull it from the db |
104 | 104 | EEH_Venue_View::$_venue = EEM_Venue::instance()->get_one_by_ID($VNU_ID); |
105 | 105 | } |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | public static function is_venue_private($VNU_ID = false) |
176 | 176 | { |
177 | 177 | $venue = EEH_Venue_View::get_venue($VNU_ID); |
178 | - if (! $venue instanceof EE_Venue) { |
|
178 | + if ( ! $venue instanceof EE_Venue) { |
|
179 | 179 | return null; |
180 | 180 | } |
181 | 181 | |
@@ -260,11 +260,11 @@ discard block |
||
260 | 260 | $venue = EEH_Venue_View::get_venue($VNU_ID); |
261 | 261 | if ($venue instanceof EE_Venue) { |
262 | 262 | $excerpt = $venue->excerpt() != null && $venue->excerpt() ? $venue->excerpt() : $venue->description(); |
263 | - $venue_link = ' ' . EEH_Venue_View::venue_details_link( |
|
263 | + $venue_link = ' '.EEH_Venue_View::venue_details_link( |
|
264 | 264 | $venue->ID(), |
265 | - esc_html__('more', 'event_espresso') . '…' |
|
265 | + esc_html__('more', 'event_espresso').'…' |
|
266 | 266 | ); |
267 | - return ! empty($excerpt) ? wp_trim_words($excerpt, 25, '') . $venue_link : ''; |
|
267 | + return ! empty($excerpt) ? wp_trim_words($excerpt, 25, '').$venue_link : ''; |
|
268 | 268 | } |
269 | 269 | return ''; |
270 | 270 | } |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | )) |
300 | 300 | || ! $hide_uncategorized) |
301 | 301 | ) { |
302 | - $category_links[] = '<a href="' . esc_url($url) . '" rel="tag">' . $term->name . '</a> '; |
|
302 | + $category_links[] = '<a href="'.esc_url($url).'" rel="tag">'.$term->name.'</a> '; |
|
303 | 303 | } |
304 | 304 | } |
305 | 305 | } |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | $venue_name = apply_filters( |
368 | 368 | 'FHEE__EEH_Venue__venue_name__append_private_venue_name', |
369 | 369 | EEH_Venue_View::is_venue_private() |
370 | - ? EEH_Venue_View::$_venue->name() . " " . esc_html__('(Private)', 'event_espresso') |
|
370 | + ? EEH_Venue_View::$_venue->name()." ".esc_html__('(Private)', 'event_espresso') |
|
371 | 371 | : EEH_Venue_View::$_venue->name(), |
372 | 372 | EEH_Venue_View::$_venue |
373 | 373 | ); |
@@ -480,7 +480,7 @@ discard block |
||
480 | 480 | $options = []; |
481 | 481 | |
482 | 482 | $options['map_ID'] = $map_ID && $map_ID != $venue->ID() |
483 | - ? $map_ID . '-' . $venue->ID() |
|
483 | + ? $map_ID.'-'.$venue->ID() |
|
484 | 484 | : $venue->ID(); |
485 | 485 | |
486 | 486 | $options['location'] = EEH_Address::format($venue, 'inline', false, false); |
@@ -627,11 +627,11 @@ discard block |
||
627 | 627 | $post_type_obj = get_post_type_object('espresso_venues'); |
628 | 628 | // build final link html |
629 | 629 | $link = |
630 | - '<a class="post-edit-link" href="' . $url . '" title="' . esc_attr( |
|
630 | + '<a class="post-edit-link" href="'.$url.'" title="'.esc_attr( |
|
631 | 631 | $post_type_obj->labels->edit_item |
632 | - ) . '">' . $link . '</a>'; |
|
632 | + ).'">'.$link.'</a>'; |
|
633 | 633 | // put it all together |
634 | - return $before . apply_filters('edit_post_link', $link, $venue->ID()) . $after; |
|
634 | + return $before.apply_filters('edit_post_link', $link, $venue->ID()).$after; |
|
635 | 635 | } |
636 | 636 | } |
637 | 637 | return ''; |
@@ -9,630 +9,630 @@ |
||
9 | 9 | */ |
10 | 10 | class EEH_Venue_View extends EEH_Base |
11 | 11 | { |
12 | - /** |
|
13 | - * @access private |
|
14 | - * @var EE_Venue |
|
15 | - */ |
|
16 | - private static $_venue = null; |
|
17 | - |
|
18 | - |
|
19 | - /** |
|
20 | - * get_venue |
|
21 | - * attempts to retrieve an EE_Venue object any way it can |
|
22 | - * |
|
23 | - * @access public |
|
24 | - * @param int $VNU_ID |
|
25 | - * @param bool $look_in_event |
|
26 | - * @param bool $privacy_check Defaults to true. |
|
27 | - * When false, means even if the venue is private we return it regardless of access. |
|
28 | - * @param bool $password_check |
|
29 | - * @return EE_Venue|null |
|
30 | - * @throws EE_Error |
|
31 | - * @throws ReflectionException |
|
32 | - */ |
|
33 | - public static function get_venue($VNU_ID = 0, $look_in_event = true, $privacy_check = true, $password_check = true) |
|
34 | - { |
|
35 | - $VNU_ID = absint($VNU_ID); |
|
36 | - // do we already have the Venue you are looking for? |
|
37 | - if (EEH_Venue_View::$_venue instanceof EE_Venue && $VNU_ID) { |
|
38 | - // If the Venue ID matches $VNU_ID, return the venue. |
|
39 | - if (EEH_Venue_View::$_venue->ID() === $VNU_ID) { |
|
40 | - return EEH_Venue_View::_get_venue($privacy_check); |
|
41 | - } |
|
42 | - // If the Venue ID does not match, try pulling a venue using $VNU_ID. |
|
43 | - $venue = EEM_Venue::instance()->get_one_by_ID($VNU_ID); |
|
44 | - if ($venue instanceof EE_Venue) { |
|
45 | - EEH_Venue_View::$_venue = $venue; |
|
46 | - return EEH_Venue_View::_get_venue($privacy_check); |
|
47 | - } |
|
48 | - } |
|
49 | - // international newspaper? |
|
50 | - global $post; |
|
51 | - if ($post instanceof WP_Post) { |
|
52 | - switch ($post->post_type) { |
|
53 | - // if this is being called from an EE_Venue post, |
|
54 | - // and the EE_Venue post corresponds to the EE_Venue that is being asked for, |
|
55 | - // then we can try to just grab the attached EE_Venue object |
|
56 | - case 'espresso_venues': |
|
57 | - // the post already contains the related EE_Venue object AND one of the following is TRUE: |
|
58 | - // the requested Venue ID matches the post ID OR... |
|
59 | - // there was no specific Venue ID requested |
|
60 | - if (isset($post->EE_Venue) && ($VNU_ID == $post->ID || ! $VNU_ID)) { |
|
61 | - // use existing related EE_Venue object |
|
62 | - EEH_Venue_View::$_venue = $post->EE_Venue; |
|
63 | - } elseif ($VNU_ID) { |
|
64 | - // there WAS a specific Venue ID requested, but it's NOT the current post object |
|
65 | - EEH_Venue_View::$_venue = EEM_Venue::instance()->get_one_by_ID($VNU_ID); |
|
66 | - } else { |
|
67 | - // no specific Venue ID requested, so use post ID to generate EE_Venue object |
|
68 | - EEH_Venue_View::$_venue = EEM_Venue::instance()->get_one_by_ID($post->ID); |
|
69 | - } |
|
70 | - break; |
|
71 | - |
|
72 | - case 'espresso_events': |
|
73 | - if ($look_in_event) { |
|
74 | - // grab the events related venues |
|
75 | - $venues = EEH_Venue_View::get_event_venues(); |
|
76 | - // make sure the result is an array |
|
77 | - $venues = is_array($venues) ? $venues : [$venues]; |
|
78 | - // do we have an ID for a specific venue? |
|
79 | - if ($VNU_ID) { |
|
80 | - // loop thru the related venues |
|
81 | - foreach ($venues as $venue) { |
|
82 | - if ($venue instanceof EE_Venue) { |
|
83 | - // until we find the venue we're looking for |
|
84 | - if ($venue->ID() == $VNU_ID) { |
|
85 | - EEH_Venue_View::$_venue = $venue; |
|
86 | - break; |
|
87 | - } |
|
88 | - } |
|
89 | - } |
|
90 | - // no venue ID ? |
|
91 | - // then the global post is an events post and this function was called with no argument |
|
92 | - } else { |
|
93 | - // just grab the first related event venue |
|
94 | - EEH_Venue_View::$_venue = reset($venues); |
|
95 | - } |
|
96 | - } |
|
97 | - break; |
|
98 | - } |
|
99 | - } |
|
100 | - // now if we STILL do NOT have an EE_Venue model object, BUT we have a Venue ID... |
|
101 | - if (! EEH_Venue_View::$_venue instanceof EE_Venue && $VNU_ID) { |
|
102 | - // sigh... pull it from the db |
|
103 | - EEH_Venue_View::$_venue = EEM_Venue::instance()->get_one_by_ID($VNU_ID); |
|
104 | - } |
|
105 | - return EEH_Venue_View::_get_venue($privacy_check, $password_check); |
|
106 | - } |
|
107 | - |
|
108 | - |
|
109 | - /** |
|
110 | - * return a single venue |
|
111 | - * |
|
112 | - * @param bool $privacy_check Defaults to true. |
|
113 | - * When false, means even if the venue is private we return it regardless of access. |
|
114 | - * @param bool $password_check |
|
115 | - * @return EE_Venue |
|
116 | - * @throws EE_Error |
|
117 | - * @throws ReflectionException |
|
118 | - */ |
|
119 | - protected static function _get_venue($privacy_check = true, $password_check = true) |
|
120 | - { |
|
121 | - // check for private venues. |
|
122 | - if ( |
|
123 | - EEH_Venue_View::$_venue instanceof EE_Venue |
|
124 | - && EEH_Venue_View::$_venue->status() == 'private' |
|
125 | - && $privacy_check |
|
126 | - && ! EE_Registry::instance()->CAP->current_user_can('ee_read_private_venues', 'get_venues') |
|
127 | - ) { |
|
128 | - return null; |
|
129 | - } |
|
130 | - // check for password protected venues |
|
131 | - if ( |
|
132 | - EEH_Venue_View::$_venue instanceof EE_Venue |
|
133 | - && $password_check |
|
134 | - && post_password_required(EEH_Venue_View::$_venue->ID()) |
|
135 | - ) { |
|
136 | - return null; |
|
137 | - } |
|
138 | - return EEH_Venue_View::$_venue instanceof EE_Venue ? EEH_Venue_View::$_venue : null; |
|
139 | - } |
|
140 | - |
|
141 | - |
|
142 | - /** |
|
143 | - * get_event_venues |
|
144 | - * |
|
145 | - * @access public |
|
146 | - * @return EE_Venue[] |
|
147 | - * @throws EE_Error |
|
148 | - * @throws ReflectionException |
|
149 | - */ |
|
150 | - public static function get_event_venues() |
|
151 | - { |
|
152 | - global $post; |
|
153 | - if ($post->post_type == 'espresso_events') { |
|
154 | - if (isset($post->EE_Event) && $post->EE_Event instanceof EE_Event) { |
|
155 | - return $post->EE_Event->venue(); |
|
156 | - } |
|
157 | - } |
|
158 | - return []; |
|
159 | - } |
|
160 | - |
|
161 | - |
|
162 | - /** |
|
163 | - * Simply checks whether a venue for the given ID (or the internally derived venue is private). |
|
164 | - * |
|
165 | - * Note: This will return true if its private, null if the venue doesn't exist, and false, if the venue exists but |
|
166 | - * is not private. So it is important to do explicit boolean checks when using this conditional. |
|
167 | - * |
|
168 | - * @param bool $VNU_ID venue to check (optional). If not included will use internally derived venue object. |
|
169 | - * |
|
170 | - * @return bool|null |
|
171 | - * @throws EE_Error |
|
172 | - * @throws ReflectionException |
|
173 | - */ |
|
174 | - public static function is_venue_private($VNU_ID = false) |
|
175 | - { |
|
176 | - $venue = EEH_Venue_View::get_venue($VNU_ID); |
|
177 | - if (! $venue instanceof EE_Venue) { |
|
178 | - return null; |
|
179 | - } |
|
180 | - |
|
181 | - return $venue->status() == 'private'; |
|
182 | - } |
|
183 | - |
|
184 | - |
|
185 | - /** |
|
186 | - * returns true or false if a venue is password protected or not |
|
187 | - * |
|
188 | - * @param bool $VNU_ID venue to check (optional). If not included will use internally derived venue object. |
|
189 | - * @return bool |
|
190 | - * @throws EE_Error |
|
191 | - * @throws ReflectionException |
|
192 | - */ |
|
193 | - public static function is_venue_password_protected($VNU_ID = false) |
|
194 | - { |
|
195 | - $venue = EEH_Venue_View::get_venue($VNU_ID, true, true, false); |
|
196 | - if ( |
|
197 | - $venue instanceof EE_Venue |
|
198 | - && post_password_required($venue->ID()) |
|
199 | - ) { |
|
200 | - return true; |
|
201 | - } |
|
202 | - return false; |
|
203 | - } |
|
204 | - |
|
205 | - |
|
206 | - /** |
|
207 | - * If a venue is password protected, this will return the password form for gaining access |
|
208 | - * returns an empty string otherwise |
|
209 | - * |
|
210 | - * @param bool $VNU_ID venue to check (optional). If not included will use internally derived venue object. |
|
211 | - * |
|
212 | - * @return string |
|
213 | - * @throws EE_Error |
|
214 | - * @throws ReflectionException |
|
215 | - */ |
|
216 | - public static function password_protected_venue_form($VNU_ID = false) |
|
217 | - { |
|
218 | - $venue = EEH_Venue_View::get_venue($VNU_ID, true, true, false); |
|
219 | - if ( |
|
220 | - $venue instanceof EE_Venue |
|
221 | - && post_password_required($venue->ID()) |
|
222 | - ) { |
|
223 | - return get_the_password_form($venue->ID()); |
|
224 | - } |
|
225 | - return ''; |
|
226 | - } |
|
227 | - |
|
228 | - |
|
229 | - /** |
|
230 | - * venue_description |
|
231 | - * |
|
232 | - * @access public |
|
233 | - * @param int $VNU_ID |
|
234 | - * @return string |
|
235 | - * @throws EE_Error |
|
236 | - * @throws ReflectionException |
|
237 | - */ |
|
238 | - public static function venue_description($VNU_ID = 0) |
|
239 | - { |
|
240 | - $venue = EEH_Venue_View::get_venue($VNU_ID); |
|
241 | - if ($venue instanceof EE_Venue) { |
|
242 | - return $venue->get_pretty('VNU_desc'); |
|
243 | - } |
|
244 | - return ''; |
|
245 | - } |
|
246 | - |
|
247 | - |
|
248 | - /** |
|
249 | - * venue_excerpt |
|
250 | - * |
|
251 | - * @access public |
|
252 | - * @param int $VNU_ID |
|
253 | - * @return string |
|
254 | - * @throws EE_Error |
|
255 | - * @throws ReflectionException |
|
256 | - */ |
|
257 | - public static function venue_excerpt($VNU_ID = 0) |
|
258 | - { |
|
259 | - $venue = EEH_Venue_View::get_venue($VNU_ID); |
|
260 | - if ($venue instanceof EE_Venue) { |
|
261 | - $excerpt = $venue->excerpt() != null && $venue->excerpt() ? $venue->excerpt() : $venue->description(); |
|
262 | - $venue_link = ' ' . EEH_Venue_View::venue_details_link( |
|
263 | - $venue->ID(), |
|
264 | - esc_html__('more', 'event_espresso') . '…' |
|
265 | - ); |
|
266 | - return ! empty($excerpt) ? wp_trim_words($excerpt, 25, '') . $venue_link : ''; |
|
267 | - } |
|
268 | - return ''; |
|
269 | - } |
|
270 | - |
|
271 | - |
|
272 | - /** |
|
273 | - * venue_categories |
|
274 | - * |
|
275 | - * @access public |
|
276 | - * @param int $VNU_ID |
|
277 | - * @param bool $hide_uncategorized |
|
278 | - * @return string |
|
279 | - * @throws EE_Error |
|
280 | - * @throws ReflectionException |
|
281 | - */ |
|
282 | - public static function venue_categories($VNU_ID = 0, $hide_uncategorized = true) |
|
283 | - { |
|
284 | - $category_links = []; |
|
285 | - $venue = EEH_Venue_View::get_venue($VNU_ID); |
|
286 | - if ($venue instanceof EE_Venue) { |
|
287 | - // get category terms |
|
288 | - if ($venue_categories = get_the_terms($venue->ID(), 'espresso_venue_categories')) { |
|
289 | - // loop thru terms and create links |
|
290 | - foreach ($venue_categories as $term) { |
|
291 | - $url = get_term_link($term, 'espresso_venue_categories'); |
|
292 | - if ( |
|
293 | - ! is_wp_error($url) |
|
294 | - && (($hide_uncategorized |
|
295 | - && strtolower($term->name) != esc_html__( |
|
296 | - 'uncategorized', |
|
297 | - 'event_espresso' |
|
298 | - )) |
|
299 | - || ! $hide_uncategorized) |
|
300 | - ) { |
|
301 | - $category_links[] = '<a href="' . esc_url($url) . '" rel="tag">' . $term->name . '</a> '; |
|
302 | - } |
|
303 | - } |
|
304 | - } |
|
305 | - } |
|
306 | - return implode(', ', $category_links); |
|
307 | - } |
|
308 | - |
|
309 | - |
|
310 | - /** |
|
311 | - * venue_address |
|
312 | - * |
|
313 | - * @access public |
|
314 | - * @param string $type |
|
315 | - * @param int $VNU_ID |
|
316 | - * @param bool $use_schema |
|
317 | - * @param bool $add_wrapper |
|
318 | - * @return string |
|
319 | - * @throws EE_Error |
|
320 | - * @throws ReflectionException |
|
321 | - */ |
|
322 | - public static function venue_address($type = 'multiline', $VNU_ID = 0, $use_schema = true, $add_wrapper = true) |
|
323 | - { |
|
324 | - $venue = EEH_Venue_View::get_venue($VNU_ID); |
|
325 | - if ($venue instanceof EE_Venue) { |
|
326 | - return EEH_Address::format($venue, $type, $use_schema, $add_wrapper); |
|
327 | - } |
|
328 | - return ''; |
|
329 | - } |
|
330 | - |
|
331 | - |
|
332 | - /** |
|
333 | - * venue_has_address |
|
334 | - * |
|
335 | - * @access public |
|
336 | - * @param int $VNU_ID |
|
337 | - * @return bool|string |
|
338 | - * @throws EE_Error |
|
339 | - * @throws ReflectionException |
|
340 | - */ |
|
341 | - public static function venue_has_address($VNU_ID = 0) |
|
342 | - { |
|
343 | - $venue = EEH_Venue_View::get_venue($VNU_ID); |
|
344 | - if ($venue instanceof EE_Venue) { |
|
345 | - return EEH_Address::format($venue, 'inline', false, false); |
|
346 | - } |
|
347 | - return false; |
|
348 | - } |
|
349 | - |
|
350 | - |
|
351 | - /** |
|
352 | - * venue_name |
|
353 | - * |
|
354 | - * @access public |
|
355 | - * @param string $link_to - options( details, website, none ) whether to turn Venue name into a clickable link to |
|
356 | - * the Venue's details page or website |
|
357 | - * @param int $VNU_ID |
|
358 | - * @return string |
|
359 | - * @throws EE_Error |
|
360 | - * @throws ReflectionException |
|
361 | - */ |
|
362 | - public static function venue_name($link_to = 'details', $VNU_ID = 0) |
|
363 | - { |
|
364 | - $venue = EEH_Venue_View::get_venue($VNU_ID); |
|
365 | - if ($venue instanceof EE_Venue) { |
|
366 | - $venue_name = apply_filters( |
|
367 | - 'FHEE__EEH_Venue__venue_name__append_private_venue_name', |
|
368 | - EEH_Venue_View::is_venue_private() |
|
369 | - ? EEH_Venue_View::$_venue->name() . " " . esc_html__('(Private)', 'event_espresso') |
|
370 | - : EEH_Venue_View::$_venue->name(), |
|
371 | - EEH_Venue_View::$_venue |
|
372 | - ); |
|
373 | - $venue_name = EEH_Schema::name($venue_name); |
|
374 | - |
|
375 | - // if venue is trashed then ignore the "link to" setting because the venue is trashed. |
|
376 | - if ($venue->get('status') == 'trash') { |
|
377 | - $link_to = ''; |
|
378 | - } |
|
379 | - switch ($link_to) { |
|
380 | - case 'details': |
|
381 | - return EEH_Venue_View::venue_details_link($venue->ID(), $venue_name); |
|
382 | - |
|
383 | - case 'website': |
|
384 | - return EEH_Venue_View::venue_website_link($venue->ID(), $venue_name); |
|
385 | - |
|
386 | - default: |
|
387 | - return $venue_name; |
|
388 | - } |
|
389 | - } |
|
390 | - return ''; |
|
391 | - } |
|
392 | - |
|
393 | - |
|
394 | - /** |
|
395 | - * venue_details_link |
|
396 | - * |
|
397 | - * @access public |
|
398 | - * @param int $VNU_ID |
|
399 | - * @param string $text |
|
400 | - * @return string |
|
401 | - * @throws EE_Error |
|
402 | - * @throws ReflectionException |
|
403 | - */ |
|
404 | - public static function venue_details_link($VNU_ID = 0, $text = '') |
|
405 | - { |
|
406 | - $venue = EEH_Venue_View::get_venue($VNU_ID); |
|
407 | - if ($venue instanceof EE_Venue) { |
|
408 | - return EEH_Schema::url(get_permalink($venue->ID()), $text); |
|
409 | - } |
|
410 | - return ''; |
|
411 | - } |
|
412 | - |
|
413 | - |
|
414 | - /** |
|
415 | - * venue_website_link |
|
416 | - * |
|
417 | - * @access public |
|
418 | - * @param int $VNU_ID |
|
419 | - * @param string $text |
|
420 | - * @return string |
|
421 | - * @throws EE_Error |
|
422 | - * @throws ReflectionException |
|
423 | - */ |
|
424 | - public static function venue_website_link($VNU_ID = 0, $text = '') |
|
425 | - { |
|
426 | - $venue = EEH_Venue_View::get_venue($VNU_ID); |
|
427 | - if ($venue instanceof EE_Venue) { |
|
428 | - $url = $venue->venue_url(); |
|
429 | - $text = ! empty($text) ? $text : $url; |
|
430 | - return ! empty($url) ? EEH_Schema::url($url, $text, ['target' => '_blank']) : ''; |
|
431 | - } |
|
432 | - return ''; |
|
433 | - } |
|
434 | - |
|
435 | - |
|
436 | - /** |
|
437 | - * venue_phone |
|
438 | - * |
|
439 | - * @access public |
|
440 | - * @param int $VNU_ID |
|
441 | - * @return string |
|
442 | - * @throws EE_Error |
|
443 | - * @throws ReflectionException |
|
444 | - */ |
|
445 | - public static function venue_phone($VNU_ID = 0) |
|
446 | - { |
|
447 | - $venue = EEH_Venue_View::get_venue($VNU_ID); |
|
448 | - if ($venue instanceof EE_Venue) { |
|
449 | - return EEH_Schema::telephone($venue->phone()); |
|
450 | - } |
|
451 | - return ''; |
|
452 | - } |
|
453 | - |
|
454 | - |
|
455 | - /** |
|
456 | - * venue_gmap |
|
457 | - * |
|
458 | - * @access public |
|
459 | - * @param int $VNU_ID |
|
460 | - * @param bool|string $map_ID a unique identifier for this map |
|
461 | - * @param array $gmap map options |
|
462 | - * @return string |
|
463 | - * @throws EE_Error |
|
464 | - * @throws ReflectionException |
|
465 | - */ |
|
466 | - public static function venue_gmap($VNU_ID = 0, $map_ID = false, $gmap = []) |
|
467 | - { |
|
468 | - |
|
469 | - $venue = EEH_Venue_View::get_venue($VNU_ID); |
|
470 | - if ($venue instanceof EE_Venue) { |
|
471 | - // check for global espresso_events post and use it's ID if no map_ID is set |
|
472 | - global $post; |
|
473 | - $map_ID = empty($map_ID) && $post->post_type == 'espresso_events' ? $post->ID : $map_ID; |
|
474 | - // grab map settings |
|
475 | - $map_cfg = EE_Registry::instance()->CFG->map_settings; |
|
476 | - // are maps enabled ? |
|
477 | - if ($map_cfg->use_google_maps && $venue->enable_for_gmap()) { |
|
478 | - $details_page = is_single(); |
|
479 | - $options = []; |
|
480 | - |
|
481 | - $options['map_ID'] = $map_ID && $map_ID != $venue->ID() |
|
482 | - ? $map_ID . '-' . $venue->ID() |
|
483 | - : $venue->ID(); |
|
484 | - |
|
485 | - $options['location'] = EEH_Address::format($venue, 'inline', false, false); |
|
486 | - |
|
487 | - $options['ee_map_width'] = $details_page |
|
488 | - ? $map_cfg->event_details_map_width |
|
489 | - : $map_cfg->event_list_map_width; |
|
490 | - |
|
491 | - $options['ee_map_width'] = isset($gmap['ee_map_width']) && ! empty($gmap['ee_map_width']) |
|
492 | - ? $gmap['ee_map_width'] |
|
493 | - : $options['ee_map_width']; |
|
494 | - |
|
495 | - $options['ee_map_height'] = $details_page |
|
496 | - ? $map_cfg->event_details_map_height |
|
497 | - : $map_cfg->event_list_map_height; |
|
498 | - |
|
499 | - $options['ee_map_height'] = isset($gmap['ee_map_height']) && ! empty($gmap['ee_map_height']) |
|
500 | - ? $gmap['ee_map_height'] |
|
501 | - : $options['ee_map_height']; |
|
502 | - |
|
503 | - $options['ee_map_zoom'] = $details_page |
|
504 | - ? $map_cfg->event_details_map_zoom |
|
505 | - : $map_cfg->event_list_map_zoom; |
|
506 | - |
|
507 | - $options['ee_map_zoom'] = isset($gmap['ee_map_zoom']) && ! empty($gmap['ee_map_zoom']) |
|
508 | - ? $gmap['ee_map_zoom'] |
|
509 | - : $options['ee_map_zoom']; |
|
510 | - |
|
511 | - $options['ee_map_nav_display'] = $details_page |
|
512 | - ? $map_cfg->event_details_display_nav |
|
513 | - : $map_cfg->event_list_display_nav; |
|
514 | - |
|
515 | - $options['ee_map_nav_display'] = |
|
516 | - isset($gmap['ee_map_nav_display']) && ! empty($gmap['ee_map_nav_display']) |
|
517 | - ? 'true' |
|
518 | - : $options['ee_map_nav_display']; |
|
519 | - |
|
520 | - $options['ee_map_nav_size'] = $details_page |
|
521 | - ? $map_cfg->event_details_nav_size |
|
522 | - : $map_cfg->event_list_nav_size; |
|
523 | - |
|
524 | - $options['ee_map_nav_size'] = isset($gmap['ee_map_nav_size']) && ! empty($gmap['ee_map_nav_size']) |
|
525 | - ? $gmap['ee_map_nav_size'] |
|
526 | - : $options['ee_map_nav_size']; |
|
527 | - |
|
528 | - $options['ee_map_type_control'] = $details_page |
|
529 | - ? $map_cfg->event_details_control_type |
|
530 | - : $map_cfg->event_list_control_type; |
|
531 | - |
|
532 | - $options['ee_map_type_control'] = |
|
533 | - isset($gmap['ee_map_type_control']) && ! empty($gmap['ee_map_type_control']) |
|
534 | - ? $gmap['ee_map_type_control'] |
|
535 | - : $options['ee_map_type_control']; |
|
536 | - |
|
537 | - $options['ee_map_align'] = $details_page |
|
538 | - ? $map_cfg->event_details_map_align |
|
539 | - : $map_cfg->event_list_map_align; |
|
540 | - |
|
541 | - $options['ee_map_align'] = isset($gmap['ee_map_align']) && ! empty($gmap['ee_map_align']) |
|
542 | - ? $gmap['ee_map_align'] |
|
543 | - : $options['ee_map_align']; |
|
544 | - |
|
545 | - $options['ee_static_url'] = isset($gmap['ee_static_url']) && ! empty($gmap['ee_static_url']) |
|
546 | - ? (bool) absint($gmap['ee_static_url']) |
|
547 | - : $venue->google_map_link(); |
|
548 | - |
|
549 | - return EEH_Maps::google_map($options); |
|
550 | - } |
|
551 | - } |
|
552 | - |
|
553 | - return ''; |
|
554 | - } |
|
555 | - |
|
556 | - |
|
557 | - /** |
|
558 | - * Gets the HTML to display a static map of the venue |
|
559 | - * |
|
560 | - * @param EE_Venue $venue |
|
561 | - * @param array $attributes like EEH_Maps::google_map_link |
|
562 | - * @return string |
|
563 | - * @throws EE_Error |
|
564 | - * @throws ReflectionException |
|
565 | - */ |
|
566 | - public static function espresso_google_static_map(EE_Venue $venue, $attributes = []) |
|
567 | - { |
|
568 | - $state = $venue->state_obj(); |
|
569 | - $country = $venue->country_obj(); |
|
570 | - $attributes = shortcode_atts( |
|
571 | - [ |
|
572 | - 'id' => $venue->ID(), |
|
573 | - 'address' => $venue->get('VNU_address'), |
|
574 | - 'city' => $venue->get('VNU_city'), |
|
575 | - 'state' => $state instanceof EE_State ? $state->name() : '', |
|
576 | - 'zip' => $venue->get('VNU_zip'), |
|
577 | - 'country' => $country instanceof EE_Country ? $country->name() : '', |
|
578 | - 'type' => 'map', |
|
579 | - 'map_w' => 200, |
|
580 | - 'map_h' => 200, |
|
581 | - ], |
|
582 | - $attributes |
|
583 | - ); |
|
584 | - return EEH_Maps::google_map_link($attributes); |
|
585 | - } |
|
586 | - |
|
587 | - |
|
588 | - /** |
|
589 | - * edit_venue_link |
|
590 | - * |
|
591 | - * @access public |
|
592 | - * @param int $VNU_ID |
|
593 | - * @param string $link |
|
594 | - * @param string $before |
|
595 | - * @param string $after |
|
596 | - * @return string |
|
597 | - * @throws EE_Error |
|
598 | - * @throws ReflectionException |
|
599 | - */ |
|
600 | - public static function edit_venue_link( |
|
601 | - $VNU_ID = 0, |
|
602 | - $link = '', |
|
603 | - $before = '<p class="edit-venue-lnk small-txt">', |
|
604 | - $after = '</p>' |
|
605 | - ) { |
|
606 | - $venue = EEH_Venue_View::get_venue($VNU_ID); |
|
607 | - if ($venue instanceof EE_Venue) { |
|
608 | - // can the user edit this post ? |
|
609 | - if (current_user_can('edit_post', $venue->ID())) { |
|
610 | - // set link text |
|
611 | - $link = ! empty($link) ? $link : esc_html__('edit this venue', 'event_espresso'); |
|
612 | - // generate nonce |
|
613 | - $nonce = wp_create_nonce('edit_nonce'); |
|
614 | - // generate url to venue editor for this venue |
|
615 | - $url = |
|
616 | - add_query_arg( |
|
617 | - [ |
|
618 | - 'page' => 'espresso_venues', |
|
619 | - 'action' => 'edit', |
|
620 | - 'post' => $venue->ID(), |
|
621 | - 'edit_nonce' => $nonce, |
|
622 | - ], |
|
623 | - admin_url('admin.php') |
|
624 | - ); |
|
625 | - // get edit CPT text |
|
626 | - $post_type_obj = get_post_type_object('espresso_venues'); |
|
627 | - // build final link html |
|
628 | - $link = |
|
629 | - '<a class="post-edit-link" href="' . $url . '" title="' . esc_attr( |
|
630 | - $post_type_obj->labels->edit_item |
|
631 | - ) . '">' . $link . '</a>'; |
|
632 | - // put it all together |
|
633 | - return $before . apply_filters('edit_post_link', $link, $venue->ID()) . $after; |
|
634 | - } |
|
635 | - } |
|
636 | - return ''; |
|
637 | - } |
|
12 | + /** |
|
13 | + * @access private |
|
14 | + * @var EE_Venue |
|
15 | + */ |
|
16 | + private static $_venue = null; |
|
17 | + |
|
18 | + |
|
19 | + /** |
|
20 | + * get_venue |
|
21 | + * attempts to retrieve an EE_Venue object any way it can |
|
22 | + * |
|
23 | + * @access public |
|
24 | + * @param int $VNU_ID |
|
25 | + * @param bool $look_in_event |
|
26 | + * @param bool $privacy_check Defaults to true. |
|
27 | + * When false, means even if the venue is private we return it regardless of access. |
|
28 | + * @param bool $password_check |
|
29 | + * @return EE_Venue|null |
|
30 | + * @throws EE_Error |
|
31 | + * @throws ReflectionException |
|
32 | + */ |
|
33 | + public static function get_venue($VNU_ID = 0, $look_in_event = true, $privacy_check = true, $password_check = true) |
|
34 | + { |
|
35 | + $VNU_ID = absint($VNU_ID); |
|
36 | + // do we already have the Venue you are looking for? |
|
37 | + if (EEH_Venue_View::$_venue instanceof EE_Venue && $VNU_ID) { |
|
38 | + // If the Venue ID matches $VNU_ID, return the venue. |
|
39 | + if (EEH_Venue_View::$_venue->ID() === $VNU_ID) { |
|
40 | + return EEH_Venue_View::_get_venue($privacy_check); |
|
41 | + } |
|
42 | + // If the Venue ID does not match, try pulling a venue using $VNU_ID. |
|
43 | + $venue = EEM_Venue::instance()->get_one_by_ID($VNU_ID); |
|
44 | + if ($venue instanceof EE_Venue) { |
|
45 | + EEH_Venue_View::$_venue = $venue; |
|
46 | + return EEH_Venue_View::_get_venue($privacy_check); |
|
47 | + } |
|
48 | + } |
|
49 | + // international newspaper? |
|
50 | + global $post; |
|
51 | + if ($post instanceof WP_Post) { |
|
52 | + switch ($post->post_type) { |
|
53 | + // if this is being called from an EE_Venue post, |
|
54 | + // and the EE_Venue post corresponds to the EE_Venue that is being asked for, |
|
55 | + // then we can try to just grab the attached EE_Venue object |
|
56 | + case 'espresso_venues': |
|
57 | + // the post already contains the related EE_Venue object AND one of the following is TRUE: |
|
58 | + // the requested Venue ID matches the post ID OR... |
|
59 | + // there was no specific Venue ID requested |
|
60 | + if (isset($post->EE_Venue) && ($VNU_ID == $post->ID || ! $VNU_ID)) { |
|
61 | + // use existing related EE_Venue object |
|
62 | + EEH_Venue_View::$_venue = $post->EE_Venue; |
|
63 | + } elseif ($VNU_ID) { |
|
64 | + // there WAS a specific Venue ID requested, but it's NOT the current post object |
|
65 | + EEH_Venue_View::$_venue = EEM_Venue::instance()->get_one_by_ID($VNU_ID); |
|
66 | + } else { |
|
67 | + // no specific Venue ID requested, so use post ID to generate EE_Venue object |
|
68 | + EEH_Venue_View::$_venue = EEM_Venue::instance()->get_one_by_ID($post->ID); |
|
69 | + } |
|
70 | + break; |
|
71 | + |
|
72 | + case 'espresso_events': |
|
73 | + if ($look_in_event) { |
|
74 | + // grab the events related venues |
|
75 | + $venues = EEH_Venue_View::get_event_venues(); |
|
76 | + // make sure the result is an array |
|
77 | + $venues = is_array($venues) ? $venues : [$venues]; |
|
78 | + // do we have an ID for a specific venue? |
|
79 | + if ($VNU_ID) { |
|
80 | + // loop thru the related venues |
|
81 | + foreach ($venues as $venue) { |
|
82 | + if ($venue instanceof EE_Venue) { |
|
83 | + // until we find the venue we're looking for |
|
84 | + if ($venue->ID() == $VNU_ID) { |
|
85 | + EEH_Venue_View::$_venue = $venue; |
|
86 | + break; |
|
87 | + } |
|
88 | + } |
|
89 | + } |
|
90 | + // no venue ID ? |
|
91 | + // then the global post is an events post and this function was called with no argument |
|
92 | + } else { |
|
93 | + // just grab the first related event venue |
|
94 | + EEH_Venue_View::$_venue = reset($venues); |
|
95 | + } |
|
96 | + } |
|
97 | + break; |
|
98 | + } |
|
99 | + } |
|
100 | + // now if we STILL do NOT have an EE_Venue model object, BUT we have a Venue ID... |
|
101 | + if (! EEH_Venue_View::$_venue instanceof EE_Venue && $VNU_ID) { |
|
102 | + // sigh... pull it from the db |
|
103 | + EEH_Venue_View::$_venue = EEM_Venue::instance()->get_one_by_ID($VNU_ID); |
|
104 | + } |
|
105 | + return EEH_Venue_View::_get_venue($privacy_check, $password_check); |
|
106 | + } |
|
107 | + |
|
108 | + |
|
109 | + /** |
|
110 | + * return a single venue |
|
111 | + * |
|
112 | + * @param bool $privacy_check Defaults to true. |
|
113 | + * When false, means even if the venue is private we return it regardless of access. |
|
114 | + * @param bool $password_check |
|
115 | + * @return EE_Venue |
|
116 | + * @throws EE_Error |
|
117 | + * @throws ReflectionException |
|
118 | + */ |
|
119 | + protected static function _get_venue($privacy_check = true, $password_check = true) |
|
120 | + { |
|
121 | + // check for private venues. |
|
122 | + if ( |
|
123 | + EEH_Venue_View::$_venue instanceof EE_Venue |
|
124 | + && EEH_Venue_View::$_venue->status() == 'private' |
|
125 | + && $privacy_check |
|
126 | + && ! EE_Registry::instance()->CAP->current_user_can('ee_read_private_venues', 'get_venues') |
|
127 | + ) { |
|
128 | + return null; |
|
129 | + } |
|
130 | + // check for password protected venues |
|
131 | + if ( |
|
132 | + EEH_Venue_View::$_venue instanceof EE_Venue |
|
133 | + && $password_check |
|
134 | + && post_password_required(EEH_Venue_View::$_venue->ID()) |
|
135 | + ) { |
|
136 | + return null; |
|
137 | + } |
|
138 | + return EEH_Venue_View::$_venue instanceof EE_Venue ? EEH_Venue_View::$_venue : null; |
|
139 | + } |
|
140 | + |
|
141 | + |
|
142 | + /** |
|
143 | + * get_event_venues |
|
144 | + * |
|
145 | + * @access public |
|
146 | + * @return EE_Venue[] |
|
147 | + * @throws EE_Error |
|
148 | + * @throws ReflectionException |
|
149 | + */ |
|
150 | + public static function get_event_venues() |
|
151 | + { |
|
152 | + global $post; |
|
153 | + if ($post->post_type == 'espresso_events') { |
|
154 | + if (isset($post->EE_Event) && $post->EE_Event instanceof EE_Event) { |
|
155 | + return $post->EE_Event->venue(); |
|
156 | + } |
|
157 | + } |
|
158 | + return []; |
|
159 | + } |
|
160 | + |
|
161 | + |
|
162 | + /** |
|
163 | + * Simply checks whether a venue for the given ID (or the internally derived venue is private). |
|
164 | + * |
|
165 | + * Note: This will return true if its private, null if the venue doesn't exist, and false, if the venue exists but |
|
166 | + * is not private. So it is important to do explicit boolean checks when using this conditional. |
|
167 | + * |
|
168 | + * @param bool $VNU_ID venue to check (optional). If not included will use internally derived venue object. |
|
169 | + * |
|
170 | + * @return bool|null |
|
171 | + * @throws EE_Error |
|
172 | + * @throws ReflectionException |
|
173 | + */ |
|
174 | + public static function is_venue_private($VNU_ID = false) |
|
175 | + { |
|
176 | + $venue = EEH_Venue_View::get_venue($VNU_ID); |
|
177 | + if (! $venue instanceof EE_Venue) { |
|
178 | + return null; |
|
179 | + } |
|
180 | + |
|
181 | + return $venue->status() == 'private'; |
|
182 | + } |
|
183 | + |
|
184 | + |
|
185 | + /** |
|
186 | + * returns true or false if a venue is password protected or not |
|
187 | + * |
|
188 | + * @param bool $VNU_ID venue to check (optional). If not included will use internally derived venue object. |
|
189 | + * @return bool |
|
190 | + * @throws EE_Error |
|
191 | + * @throws ReflectionException |
|
192 | + */ |
|
193 | + public static function is_venue_password_protected($VNU_ID = false) |
|
194 | + { |
|
195 | + $venue = EEH_Venue_View::get_venue($VNU_ID, true, true, false); |
|
196 | + if ( |
|
197 | + $venue instanceof EE_Venue |
|
198 | + && post_password_required($venue->ID()) |
|
199 | + ) { |
|
200 | + return true; |
|
201 | + } |
|
202 | + return false; |
|
203 | + } |
|
204 | + |
|
205 | + |
|
206 | + /** |
|
207 | + * If a venue is password protected, this will return the password form for gaining access |
|
208 | + * returns an empty string otherwise |
|
209 | + * |
|
210 | + * @param bool $VNU_ID venue to check (optional). If not included will use internally derived venue object. |
|
211 | + * |
|
212 | + * @return string |
|
213 | + * @throws EE_Error |
|
214 | + * @throws ReflectionException |
|
215 | + */ |
|
216 | + public static function password_protected_venue_form($VNU_ID = false) |
|
217 | + { |
|
218 | + $venue = EEH_Venue_View::get_venue($VNU_ID, true, true, false); |
|
219 | + if ( |
|
220 | + $venue instanceof EE_Venue |
|
221 | + && post_password_required($venue->ID()) |
|
222 | + ) { |
|
223 | + return get_the_password_form($venue->ID()); |
|
224 | + } |
|
225 | + return ''; |
|
226 | + } |
|
227 | + |
|
228 | + |
|
229 | + /** |
|
230 | + * venue_description |
|
231 | + * |
|
232 | + * @access public |
|
233 | + * @param int $VNU_ID |
|
234 | + * @return string |
|
235 | + * @throws EE_Error |
|
236 | + * @throws ReflectionException |
|
237 | + */ |
|
238 | + public static function venue_description($VNU_ID = 0) |
|
239 | + { |
|
240 | + $venue = EEH_Venue_View::get_venue($VNU_ID); |
|
241 | + if ($venue instanceof EE_Venue) { |
|
242 | + return $venue->get_pretty('VNU_desc'); |
|
243 | + } |
|
244 | + return ''; |
|
245 | + } |
|
246 | + |
|
247 | + |
|
248 | + /** |
|
249 | + * venue_excerpt |
|
250 | + * |
|
251 | + * @access public |
|
252 | + * @param int $VNU_ID |
|
253 | + * @return string |
|
254 | + * @throws EE_Error |
|
255 | + * @throws ReflectionException |
|
256 | + */ |
|
257 | + public static function venue_excerpt($VNU_ID = 0) |
|
258 | + { |
|
259 | + $venue = EEH_Venue_View::get_venue($VNU_ID); |
|
260 | + if ($venue instanceof EE_Venue) { |
|
261 | + $excerpt = $venue->excerpt() != null && $venue->excerpt() ? $venue->excerpt() : $venue->description(); |
|
262 | + $venue_link = ' ' . EEH_Venue_View::venue_details_link( |
|
263 | + $venue->ID(), |
|
264 | + esc_html__('more', 'event_espresso') . '…' |
|
265 | + ); |
|
266 | + return ! empty($excerpt) ? wp_trim_words($excerpt, 25, '') . $venue_link : ''; |
|
267 | + } |
|
268 | + return ''; |
|
269 | + } |
|
270 | + |
|
271 | + |
|
272 | + /** |
|
273 | + * venue_categories |
|
274 | + * |
|
275 | + * @access public |
|
276 | + * @param int $VNU_ID |
|
277 | + * @param bool $hide_uncategorized |
|
278 | + * @return string |
|
279 | + * @throws EE_Error |
|
280 | + * @throws ReflectionException |
|
281 | + */ |
|
282 | + public static function venue_categories($VNU_ID = 0, $hide_uncategorized = true) |
|
283 | + { |
|
284 | + $category_links = []; |
|
285 | + $venue = EEH_Venue_View::get_venue($VNU_ID); |
|
286 | + if ($venue instanceof EE_Venue) { |
|
287 | + // get category terms |
|
288 | + if ($venue_categories = get_the_terms($venue->ID(), 'espresso_venue_categories')) { |
|
289 | + // loop thru terms and create links |
|
290 | + foreach ($venue_categories as $term) { |
|
291 | + $url = get_term_link($term, 'espresso_venue_categories'); |
|
292 | + if ( |
|
293 | + ! is_wp_error($url) |
|
294 | + && (($hide_uncategorized |
|
295 | + && strtolower($term->name) != esc_html__( |
|
296 | + 'uncategorized', |
|
297 | + 'event_espresso' |
|
298 | + )) |
|
299 | + || ! $hide_uncategorized) |
|
300 | + ) { |
|
301 | + $category_links[] = '<a href="' . esc_url($url) . '" rel="tag">' . $term->name . '</a> '; |
|
302 | + } |
|
303 | + } |
|
304 | + } |
|
305 | + } |
|
306 | + return implode(', ', $category_links); |
|
307 | + } |
|
308 | + |
|
309 | + |
|
310 | + /** |
|
311 | + * venue_address |
|
312 | + * |
|
313 | + * @access public |
|
314 | + * @param string $type |
|
315 | + * @param int $VNU_ID |
|
316 | + * @param bool $use_schema |
|
317 | + * @param bool $add_wrapper |
|
318 | + * @return string |
|
319 | + * @throws EE_Error |
|
320 | + * @throws ReflectionException |
|
321 | + */ |
|
322 | + public static function venue_address($type = 'multiline', $VNU_ID = 0, $use_schema = true, $add_wrapper = true) |
|
323 | + { |
|
324 | + $venue = EEH_Venue_View::get_venue($VNU_ID); |
|
325 | + if ($venue instanceof EE_Venue) { |
|
326 | + return EEH_Address::format($venue, $type, $use_schema, $add_wrapper); |
|
327 | + } |
|
328 | + return ''; |
|
329 | + } |
|
330 | + |
|
331 | + |
|
332 | + /** |
|
333 | + * venue_has_address |
|
334 | + * |
|
335 | + * @access public |
|
336 | + * @param int $VNU_ID |
|
337 | + * @return bool|string |
|
338 | + * @throws EE_Error |
|
339 | + * @throws ReflectionException |
|
340 | + */ |
|
341 | + public static function venue_has_address($VNU_ID = 0) |
|
342 | + { |
|
343 | + $venue = EEH_Venue_View::get_venue($VNU_ID); |
|
344 | + if ($venue instanceof EE_Venue) { |
|
345 | + return EEH_Address::format($venue, 'inline', false, false); |
|
346 | + } |
|
347 | + return false; |
|
348 | + } |
|
349 | + |
|
350 | + |
|
351 | + /** |
|
352 | + * venue_name |
|
353 | + * |
|
354 | + * @access public |
|
355 | + * @param string $link_to - options( details, website, none ) whether to turn Venue name into a clickable link to |
|
356 | + * the Venue's details page or website |
|
357 | + * @param int $VNU_ID |
|
358 | + * @return string |
|
359 | + * @throws EE_Error |
|
360 | + * @throws ReflectionException |
|
361 | + */ |
|
362 | + public static function venue_name($link_to = 'details', $VNU_ID = 0) |
|
363 | + { |
|
364 | + $venue = EEH_Venue_View::get_venue($VNU_ID); |
|
365 | + if ($venue instanceof EE_Venue) { |
|
366 | + $venue_name = apply_filters( |
|
367 | + 'FHEE__EEH_Venue__venue_name__append_private_venue_name', |
|
368 | + EEH_Venue_View::is_venue_private() |
|
369 | + ? EEH_Venue_View::$_venue->name() . " " . esc_html__('(Private)', 'event_espresso') |
|
370 | + : EEH_Venue_View::$_venue->name(), |
|
371 | + EEH_Venue_View::$_venue |
|
372 | + ); |
|
373 | + $venue_name = EEH_Schema::name($venue_name); |
|
374 | + |
|
375 | + // if venue is trashed then ignore the "link to" setting because the venue is trashed. |
|
376 | + if ($venue->get('status') == 'trash') { |
|
377 | + $link_to = ''; |
|
378 | + } |
|
379 | + switch ($link_to) { |
|
380 | + case 'details': |
|
381 | + return EEH_Venue_View::venue_details_link($venue->ID(), $venue_name); |
|
382 | + |
|
383 | + case 'website': |
|
384 | + return EEH_Venue_View::venue_website_link($venue->ID(), $venue_name); |
|
385 | + |
|
386 | + default: |
|
387 | + return $venue_name; |
|
388 | + } |
|
389 | + } |
|
390 | + return ''; |
|
391 | + } |
|
392 | + |
|
393 | + |
|
394 | + /** |
|
395 | + * venue_details_link |
|
396 | + * |
|
397 | + * @access public |
|
398 | + * @param int $VNU_ID |
|
399 | + * @param string $text |
|
400 | + * @return string |
|
401 | + * @throws EE_Error |
|
402 | + * @throws ReflectionException |
|
403 | + */ |
|
404 | + public static function venue_details_link($VNU_ID = 0, $text = '') |
|
405 | + { |
|
406 | + $venue = EEH_Venue_View::get_venue($VNU_ID); |
|
407 | + if ($venue instanceof EE_Venue) { |
|
408 | + return EEH_Schema::url(get_permalink($venue->ID()), $text); |
|
409 | + } |
|
410 | + return ''; |
|
411 | + } |
|
412 | + |
|
413 | + |
|
414 | + /** |
|
415 | + * venue_website_link |
|
416 | + * |
|
417 | + * @access public |
|
418 | + * @param int $VNU_ID |
|
419 | + * @param string $text |
|
420 | + * @return string |
|
421 | + * @throws EE_Error |
|
422 | + * @throws ReflectionException |
|
423 | + */ |
|
424 | + public static function venue_website_link($VNU_ID = 0, $text = '') |
|
425 | + { |
|
426 | + $venue = EEH_Venue_View::get_venue($VNU_ID); |
|
427 | + if ($venue instanceof EE_Venue) { |
|
428 | + $url = $venue->venue_url(); |
|
429 | + $text = ! empty($text) ? $text : $url; |
|
430 | + return ! empty($url) ? EEH_Schema::url($url, $text, ['target' => '_blank']) : ''; |
|
431 | + } |
|
432 | + return ''; |
|
433 | + } |
|
434 | + |
|
435 | + |
|
436 | + /** |
|
437 | + * venue_phone |
|
438 | + * |
|
439 | + * @access public |
|
440 | + * @param int $VNU_ID |
|
441 | + * @return string |
|
442 | + * @throws EE_Error |
|
443 | + * @throws ReflectionException |
|
444 | + */ |
|
445 | + public static function venue_phone($VNU_ID = 0) |
|
446 | + { |
|
447 | + $venue = EEH_Venue_View::get_venue($VNU_ID); |
|
448 | + if ($venue instanceof EE_Venue) { |
|
449 | + return EEH_Schema::telephone($venue->phone()); |
|
450 | + } |
|
451 | + return ''; |
|
452 | + } |
|
453 | + |
|
454 | + |
|
455 | + /** |
|
456 | + * venue_gmap |
|
457 | + * |
|
458 | + * @access public |
|
459 | + * @param int $VNU_ID |
|
460 | + * @param bool|string $map_ID a unique identifier for this map |
|
461 | + * @param array $gmap map options |
|
462 | + * @return string |
|
463 | + * @throws EE_Error |
|
464 | + * @throws ReflectionException |
|
465 | + */ |
|
466 | + public static function venue_gmap($VNU_ID = 0, $map_ID = false, $gmap = []) |
|
467 | + { |
|
468 | + |
|
469 | + $venue = EEH_Venue_View::get_venue($VNU_ID); |
|
470 | + if ($venue instanceof EE_Venue) { |
|
471 | + // check for global espresso_events post and use it's ID if no map_ID is set |
|
472 | + global $post; |
|
473 | + $map_ID = empty($map_ID) && $post->post_type == 'espresso_events' ? $post->ID : $map_ID; |
|
474 | + // grab map settings |
|
475 | + $map_cfg = EE_Registry::instance()->CFG->map_settings; |
|
476 | + // are maps enabled ? |
|
477 | + if ($map_cfg->use_google_maps && $venue->enable_for_gmap()) { |
|
478 | + $details_page = is_single(); |
|
479 | + $options = []; |
|
480 | + |
|
481 | + $options['map_ID'] = $map_ID && $map_ID != $venue->ID() |
|
482 | + ? $map_ID . '-' . $venue->ID() |
|
483 | + : $venue->ID(); |
|
484 | + |
|
485 | + $options['location'] = EEH_Address::format($venue, 'inline', false, false); |
|
486 | + |
|
487 | + $options['ee_map_width'] = $details_page |
|
488 | + ? $map_cfg->event_details_map_width |
|
489 | + : $map_cfg->event_list_map_width; |
|
490 | + |
|
491 | + $options['ee_map_width'] = isset($gmap['ee_map_width']) && ! empty($gmap['ee_map_width']) |
|
492 | + ? $gmap['ee_map_width'] |
|
493 | + : $options['ee_map_width']; |
|
494 | + |
|
495 | + $options['ee_map_height'] = $details_page |
|
496 | + ? $map_cfg->event_details_map_height |
|
497 | + : $map_cfg->event_list_map_height; |
|
498 | + |
|
499 | + $options['ee_map_height'] = isset($gmap['ee_map_height']) && ! empty($gmap['ee_map_height']) |
|
500 | + ? $gmap['ee_map_height'] |
|
501 | + : $options['ee_map_height']; |
|
502 | + |
|
503 | + $options['ee_map_zoom'] = $details_page |
|
504 | + ? $map_cfg->event_details_map_zoom |
|
505 | + : $map_cfg->event_list_map_zoom; |
|
506 | + |
|
507 | + $options['ee_map_zoom'] = isset($gmap['ee_map_zoom']) && ! empty($gmap['ee_map_zoom']) |
|
508 | + ? $gmap['ee_map_zoom'] |
|
509 | + : $options['ee_map_zoom']; |
|
510 | + |
|
511 | + $options['ee_map_nav_display'] = $details_page |
|
512 | + ? $map_cfg->event_details_display_nav |
|
513 | + : $map_cfg->event_list_display_nav; |
|
514 | + |
|
515 | + $options['ee_map_nav_display'] = |
|
516 | + isset($gmap['ee_map_nav_display']) && ! empty($gmap['ee_map_nav_display']) |
|
517 | + ? 'true' |
|
518 | + : $options['ee_map_nav_display']; |
|
519 | + |
|
520 | + $options['ee_map_nav_size'] = $details_page |
|
521 | + ? $map_cfg->event_details_nav_size |
|
522 | + : $map_cfg->event_list_nav_size; |
|
523 | + |
|
524 | + $options['ee_map_nav_size'] = isset($gmap['ee_map_nav_size']) && ! empty($gmap['ee_map_nav_size']) |
|
525 | + ? $gmap['ee_map_nav_size'] |
|
526 | + : $options['ee_map_nav_size']; |
|
527 | + |
|
528 | + $options['ee_map_type_control'] = $details_page |
|
529 | + ? $map_cfg->event_details_control_type |
|
530 | + : $map_cfg->event_list_control_type; |
|
531 | + |
|
532 | + $options['ee_map_type_control'] = |
|
533 | + isset($gmap['ee_map_type_control']) && ! empty($gmap['ee_map_type_control']) |
|
534 | + ? $gmap['ee_map_type_control'] |
|
535 | + : $options['ee_map_type_control']; |
|
536 | + |
|
537 | + $options['ee_map_align'] = $details_page |
|
538 | + ? $map_cfg->event_details_map_align |
|
539 | + : $map_cfg->event_list_map_align; |
|
540 | + |
|
541 | + $options['ee_map_align'] = isset($gmap['ee_map_align']) && ! empty($gmap['ee_map_align']) |
|
542 | + ? $gmap['ee_map_align'] |
|
543 | + : $options['ee_map_align']; |
|
544 | + |
|
545 | + $options['ee_static_url'] = isset($gmap['ee_static_url']) && ! empty($gmap['ee_static_url']) |
|
546 | + ? (bool) absint($gmap['ee_static_url']) |
|
547 | + : $venue->google_map_link(); |
|
548 | + |
|
549 | + return EEH_Maps::google_map($options); |
|
550 | + } |
|
551 | + } |
|
552 | + |
|
553 | + return ''; |
|
554 | + } |
|
555 | + |
|
556 | + |
|
557 | + /** |
|
558 | + * Gets the HTML to display a static map of the venue |
|
559 | + * |
|
560 | + * @param EE_Venue $venue |
|
561 | + * @param array $attributes like EEH_Maps::google_map_link |
|
562 | + * @return string |
|
563 | + * @throws EE_Error |
|
564 | + * @throws ReflectionException |
|
565 | + */ |
|
566 | + public static function espresso_google_static_map(EE_Venue $venue, $attributes = []) |
|
567 | + { |
|
568 | + $state = $venue->state_obj(); |
|
569 | + $country = $venue->country_obj(); |
|
570 | + $attributes = shortcode_atts( |
|
571 | + [ |
|
572 | + 'id' => $venue->ID(), |
|
573 | + 'address' => $venue->get('VNU_address'), |
|
574 | + 'city' => $venue->get('VNU_city'), |
|
575 | + 'state' => $state instanceof EE_State ? $state->name() : '', |
|
576 | + 'zip' => $venue->get('VNU_zip'), |
|
577 | + 'country' => $country instanceof EE_Country ? $country->name() : '', |
|
578 | + 'type' => 'map', |
|
579 | + 'map_w' => 200, |
|
580 | + 'map_h' => 200, |
|
581 | + ], |
|
582 | + $attributes |
|
583 | + ); |
|
584 | + return EEH_Maps::google_map_link($attributes); |
|
585 | + } |
|
586 | + |
|
587 | + |
|
588 | + /** |
|
589 | + * edit_venue_link |
|
590 | + * |
|
591 | + * @access public |
|
592 | + * @param int $VNU_ID |
|
593 | + * @param string $link |
|
594 | + * @param string $before |
|
595 | + * @param string $after |
|
596 | + * @return string |
|
597 | + * @throws EE_Error |
|
598 | + * @throws ReflectionException |
|
599 | + */ |
|
600 | + public static function edit_venue_link( |
|
601 | + $VNU_ID = 0, |
|
602 | + $link = '', |
|
603 | + $before = '<p class="edit-venue-lnk small-txt">', |
|
604 | + $after = '</p>' |
|
605 | + ) { |
|
606 | + $venue = EEH_Venue_View::get_venue($VNU_ID); |
|
607 | + if ($venue instanceof EE_Venue) { |
|
608 | + // can the user edit this post ? |
|
609 | + if (current_user_can('edit_post', $venue->ID())) { |
|
610 | + // set link text |
|
611 | + $link = ! empty($link) ? $link : esc_html__('edit this venue', 'event_espresso'); |
|
612 | + // generate nonce |
|
613 | + $nonce = wp_create_nonce('edit_nonce'); |
|
614 | + // generate url to venue editor for this venue |
|
615 | + $url = |
|
616 | + add_query_arg( |
|
617 | + [ |
|
618 | + 'page' => 'espresso_venues', |
|
619 | + 'action' => 'edit', |
|
620 | + 'post' => $venue->ID(), |
|
621 | + 'edit_nonce' => $nonce, |
|
622 | + ], |
|
623 | + admin_url('admin.php') |
|
624 | + ); |
|
625 | + // get edit CPT text |
|
626 | + $post_type_obj = get_post_type_object('espresso_venues'); |
|
627 | + // build final link html |
|
628 | + $link = |
|
629 | + '<a class="post-edit-link" href="' . $url . '" title="' . esc_attr( |
|
630 | + $post_type_obj->labels->edit_item |
|
631 | + ) . '">' . $link . '</a>'; |
|
632 | + // put it all together |
|
633 | + return $before . apply_filters('edit_post_link', $link, $venue->ID()) . $after; |
|
634 | + } |
|
635 | + } |
|
636 | + return ''; |
|
637 | + } |
|
638 | 638 | } |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | } |
39 | 39 | // reset property so that the new event is cached. |
40 | 40 | EEH_Event_View::$_event = null; |
41 | - if (! $EVT_ID && $post instanceof EE_Event) { |
|
41 | + if ( ! $EVT_ID && $post instanceof EE_Event) { |
|
42 | 42 | EEH_Event_View::$_event = $post; |
43 | 43 | return EEH_Event_View::$_event; |
44 | 44 | } |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | return EEH_Event_View::$_event; |
58 | 58 | } |
59 | 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) { |
|
60 | + if ( ! EEH_Event_View::$_event instanceof EE_Event && $EVT_ID) { |
|
61 | 61 | EEH_Event_View::$_event = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
62 | 62 | } |
63 | 63 | return EEH_Event_View::$_event; |
@@ -164,18 +164,18 @@ discard block |
||
164 | 164 | // admin has chosen "excerpt (short desc)" |
165 | 165 | // for the "Event Espresso - Events > Templates > Display Description" option |
166 | 166 | // but NO excerpt actually exists, so we need to create one |
167 | - if (! empty($num_words)) { |
|
167 | + if ( ! empty($num_words)) { |
|
168 | 168 | if (empty($more)) { |
169 | 169 | $more_link_text = esc_html__('(more…)', 'event_espresso'); |
170 | - $more = ' <a href="' . get_permalink() . '"'; |
|
170 | + $more = ' <a href="'.get_permalink().'"'; |
|
171 | 171 | $more .= ' class="more-link"'; |
172 | 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); |
|
173 | + $more .= '>'.$more_link_text.'</a>'; |
|
174 | + $more = apply_filters('the_content_more_link', $more, $more_link_text); |
|
175 | 175 | } |
176 | 176 | $content = str_replace('NOMORELINK', '', get_the_content('NOMORELINK')); |
177 | 177 | |
178 | - $content = wp_trim_words($content, $num_words, ' ') . $more; |
|
178 | + $content = wp_trim_words($content, $num_words, ' ').$more; |
|
179 | 179 | } else { |
180 | 180 | $content = get_the_content(); |
181 | 181 | } |
@@ -257,8 +257,8 @@ discard block |
||
257 | 257 | || ! $hide_uncategorized |
258 | 258 | ) |
259 | 259 | ) { |
260 | - $category_links[] = '<a href="' . esc_url_raw($url) . '" ' |
|
261 | - . 'rel="tag" ' . EED_Events_Archive::link_target() . '>' |
|
260 | + $category_links[] = '<a href="'.esc_url_raw($url).'" ' |
|
261 | + . 'rel="tag" '.EED_Events_Archive::link_target().'>' |
|
262 | 262 | . esc_html($term->name) |
263 | 263 | . '</a>'; |
264 | 264 | } |
@@ -283,8 +283,8 @@ discard block |
||
283 | 283 | { |
284 | 284 | $datetime = EEH_Event_View::get_primary_date_obj($EVT_ID); |
285 | 285 | $format = ! empty($date_format) && ! empty($time_format) |
286 | - ? $date_format . ' ' . $time_format |
|
287 | - : $date_format . $time_format; |
|
286 | + ? $date_format.' '.$time_format |
|
287 | + : $date_format.$time_format; |
|
288 | 288 | return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime('DTT_EVT_start', $format) : ''; |
289 | 289 | } |
290 | 290 | |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | $datetime = EEH_Event_View::get_last_date_obj($EVT_ID); |
305 | 305 | $format = |
306 | 306 | ! empty($date_format) && ! empty($time_format) |
307 | - ? $date_format . ' ' . $time_format |
|
307 | + ? $date_format.' '.$time_format |
|
308 | 308 | : $date_format |
309 | 309 | . $time_format; |
310 | 310 | return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime('DTT_EVT_end', $format) : ''; |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | $datetime = EEH_Event_View::get_earliest_date_obj($EVT_ID); |
327 | 327 | $format = |
328 | 328 | ! empty($date_format) && ! empty($time_format) |
329 | - ? $date_format . ' ' . $time_format |
|
329 | + ? $date_format.' '.$time_format |
|
330 | 330 | : $date_format |
331 | 331 | . $time_format; |
332 | 332 | return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime('DTT_EVT_start', $format) : ''; |
@@ -348,7 +348,7 @@ discard block |
||
348 | 348 | $datetime = EEH_Event_View::get_latest_date_obj($EVT_ID); |
349 | 349 | $format = |
350 | 350 | ! empty($date_format) && ! empty($time_format) |
351 | - ? $date_format . ' ' . $time_format |
|
351 | + ? $date_format.' '.$time_format |
|
352 | 352 | : $date_format |
353 | 353 | . $time_format; |
354 | 354 | return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime('DTT_EVT_end', $format) : ''; |
@@ -553,7 +553,7 @@ discard block |
||
553 | 553 | $url = $event->external_url() !== null && $event->external_url() !== '' |
554 | 554 | ? $event->external_url() |
555 | 555 | : get_permalink($event->ID()); |
556 | - $url = preg_match("~^(?:f|ht)tps?://~i", $url) ? $url : 'https://' . $url; |
|
556 | + $url = preg_match("~^(?:f|ht)tps?://~i", $url) ? $url : 'https://'.$url; |
|
557 | 557 | return esc_url_raw($url); |
558 | 558 | } |
559 | 559 | return ''; |
@@ -614,12 +614,12 @@ discard block |
||
614 | 614 | // get edit CPT text |
615 | 615 | $post_type_obj = get_post_type_object('espresso_events'); |
616 | 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) . '"'; |
|
617 | + $link = '<a class="post-edit-link" href="'.$url.'" '; |
|
618 | + $link .= ' title="'.esc_attr($post_type_obj->labels->edit_item).'"'; |
|
619 | 619 | $link .= EED_Events_Archive::link_target(); |
620 | - $link .= '>' . $link_text . '</a>'; |
|
620 | + $link .= '>'.$link_text.'</a>'; |
|
621 | 621 | // put it all together |
622 | - return $before . apply_filters('edit_post_link', $link, $event->ID()) . $after; |
|
622 | + return $before.apply_filters('edit_post_link', $link, $event->ID()).$after; |
|
623 | 623 | } |
624 | 624 | } |
625 | 625 | return ''; |
@@ -9,364 +9,364 @@ discard block |
||
9 | 9 | */ |
10 | 10 | class EEH_Event_View extends EEH_Base |
11 | 11 | { |
12 | - /** |
|
13 | - * @var EE_Event $_event |
|
14 | - */ |
|
15 | - private static $_event = null; |
|
16 | - |
|
17 | - |
|
18 | - /** |
|
19 | - * get_event |
|
20 | - * attempts to retrieve an EE_Event object any way it can |
|
21 | - * |
|
22 | - * @param int|WP_Post $EVT_ID |
|
23 | - * @return EE_Event|null |
|
24 | - * @throws EE_Error |
|
25 | - * @throws ReflectionException |
|
26 | - */ |
|
27 | - public static function get_event($EVT_ID = 0) |
|
28 | - { |
|
29 | - // international newspaper? |
|
30 | - global $post; |
|
31 | - $EVT_ID = $EVT_ID instanceof WP_Post && $EVT_ID->post_type === 'espresso_events' |
|
32 | - ? $EVT_ID->ID |
|
33 | - : absint($EVT_ID); |
|
34 | - // do we already have the Event you are looking for? |
|
35 | - if (EEH_Event_View::$_event instanceof EE_Event && $EVT_ID && EEH_Event_View::$_event->ID() === $EVT_ID) { |
|
36 | - return EEH_Event_View::$_event; |
|
37 | - } |
|
38 | - // reset property so that the new event is cached. |
|
39 | - EEH_Event_View::$_event = null; |
|
40 | - if (! $EVT_ID && $post instanceof EE_Event) { |
|
41 | - EEH_Event_View::$_event = $post; |
|
42 | - return EEH_Event_View::$_event; |
|
43 | - } |
|
44 | - // if the post type is for an event and it has a cached event and we don't have a different incoming $EVT_ID |
|
45 | - // then let's just use that cached event on the $post object. |
|
46 | - if ( |
|
47 | - $post instanceof WP_Post |
|
48 | - && $post->post_type === 'espresso_events' |
|
49 | - && isset($post->EE_Event) |
|
50 | - && ( |
|
51 | - $EVT_ID === 0 |
|
52 | - || $EVT_ID === $post->ID |
|
53 | - ) |
|
54 | - ) { |
|
55 | - EEH_Event_View::$_event = $post->EE_Event; |
|
56 | - return EEH_Event_View::$_event; |
|
57 | - } |
|
58 | - // 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. |
|
59 | - if (! EEH_Event_View::$_event instanceof EE_Event && $EVT_ID) { |
|
60 | - EEH_Event_View::$_event = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
61 | - } |
|
62 | - return EEH_Event_View::$_event; |
|
63 | - } |
|
64 | - |
|
65 | - |
|
66 | - /** |
|
67 | - * display_ticket_selector |
|
68 | - * |
|
69 | - * @param int $EVT_ID |
|
70 | - * @return boolean |
|
71 | - * @throws EE_Error |
|
72 | - * @throws EE_Error |
|
73 | - * @throws ReflectionException |
|
74 | - */ |
|
75 | - public static function display_ticket_selector($EVT_ID = 0) |
|
76 | - { |
|
77 | - $event = EEH_Event_View::get_event($EVT_ID); |
|
78 | - return $event instanceof EE_Event && $event->display_ticket_selector(); |
|
79 | - } |
|
80 | - |
|
81 | - |
|
82 | - /** |
|
83 | - * event_status |
|
84 | - * |
|
85 | - * @param int $EVT_ID |
|
86 | - * @return string |
|
87 | - * @throws EE_Error |
|
88 | - * @throws EE_Error |
|
89 | - * @throws ReflectionException |
|
90 | - */ |
|
91 | - public static function event_status($EVT_ID = 0) |
|
92 | - { |
|
93 | - $event = EEH_Event_View::get_event($EVT_ID); |
|
94 | - return $event instanceof EE_Event ? $event->pretty_active_status(false) : ''; |
|
95 | - } |
|
96 | - |
|
97 | - |
|
98 | - /** |
|
99 | - * event_active_status |
|
100 | - * |
|
101 | - * @param int $EVT_ID |
|
102 | - * @return string |
|
103 | - * @throws EE_Error |
|
104 | - * @throws EE_Error |
|
105 | - * @throws ReflectionException |
|
106 | - */ |
|
107 | - public static function event_active_status($EVT_ID = 0, $echo = true) |
|
108 | - { |
|
109 | - $event = EEH_Event_View::get_event($EVT_ID); |
|
110 | - return $event instanceof EE_Event ? $event->pretty_active_status($echo) : 'inactive'; |
|
111 | - } |
|
112 | - |
|
113 | - |
|
114 | - /** |
|
115 | - * event_has_content_or_excerpt |
|
116 | - * |
|
117 | - * @param int $EVT_ID |
|
118 | - * @return bool |
|
119 | - * @throws EE_Error |
|
120 | - * @throws EE_Error |
|
121 | - * @throws ReflectionException |
|
122 | - */ |
|
123 | - public static function event_has_content_or_excerpt($EVT_ID = 0) |
|
124 | - { |
|
125 | - $event = EEH_Event_View::get_event($EVT_ID); |
|
126 | - $has_content_or_excerpt = false; |
|
127 | - if ($event instanceof EE_Event) { |
|
128 | - $has_content_or_excerpt = $event->description() != '' || $event->short_description(null, null, true) != ''; |
|
129 | - } |
|
130 | - if ( |
|
131 | - is_archive() |
|
132 | - && ! (espresso_display_full_description_in_event_list() |
|
133 | - || espresso_display_excerpt_in_event_list()) |
|
134 | - ) { |
|
135 | - $has_content_or_excerpt = false; |
|
136 | - } |
|
137 | - return $has_content_or_excerpt; |
|
138 | - } |
|
139 | - |
|
140 | - |
|
141 | - /** |
|
142 | - * event_active_status |
|
143 | - * |
|
144 | - * @param null $num_words |
|
145 | - * @param null $more |
|
146 | - * @return string |
|
147 | - */ |
|
148 | - public static function event_content_or_excerpt($num_words = null, $more = null) |
|
149 | - { |
|
150 | - global $post; |
|
151 | - ob_start(); |
|
152 | - if ((is_single()) || (is_archive() && espresso_display_full_description_in_event_list())) { |
|
153 | - // admin has chosen "full description" |
|
154 | - // for the "Event Espresso - Events > Templates > Display Description" option |
|
155 | - the_content(); |
|
156 | - } elseif ((is_archive() && espresso_display_excerpt_in_event_list())) { |
|
157 | - if (has_excerpt($post->ID)) { |
|
158 | - // admin has chosen "excerpt (short desc)" |
|
159 | - // for the "Event Espresso - Events > Templates > Display Description" option |
|
160 | - // AND an excerpt actually exists |
|
161 | - the_excerpt(); |
|
162 | - } else { |
|
163 | - // admin has chosen "excerpt (short desc)" |
|
164 | - // for the "Event Espresso - Events > Templates > Display Description" option |
|
165 | - // but NO excerpt actually exists, so we need to create one |
|
166 | - if (! empty($num_words)) { |
|
167 | - if (empty($more)) { |
|
168 | - $more_link_text = esc_html__('(more…)', 'event_espresso'); |
|
169 | - $more = ' <a href="' . get_permalink() . '"'; |
|
170 | - $more .= ' class="more-link"'; |
|
171 | - $more .= EED_Events_Archive::link_target(); |
|
172 | - $more .= '>' . $more_link_text . '</a>'; |
|
173 | - $more = apply_filters('the_content_more_link', $more, $more_link_text); |
|
174 | - } |
|
175 | - $content = str_replace('NOMORELINK', '', get_the_content('NOMORELINK')); |
|
176 | - |
|
177 | - $content = wp_trim_words($content, $num_words, ' ') . $more; |
|
178 | - } else { |
|
179 | - $content = get_the_content(); |
|
180 | - } |
|
181 | - global $allowedtags; |
|
182 | - // make sure links are allowed |
|
183 | - $allowedtags['a'] = isset($allowedtags['a']) |
|
184 | - ? $allowedtags['a'] |
|
185 | - : []; |
|
186 | - // as well as target attribute |
|
187 | - $allowedtags['a']['target'] = isset($allowedtags['a']['target']) |
|
188 | - ? $allowedtags['a']['target'] |
|
189 | - : false; |
|
190 | - // but get previous value so we can reset it |
|
191 | - $prev_value = $allowedtags['a']['target']; |
|
192 | - $allowedtags['a']['target'] = true; |
|
193 | - $content = wp_kses($content, $allowedtags); |
|
194 | - $content = strip_shortcodes($content); |
|
195 | - echo apply_filters('the_content', $content); |
|
196 | - $allowedtags['a']['target'] = $prev_value; |
|
197 | - } |
|
198 | - } else { |
|
199 | - // admin has chosen "none" |
|
200 | - // for the "Event Espresso - Events > Templates > Display Description" option |
|
201 | - echo apply_filters('the_content', ''); |
|
202 | - } |
|
203 | - return ob_get_clean(); |
|
204 | - } |
|
205 | - |
|
206 | - |
|
207 | - /** |
|
208 | - * event_tickets_available |
|
209 | - * |
|
210 | - * @param int $EVT_ID |
|
211 | - * @return EE_Ticket[] |
|
212 | - * @throws EE_Error |
|
213 | - * @throws ReflectionException |
|
214 | - */ |
|
215 | - public static function event_tickets_available($EVT_ID = 0) |
|
216 | - { |
|
217 | - $event = EEH_Event_View::get_event($EVT_ID); |
|
218 | - $tickets_available_for_purchase = []; |
|
219 | - if ($event instanceof EE_Event) { |
|
220 | - $datetimes = EEH_Event_View::get_all_date_obj($EVT_ID, false); |
|
221 | - foreach ($datetimes as $datetime) { |
|
222 | - $tickets_available_for_purchase = |
|
223 | - array_merge($tickets_available_for_purchase, $datetime->ticket_types_available_for_purchase()); |
|
224 | - } |
|
225 | - } |
|
226 | - return $tickets_available_for_purchase; |
|
227 | - } |
|
228 | - |
|
229 | - |
|
230 | - /** |
|
231 | - * the_event_date |
|
232 | - * |
|
233 | - * @param int $EVT_ID |
|
234 | - * @param bool $hide_uncategorized |
|
235 | - * @return string |
|
236 | - * @throws EE_Error |
|
237 | - * @throws ReflectionException |
|
238 | - */ |
|
239 | - public static function event_categories($EVT_ID = 0, $hide_uncategorized = true) |
|
240 | - { |
|
241 | - $category_links = []; |
|
242 | - $event = EEH_Event_View::get_event($EVT_ID); |
|
243 | - if ($event instanceof EE_Event) { |
|
244 | - $event_categories = get_the_terms($event->ID(), 'espresso_event_categories'); |
|
245 | - if ($event_categories) { |
|
246 | - // loop thru terms and create links |
|
247 | - foreach ($event_categories as $term) { |
|
248 | - $url = get_term_link($term, 'espresso_venue_categories'); |
|
249 | - if ( |
|
250 | - ! is_wp_error($url) |
|
251 | - && ( |
|
252 | - ( |
|
253 | - $hide_uncategorized |
|
254 | - && strtolower($term->name) != esc_html__('uncategorized', 'event_espresso') |
|
255 | - ) |
|
256 | - || ! $hide_uncategorized |
|
257 | - ) |
|
258 | - ) { |
|
259 | - $category_links[] = '<a href="' . esc_url_raw($url) . '" ' |
|
260 | - . 'rel="tag" ' . EED_Events_Archive::link_target() . '>' |
|
261 | - . esc_html($term->name) |
|
262 | - . '</a>'; |
|
263 | - } |
|
264 | - } |
|
265 | - } |
|
266 | - } |
|
267 | - return implode(', ', $category_links); |
|
268 | - } |
|
269 | - |
|
270 | - |
|
271 | - /** |
|
272 | - * the_event_date - first date by date order |
|
273 | - * |
|
274 | - * @param string $date_format |
|
275 | - * @param string $time_format |
|
276 | - * @param int $EVT_ID |
|
277 | - * @return string |
|
278 | - * @throws EE_Error |
|
279 | - * @throws ReflectionException |
|
280 | - */ |
|
281 | - public static function the_event_date($date_format = 'D M jS', $time_format = 'g:i a', $EVT_ID = 0) |
|
282 | - { |
|
283 | - $datetime = EEH_Event_View::get_primary_date_obj($EVT_ID); |
|
284 | - $format = ! empty($date_format) && ! empty($time_format) |
|
285 | - ? $date_format . ' ' . $time_format |
|
286 | - : $date_format . $time_format; |
|
287 | - return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime('DTT_EVT_start', $format) : ''; |
|
288 | - } |
|
289 | - |
|
290 | - |
|
291 | - /** |
|
292 | - * the_event_end_date - last date by date order |
|
293 | - * |
|
294 | - * @param string $date_format |
|
295 | - * @param string $time_format |
|
296 | - * @param int $EVT_ID |
|
297 | - * @return string |
|
298 | - * @throws EE_Error |
|
299 | - * @throws ReflectionException |
|
300 | - */ |
|
301 | - public static function the_event_end_date($date_format = 'D M jS', $time_format = 'g:i a', $EVT_ID = 0) |
|
302 | - { |
|
303 | - $datetime = EEH_Event_View::get_last_date_obj($EVT_ID); |
|
304 | - $format = |
|
305 | - ! empty($date_format) && ! empty($time_format) |
|
306 | - ? $date_format . ' ' . $time_format |
|
307 | - : $date_format |
|
308 | - . $time_format; |
|
309 | - return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime('DTT_EVT_end', $format) : ''; |
|
310 | - } |
|
311 | - |
|
312 | - |
|
313 | - /** |
|
314 | - * the_earliest_event_date - first date chronologically |
|
315 | - * |
|
316 | - * @param string $date_format |
|
317 | - * @param string $time_format |
|
318 | - * @param int $EVT_ID |
|
319 | - * @return string |
|
320 | - * @throws EE_Error |
|
321 | - * @throws ReflectionException |
|
322 | - */ |
|
323 | - public static function the_earliest_event_date($date_format = 'D M jS', $time_format = 'g:i a', $EVT_ID = 0) |
|
324 | - { |
|
325 | - $datetime = EEH_Event_View::get_earliest_date_obj($EVT_ID); |
|
326 | - $format = |
|
327 | - ! empty($date_format) && ! empty($time_format) |
|
328 | - ? $date_format . ' ' . $time_format |
|
329 | - : $date_format |
|
330 | - . $time_format; |
|
331 | - return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime('DTT_EVT_start', $format) : ''; |
|
332 | - } |
|
333 | - |
|
334 | - |
|
335 | - /** |
|
336 | - * the_latest_event_date - latest date chronologically |
|
337 | - * |
|
338 | - * @param string $date_format |
|
339 | - * @param string $time_format |
|
340 | - * @param int $EVT_ID |
|
341 | - * @return string |
|
342 | - * @throws EE_Error |
|
343 | - * @throws ReflectionException |
|
344 | - */ |
|
345 | - public static function the_latest_event_date($date_format = 'D M jS', $time_format = 'g:i a', $EVT_ID = 0) |
|
346 | - { |
|
347 | - $datetime = EEH_Event_View::get_latest_date_obj($EVT_ID); |
|
348 | - $format = |
|
349 | - ! empty($date_format) && ! empty($time_format) |
|
350 | - ? $date_format . ' ' . $time_format |
|
351 | - : $date_format |
|
352 | - . $time_format; |
|
353 | - return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime('DTT_EVT_end', $format) : ''; |
|
354 | - } |
|
355 | - |
|
356 | - |
|
357 | - /** |
|
358 | - * event_date_as_calendar_page |
|
359 | - * |
|
360 | - * @param int $EVT_ID |
|
361 | - * @return void |
|
362 | - * @throws EE_Error |
|
363 | - * @throws ReflectionException |
|
364 | - */ |
|
365 | - public static function event_date_as_calendar_page($EVT_ID = 0) |
|
366 | - { |
|
367 | - $datetime = EEH_Event_View::get_primary_date_obj($EVT_ID); |
|
368 | - if ($datetime instanceof EE_Datetime) { |
|
369 | - ?> |
|
12 | + /** |
|
13 | + * @var EE_Event $_event |
|
14 | + */ |
|
15 | + private static $_event = null; |
|
16 | + |
|
17 | + |
|
18 | + /** |
|
19 | + * get_event |
|
20 | + * attempts to retrieve an EE_Event object any way it can |
|
21 | + * |
|
22 | + * @param int|WP_Post $EVT_ID |
|
23 | + * @return EE_Event|null |
|
24 | + * @throws EE_Error |
|
25 | + * @throws ReflectionException |
|
26 | + */ |
|
27 | + public static function get_event($EVT_ID = 0) |
|
28 | + { |
|
29 | + // international newspaper? |
|
30 | + global $post; |
|
31 | + $EVT_ID = $EVT_ID instanceof WP_Post && $EVT_ID->post_type === 'espresso_events' |
|
32 | + ? $EVT_ID->ID |
|
33 | + : absint($EVT_ID); |
|
34 | + // do we already have the Event you are looking for? |
|
35 | + if (EEH_Event_View::$_event instanceof EE_Event && $EVT_ID && EEH_Event_View::$_event->ID() === $EVT_ID) { |
|
36 | + return EEH_Event_View::$_event; |
|
37 | + } |
|
38 | + // reset property so that the new event is cached. |
|
39 | + EEH_Event_View::$_event = null; |
|
40 | + if (! $EVT_ID && $post instanceof EE_Event) { |
|
41 | + EEH_Event_View::$_event = $post; |
|
42 | + return EEH_Event_View::$_event; |
|
43 | + } |
|
44 | + // if the post type is for an event and it has a cached event and we don't have a different incoming $EVT_ID |
|
45 | + // then let's just use that cached event on the $post object. |
|
46 | + if ( |
|
47 | + $post instanceof WP_Post |
|
48 | + && $post->post_type === 'espresso_events' |
|
49 | + && isset($post->EE_Event) |
|
50 | + && ( |
|
51 | + $EVT_ID === 0 |
|
52 | + || $EVT_ID === $post->ID |
|
53 | + ) |
|
54 | + ) { |
|
55 | + EEH_Event_View::$_event = $post->EE_Event; |
|
56 | + return EEH_Event_View::$_event; |
|
57 | + } |
|
58 | + // 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. |
|
59 | + if (! EEH_Event_View::$_event instanceof EE_Event && $EVT_ID) { |
|
60 | + EEH_Event_View::$_event = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
61 | + } |
|
62 | + return EEH_Event_View::$_event; |
|
63 | + } |
|
64 | + |
|
65 | + |
|
66 | + /** |
|
67 | + * display_ticket_selector |
|
68 | + * |
|
69 | + * @param int $EVT_ID |
|
70 | + * @return boolean |
|
71 | + * @throws EE_Error |
|
72 | + * @throws EE_Error |
|
73 | + * @throws ReflectionException |
|
74 | + */ |
|
75 | + public static function display_ticket_selector($EVT_ID = 0) |
|
76 | + { |
|
77 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
78 | + return $event instanceof EE_Event && $event->display_ticket_selector(); |
|
79 | + } |
|
80 | + |
|
81 | + |
|
82 | + /** |
|
83 | + * event_status |
|
84 | + * |
|
85 | + * @param int $EVT_ID |
|
86 | + * @return string |
|
87 | + * @throws EE_Error |
|
88 | + * @throws EE_Error |
|
89 | + * @throws ReflectionException |
|
90 | + */ |
|
91 | + public static function event_status($EVT_ID = 0) |
|
92 | + { |
|
93 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
94 | + return $event instanceof EE_Event ? $event->pretty_active_status(false) : ''; |
|
95 | + } |
|
96 | + |
|
97 | + |
|
98 | + /** |
|
99 | + * event_active_status |
|
100 | + * |
|
101 | + * @param int $EVT_ID |
|
102 | + * @return string |
|
103 | + * @throws EE_Error |
|
104 | + * @throws EE_Error |
|
105 | + * @throws ReflectionException |
|
106 | + */ |
|
107 | + public static function event_active_status($EVT_ID = 0, $echo = true) |
|
108 | + { |
|
109 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
110 | + return $event instanceof EE_Event ? $event->pretty_active_status($echo) : 'inactive'; |
|
111 | + } |
|
112 | + |
|
113 | + |
|
114 | + /** |
|
115 | + * event_has_content_or_excerpt |
|
116 | + * |
|
117 | + * @param int $EVT_ID |
|
118 | + * @return bool |
|
119 | + * @throws EE_Error |
|
120 | + * @throws EE_Error |
|
121 | + * @throws ReflectionException |
|
122 | + */ |
|
123 | + public static function event_has_content_or_excerpt($EVT_ID = 0) |
|
124 | + { |
|
125 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
126 | + $has_content_or_excerpt = false; |
|
127 | + if ($event instanceof EE_Event) { |
|
128 | + $has_content_or_excerpt = $event->description() != '' || $event->short_description(null, null, true) != ''; |
|
129 | + } |
|
130 | + if ( |
|
131 | + is_archive() |
|
132 | + && ! (espresso_display_full_description_in_event_list() |
|
133 | + || espresso_display_excerpt_in_event_list()) |
|
134 | + ) { |
|
135 | + $has_content_or_excerpt = false; |
|
136 | + } |
|
137 | + return $has_content_or_excerpt; |
|
138 | + } |
|
139 | + |
|
140 | + |
|
141 | + /** |
|
142 | + * event_active_status |
|
143 | + * |
|
144 | + * @param null $num_words |
|
145 | + * @param null $more |
|
146 | + * @return string |
|
147 | + */ |
|
148 | + public static function event_content_or_excerpt($num_words = null, $more = null) |
|
149 | + { |
|
150 | + global $post; |
|
151 | + ob_start(); |
|
152 | + if ((is_single()) || (is_archive() && espresso_display_full_description_in_event_list())) { |
|
153 | + // admin has chosen "full description" |
|
154 | + // for the "Event Espresso - Events > Templates > Display Description" option |
|
155 | + the_content(); |
|
156 | + } elseif ((is_archive() && espresso_display_excerpt_in_event_list())) { |
|
157 | + if (has_excerpt($post->ID)) { |
|
158 | + // admin has chosen "excerpt (short desc)" |
|
159 | + // for the "Event Espresso - Events > Templates > Display Description" option |
|
160 | + // AND an excerpt actually exists |
|
161 | + the_excerpt(); |
|
162 | + } else { |
|
163 | + // admin has chosen "excerpt (short desc)" |
|
164 | + // for the "Event Espresso - Events > Templates > Display Description" option |
|
165 | + // but NO excerpt actually exists, so we need to create one |
|
166 | + if (! empty($num_words)) { |
|
167 | + if (empty($more)) { |
|
168 | + $more_link_text = esc_html__('(more…)', 'event_espresso'); |
|
169 | + $more = ' <a href="' . get_permalink() . '"'; |
|
170 | + $more .= ' class="more-link"'; |
|
171 | + $more .= EED_Events_Archive::link_target(); |
|
172 | + $more .= '>' . $more_link_text . '</a>'; |
|
173 | + $more = apply_filters('the_content_more_link', $more, $more_link_text); |
|
174 | + } |
|
175 | + $content = str_replace('NOMORELINK', '', get_the_content('NOMORELINK')); |
|
176 | + |
|
177 | + $content = wp_trim_words($content, $num_words, ' ') . $more; |
|
178 | + } else { |
|
179 | + $content = get_the_content(); |
|
180 | + } |
|
181 | + global $allowedtags; |
|
182 | + // make sure links are allowed |
|
183 | + $allowedtags['a'] = isset($allowedtags['a']) |
|
184 | + ? $allowedtags['a'] |
|
185 | + : []; |
|
186 | + // as well as target attribute |
|
187 | + $allowedtags['a']['target'] = isset($allowedtags['a']['target']) |
|
188 | + ? $allowedtags['a']['target'] |
|
189 | + : false; |
|
190 | + // but get previous value so we can reset it |
|
191 | + $prev_value = $allowedtags['a']['target']; |
|
192 | + $allowedtags['a']['target'] = true; |
|
193 | + $content = wp_kses($content, $allowedtags); |
|
194 | + $content = strip_shortcodes($content); |
|
195 | + echo apply_filters('the_content', $content); |
|
196 | + $allowedtags['a']['target'] = $prev_value; |
|
197 | + } |
|
198 | + } else { |
|
199 | + // admin has chosen "none" |
|
200 | + // for the "Event Espresso - Events > Templates > Display Description" option |
|
201 | + echo apply_filters('the_content', ''); |
|
202 | + } |
|
203 | + return ob_get_clean(); |
|
204 | + } |
|
205 | + |
|
206 | + |
|
207 | + /** |
|
208 | + * event_tickets_available |
|
209 | + * |
|
210 | + * @param int $EVT_ID |
|
211 | + * @return EE_Ticket[] |
|
212 | + * @throws EE_Error |
|
213 | + * @throws ReflectionException |
|
214 | + */ |
|
215 | + public static function event_tickets_available($EVT_ID = 0) |
|
216 | + { |
|
217 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
218 | + $tickets_available_for_purchase = []; |
|
219 | + if ($event instanceof EE_Event) { |
|
220 | + $datetimes = EEH_Event_View::get_all_date_obj($EVT_ID, false); |
|
221 | + foreach ($datetimes as $datetime) { |
|
222 | + $tickets_available_for_purchase = |
|
223 | + array_merge($tickets_available_for_purchase, $datetime->ticket_types_available_for_purchase()); |
|
224 | + } |
|
225 | + } |
|
226 | + return $tickets_available_for_purchase; |
|
227 | + } |
|
228 | + |
|
229 | + |
|
230 | + /** |
|
231 | + * the_event_date |
|
232 | + * |
|
233 | + * @param int $EVT_ID |
|
234 | + * @param bool $hide_uncategorized |
|
235 | + * @return string |
|
236 | + * @throws EE_Error |
|
237 | + * @throws ReflectionException |
|
238 | + */ |
|
239 | + public static function event_categories($EVT_ID = 0, $hide_uncategorized = true) |
|
240 | + { |
|
241 | + $category_links = []; |
|
242 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
243 | + if ($event instanceof EE_Event) { |
|
244 | + $event_categories = get_the_terms($event->ID(), 'espresso_event_categories'); |
|
245 | + if ($event_categories) { |
|
246 | + // loop thru terms and create links |
|
247 | + foreach ($event_categories as $term) { |
|
248 | + $url = get_term_link($term, 'espresso_venue_categories'); |
|
249 | + if ( |
|
250 | + ! is_wp_error($url) |
|
251 | + && ( |
|
252 | + ( |
|
253 | + $hide_uncategorized |
|
254 | + && strtolower($term->name) != esc_html__('uncategorized', 'event_espresso') |
|
255 | + ) |
|
256 | + || ! $hide_uncategorized |
|
257 | + ) |
|
258 | + ) { |
|
259 | + $category_links[] = '<a href="' . esc_url_raw($url) . '" ' |
|
260 | + . 'rel="tag" ' . EED_Events_Archive::link_target() . '>' |
|
261 | + . esc_html($term->name) |
|
262 | + . '</a>'; |
|
263 | + } |
|
264 | + } |
|
265 | + } |
|
266 | + } |
|
267 | + return implode(', ', $category_links); |
|
268 | + } |
|
269 | + |
|
270 | + |
|
271 | + /** |
|
272 | + * the_event_date - first date by date order |
|
273 | + * |
|
274 | + * @param string $date_format |
|
275 | + * @param string $time_format |
|
276 | + * @param int $EVT_ID |
|
277 | + * @return string |
|
278 | + * @throws EE_Error |
|
279 | + * @throws ReflectionException |
|
280 | + */ |
|
281 | + public static function the_event_date($date_format = 'D M jS', $time_format = 'g:i a', $EVT_ID = 0) |
|
282 | + { |
|
283 | + $datetime = EEH_Event_View::get_primary_date_obj($EVT_ID); |
|
284 | + $format = ! empty($date_format) && ! empty($time_format) |
|
285 | + ? $date_format . ' ' . $time_format |
|
286 | + : $date_format . $time_format; |
|
287 | + return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime('DTT_EVT_start', $format) : ''; |
|
288 | + } |
|
289 | + |
|
290 | + |
|
291 | + /** |
|
292 | + * the_event_end_date - last date by date order |
|
293 | + * |
|
294 | + * @param string $date_format |
|
295 | + * @param string $time_format |
|
296 | + * @param int $EVT_ID |
|
297 | + * @return string |
|
298 | + * @throws EE_Error |
|
299 | + * @throws ReflectionException |
|
300 | + */ |
|
301 | + public static function the_event_end_date($date_format = 'D M jS', $time_format = 'g:i a', $EVT_ID = 0) |
|
302 | + { |
|
303 | + $datetime = EEH_Event_View::get_last_date_obj($EVT_ID); |
|
304 | + $format = |
|
305 | + ! empty($date_format) && ! empty($time_format) |
|
306 | + ? $date_format . ' ' . $time_format |
|
307 | + : $date_format |
|
308 | + . $time_format; |
|
309 | + return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime('DTT_EVT_end', $format) : ''; |
|
310 | + } |
|
311 | + |
|
312 | + |
|
313 | + /** |
|
314 | + * the_earliest_event_date - first date chronologically |
|
315 | + * |
|
316 | + * @param string $date_format |
|
317 | + * @param string $time_format |
|
318 | + * @param int $EVT_ID |
|
319 | + * @return string |
|
320 | + * @throws EE_Error |
|
321 | + * @throws ReflectionException |
|
322 | + */ |
|
323 | + public static function the_earliest_event_date($date_format = 'D M jS', $time_format = 'g:i a', $EVT_ID = 0) |
|
324 | + { |
|
325 | + $datetime = EEH_Event_View::get_earliest_date_obj($EVT_ID); |
|
326 | + $format = |
|
327 | + ! empty($date_format) && ! empty($time_format) |
|
328 | + ? $date_format . ' ' . $time_format |
|
329 | + : $date_format |
|
330 | + . $time_format; |
|
331 | + return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime('DTT_EVT_start', $format) : ''; |
|
332 | + } |
|
333 | + |
|
334 | + |
|
335 | + /** |
|
336 | + * the_latest_event_date - latest date chronologically |
|
337 | + * |
|
338 | + * @param string $date_format |
|
339 | + * @param string $time_format |
|
340 | + * @param int $EVT_ID |
|
341 | + * @return string |
|
342 | + * @throws EE_Error |
|
343 | + * @throws ReflectionException |
|
344 | + */ |
|
345 | + public static function the_latest_event_date($date_format = 'D M jS', $time_format = 'g:i a', $EVT_ID = 0) |
|
346 | + { |
|
347 | + $datetime = EEH_Event_View::get_latest_date_obj($EVT_ID); |
|
348 | + $format = |
|
349 | + ! empty($date_format) && ! empty($time_format) |
|
350 | + ? $date_format . ' ' . $time_format |
|
351 | + : $date_format |
|
352 | + . $time_format; |
|
353 | + return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime('DTT_EVT_end', $format) : ''; |
|
354 | + } |
|
355 | + |
|
356 | + |
|
357 | + /** |
|
358 | + * event_date_as_calendar_page |
|
359 | + * |
|
360 | + * @param int $EVT_ID |
|
361 | + * @return void |
|
362 | + * @throws EE_Error |
|
363 | + * @throws ReflectionException |
|
364 | + */ |
|
365 | + public static function event_date_as_calendar_page($EVT_ID = 0) |
|
366 | + { |
|
367 | + $datetime = EEH_Event_View::get_primary_date_obj($EVT_ID); |
|
368 | + if ($datetime instanceof EE_Datetime) { |
|
369 | + ?> |
|
370 | 370 | <div class="event-date-calendar-page-dv"> |
371 | 371 | <div class="event-date-calendar-page-month-dv"> |
372 | 372 | <?php echo esc_html($datetime->get_i18n_datetime('DTT_EVT_start', 'M')); ?> |
@@ -376,275 +376,275 @@ discard block |
||
376 | 376 | </div> |
377 | 377 | </div> |
378 | 378 | <?php |
379 | - } |
|
380 | - } |
|
381 | - |
|
382 | - |
|
383 | - /** |
|
384 | - * get_primary_date_obj - orders date by DTT_order |
|
385 | - * |
|
386 | - * @param int $EVT_ID |
|
387 | - * @return EE_Datetime |
|
388 | - * @throws EE_Error |
|
389 | - * @throws ReflectionException |
|
390 | - */ |
|
391 | - public static function get_primary_date_obj($EVT_ID = 0) |
|
392 | - { |
|
393 | - $event = EEH_Event_View::get_event($EVT_ID); |
|
394 | - if ($event instanceof EE_Event) { |
|
395 | - $datetimes = $event->get_many_related( |
|
396 | - 'Datetime', |
|
397 | - [ |
|
398 | - 'limit' => 1, |
|
399 | - 'order_by' => ['DTT_order' => 'ASC'], |
|
400 | - ] |
|
401 | - ); |
|
402 | - return reset($datetimes); |
|
403 | - } |
|
404 | - return null; |
|
405 | - } |
|
406 | - |
|
407 | - |
|
408 | - /** |
|
409 | - * get_last_date_obj - orders date by DTT_order |
|
410 | - * |
|
411 | - * @param int $EVT_ID |
|
412 | - * @return EE_Datetime |
|
413 | - * @throws EE_Error |
|
414 | - * @throws ReflectionException |
|
415 | - */ |
|
416 | - public static function get_last_date_obj($EVT_ID = 0) |
|
417 | - { |
|
418 | - $event = EEH_Event_View::get_event($EVT_ID); |
|
419 | - if ($event instanceof EE_Event) { |
|
420 | - $datetimes = $event->get_many_related( |
|
421 | - 'Datetime', |
|
422 | - [ |
|
423 | - 'limit' => 1, |
|
424 | - 'order_by' => ['DTT_order' => 'DESC'], |
|
425 | - ] |
|
426 | - ); |
|
427 | - return end($datetimes); |
|
428 | - } |
|
429 | - return null; |
|
430 | - } |
|
431 | - |
|
432 | - |
|
433 | - /** |
|
434 | - * get_earliest_date_obj - orders date chronologically |
|
435 | - * |
|
436 | - * @param int $EVT_ID |
|
437 | - * @return EE_Datetime |
|
438 | - * @throws EE_Error |
|
439 | - * @throws ReflectionException |
|
440 | - */ |
|
441 | - public static function get_earliest_date_obj($EVT_ID = 0) |
|
442 | - { |
|
443 | - $event = EEH_Event_View::get_event($EVT_ID); |
|
444 | - if ($event instanceof EE_Event) { |
|
445 | - $datetimes = $event->get_many_related( |
|
446 | - 'Datetime', |
|
447 | - [ |
|
448 | - 'limit' => 1, |
|
449 | - 'order_by' => ['DTT_EVT_start' => 'ASC'], |
|
450 | - ] |
|
451 | - ); |
|
452 | - return reset($datetimes); |
|
453 | - } |
|
454 | - return null; |
|
455 | - } |
|
456 | - |
|
457 | - |
|
458 | - /** |
|
459 | - * get_latest_date_obj - orders date chronologically |
|
460 | - * |
|
461 | - * @param int $EVT_ID |
|
462 | - * @return EE_Datetime |
|
463 | - * @throws EE_Error |
|
464 | - * @throws ReflectionException |
|
465 | - */ |
|
466 | - public static function get_latest_date_obj($EVT_ID = 0) |
|
467 | - { |
|
468 | - $event = EEH_Event_View::get_event($EVT_ID); |
|
469 | - if ($event instanceof EE_Event) { |
|
470 | - $datetimes = $event->get_many_related( |
|
471 | - 'Datetime', |
|
472 | - [ |
|
473 | - 'limit' => 1, |
|
474 | - 'order_by' => ['DTT_EVT_start' => 'DESC'], |
|
475 | - ] |
|
476 | - ); |
|
477 | - return end($datetimes); |
|
478 | - } |
|
479 | - return null; |
|
480 | - } |
|
481 | - |
|
482 | - |
|
483 | - /** |
|
484 | - * get_next_upcoming_date_obj - return the next upcoming datetime |
|
485 | - * |
|
486 | - * @param int $EVT_ID |
|
487 | - * @return EE_Datetime|null |
|
488 | - * @throws EE_Error |
|
489 | - * @throws EE_Error |
|
490 | - */ |
|
491 | - public static function get_next_upcoming_date_obj($EVT_ID = 0) |
|
492 | - { |
|
493 | - $datetime = EEM_Datetime::instance()->get_one( |
|
494 | - [ |
|
495 | - [ |
|
496 | - 'Event.EVT_ID' => $EVT_ID, |
|
497 | - 'DTT_EVT_start' => ['>=', current_time('mysql', true)], |
|
498 | - ], |
|
499 | - 'order_by' => ['DTT_EVT_start' => 'asc'], |
|
500 | - ] |
|
501 | - ); |
|
502 | - return $datetime instanceof EE_Datetime ? $datetime : null; |
|
503 | - } |
|
504 | - |
|
505 | - |
|
506 | - /** |
|
507 | - * get_next_upcoming_date_obj - return the next upcoming datetime |
|
508 | - * |
|
509 | - * @param int $DTT_ID |
|
510 | - * @return EE_Datetime|null |
|
511 | - * @throws EE_Error |
|
512 | - * @throws ReflectionException |
|
513 | - */ |
|
514 | - public static function get_date_obj(int $DTT_ID = 0): ?EE_Datetime |
|
515 | - { |
|
516 | - $datetime = EEM_Datetime::instance()->get_one_by_ID($DTT_ID); |
|
517 | - return $datetime instanceof EE_Datetime ? $datetime : null; |
|
518 | - } |
|
519 | - |
|
520 | - |
|
521 | - /** |
|
522 | - * get_all_date_obj |
|
523 | - * |
|
524 | - * @param int $EVT_ID |
|
525 | - * @param null $include_expired |
|
526 | - * @param bool $include_deleted |
|
527 | - * @param null $limit |
|
528 | - * @return EE_Datetime[] |
|
529 | - * @throws EE_Error |
|
530 | - * @throws EE_Error |
|
531 | - * @throws ReflectionException |
|
532 | - */ |
|
533 | - public static function get_all_date_obj( |
|
534 | - $EVT_ID = 0, |
|
535 | - $include_expired = null, |
|
536 | - $include_deleted = false, |
|
537 | - $limit = null |
|
538 | - ) { |
|
539 | - $event = EEH_Event_View::get_event($EVT_ID); |
|
540 | - if ($include_expired === null) { |
|
541 | - if ($event instanceof EE_Event && $event->is_expired()) { |
|
542 | - $include_expired = true; |
|
543 | - } else { |
|
544 | - $include_expired = false; |
|
545 | - } |
|
546 | - } |
|
547 | - |
|
548 | - if ($event instanceof EE_Event) { |
|
549 | - return $event->datetimes_ordered($include_expired, $include_deleted, $limit); |
|
550 | - } |
|
551 | - return []; |
|
552 | - } |
|
553 | - |
|
554 | - |
|
555 | - /** |
|
556 | - * event_link_url |
|
557 | - * |
|
558 | - * @param int $EVT_ID |
|
559 | - * @return string |
|
560 | - * @throws EE_Error |
|
561 | - * @throws ReflectionException |
|
562 | - */ |
|
563 | - public static function event_link_url($EVT_ID = 0) |
|
564 | - { |
|
565 | - $event = EEH_Event_View::get_event($EVT_ID); |
|
566 | - if ($event instanceof EE_Event) { |
|
567 | - $url = $event->external_url() !== null && $event->external_url() !== '' |
|
568 | - ? $event->external_url() |
|
569 | - : get_permalink($event->ID()); |
|
570 | - $url = preg_match("~^(?:f|ht)tps?://~i", $url) ? $url : 'https://' . $url; |
|
571 | - return esc_url_raw($url); |
|
572 | - } |
|
573 | - return ''; |
|
574 | - } |
|
575 | - |
|
576 | - |
|
577 | - /** |
|
578 | - * event_phone |
|
579 | - * |
|
580 | - * @param int $EVT_ID |
|
581 | - * @return string |
|
582 | - * @throws EE_Error |
|
583 | - * @throws EE_Error |
|
584 | - * @throws ReflectionException |
|
585 | - */ |
|
586 | - public static function event_phone($EVT_ID = 0) |
|
587 | - { |
|
588 | - $event = EEH_Event_View::get_event($EVT_ID); |
|
589 | - if ($event instanceof EE_Event) { |
|
590 | - return EEH_Schema::telephone($event->phone()); |
|
591 | - } |
|
592 | - return null; |
|
593 | - } |
|
594 | - |
|
595 | - |
|
596 | - /** |
|
597 | - * edit_event_link |
|
598 | - * |
|
599 | - * @param int $EVT_ID |
|
600 | - * @param string $link |
|
601 | - * @param string $before |
|
602 | - * @param string $after |
|
603 | - * @return string |
|
604 | - * @throws EE_Error |
|
605 | - * @throws ReflectionException |
|
606 | - */ |
|
607 | - public static function edit_event_link($EVT_ID = 0, $link = '', $before = '', $after = '') |
|
608 | - { |
|
609 | - $event = EEH_Event_View::get_event($EVT_ID); |
|
610 | - if ($event instanceof EE_Event) { |
|
611 | - // can the user edit this post ? |
|
612 | - if (current_user_can('edit_post', $event->ID())) { |
|
613 | - // set link text |
|
614 | - $link_text = ! empty($link) ? $link : esc_html__('edit this event', 'event_espresso'); |
|
615 | - // generate nonce |
|
616 | - $nonce = wp_create_nonce('edit_nonce'); |
|
617 | - // generate url to event editor for this event |
|
618 | - $url = |
|
619 | - add_query_arg( |
|
620 | - [ |
|
621 | - 'page' => 'espresso_events', |
|
622 | - 'action' => 'edit', |
|
623 | - 'post' => $event->ID(), |
|
624 | - 'edit_nonce' => $nonce, |
|
625 | - ], |
|
626 | - admin_url() |
|
627 | - ); |
|
628 | - // get edit CPT text |
|
629 | - $post_type_obj = get_post_type_object('espresso_events'); |
|
630 | - // build final link html |
|
631 | - $link = '<a class="post-edit-link" href="' . $url . '" '; |
|
632 | - $link .= ' title="' . esc_attr($post_type_obj->labels->edit_item) . '"'; |
|
633 | - $link .= EED_Events_Archive::link_target(); |
|
634 | - $link .= '>' . $link_text . '</a>'; |
|
635 | - // put it all together |
|
636 | - return $before . apply_filters('edit_post_link', $link, $event->ID()) . $after; |
|
637 | - } |
|
638 | - } |
|
639 | - return ''; |
|
640 | - } |
|
641 | - |
|
642 | - |
|
643 | - /** |
|
644 | - * @return string |
|
645 | - */ |
|
646 | - public static function event_archive_url() |
|
647 | - { |
|
648 | - return get_post_type_archive_link('espresso_events'); |
|
649 | - } |
|
379 | + } |
|
380 | + } |
|
381 | + |
|
382 | + |
|
383 | + /** |
|
384 | + * get_primary_date_obj - orders date by DTT_order |
|
385 | + * |
|
386 | + * @param int $EVT_ID |
|
387 | + * @return EE_Datetime |
|
388 | + * @throws EE_Error |
|
389 | + * @throws ReflectionException |
|
390 | + */ |
|
391 | + public static function get_primary_date_obj($EVT_ID = 0) |
|
392 | + { |
|
393 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
394 | + if ($event instanceof EE_Event) { |
|
395 | + $datetimes = $event->get_many_related( |
|
396 | + 'Datetime', |
|
397 | + [ |
|
398 | + 'limit' => 1, |
|
399 | + 'order_by' => ['DTT_order' => 'ASC'], |
|
400 | + ] |
|
401 | + ); |
|
402 | + return reset($datetimes); |
|
403 | + } |
|
404 | + return null; |
|
405 | + } |
|
406 | + |
|
407 | + |
|
408 | + /** |
|
409 | + * get_last_date_obj - orders date by DTT_order |
|
410 | + * |
|
411 | + * @param int $EVT_ID |
|
412 | + * @return EE_Datetime |
|
413 | + * @throws EE_Error |
|
414 | + * @throws ReflectionException |
|
415 | + */ |
|
416 | + public static function get_last_date_obj($EVT_ID = 0) |
|
417 | + { |
|
418 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
419 | + if ($event instanceof EE_Event) { |
|
420 | + $datetimes = $event->get_many_related( |
|
421 | + 'Datetime', |
|
422 | + [ |
|
423 | + 'limit' => 1, |
|
424 | + 'order_by' => ['DTT_order' => 'DESC'], |
|
425 | + ] |
|
426 | + ); |
|
427 | + return end($datetimes); |
|
428 | + } |
|
429 | + return null; |
|
430 | + } |
|
431 | + |
|
432 | + |
|
433 | + /** |
|
434 | + * get_earliest_date_obj - orders date chronologically |
|
435 | + * |
|
436 | + * @param int $EVT_ID |
|
437 | + * @return EE_Datetime |
|
438 | + * @throws EE_Error |
|
439 | + * @throws ReflectionException |
|
440 | + */ |
|
441 | + public static function get_earliest_date_obj($EVT_ID = 0) |
|
442 | + { |
|
443 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
444 | + if ($event instanceof EE_Event) { |
|
445 | + $datetimes = $event->get_many_related( |
|
446 | + 'Datetime', |
|
447 | + [ |
|
448 | + 'limit' => 1, |
|
449 | + 'order_by' => ['DTT_EVT_start' => 'ASC'], |
|
450 | + ] |
|
451 | + ); |
|
452 | + return reset($datetimes); |
|
453 | + } |
|
454 | + return null; |
|
455 | + } |
|
456 | + |
|
457 | + |
|
458 | + /** |
|
459 | + * get_latest_date_obj - orders date chronologically |
|
460 | + * |
|
461 | + * @param int $EVT_ID |
|
462 | + * @return EE_Datetime |
|
463 | + * @throws EE_Error |
|
464 | + * @throws ReflectionException |
|
465 | + */ |
|
466 | + public static function get_latest_date_obj($EVT_ID = 0) |
|
467 | + { |
|
468 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
469 | + if ($event instanceof EE_Event) { |
|
470 | + $datetimes = $event->get_many_related( |
|
471 | + 'Datetime', |
|
472 | + [ |
|
473 | + 'limit' => 1, |
|
474 | + 'order_by' => ['DTT_EVT_start' => 'DESC'], |
|
475 | + ] |
|
476 | + ); |
|
477 | + return end($datetimes); |
|
478 | + } |
|
479 | + return null; |
|
480 | + } |
|
481 | + |
|
482 | + |
|
483 | + /** |
|
484 | + * get_next_upcoming_date_obj - return the next upcoming datetime |
|
485 | + * |
|
486 | + * @param int $EVT_ID |
|
487 | + * @return EE_Datetime|null |
|
488 | + * @throws EE_Error |
|
489 | + * @throws EE_Error |
|
490 | + */ |
|
491 | + public static function get_next_upcoming_date_obj($EVT_ID = 0) |
|
492 | + { |
|
493 | + $datetime = EEM_Datetime::instance()->get_one( |
|
494 | + [ |
|
495 | + [ |
|
496 | + 'Event.EVT_ID' => $EVT_ID, |
|
497 | + 'DTT_EVT_start' => ['>=', current_time('mysql', true)], |
|
498 | + ], |
|
499 | + 'order_by' => ['DTT_EVT_start' => 'asc'], |
|
500 | + ] |
|
501 | + ); |
|
502 | + return $datetime instanceof EE_Datetime ? $datetime : null; |
|
503 | + } |
|
504 | + |
|
505 | + |
|
506 | + /** |
|
507 | + * get_next_upcoming_date_obj - return the next upcoming datetime |
|
508 | + * |
|
509 | + * @param int $DTT_ID |
|
510 | + * @return EE_Datetime|null |
|
511 | + * @throws EE_Error |
|
512 | + * @throws ReflectionException |
|
513 | + */ |
|
514 | + public static function get_date_obj(int $DTT_ID = 0): ?EE_Datetime |
|
515 | + { |
|
516 | + $datetime = EEM_Datetime::instance()->get_one_by_ID($DTT_ID); |
|
517 | + return $datetime instanceof EE_Datetime ? $datetime : null; |
|
518 | + } |
|
519 | + |
|
520 | + |
|
521 | + /** |
|
522 | + * get_all_date_obj |
|
523 | + * |
|
524 | + * @param int $EVT_ID |
|
525 | + * @param null $include_expired |
|
526 | + * @param bool $include_deleted |
|
527 | + * @param null $limit |
|
528 | + * @return EE_Datetime[] |
|
529 | + * @throws EE_Error |
|
530 | + * @throws EE_Error |
|
531 | + * @throws ReflectionException |
|
532 | + */ |
|
533 | + public static function get_all_date_obj( |
|
534 | + $EVT_ID = 0, |
|
535 | + $include_expired = null, |
|
536 | + $include_deleted = false, |
|
537 | + $limit = null |
|
538 | + ) { |
|
539 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
540 | + if ($include_expired === null) { |
|
541 | + if ($event instanceof EE_Event && $event->is_expired()) { |
|
542 | + $include_expired = true; |
|
543 | + } else { |
|
544 | + $include_expired = false; |
|
545 | + } |
|
546 | + } |
|
547 | + |
|
548 | + if ($event instanceof EE_Event) { |
|
549 | + return $event->datetimes_ordered($include_expired, $include_deleted, $limit); |
|
550 | + } |
|
551 | + return []; |
|
552 | + } |
|
553 | + |
|
554 | + |
|
555 | + /** |
|
556 | + * event_link_url |
|
557 | + * |
|
558 | + * @param int $EVT_ID |
|
559 | + * @return string |
|
560 | + * @throws EE_Error |
|
561 | + * @throws ReflectionException |
|
562 | + */ |
|
563 | + public static function event_link_url($EVT_ID = 0) |
|
564 | + { |
|
565 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
566 | + if ($event instanceof EE_Event) { |
|
567 | + $url = $event->external_url() !== null && $event->external_url() !== '' |
|
568 | + ? $event->external_url() |
|
569 | + : get_permalink($event->ID()); |
|
570 | + $url = preg_match("~^(?:f|ht)tps?://~i", $url) ? $url : 'https://' . $url; |
|
571 | + return esc_url_raw($url); |
|
572 | + } |
|
573 | + return ''; |
|
574 | + } |
|
575 | + |
|
576 | + |
|
577 | + /** |
|
578 | + * event_phone |
|
579 | + * |
|
580 | + * @param int $EVT_ID |
|
581 | + * @return string |
|
582 | + * @throws EE_Error |
|
583 | + * @throws EE_Error |
|
584 | + * @throws ReflectionException |
|
585 | + */ |
|
586 | + public static function event_phone($EVT_ID = 0) |
|
587 | + { |
|
588 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
589 | + if ($event instanceof EE_Event) { |
|
590 | + return EEH_Schema::telephone($event->phone()); |
|
591 | + } |
|
592 | + return null; |
|
593 | + } |
|
594 | + |
|
595 | + |
|
596 | + /** |
|
597 | + * edit_event_link |
|
598 | + * |
|
599 | + * @param int $EVT_ID |
|
600 | + * @param string $link |
|
601 | + * @param string $before |
|
602 | + * @param string $after |
|
603 | + * @return string |
|
604 | + * @throws EE_Error |
|
605 | + * @throws ReflectionException |
|
606 | + */ |
|
607 | + public static function edit_event_link($EVT_ID = 0, $link = '', $before = '', $after = '') |
|
608 | + { |
|
609 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
610 | + if ($event instanceof EE_Event) { |
|
611 | + // can the user edit this post ? |
|
612 | + if (current_user_can('edit_post', $event->ID())) { |
|
613 | + // set link text |
|
614 | + $link_text = ! empty($link) ? $link : esc_html__('edit this event', 'event_espresso'); |
|
615 | + // generate nonce |
|
616 | + $nonce = wp_create_nonce('edit_nonce'); |
|
617 | + // generate url to event editor for this event |
|
618 | + $url = |
|
619 | + add_query_arg( |
|
620 | + [ |
|
621 | + 'page' => 'espresso_events', |
|
622 | + 'action' => 'edit', |
|
623 | + 'post' => $event->ID(), |
|
624 | + 'edit_nonce' => $nonce, |
|
625 | + ], |
|
626 | + admin_url() |
|
627 | + ); |
|
628 | + // get edit CPT text |
|
629 | + $post_type_obj = get_post_type_object('espresso_events'); |
|
630 | + // build final link html |
|
631 | + $link = '<a class="post-edit-link" href="' . $url . '" '; |
|
632 | + $link .= ' title="' . esc_attr($post_type_obj->labels->edit_item) . '"'; |
|
633 | + $link .= EED_Events_Archive::link_target(); |
|
634 | + $link .= '>' . $link_text . '</a>'; |
|
635 | + // put it all together |
|
636 | + return $before . apply_filters('edit_post_link', $link, $event->ID()) . $after; |
|
637 | + } |
|
638 | + } |
|
639 | + return ''; |
|
640 | + } |
|
641 | + |
|
642 | + |
|
643 | + /** |
|
644 | + * @return string |
|
645 | + */ |
|
646 | + public static function event_archive_url() |
|
647 | + { |
|
648 | + return get_post_type_archive_link('espresso_events'); |
|
649 | + } |
|
650 | 650 | } |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | */ |
122 | 122 | protected function setId($id = '') |
123 | 123 | { |
124 | - if (! is_string($id)) { |
|
124 | + if ( ! is_string($id)) { |
|
125 | 125 | throw new InvalidDataTypeException('$id', $id, 'string'); |
126 | 126 | } |
127 | 127 | $this->id = $id; |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | */ |
145 | 145 | protected function setOrder($order = 0) |
146 | 146 | { |
147 | - if (! is_int($order)) { |
|
147 | + if ( ! is_int($order)) { |
|
148 | 148 | throw new InvalidDataTypeException('$order', $order, 'integer'); |
149 | 149 | } |
150 | 150 | $this->order = absint($order); |
@@ -173,11 +173,11 @@ discard block |
||
173 | 173 | */ |
174 | 174 | protected function setHtmlClass($html_class) |
175 | 175 | { |
176 | - if (! is_string($html_class)) { |
|
176 | + if ( ! is_string($html_class)) { |
|
177 | 177 | throw new InvalidDataTypeException('$html_class', $html_class, 'string'); |
178 | 178 | } |
179 | 179 | if (strpos($html_class, 'progress-step-') === false) { |
180 | - $html_class = 'progress-step-' . $html_class; |
|
180 | + $html_class = 'progress-step-'.$html_class; |
|
181 | 181 | } |
182 | 182 | $this->html_class = $html_class; |
183 | 183 | } |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | */ |
200 | 200 | protected function setText($text) |
201 | 201 | { |
202 | - if (! is_string($text)) { |
|
202 | + if ( ! is_string($text)) { |
|
203 | 203 | throw new InvalidDataTypeException('$text', $text, 'string'); |
204 | 204 | } |
205 | 205 | $this->text = sanitize_text_field($text); |
@@ -16,190 +16,190 @@ |
||
16 | 16 | */ |
17 | 17 | class ProgressStep implements ProgressStepInterface |
18 | 18 | { |
19 | - /** |
|
20 | - * @var boolean $current |
|
21 | - */ |
|
22 | - private $current = false; |
|
23 | - |
|
24 | - |
|
25 | - /** |
|
26 | - * @var boolean $completed |
|
27 | - */ |
|
28 | - private $completed = false; |
|
29 | - |
|
30 | - |
|
31 | - /** |
|
32 | - * @var string $html_class |
|
33 | - */ |
|
34 | - private $html_class; |
|
35 | - |
|
36 | - /** |
|
37 | - * @var string $id |
|
38 | - */ |
|
39 | - private $id = ''; |
|
40 | - |
|
41 | - /** |
|
42 | - * @var int $order |
|
43 | - */ |
|
44 | - private $order = 0; |
|
45 | - |
|
46 | - /** |
|
47 | - * @var string $text |
|
48 | - */ |
|
49 | - private $text = ''; |
|
50 | - |
|
51 | - |
|
52 | - /** |
|
53 | - * ProgressStep constructor |
|
54 | - * |
|
55 | - * @param int $order |
|
56 | - * @param string $id |
|
57 | - * @param string $html_class |
|
58 | - * @param string $text |
|
59 | - * @throws InvalidDataTypeException |
|
60 | - */ |
|
61 | - public function __construct($order, $id, $html_class, $text) |
|
62 | - { |
|
63 | - $this->setOrder($order); |
|
64 | - $this->setId($id); |
|
65 | - $this->setHtmlClass($html_class); |
|
66 | - $this->setText($text); |
|
67 | - } |
|
68 | - |
|
69 | - |
|
70 | - /** |
|
71 | - * @return boolean |
|
72 | - */ |
|
73 | - public function isCurrent() |
|
74 | - { |
|
75 | - return $this->current; |
|
76 | - } |
|
77 | - |
|
78 | - |
|
79 | - /** |
|
80 | - * @param boolean $current |
|
81 | - */ |
|
82 | - public function setIsCurrent($current = true) |
|
83 | - { |
|
84 | - $this->current = filter_var($current, FILTER_VALIDATE_BOOLEAN); |
|
85 | - } |
|
86 | - |
|
87 | - |
|
88 | - /** |
|
89 | - * @return boolean |
|
90 | - */ |
|
91 | - public function isCompleted() |
|
92 | - { |
|
93 | - return $this->completed; |
|
94 | - } |
|
95 | - |
|
96 | - |
|
97 | - /** |
|
98 | - * @param boolean $completed |
|
99 | - */ |
|
100 | - public function setIsCompleted($completed = true) |
|
101 | - { |
|
102 | - $this->completed = filter_var($completed, FILTER_VALIDATE_BOOLEAN); |
|
103 | - } |
|
104 | - |
|
105 | - |
|
106 | - /** |
|
107 | - * @return string |
|
108 | - */ |
|
109 | - public function id() |
|
110 | - { |
|
111 | - return $this->id; |
|
112 | - } |
|
113 | - |
|
114 | - |
|
115 | - /** |
|
116 | - * @access protected |
|
117 | - * @param string $id |
|
118 | - * @throws InvalidDataTypeException |
|
119 | - */ |
|
120 | - protected function setId($id = '') |
|
121 | - { |
|
122 | - if (! is_string($id)) { |
|
123 | - throw new InvalidDataTypeException('$id', $id, 'string'); |
|
124 | - } |
|
125 | - $this->id = $id; |
|
126 | - } |
|
127 | - |
|
128 | - |
|
129 | - /** |
|
130 | - * @return int |
|
131 | - */ |
|
132 | - public function order() |
|
133 | - { |
|
134 | - return $this->order; |
|
135 | - } |
|
136 | - |
|
137 | - |
|
138 | - /** |
|
139 | - * @access protected |
|
140 | - * @param int $order |
|
141 | - * @throws InvalidDataTypeException |
|
142 | - */ |
|
143 | - protected function setOrder($order = 0) |
|
144 | - { |
|
145 | - if (! is_int($order)) { |
|
146 | - throw new InvalidDataTypeException('$order', $order, 'integer'); |
|
147 | - } |
|
148 | - $this->order = absint($order); |
|
149 | - } |
|
150 | - |
|
151 | - |
|
152 | - /** |
|
153 | - * @return string |
|
154 | - */ |
|
155 | - public function htmlClass() |
|
156 | - { |
|
157 | - $html_class = $this->html_class; |
|
158 | - if ($this->isCurrent()) { |
|
159 | - $html_class .= ' progress-step-active'; |
|
160 | - } elseif ($this->isCompleted()) { |
|
161 | - $html_class .= ' progress-step-completed'; |
|
162 | - } |
|
163 | - return $html_class; |
|
164 | - } |
|
165 | - |
|
166 | - |
|
167 | - /** |
|
168 | - * @access protected |
|
169 | - * @param string $html_class |
|
170 | - * @throws InvalidDataTypeException |
|
171 | - */ |
|
172 | - protected function setHtmlClass($html_class) |
|
173 | - { |
|
174 | - if (! is_string($html_class)) { |
|
175 | - throw new InvalidDataTypeException('$html_class', $html_class, 'string'); |
|
176 | - } |
|
177 | - if (strpos($html_class, 'progress-step-') === false) { |
|
178 | - $html_class = 'progress-step-' . $html_class; |
|
179 | - } |
|
180 | - $this->html_class = $html_class; |
|
181 | - } |
|
182 | - |
|
183 | - |
|
184 | - /** |
|
185 | - * @return string |
|
186 | - */ |
|
187 | - public function text() |
|
188 | - { |
|
189 | - return $this->text; |
|
190 | - } |
|
191 | - |
|
192 | - |
|
193 | - /** |
|
194 | - * @access protected |
|
195 | - * @param string $text |
|
196 | - * @throws InvalidDataTypeException |
|
197 | - */ |
|
198 | - protected function setText($text) |
|
199 | - { |
|
200 | - if (! is_string($text)) { |
|
201 | - throw new InvalidDataTypeException('$text', $text, 'string'); |
|
202 | - } |
|
203 | - $this->text = sanitize_text_field($text); |
|
204 | - } |
|
19 | + /** |
|
20 | + * @var boolean $current |
|
21 | + */ |
|
22 | + private $current = false; |
|
23 | + |
|
24 | + |
|
25 | + /** |
|
26 | + * @var boolean $completed |
|
27 | + */ |
|
28 | + private $completed = false; |
|
29 | + |
|
30 | + |
|
31 | + /** |
|
32 | + * @var string $html_class |
|
33 | + */ |
|
34 | + private $html_class; |
|
35 | + |
|
36 | + /** |
|
37 | + * @var string $id |
|
38 | + */ |
|
39 | + private $id = ''; |
|
40 | + |
|
41 | + /** |
|
42 | + * @var int $order |
|
43 | + */ |
|
44 | + private $order = 0; |
|
45 | + |
|
46 | + /** |
|
47 | + * @var string $text |
|
48 | + */ |
|
49 | + private $text = ''; |
|
50 | + |
|
51 | + |
|
52 | + /** |
|
53 | + * ProgressStep constructor |
|
54 | + * |
|
55 | + * @param int $order |
|
56 | + * @param string $id |
|
57 | + * @param string $html_class |
|
58 | + * @param string $text |
|
59 | + * @throws InvalidDataTypeException |
|
60 | + */ |
|
61 | + public function __construct($order, $id, $html_class, $text) |
|
62 | + { |
|
63 | + $this->setOrder($order); |
|
64 | + $this->setId($id); |
|
65 | + $this->setHtmlClass($html_class); |
|
66 | + $this->setText($text); |
|
67 | + } |
|
68 | + |
|
69 | + |
|
70 | + /** |
|
71 | + * @return boolean |
|
72 | + */ |
|
73 | + public function isCurrent() |
|
74 | + { |
|
75 | + return $this->current; |
|
76 | + } |
|
77 | + |
|
78 | + |
|
79 | + /** |
|
80 | + * @param boolean $current |
|
81 | + */ |
|
82 | + public function setIsCurrent($current = true) |
|
83 | + { |
|
84 | + $this->current = filter_var($current, FILTER_VALIDATE_BOOLEAN); |
|
85 | + } |
|
86 | + |
|
87 | + |
|
88 | + /** |
|
89 | + * @return boolean |
|
90 | + */ |
|
91 | + public function isCompleted() |
|
92 | + { |
|
93 | + return $this->completed; |
|
94 | + } |
|
95 | + |
|
96 | + |
|
97 | + /** |
|
98 | + * @param boolean $completed |
|
99 | + */ |
|
100 | + public function setIsCompleted($completed = true) |
|
101 | + { |
|
102 | + $this->completed = filter_var($completed, FILTER_VALIDATE_BOOLEAN); |
|
103 | + } |
|
104 | + |
|
105 | + |
|
106 | + /** |
|
107 | + * @return string |
|
108 | + */ |
|
109 | + public function id() |
|
110 | + { |
|
111 | + return $this->id; |
|
112 | + } |
|
113 | + |
|
114 | + |
|
115 | + /** |
|
116 | + * @access protected |
|
117 | + * @param string $id |
|
118 | + * @throws InvalidDataTypeException |
|
119 | + */ |
|
120 | + protected function setId($id = '') |
|
121 | + { |
|
122 | + if (! is_string($id)) { |
|
123 | + throw new InvalidDataTypeException('$id', $id, 'string'); |
|
124 | + } |
|
125 | + $this->id = $id; |
|
126 | + } |
|
127 | + |
|
128 | + |
|
129 | + /** |
|
130 | + * @return int |
|
131 | + */ |
|
132 | + public function order() |
|
133 | + { |
|
134 | + return $this->order; |
|
135 | + } |
|
136 | + |
|
137 | + |
|
138 | + /** |
|
139 | + * @access protected |
|
140 | + * @param int $order |
|
141 | + * @throws InvalidDataTypeException |
|
142 | + */ |
|
143 | + protected function setOrder($order = 0) |
|
144 | + { |
|
145 | + if (! is_int($order)) { |
|
146 | + throw new InvalidDataTypeException('$order', $order, 'integer'); |
|
147 | + } |
|
148 | + $this->order = absint($order); |
|
149 | + } |
|
150 | + |
|
151 | + |
|
152 | + /** |
|
153 | + * @return string |
|
154 | + */ |
|
155 | + public function htmlClass() |
|
156 | + { |
|
157 | + $html_class = $this->html_class; |
|
158 | + if ($this->isCurrent()) { |
|
159 | + $html_class .= ' progress-step-active'; |
|
160 | + } elseif ($this->isCompleted()) { |
|
161 | + $html_class .= ' progress-step-completed'; |
|
162 | + } |
|
163 | + return $html_class; |
|
164 | + } |
|
165 | + |
|
166 | + |
|
167 | + /** |
|
168 | + * @access protected |
|
169 | + * @param string $html_class |
|
170 | + * @throws InvalidDataTypeException |
|
171 | + */ |
|
172 | + protected function setHtmlClass($html_class) |
|
173 | + { |
|
174 | + if (! is_string($html_class)) { |
|
175 | + throw new InvalidDataTypeException('$html_class', $html_class, 'string'); |
|
176 | + } |
|
177 | + if (strpos($html_class, 'progress-step-') === false) { |
|
178 | + $html_class = 'progress-step-' . $html_class; |
|
179 | + } |
|
180 | + $this->html_class = $html_class; |
|
181 | + } |
|
182 | + |
|
183 | + |
|
184 | + /** |
|
185 | + * @return string |
|
186 | + */ |
|
187 | + public function text() |
|
188 | + { |
|
189 | + return $this->text; |
|
190 | + } |
|
191 | + |
|
192 | + |
|
193 | + /** |
|
194 | + * @access protected |
|
195 | + * @param string $text |
|
196 | + * @throws InvalidDataTypeException |
|
197 | + */ |
|
198 | + protected function setText($text) |
|
199 | + { |
|
200 | + if (! is_string($text)) { |
|
201 | + throw new InvalidDataTypeException('$text', $text, 'string'); |
|
202 | + } |
|
203 | + $this->text = sanitize_text_field($text); |
|
204 | + } |
|
205 | 205 | } |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | |
147 | 147 | public function get_shortcode_helper() |
148 | 148 | { |
149 | - if (! $this->_shortcode_helper instanceof EEH_Parse_Shortcodes) { |
|
149 | + if ( ! $this->_shortcode_helper instanceof EEH_Parse_Shortcodes) { |
|
150 | 150 | $this->_set_shortcode_helper(); |
151 | 151 | } |
152 | 152 | return $this->_shortcode_helper; |
@@ -170,17 +170,17 @@ discard block |
||
170 | 170 | |
171 | 171 | // we need to setup any dynamic shortcodes so that they work with the array_key_exists |
172 | 172 | preg_match_all('/(\[[A-Za-z0-9\_]+_\*)/', $shortcode, $matches); |
173 | - $sc_to_verify = ! empty($matches[0]) ? $matches[0][0] . ']' : $shortcode; |
|
173 | + $sc_to_verify = ! empty($matches[0]) ? $matches[0][0].']' : $shortcode; |
|
174 | 174 | |
175 | 175 | // first we want to make sure this is a valid shortcode |
176 | - if (! array_key_exists($sc_to_verify, $this->_shortcodes)) { |
|
176 | + if ( ! array_key_exists($sc_to_verify, $this->_shortcodes)) { |
|
177 | 177 | return false; |
178 | 178 | } //get out, this parser doesn't handle the incoming shortcode. |
179 | 179 | $this->_data = $data; |
180 | 180 | $this->_extra_data = $extra_data; |
181 | 181 | $this->_set_messages_properties(); |
182 | 182 | $parsed = apply_filters( |
183 | - 'FHEE__' . get_class($this) . '__parser_after', |
|
183 | + 'FHEE__'.get_class($this).'__parser_after', |
|
184 | 184 | $this->_parser($shortcode), |
185 | 185 | $shortcode, |
186 | 186 | $data, |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | */ |
202 | 202 | public function get_shortcodes() |
203 | 203 | { |
204 | - $this->_shortcodes = apply_filters('FHEE__' . get_class($this) . '__shortcodes', $this->_shortcodes, $this); |
|
204 | + $this->_shortcodes = apply_filters('FHEE__'.get_class($this).'__shortcodes', $this->_shortcodes, $this); |
|
205 | 205 | |
206 | 206 | // note the below filter applies to ALL shortcode parsers... be careful! |
207 | 207 | $this->_shortcodes = apply_filters('FHEE__EE_Shortcodes__shortcodes', $this->_shortcodes, $this); |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | { |
249 | 249 | |
250 | 250 | // first test to make sure we've got an array! |
251 | - if (! is_array($this->_data)) { |
|
251 | + if ( ! is_array($this->_data)) { |
|
252 | 252 | throw new EE_Error( |
253 | 253 | sprintf( |
254 | 254 | esc_html__( |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | } |
263 | 263 | |
264 | 264 | // next test to make sure we've got the required template in the index! |
265 | - if (! isset($this->_data['template'])) { |
|
265 | + if ( ! isset($this->_data['template'])) { |
|
266 | 266 | throw new EE_Error( |
267 | 267 | sprintf( |
268 | 268 | esc_html__( |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | } |
275 | 275 | |
276 | 276 | // next test to make sure we've got got a data index in the incoming data array |
277 | - if (! isset($this->_data['data'])) { |
|
277 | + if ( ! isset($this->_data['data'])) { |
|
278 | 278 | throw new EE_Error( |
279 | 279 | esc_html__( |
280 | 280 | 'The incoming data does not have the required data index in its array', |
@@ -303,8 +303,8 @@ discard block |
||
303 | 303 | { |
304 | 304 | // make sure the required wp helper function is present |
305 | 305 | // require the shortcode file if necessary |
306 | - if (! function_exists('shortcode_parse_atts')) { |
|
307 | - require_once(ABSPATH . WPINC . '/shortcodes.php'); |
|
306 | + if ( ! function_exists('shortcode_parse_atts')) { |
|
307 | + require_once(ABSPATH.WPINC.'/shortcodes.php'); |
|
308 | 308 | } |
309 | 309 | |
310 | 310 | // let's get any attributes that may be present and set the defaults. |
@@ -329,15 +329,15 @@ discard block |
||
329 | 329 | protected function _mutate_conditional_block_in_template($shortcode, $show = true) |
330 | 330 | { |
331 | 331 | // first let's get all the matches in the template for this particular shortcode. |
332 | - preg_match_all('~' . $this->_get_conditional_block_regex($shortcode) . '~', $this->_data['template'], $matches); |
|
332 | + preg_match_all('~'.$this->_get_conditional_block_regex($shortcode).'~', $this->_data['template'], $matches); |
|
333 | 333 | |
334 | 334 | if ($matches && is_array($matches[0]) && ! empty($matches[0])) { |
335 | 335 | // we need to hide all instances of the matches |
336 | 336 | foreach ($matches[0] as $index => $content_to_show_or_hide) { |
337 | 337 | $content_to_show_or_hide = preg_quote($content_to_show_or_hide); |
338 | - $replacement = $show ? $matches[4][ $index ] : ''; |
|
338 | + $replacement = $show ? $matches[4][$index] : ''; |
|
339 | 339 | $this->_data['template'] = preg_replace( |
340 | - '~' . $content_to_show_or_hide . '~', |
|
340 | + '~'.$content_to_show_or_hide.'~', |
|
341 | 341 | $replacement, |
342 | 342 | $this->_data['template'] |
343 | 343 | ); |
@@ -16,456 +16,456 @@ |
||
16 | 16 | */ |
17 | 17 | abstract class EE_Shortcodes extends EE_Base |
18 | 18 | { |
19 | - /** |
|
20 | - * holds label for library |
|
21 | - * This is used for referencing the library label |
|
22 | - * |
|
23 | - * @access public |
|
24 | - * @var string |
|
25 | - */ |
|
26 | - public $label; |
|
27 | - |
|
28 | - |
|
29 | - /** |
|
30 | - * This property is used for referencing a short description of the library |
|
31 | - * |
|
32 | - * @access public |
|
33 | - * @var string |
|
34 | - */ |
|
35 | - public $description; |
|
36 | - |
|
37 | - |
|
38 | - /** |
|
39 | - * This will hold an array of shortcodes with the key as the shortcode ([shortcode]) and the value as a |
|
40 | - * label/description for the shortcode. |
|
41 | - * |
|
42 | - * @access protected |
|
43 | - * @var array |
|
44 | - */ |
|
45 | - protected $_shortcodes; |
|
46 | - |
|
47 | - |
|
48 | - /** |
|
49 | - * This will hold the incoming data item sent to the parser method |
|
50 | - * |
|
51 | - * @access protected |
|
52 | - * @var mixed (array|object) |
|
53 | - */ |
|
54 | - protected $_data; |
|
55 | - |
|
56 | - |
|
57 | - /** |
|
58 | - * some shortcodes may require extra data to parse. This property is provided for that. |
|
59 | - * |
|
60 | - * @var array |
|
61 | - */ |
|
62 | - protected $_extra_data; |
|
63 | - |
|
64 | - |
|
65 | - /** |
|
66 | - * EE_messenger used to generate the template being parsed. |
|
67 | - * |
|
68 | - * @since 4.5.0 |
|
69 | - * @var EE_messenger |
|
70 | - */ |
|
71 | - protected $_messenger; |
|
72 | - |
|
73 | - |
|
74 | - /** |
|
75 | - * message type used to generate the template being parsed. |
|
76 | - * |
|
77 | - * @since 4.5.0 |
|
78 | - * @var EE_message_type |
|
79 | - */ |
|
80 | - protected $_message_type; |
|
81 | - |
|
82 | - |
|
83 | - /** |
|
84 | - * context used for the template being parsed |
|
85 | - * |
|
86 | - * @since 4.5.0 |
|
87 | - * @var string |
|
88 | - */ |
|
89 | - protected $_context; |
|
90 | - |
|
91 | - |
|
92 | - /** |
|
93 | - * Specific Message Template Group ID |
|
94 | - * |
|
95 | - * @since 4.5.0 |
|
96 | - * @var int |
|
97 | - */ |
|
98 | - protected $_GRP_ID; |
|
99 | - |
|
100 | - |
|
101 | - /** |
|
102 | - * @since 4.9.0 |
|
103 | - * @type EE_Message |
|
104 | - */ |
|
105 | - protected $_message; |
|
106 | - |
|
107 | - |
|
108 | - /** |
|
109 | - * This will hold an instance of the EEH_Parse_Shortcodes helper that will be used when handling list type |
|
110 | - * shortcodes |
|
111 | - * |
|
112 | - * @var EEH_Parse_Shortcodes |
|
113 | - */ |
|
114 | - protected $_shortcode_helper; |
|
115 | - |
|
116 | - |
|
117 | - public function __construct() |
|
118 | - { |
|
119 | - $this->_set_defaults(); |
|
120 | - $this->_init_props(); |
|
121 | - } |
|
122 | - |
|
123 | - |
|
124 | - /** |
|
125 | - * This sets the defaults for the properties. Child classes will override these properties in their _init_props |
|
126 | - * method |
|
127 | - */ |
|
128 | - private function _set_defaults() |
|
129 | - { |
|
130 | - $this->name = $this->description = ''; |
|
131 | - $this->_shortcodes = array(); |
|
132 | - $this->_set_shortcode_helper(); |
|
133 | - } |
|
134 | - |
|
135 | - |
|
136 | - /** |
|
137 | - * loads an instance of the EE_Shortcode_Parser helper when requested |
|
138 | - */ |
|
139 | - protected function _set_shortcode_helper() |
|
140 | - { |
|
141 | - // get shortcode_replace instance- set when _get_messages is called in child... |
|
142 | - $this->_shortcode_helper = new EEH_Parse_Shortcodes(); |
|
143 | - } |
|
144 | - |
|
145 | - |
|
146 | - public function get_shortcode_helper() |
|
147 | - { |
|
148 | - if (! $this->_shortcode_helper instanceof EEH_Parse_Shortcodes) { |
|
149 | - $this->_set_shortcode_helper(); |
|
150 | - } |
|
151 | - return $this->_shortcode_helper; |
|
152 | - } |
|
153 | - |
|
154 | - |
|
155 | - /** |
|
156 | - * This is the public method for kicking of the parser included with each child. It can be overridden by child |
|
157 | - * classes if necessary (see EE_Questions_Answers for example) |
|
158 | - * |
|
159 | - * @param string $shortcode incoming shortcode to be parsed |
|
160 | - * @param mixed (object|array) $data incoming data to be be used for parsing |
|
161 | - * @param mixed (object|array) $extra_data extra incoming data (usually EE_Messages_Addressee) |
|
162 | - * @return string parsed shortcode. |
|
163 | - */ |
|
164 | - public function parser($shortcode, $data, $extra_data = array()) |
|
165 | - { |
|
166 | - |
|
167 | - // filter setup shortcodes |
|
168 | - $this->_shortcodes = $this->get_shortcodes(); |
|
169 | - |
|
170 | - // we need to setup any dynamic shortcodes so that they work with the array_key_exists |
|
171 | - preg_match_all('/(\[[A-Za-z0-9\_]+_\*)/', $shortcode, $matches); |
|
172 | - $sc_to_verify = ! empty($matches[0]) ? $matches[0][0] . ']' : $shortcode; |
|
173 | - |
|
174 | - // first we want to make sure this is a valid shortcode |
|
175 | - if (! array_key_exists($sc_to_verify, $this->_shortcodes)) { |
|
176 | - return false; |
|
177 | - } //get out, this parser doesn't handle the incoming shortcode. |
|
178 | - $this->_data = $data; |
|
179 | - $this->_extra_data = $extra_data; |
|
180 | - $this->_set_messages_properties(); |
|
181 | - $parsed = apply_filters( |
|
182 | - 'FHEE__' . get_class($this) . '__parser_after', |
|
183 | - $this->_parser($shortcode), |
|
184 | - $shortcode, |
|
185 | - $data, |
|
186 | - $extra_data, |
|
187 | - $this |
|
188 | - ); |
|
189 | - |
|
190 | - // note the below filter applies to ALL shortcode parsers... be careful! |
|
191 | - return apply_filters('FHEE__EE_Shortcodes__parser_after', $parsed, $shortcode, $data, $extra_data, $this); |
|
192 | - } |
|
193 | - |
|
194 | - |
|
195 | - /** |
|
196 | - * This method just returns the shortcodes in the $_shortcodes array property. |
|
197 | - * |
|
198 | - * @access public |
|
199 | - * @return array array of shortcodes => description pairs |
|
200 | - */ |
|
201 | - public function get_shortcodes() |
|
202 | - { |
|
203 | - $this->_shortcodes = apply_filters('FHEE__' . get_class($this) . '__shortcodes', $this->_shortcodes, $this); |
|
204 | - |
|
205 | - // note the below filter applies to ALL shortcode parsers... be careful! |
|
206 | - $this->_shortcodes = apply_filters('FHEE__EE_Shortcodes__shortcodes', $this->_shortcodes, $this); |
|
207 | - |
|
208 | - return $this->_shortcodes; |
|
209 | - } |
|
210 | - |
|
211 | - |
|
212 | - /** |
|
213 | - * Child classes use this method to set the $name, $description, and $_shortcodes properties. |
|
214 | - * |
|
215 | - * @abstract |
|
216 | - * @access protected |
|
217 | - * @return void |
|
218 | - */ |
|
219 | - abstract protected function _init_props(); |
|
220 | - |
|
221 | - |
|
222 | - /** |
|
223 | - * This method will give parsing instructions for each shortcode defined in the _shortcodes array. Child methods |
|
224 | - * will have to take care of handling. |
|
225 | - * |
|
226 | - * @abstract |
|
227 | - * @access protected |
|
228 | - * @param string $shortcode the shortcode to be parsed. |
|
229 | - * @param mixed (object|array) $data incoming data for the parser. The data could be either an object or |
|
230 | - * array because there are some shortcodes that might be replaced by prepared data that |
|
231 | - * has multiple items in a list (i.e. list of attendees in an event and we're showing |
|
232 | - * fname/lname for each attendee). In this case data will be in an array. Otherwise |
|
233 | - * the data shoudl be in a properly formatted object. The |
|
234 | - * EEH_Parse_Shortcodes.helper.php describes the data object we're expecting. |
|
235 | - * @return string parsed shortcode |
|
236 | - */ |
|
237 | - abstract protected function _parser($shortcode); |
|
238 | - |
|
239 | - |
|
240 | - /** |
|
241 | - * This just validates incoming data for list type shortcode parsers (and they call this method) to make sure it |
|
242 | - * meets their requirements |
|
243 | - * |
|
244 | - * @return mixed (void|exception) If validation fails we'll throw an exception. |
|
245 | - */ |
|
246 | - protected function _validate_list_requirements() |
|
247 | - { |
|
248 | - |
|
249 | - // first test to make sure we've got an array! |
|
250 | - if (! is_array($this->_data)) { |
|
251 | - throw new EE_Error( |
|
252 | - sprintf( |
|
253 | - esc_html__( |
|
254 | - 'Expecting an array for the data sent to %s. Instead it was %s', |
|
255 | - 'event_espresso' |
|
256 | - ), |
|
257 | - get_class($this), |
|
258 | - gettype($this->_data) |
|
259 | - ) |
|
260 | - ); |
|
261 | - } |
|
262 | - |
|
263 | - // next test to make sure we've got the required template in the index! |
|
264 | - if (! isset($this->_data['template'])) { |
|
265 | - throw new EE_Error( |
|
266 | - sprintf( |
|
267 | - esc_html__( |
|
268 | - 'The incoming data does not have the required template index in its array', |
|
269 | - 'event_espresso' |
|
270 | - ) |
|
271 | - ) |
|
272 | - ); |
|
273 | - } |
|
274 | - |
|
275 | - // next test to make sure we've got got a data index in the incoming data array |
|
276 | - if (! isset($this->_data['data'])) { |
|
277 | - throw new EE_Error( |
|
278 | - esc_html__( |
|
279 | - 'The incoming data does not have the required data index in its array', |
|
280 | - 'event_espresso' |
|
281 | - ) |
|
282 | - ); |
|
283 | - } |
|
284 | - |
|
285 | - // all is well let's make sure _extra_data always has the values needed. |
|
286 | - // let's make sure that extra_data includes all templates (for later parsing if necessary) |
|
287 | - if (empty($this->_extra_data) || (empty($this->_extra_data['data']) && empty($this->_extra_data['template']))) { |
|
288 | - $this->_extra_data['data'] = $this->_data['data']; |
|
289 | - $this->_extra_data['template'] = $this->_data['template']; |
|
290 | - } |
|
291 | - } |
|
292 | - |
|
293 | - |
|
294 | - /** |
|
295 | - * This returns any attributes that may be existing on an EE_Shortcode |
|
296 | - * |
|
297 | - * @since 4.5.0 |
|
298 | - * @param string $shortcode incoming shortcode |
|
299 | - * @return array An array with the attributes |
|
300 | - */ |
|
301 | - protected function _get_shortcode_attrs($shortcode) |
|
302 | - { |
|
303 | - // make sure the required wp helper function is present |
|
304 | - // require the shortcode file if necessary |
|
305 | - if (! function_exists('shortcode_parse_atts')) { |
|
306 | - require_once(ABSPATH . WPINC . '/shortcodes.php'); |
|
307 | - } |
|
308 | - |
|
309 | - // let's get any attributes that may be present and set the defaults. |
|
310 | - $shortcode_to_parse = str_replace('[', '', str_replace(']', '', $shortcode)); |
|
311 | - return shortcode_parse_atts($shortcode_to_parse); |
|
312 | - } |
|
313 | - |
|
314 | - |
|
315 | - /** |
|
316 | - * Conditional blocks are shortcode patterns with an opening conditional tag `[IF_*]` and a corresponding |
|
317 | - * closing tag (eg `[/IF_*]`). The content within the tags will be displayed/hidden depending on whatever |
|
318 | - * conditions existed in the opening tag. This method handles parsing the actual template to show/hide this |
|
319 | - * conditional content. |
|
320 | - * |
|
321 | - * @since 4.9.32 |
|
322 | - * |
|
323 | - * @param string $shortcode This should be original shortcode as used in the template and passed to the parser. |
|
324 | - * @param bool $show true means the opening and closing tags are removed and the content is left showing, |
|
325 | - * false means the opening and closing tags and the contained content are removed. |
|
326 | - * @return string The template for the shortcode is returned. |
|
327 | - */ |
|
328 | - protected function _mutate_conditional_block_in_template($shortcode, $show = true) |
|
329 | - { |
|
330 | - // first let's get all the matches in the template for this particular shortcode. |
|
331 | - preg_match_all('~' . $this->_get_conditional_block_regex($shortcode) . '~', $this->_data['template'], $matches); |
|
332 | - |
|
333 | - if ($matches && is_array($matches[0]) && ! empty($matches[0])) { |
|
334 | - // we need to hide all instances of the matches |
|
335 | - foreach ($matches[0] as $index => $content_to_show_or_hide) { |
|
336 | - $content_to_show_or_hide = preg_quote($content_to_show_or_hide); |
|
337 | - $replacement = $show ? $matches[4][ $index ] : ''; |
|
338 | - $this->_data['template'] = preg_replace( |
|
339 | - '~' . $content_to_show_or_hide . '~', |
|
340 | - $replacement, |
|
341 | - $this->_data['template'] |
|
342 | - ); |
|
343 | - } |
|
344 | - } |
|
345 | - // return $template |
|
346 | - return $this->_data['template']; |
|
347 | - } |
|
348 | - |
|
349 | - |
|
350 | - /** |
|
351 | - * This returns the regex pattern to use for conditional shortcodes parsing. |
|
352 | - * |
|
353 | - * Note: regex comes in part from the WP `get_shortcode_regex` expression in \wp-includes\shortcodes.php |
|
354 | - * |
|
355 | - * @param $shortcode |
|
356 | - * @since 4.9.32 |
|
357 | - * @return string |
|
358 | - */ |
|
359 | - private function _get_conditional_block_regex($shortcode) |
|
360 | - { |
|
361 | - // get just the shortcode tag for the match |
|
362 | - preg_match('@\[([^<>&/\[\]\x00-\x20=]++)@', $shortcode, $shortcode_tag_matches); |
|
363 | - if (empty($shortcode_tag_matches[1])) { |
|
364 | - return $this->_data['template']; |
|
365 | - } |
|
366 | - |
|
367 | - $shortcode_tag = $shortcode_tag_matches[1]; |
|
368 | - // get attributes_part_of_tag |
|
369 | - $attributes_part = preg_quote(str_replace(array($shortcode_tag, '[', ']'), '', $shortcode)); |
|
370 | - // escape |
|
371 | - $shortcode_tag = preg_quote($shortcode_tag); |
|
372 | - |
|
373 | - return |
|
374 | - '\[' // Opening Bracket |
|
375 | - . "($shortcode_tag)$attributes_part" // 1: Shortcode Name |
|
376 | - . '(?![\w-])' // Not followed by word character or hyphen |
|
377 | - . '(' // 2: Unroll the loop: Inside the opening shortcode tag |
|
378 | - . '[^\]\/]*' // Not a closing bracket or forward slash |
|
379 | - . '(?:' |
|
380 | - . '\/(?!\])' // A forward slash not followed by a closing bracket |
|
381 | - . '[^\]\/]*' // Not a closing bracket or forward slash. |
|
382 | - . ')*?' |
|
383 | - . ')' |
|
384 | - . '(?:' |
|
385 | - . '(\/)' // 3. Self closing tag ... |
|
386 | - . '\]' // ... and closing bracket |
|
387 | - . '|' |
|
388 | - . '\]' // Closing bracket |
|
389 | - . '(?:' |
|
390 | - . '(' // 4: Unroll the loop: Optionally, anything between the opening and closing brackets |
|
391 | - . '[^\[]*+' // Not an opening bracket |
|
392 | - . '(?:' |
|
393 | - . '\[(?!\/\1\])' // An opening bracket not followed by the closing shortcode tag. |
|
394 | - . '[^\[]*+' // Not an opening bracket |
|
395 | - . ')*+' |
|
396 | - . ')' |
|
397 | - . '\[\/\1\]' // Closing shortcode tag |
|
398 | - . ')?' |
|
399 | - . ')'; |
|
400 | - } |
|
401 | - |
|
402 | - |
|
403 | - /** |
|
404 | - * This sets the properties related to the messages system |
|
405 | - * |
|
406 | - * @since 4.5.0 |
|
407 | - * @return void |
|
408 | - */ |
|
409 | - protected function _set_messages_properties() |
|
410 | - { |
|
411 | - // should be in _extra_data |
|
412 | - if (isset($this->_extra_data['messenger'])) { |
|
413 | - $this->_messenger = $this->_extra_data['messenger']; |
|
414 | - $this->_message_type = $this->_extra_data['message_type']; |
|
415 | - $this->_context = $this->_extra_data['message'] instanceof EE_Message |
|
416 | - ? $this->_extra_data['message']->context() : ''; |
|
417 | - $this->_GRP_ID = $this->_extra_data['message'] instanceof EE_Message |
|
418 | - ? $this->_extra_data['message']->GRP_ID() : 0; |
|
419 | - $this->_message = $this->_extra_data['message'] instanceof EE_Message ? $this->_extra_data['message'] |
|
420 | - : null; |
|
421 | - } |
|
422 | - } |
|
423 | - |
|
424 | - |
|
425 | - /** |
|
426 | - * This returns whatever the set message type object is that was set on this shortcode parser. |
|
427 | - * |
|
428 | - * @since 4.5.0 |
|
429 | - * @return EE_message_type |
|
430 | - */ |
|
431 | - public function get_set_message_type() |
|
432 | - { |
|
433 | - return $this->_message_type; |
|
434 | - } |
|
435 | - |
|
436 | - |
|
437 | - /** |
|
438 | - * This returns whatever the set messenger object is that was set on this shortcode parser |
|
439 | - * |
|
440 | - * @since 4.5.0 |
|
441 | - * @return EE_messenger |
|
442 | - */ |
|
443 | - public function get_set_messenger() |
|
444 | - { |
|
445 | - return $this->_messenger; |
|
446 | - } |
|
447 | - |
|
448 | - |
|
449 | - /** |
|
450 | - * This returns whatever the set context string is on this shortcode parser. |
|
451 | - * |
|
452 | - * @since 4.5.0 |
|
453 | - * @return string |
|
454 | - */ |
|
455 | - public function get_set_context() |
|
456 | - { |
|
457 | - return $this->_context; |
|
458 | - } |
|
459 | - |
|
460 | - |
|
461 | - /** |
|
462 | - * This returns whatever the set EE_Message object is on this shortcode. |
|
463 | - * |
|
464 | - * @since 4.9.0 |
|
465 | - * @return EE_Message |
|
466 | - */ |
|
467 | - public function get_set_message() |
|
468 | - { |
|
469 | - return $this->_message; |
|
470 | - } |
|
19 | + /** |
|
20 | + * holds label for library |
|
21 | + * This is used for referencing the library label |
|
22 | + * |
|
23 | + * @access public |
|
24 | + * @var string |
|
25 | + */ |
|
26 | + public $label; |
|
27 | + |
|
28 | + |
|
29 | + /** |
|
30 | + * This property is used for referencing a short description of the library |
|
31 | + * |
|
32 | + * @access public |
|
33 | + * @var string |
|
34 | + */ |
|
35 | + public $description; |
|
36 | + |
|
37 | + |
|
38 | + /** |
|
39 | + * This will hold an array of shortcodes with the key as the shortcode ([shortcode]) and the value as a |
|
40 | + * label/description for the shortcode. |
|
41 | + * |
|
42 | + * @access protected |
|
43 | + * @var array |
|
44 | + */ |
|
45 | + protected $_shortcodes; |
|
46 | + |
|
47 | + |
|
48 | + /** |
|
49 | + * This will hold the incoming data item sent to the parser method |
|
50 | + * |
|
51 | + * @access protected |
|
52 | + * @var mixed (array|object) |
|
53 | + */ |
|
54 | + protected $_data; |
|
55 | + |
|
56 | + |
|
57 | + /** |
|
58 | + * some shortcodes may require extra data to parse. This property is provided for that. |
|
59 | + * |
|
60 | + * @var array |
|
61 | + */ |
|
62 | + protected $_extra_data; |
|
63 | + |
|
64 | + |
|
65 | + /** |
|
66 | + * EE_messenger used to generate the template being parsed. |
|
67 | + * |
|
68 | + * @since 4.5.0 |
|
69 | + * @var EE_messenger |
|
70 | + */ |
|
71 | + protected $_messenger; |
|
72 | + |
|
73 | + |
|
74 | + /** |
|
75 | + * message type used to generate the template being parsed. |
|
76 | + * |
|
77 | + * @since 4.5.0 |
|
78 | + * @var EE_message_type |
|
79 | + */ |
|
80 | + protected $_message_type; |
|
81 | + |
|
82 | + |
|
83 | + /** |
|
84 | + * context used for the template being parsed |
|
85 | + * |
|
86 | + * @since 4.5.0 |
|
87 | + * @var string |
|
88 | + */ |
|
89 | + protected $_context; |
|
90 | + |
|
91 | + |
|
92 | + /** |
|
93 | + * Specific Message Template Group ID |
|
94 | + * |
|
95 | + * @since 4.5.0 |
|
96 | + * @var int |
|
97 | + */ |
|
98 | + protected $_GRP_ID; |
|
99 | + |
|
100 | + |
|
101 | + /** |
|
102 | + * @since 4.9.0 |
|
103 | + * @type EE_Message |
|
104 | + */ |
|
105 | + protected $_message; |
|
106 | + |
|
107 | + |
|
108 | + /** |
|
109 | + * This will hold an instance of the EEH_Parse_Shortcodes helper that will be used when handling list type |
|
110 | + * shortcodes |
|
111 | + * |
|
112 | + * @var EEH_Parse_Shortcodes |
|
113 | + */ |
|
114 | + protected $_shortcode_helper; |
|
115 | + |
|
116 | + |
|
117 | + public function __construct() |
|
118 | + { |
|
119 | + $this->_set_defaults(); |
|
120 | + $this->_init_props(); |
|
121 | + } |
|
122 | + |
|
123 | + |
|
124 | + /** |
|
125 | + * This sets the defaults for the properties. Child classes will override these properties in their _init_props |
|
126 | + * method |
|
127 | + */ |
|
128 | + private function _set_defaults() |
|
129 | + { |
|
130 | + $this->name = $this->description = ''; |
|
131 | + $this->_shortcodes = array(); |
|
132 | + $this->_set_shortcode_helper(); |
|
133 | + } |
|
134 | + |
|
135 | + |
|
136 | + /** |
|
137 | + * loads an instance of the EE_Shortcode_Parser helper when requested |
|
138 | + */ |
|
139 | + protected function _set_shortcode_helper() |
|
140 | + { |
|
141 | + // get shortcode_replace instance- set when _get_messages is called in child... |
|
142 | + $this->_shortcode_helper = new EEH_Parse_Shortcodes(); |
|
143 | + } |
|
144 | + |
|
145 | + |
|
146 | + public function get_shortcode_helper() |
|
147 | + { |
|
148 | + if (! $this->_shortcode_helper instanceof EEH_Parse_Shortcodes) { |
|
149 | + $this->_set_shortcode_helper(); |
|
150 | + } |
|
151 | + return $this->_shortcode_helper; |
|
152 | + } |
|
153 | + |
|
154 | + |
|
155 | + /** |
|
156 | + * This is the public method for kicking of the parser included with each child. It can be overridden by child |
|
157 | + * classes if necessary (see EE_Questions_Answers for example) |
|
158 | + * |
|
159 | + * @param string $shortcode incoming shortcode to be parsed |
|
160 | + * @param mixed (object|array) $data incoming data to be be used for parsing |
|
161 | + * @param mixed (object|array) $extra_data extra incoming data (usually EE_Messages_Addressee) |
|
162 | + * @return string parsed shortcode. |
|
163 | + */ |
|
164 | + public function parser($shortcode, $data, $extra_data = array()) |
|
165 | + { |
|
166 | + |
|
167 | + // filter setup shortcodes |
|
168 | + $this->_shortcodes = $this->get_shortcodes(); |
|
169 | + |
|
170 | + // we need to setup any dynamic shortcodes so that they work with the array_key_exists |
|
171 | + preg_match_all('/(\[[A-Za-z0-9\_]+_\*)/', $shortcode, $matches); |
|
172 | + $sc_to_verify = ! empty($matches[0]) ? $matches[0][0] . ']' : $shortcode; |
|
173 | + |
|
174 | + // first we want to make sure this is a valid shortcode |
|
175 | + if (! array_key_exists($sc_to_verify, $this->_shortcodes)) { |
|
176 | + return false; |
|
177 | + } //get out, this parser doesn't handle the incoming shortcode. |
|
178 | + $this->_data = $data; |
|
179 | + $this->_extra_data = $extra_data; |
|
180 | + $this->_set_messages_properties(); |
|
181 | + $parsed = apply_filters( |
|
182 | + 'FHEE__' . get_class($this) . '__parser_after', |
|
183 | + $this->_parser($shortcode), |
|
184 | + $shortcode, |
|
185 | + $data, |
|
186 | + $extra_data, |
|
187 | + $this |
|
188 | + ); |
|
189 | + |
|
190 | + // note the below filter applies to ALL shortcode parsers... be careful! |
|
191 | + return apply_filters('FHEE__EE_Shortcodes__parser_after', $parsed, $shortcode, $data, $extra_data, $this); |
|
192 | + } |
|
193 | + |
|
194 | + |
|
195 | + /** |
|
196 | + * This method just returns the shortcodes in the $_shortcodes array property. |
|
197 | + * |
|
198 | + * @access public |
|
199 | + * @return array array of shortcodes => description pairs |
|
200 | + */ |
|
201 | + public function get_shortcodes() |
|
202 | + { |
|
203 | + $this->_shortcodes = apply_filters('FHEE__' . get_class($this) . '__shortcodes', $this->_shortcodes, $this); |
|
204 | + |
|
205 | + // note the below filter applies to ALL shortcode parsers... be careful! |
|
206 | + $this->_shortcodes = apply_filters('FHEE__EE_Shortcodes__shortcodes', $this->_shortcodes, $this); |
|
207 | + |
|
208 | + return $this->_shortcodes; |
|
209 | + } |
|
210 | + |
|
211 | + |
|
212 | + /** |
|
213 | + * Child classes use this method to set the $name, $description, and $_shortcodes properties. |
|
214 | + * |
|
215 | + * @abstract |
|
216 | + * @access protected |
|
217 | + * @return void |
|
218 | + */ |
|
219 | + abstract protected function _init_props(); |
|
220 | + |
|
221 | + |
|
222 | + /** |
|
223 | + * This method will give parsing instructions for each shortcode defined in the _shortcodes array. Child methods |
|
224 | + * will have to take care of handling. |
|
225 | + * |
|
226 | + * @abstract |
|
227 | + * @access protected |
|
228 | + * @param string $shortcode the shortcode to be parsed. |
|
229 | + * @param mixed (object|array) $data incoming data for the parser. The data could be either an object or |
|
230 | + * array because there are some shortcodes that might be replaced by prepared data that |
|
231 | + * has multiple items in a list (i.e. list of attendees in an event and we're showing |
|
232 | + * fname/lname for each attendee). In this case data will be in an array. Otherwise |
|
233 | + * the data shoudl be in a properly formatted object. The |
|
234 | + * EEH_Parse_Shortcodes.helper.php describes the data object we're expecting. |
|
235 | + * @return string parsed shortcode |
|
236 | + */ |
|
237 | + abstract protected function _parser($shortcode); |
|
238 | + |
|
239 | + |
|
240 | + /** |
|
241 | + * This just validates incoming data for list type shortcode parsers (and they call this method) to make sure it |
|
242 | + * meets their requirements |
|
243 | + * |
|
244 | + * @return mixed (void|exception) If validation fails we'll throw an exception. |
|
245 | + */ |
|
246 | + protected function _validate_list_requirements() |
|
247 | + { |
|
248 | + |
|
249 | + // first test to make sure we've got an array! |
|
250 | + if (! is_array($this->_data)) { |
|
251 | + throw new EE_Error( |
|
252 | + sprintf( |
|
253 | + esc_html__( |
|
254 | + 'Expecting an array for the data sent to %s. Instead it was %s', |
|
255 | + 'event_espresso' |
|
256 | + ), |
|
257 | + get_class($this), |
|
258 | + gettype($this->_data) |
|
259 | + ) |
|
260 | + ); |
|
261 | + } |
|
262 | + |
|
263 | + // next test to make sure we've got the required template in the index! |
|
264 | + if (! isset($this->_data['template'])) { |
|
265 | + throw new EE_Error( |
|
266 | + sprintf( |
|
267 | + esc_html__( |
|
268 | + 'The incoming data does not have the required template index in its array', |
|
269 | + 'event_espresso' |
|
270 | + ) |
|
271 | + ) |
|
272 | + ); |
|
273 | + } |
|
274 | + |
|
275 | + // next test to make sure we've got got a data index in the incoming data array |
|
276 | + if (! isset($this->_data['data'])) { |
|
277 | + throw new EE_Error( |
|
278 | + esc_html__( |
|
279 | + 'The incoming data does not have the required data index in its array', |
|
280 | + 'event_espresso' |
|
281 | + ) |
|
282 | + ); |
|
283 | + } |
|
284 | + |
|
285 | + // all is well let's make sure _extra_data always has the values needed. |
|
286 | + // let's make sure that extra_data includes all templates (for later parsing if necessary) |
|
287 | + if (empty($this->_extra_data) || (empty($this->_extra_data['data']) && empty($this->_extra_data['template']))) { |
|
288 | + $this->_extra_data['data'] = $this->_data['data']; |
|
289 | + $this->_extra_data['template'] = $this->_data['template']; |
|
290 | + } |
|
291 | + } |
|
292 | + |
|
293 | + |
|
294 | + /** |
|
295 | + * This returns any attributes that may be existing on an EE_Shortcode |
|
296 | + * |
|
297 | + * @since 4.5.0 |
|
298 | + * @param string $shortcode incoming shortcode |
|
299 | + * @return array An array with the attributes |
|
300 | + */ |
|
301 | + protected function _get_shortcode_attrs($shortcode) |
|
302 | + { |
|
303 | + // make sure the required wp helper function is present |
|
304 | + // require the shortcode file if necessary |
|
305 | + if (! function_exists('shortcode_parse_atts')) { |
|
306 | + require_once(ABSPATH . WPINC . '/shortcodes.php'); |
|
307 | + } |
|
308 | + |
|
309 | + // let's get any attributes that may be present and set the defaults. |
|
310 | + $shortcode_to_parse = str_replace('[', '', str_replace(']', '', $shortcode)); |
|
311 | + return shortcode_parse_atts($shortcode_to_parse); |
|
312 | + } |
|
313 | + |
|
314 | + |
|
315 | + /** |
|
316 | + * Conditional blocks are shortcode patterns with an opening conditional tag `[IF_*]` and a corresponding |
|
317 | + * closing tag (eg `[/IF_*]`). The content within the tags will be displayed/hidden depending on whatever |
|
318 | + * conditions existed in the opening tag. This method handles parsing the actual template to show/hide this |
|
319 | + * conditional content. |
|
320 | + * |
|
321 | + * @since 4.9.32 |
|
322 | + * |
|
323 | + * @param string $shortcode This should be original shortcode as used in the template and passed to the parser. |
|
324 | + * @param bool $show true means the opening and closing tags are removed and the content is left showing, |
|
325 | + * false means the opening and closing tags and the contained content are removed. |
|
326 | + * @return string The template for the shortcode is returned. |
|
327 | + */ |
|
328 | + protected function _mutate_conditional_block_in_template($shortcode, $show = true) |
|
329 | + { |
|
330 | + // first let's get all the matches in the template for this particular shortcode. |
|
331 | + preg_match_all('~' . $this->_get_conditional_block_regex($shortcode) . '~', $this->_data['template'], $matches); |
|
332 | + |
|
333 | + if ($matches && is_array($matches[0]) && ! empty($matches[0])) { |
|
334 | + // we need to hide all instances of the matches |
|
335 | + foreach ($matches[0] as $index => $content_to_show_or_hide) { |
|
336 | + $content_to_show_or_hide = preg_quote($content_to_show_or_hide); |
|
337 | + $replacement = $show ? $matches[4][ $index ] : ''; |
|
338 | + $this->_data['template'] = preg_replace( |
|
339 | + '~' . $content_to_show_or_hide . '~', |
|
340 | + $replacement, |
|
341 | + $this->_data['template'] |
|
342 | + ); |
|
343 | + } |
|
344 | + } |
|
345 | + // return $template |
|
346 | + return $this->_data['template']; |
|
347 | + } |
|
348 | + |
|
349 | + |
|
350 | + /** |
|
351 | + * This returns the regex pattern to use for conditional shortcodes parsing. |
|
352 | + * |
|
353 | + * Note: regex comes in part from the WP `get_shortcode_regex` expression in \wp-includes\shortcodes.php |
|
354 | + * |
|
355 | + * @param $shortcode |
|
356 | + * @since 4.9.32 |
|
357 | + * @return string |
|
358 | + */ |
|
359 | + private function _get_conditional_block_regex($shortcode) |
|
360 | + { |
|
361 | + // get just the shortcode tag for the match |
|
362 | + preg_match('@\[([^<>&/\[\]\x00-\x20=]++)@', $shortcode, $shortcode_tag_matches); |
|
363 | + if (empty($shortcode_tag_matches[1])) { |
|
364 | + return $this->_data['template']; |
|
365 | + } |
|
366 | + |
|
367 | + $shortcode_tag = $shortcode_tag_matches[1]; |
|
368 | + // get attributes_part_of_tag |
|
369 | + $attributes_part = preg_quote(str_replace(array($shortcode_tag, '[', ']'), '', $shortcode)); |
|
370 | + // escape |
|
371 | + $shortcode_tag = preg_quote($shortcode_tag); |
|
372 | + |
|
373 | + return |
|
374 | + '\[' // Opening Bracket |
|
375 | + . "($shortcode_tag)$attributes_part" // 1: Shortcode Name |
|
376 | + . '(?![\w-])' // Not followed by word character or hyphen |
|
377 | + . '(' // 2: Unroll the loop: Inside the opening shortcode tag |
|
378 | + . '[^\]\/]*' // Not a closing bracket or forward slash |
|
379 | + . '(?:' |
|
380 | + . '\/(?!\])' // A forward slash not followed by a closing bracket |
|
381 | + . '[^\]\/]*' // Not a closing bracket or forward slash. |
|
382 | + . ')*?' |
|
383 | + . ')' |
|
384 | + . '(?:' |
|
385 | + . '(\/)' // 3. Self closing tag ... |
|
386 | + . '\]' // ... and closing bracket |
|
387 | + . '|' |
|
388 | + . '\]' // Closing bracket |
|
389 | + . '(?:' |
|
390 | + . '(' // 4: Unroll the loop: Optionally, anything between the opening and closing brackets |
|
391 | + . '[^\[]*+' // Not an opening bracket |
|
392 | + . '(?:' |
|
393 | + . '\[(?!\/\1\])' // An opening bracket not followed by the closing shortcode tag. |
|
394 | + . '[^\[]*+' // Not an opening bracket |
|
395 | + . ')*+' |
|
396 | + . ')' |
|
397 | + . '\[\/\1\]' // Closing shortcode tag |
|
398 | + . ')?' |
|
399 | + . ')'; |
|
400 | + } |
|
401 | + |
|
402 | + |
|
403 | + /** |
|
404 | + * This sets the properties related to the messages system |
|
405 | + * |
|
406 | + * @since 4.5.0 |
|
407 | + * @return void |
|
408 | + */ |
|
409 | + protected function _set_messages_properties() |
|
410 | + { |
|
411 | + // should be in _extra_data |
|
412 | + if (isset($this->_extra_data['messenger'])) { |
|
413 | + $this->_messenger = $this->_extra_data['messenger']; |
|
414 | + $this->_message_type = $this->_extra_data['message_type']; |
|
415 | + $this->_context = $this->_extra_data['message'] instanceof EE_Message |
|
416 | + ? $this->_extra_data['message']->context() : ''; |
|
417 | + $this->_GRP_ID = $this->_extra_data['message'] instanceof EE_Message |
|
418 | + ? $this->_extra_data['message']->GRP_ID() : 0; |
|
419 | + $this->_message = $this->_extra_data['message'] instanceof EE_Message ? $this->_extra_data['message'] |
|
420 | + : null; |
|
421 | + } |
|
422 | + } |
|
423 | + |
|
424 | + |
|
425 | + /** |
|
426 | + * This returns whatever the set message type object is that was set on this shortcode parser. |
|
427 | + * |
|
428 | + * @since 4.5.0 |
|
429 | + * @return EE_message_type |
|
430 | + */ |
|
431 | + public function get_set_message_type() |
|
432 | + { |
|
433 | + return $this->_message_type; |
|
434 | + } |
|
435 | + |
|
436 | + |
|
437 | + /** |
|
438 | + * This returns whatever the set messenger object is that was set on this shortcode parser |
|
439 | + * |
|
440 | + * @since 4.5.0 |
|
441 | + * @return EE_messenger |
|
442 | + */ |
|
443 | + public function get_set_messenger() |
|
444 | + { |
|
445 | + return $this->_messenger; |
|
446 | + } |
|
447 | + |
|
448 | + |
|
449 | + /** |
|
450 | + * This returns whatever the set context string is on this shortcode parser. |
|
451 | + * |
|
452 | + * @since 4.5.0 |
|
453 | + * @return string |
|
454 | + */ |
|
455 | + public function get_set_context() |
|
456 | + { |
|
457 | + return $this->_context; |
|
458 | + } |
|
459 | + |
|
460 | + |
|
461 | + /** |
|
462 | + * This returns whatever the set EE_Message object is on this shortcode. |
|
463 | + * |
|
464 | + * @since 4.9.0 |
|
465 | + * @return EE_Message |
|
466 | + */ |
|
467 | + public function get_set_message() |
|
468 | + { |
|
469 | + return $this->_message; |
|
470 | + } |
|
471 | 471 | } |
@@ -24,9 +24,12 @@ |
||
24 | 24 | <title><?php echo wp_strip_all_tags($title); ?></title> |
25 | 25 | <?php if ($enqueue_wp_assets) : ?> |
26 | 26 | <?php wp_head(); ?> |
27 | - <?php else : ?> |
|
27 | + <?php else { |
|
28 | + : ?> |
|
28 | 29 | <?php foreach ($css as $url) :?> |
29 | - <link rel="stylesheet" type="text/css" href="<?php echo esc_url_raw($url); ?>"> |
|
30 | + <link rel="stylesheet" type="text/css" href="<?php echo esc_url_raw($url); |
|
31 | +} |
|
32 | +?>"> |
|
30 | 33 | <?php endforeach; ?> |
31 | 34 | <script type="text/javascript"> |
32 | 35 | <?php echo $eei18n; ?> |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | <?php echo $eei18n; ?> |
37 | 37 | </script> |
38 | 38 | <?php foreach ($header_js as $key => $url) :?> |
39 | - <?php $header_attributes = isset($header_js_attributes[ $key ]) ? $header_js_attributes[ $key ] : ''; ?> |
|
39 | + <?php $header_attributes = isset($header_js_attributes[$key]) ? $header_js_attributes[$key] : ''; ?> |
|
40 | 40 | <script type="text/javascript" src="<?php echo esc_url_raw($url); ?>" <?php echo AttributesSanitizer::clean($header_attributes, AllowedTags::getAllowedTags(), 'script'); ?>></script> |
41 | 41 | <?php endforeach; ?> |
42 | 42 | <?php endif; ?> |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | <?php echo wp_kses($content, AllowedTags::getWithFullTags()); ?> |
48 | 48 | </div> |
49 | 49 | <?php foreach ($footer_js as $key => $url) : ?> |
50 | - <?php $footer_attributes = isset($footer_js_attributes[ $key ]) ? $footer_js_attributes[ $key ] : ''; ?> |
|
50 | + <?php $footer_attributes = isset($footer_js_attributes[$key]) ? $footer_js_attributes[$key] : ''; ?> |
|
51 | 51 | <script type="text/javascript" src="<?php echo esc_url_raw($url); ?>" <?php echo AttributesSanitizer::clean($footer_attributes, AllowedTags::getAllowedTags(), 'script'); ?>></script> |
52 | 52 | <?php endforeach; ?> |
53 | 53 | <?php if ($enqueue_wp_assets) : ?> |