@@ -3,12 +3,12 @@ discard block |
||
3 | 3 | |
4 | 4 | global $post; |
5 | 5 | |
6 | -do_action( 'AHEE__content_espresso_venues_template__before_featured_img', $post ); |
|
6 | +do_action('AHEE__content_espresso_venues_template__before_featured_img', $post); |
|
7 | 7 | |
8 | -if ( has_post_thumbnail( $post->ID )) : |
|
9 | - if ( $img_ID = get_post_thumbnail_id( $post->ID )) : |
|
10 | - if ( $featured_img = wp_get_attachment_image_src( $img_ID, 'large' )) : |
|
11 | - $caption = get_post( get_post( $img_ID ))->post_excerpt; |
|
8 | +if (has_post_thumbnail($post->ID)) : |
|
9 | + if ($img_ID = get_post_thumbnail_id($post->ID)) : |
|
10 | + if ($featured_img = wp_get_attachment_image_src($img_ID, 'large')) : |
|
11 | + $caption = get_post(get_post($img_ID))->post_excerpt; |
|
12 | 12 | $wrap_class .= ' has-img'; |
13 | 13 | ?> |
14 | 14 | <div id="ee-venue-img-dv-<?php echo esc_attr($post->ID); ?>" class="ee-venue-img-dv"> |
@@ -26,5 +26,5 @@ discard block |
||
26 | 26 | endif; |
27 | 27 | endif; |
28 | 28 | ?> |
29 | -<?php do_action( 'AHEE__content_espresso_venues_template__after_featured_img', $post );?> |
|
29 | +<?php do_action('AHEE__content_espresso_venues_template__after_featured_img', $post); ?> |
|
30 | 30 | <!-- .venue-content --> |
@@ -13,20 +13,20 @@ |
||
13 | 13 | <?php if ( ! post_password_required() && ( comments_open() || get_comments_number() ) ) : ?> |
14 | 14 | <span class="comments-link"> |
15 | 15 | <?php comments_popup_link( |
16 | - esc_html__( 'Leave a comment', 'event_espresso' ), |
|
17 | - esc_html__( '1 Comment', 'event_espresso' ), |
|
18 | - esc_html__( '% Comments', 'event_espresso' ) |
|
19 | - ); ?> |
|
16 | + esc_html__( 'Leave a comment', 'event_espresso' ), |
|
17 | + esc_html__( '1 Comment', 'event_espresso' ), |
|
18 | + esc_html__( '% Comments', 'event_espresso' ) |
|
19 | + ); ?> |
|
20 | 20 | </span> |
21 | 21 | |
22 | 22 | <?php |
23 | - endif; |
|
24 | - edit_post_link( |
|
25 | - esc_html__( 'Edit', 'event_espresso' ), |
|
26 | - '<span class="edit-link">', |
|
27 | - '</span>' |
|
28 | - ); |
|
29 | - ?> |
|
23 | + endif; |
|
24 | + edit_post_link( |
|
25 | + esc_html__( 'Edit', 'event_espresso' ), |
|
26 | + '<span class="edit-link">', |
|
27 | + '</span>' |
|
28 | + ); |
|
29 | + ?> |
|
30 | 30 | </div> |
31 | 31 | |
32 | 32 | <?php endif; |
@@ -4,27 +4,27 @@ discard block |
||
4 | 4 | <div class="event-content"> |
5 | 5 | <?php use EventEspresso\core\services\request\sanitizers\AllowedTags; |
6 | 6 | |
7 | -if ( apply_filters( 'FHEE__content_espresso_events_details_template__display_entry_meta', TRUE )): ?> |
|
7 | +if (apply_filters('FHEE__content_espresso_events_details_template__display_entry_meta', TRUE)): ?> |
|
8 | 8 | |
9 | 9 | <div class="entry-meta"> |
10 | 10 | |
11 | 11 | <span class="tags-links"> |
12 | - <?php espresso_event_categories( $post->ID, TRUE, TRUE ); ?> |
|
12 | + <?php espresso_event_categories($post->ID, TRUE, TRUE); ?> |
|
13 | 13 | </span> |
14 | 14 | |
15 | - <?php if ( ! post_password_required() && ( comments_open() || get_comments_number() ) ) : ?> |
|
15 | + <?php if ( ! post_password_required() && (comments_open() || get_comments_number())) : ?> |
|
16 | 16 | <span class="comments-link"> |
17 | 17 | <?php comments_popup_link( |
18 | - esc_html__( 'Leave a comment', 'event_espresso' ), |
|
19 | - esc_html__( '1 Comment', 'event_espresso' ), |
|
20 | - esc_html__( '% Comments', 'event_espresso' ) |
|
18 | + esc_html__('Leave a comment', 'event_espresso'), |
|
19 | + esc_html__('1 Comment', 'event_espresso'), |
|
20 | + esc_html__('% Comments', 'event_espresso') |
|
21 | 21 | ); ?> |
22 | 22 | </span> |
23 | 23 | |
24 | 24 | <?php |
25 | 25 | endif; |
26 | 26 | edit_post_link( |
27 | - esc_html__( 'Edit', 'event_espresso' ), |
|
27 | + esc_html__('Edit', 'event_espresso'), |
|
28 | 28 | '<span class="edit-link">', |
29 | 29 | '</span>' |
30 | 30 | ); |
@@ -32,25 +32,25 @@ discard block |
||
32 | 32 | </div> |
33 | 33 | |
34 | 34 | <?php endif; |
35 | - $event_phone = espresso_event_phone( $post->ID, FALSE ); |
|
35 | + $event_phone = espresso_event_phone($post->ID, FALSE); |
|
36 | 36 | |
37 | - if ( $event_phone != '' ) : ?> |
|
37 | + if ($event_phone != '') : ?> |
|
38 | 38 | <p class="event-phone"> |
39 | 39 | <span class="small-text"> |
40 | - <strong><?php esc_html_e( 'Event Phone:', 'event_espresso' ); ?> </strong> |
|
40 | + <strong><?php esc_html_e('Event Phone:', 'event_espresso'); ?> </strong> |
|
41 | 41 | </span> |
42 | 42 | <?php echo wp_kses($event_phone, AllowedTags::getAllowedTags()); ?> |
43 | 43 | </p> |
44 | -<?php endif; ?> |
|
44 | +<?php endif; ?> |
|
45 | 45 | |
46 | 46 | <?php |
47 | - if ( apply_filters( 'FHEE__content_espresso_events_details_template__display_the_content', true ) ) { |
|
48 | - do_action( 'AHEE_event_details_before_the_content', $post ); |
|
47 | + if (apply_filters('FHEE__content_espresso_events_details_template__display_the_content', true)) { |
|
48 | + do_action('AHEE_event_details_before_the_content', $post); |
|
49 | 49 | echo apply_filters( |
50 | 50 | 'FHEE__content_espresso_events_details_template__the_content', |
51 | - espresso_event_content_or_excerpt( 55, null, false ) |
|
51 | + espresso_event_content_or_excerpt(55, null, false) |
|
52 | 52 | ); |
53 | - do_action( 'AHEE_event_details_after_the_content', $post ); |
|
53 | + do_action('AHEE_event_details_after_the_content', $post); |
|
54 | 54 | } |
55 | 55 | ?> |
56 | 56 | </div> |
@@ -1,16 +1,16 @@ |
||
1 | 1 | <?php //echo '<h1>' . __FILE__ . '</h1>'; |
2 | 2 | global $post; |
3 | -if ( espresso_venue_has_address( $post->ID )) : |
|
3 | +if (espresso_venue_has_address($post->ID)) : |
|
4 | 4 | ?> |
5 | 5 | <div class="venue-location"> |
6 | 6 | |
7 | 7 | <h3 class="venue-address-h3 ee-venue-h3"> |
8 | - <span class="dashicons dashicons-location-alt"></span><?php esc_html_e( 'Location', 'event_espresso' ); ?> |
|
8 | + <span class="dashicons dashicons-location-alt"></span><?php esc_html_e('Location', 'event_espresso'); ?> |
|
9 | 9 | </h3> |
10 | - <span class="small-text"><strong><?php esc_html_e( 'Address:', 'event_espresso' ); ?></strong></span><?php espresso_venue_address( 'inline', $post->ID ); ?> |
|
10 | + <span class="small-text"><strong><?php esc_html_e('Address:', 'event_espresso'); ?></strong></span><?php espresso_venue_address('inline', $post->ID); ?> |
|
11 | 11 | <div class="clear"></div> |
12 | 12 | |
13 | - <div class="venue-gmap"><?php espresso_venue_gmap( $post->ID ); ?></div> |
|
13 | + <div class="venue-gmap"><?php espresso_venue_gmap($post->ID); ?></div> |
|
14 | 14 | <div class="clear"></div> |
15 | 15 | |
16 | 16 | </div> |
@@ -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"> |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | { |
31 | 31 | |
32 | 32 | // first check if $tabs_names is not empty then the count must match the count of $tabs_content otherwise we've got a problem houston |
33 | - if (! empty($tabs_names) && (count((array) $tabs_names) != count((array) $tabs_content))) { |
|
33 | + if ( ! empty($tabs_names) && (count((array) $tabs_names) != count((array) $tabs_content))) { |
|
34 | 34 | throw new EE_Error( |
35 | 35 | esc_html__('The count for $tabs_names and $tabs_content does not match.', 'event_espresso') |
36 | 36 | ); |
@@ -49,9 +49,9 @@ discard block |
||
49 | 49 | |
50 | 50 | $index = 0; |
51 | 51 | foreach ($tabs as $tab) { |
52 | - $active = $index === 0; |
|
52 | + $active = $index === 0; |
|
53 | 53 | $tabs_html .= self::tab($tab, $active); |
54 | - $tabs_content_html .= self::tab_content($tab, $tabs_content[ $tab ], $active); |
|
54 | + $tabs_content_html .= self::tab_content($tab, $tabs_content[$tab], $active); |
|
55 | 55 | $index++; |
56 | 56 | } |
57 | 57 | |
@@ -118,9 +118,9 @@ discard block |
||
118 | 118 | { |
119 | 119 | $nice_name = $nice_name ?: esc_html(ucwords(str_replace(['_', '-'], ' ', $name))); |
120 | 120 | $name = self::generateTadID($name); |
121 | - $class = $css ? ' ' . esc_attr($css) : ''; |
|
122 | - $class .= $active ? ' nav-tab-active' : ''; |
|
123 | - $url = $url ?: '#' . esc_attr($name); |
|
121 | + $class = $css ? ' '.esc_attr($css) : ''; |
|
122 | + $class .= $active ? ' nav-tab-active' : ''; |
|
123 | + $url = $url ?: '#'.esc_attr($name); |
|
124 | 124 | return " |
125 | 125 | <a class='nav-tab{$class}' rel='{$name}' href='{$url}'> |
126 | 126 | $nice_name |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | */ |
137 | 137 | private static function generateTadID($tab_name) |
138 | 138 | { |
139 | - return 'ee-tab-' . esc_attr(str_replace(' ', '-', $tab_name)); |
|
139 | + return 'ee-tab-'.esc_attr(str_replace(' ', '-', $tab_name)); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | |
@@ -187,18 +187,18 @@ discard block |
||
187 | 187 | public static function tab_text_links(array $item_array, $container_class = '', $sep = '|', $default = '') |
188 | 188 | { |
189 | 189 | $item_array = apply_filters('FHEE__EEH_Tabbed_Content__tab_text_links', $item_array, $container_class); |
190 | - if (! is_array($item_array) || empty($item_array)) { |
|
190 | + if ( ! is_array($item_array) || empty($item_array)) { |
|
191 | 191 | return false; // get out we don't have even the basic thing we need! |
192 | 192 | } |
193 | 193 | |
194 | - $defaults = [ |
|
194 | + $defaults = [ |
|
195 | 195 | 'label' => esc_html__('Item', 'event_espresso'), |
196 | 196 | 'class' => '', |
197 | 197 | 'href' => '', |
198 | 198 | 'title' => esc_attr__('Link for Item', 'event_espresso'), |
199 | 199 | 'slug' => 'item_slug', |
200 | 200 | ]; |
201 | - $container_class = ! empty($container_class) ? ' ' . esc_attr($container_class) : ''; |
|
201 | + $container_class = ! empty($container_class) ? ' '.esc_attr($container_class) : ''; |
|
202 | 202 | $list = ''; |
203 | 203 | $list_length = count($item_array); |
204 | 204 | // if we're' adding separators, set $current to 1, otherwise set it to list length + 1 |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | // (if we aren't adding separators $current will always be > list length cuz it started at list length + 1) |
207 | 207 | $current = empty($sep) ? $list_length + 1 : 1; |
208 | 208 | foreach ($item_array as $item) { |
209 | - $item = wp_parse_args($item, $defaults); |
|
209 | + $item = wp_parse_args($item, $defaults); |
|
210 | 210 | $item['class'] .= $default === $item['slug'] ? ' item_display' : ''; |
211 | 211 | $list .= self::textLinkItem($item); |
212 | 212 | $list .= $current < $list_length ? self::textLinkSeparator($sep) : ''; |
@@ -13,246 +13,246 @@ |
||
13 | 13 | */ |
14 | 14 | class EEH_Tabbed_Content |
15 | 15 | { |
16 | - /** |
|
17 | - * assembles and returns the html structure for tabs |
|
18 | - * |
|
19 | - * @static |
|
20 | - * @param array $tabs_contents an array of the content for each tab [required] |
|
21 | - * @param array $tabs_names a numerically indexed array of names for each tab [optional] |
|
22 | - * - if this isn't included then we use the indexes for $tabs_content as the tab names) |
|
23 | - * @param bool $small_tabs |
|
24 | - * @param bool $tabs_content |
|
25 | - * @return string the assembled html string containing the tabbed content for display. |
|
26 | - * @throws EE_Error |
|
27 | - */ |
|
28 | - public static function display($tabs_contents, $tabs_names = [], $small_tabs = true, $tabs_content = true) |
|
29 | - { |
|
16 | + /** |
|
17 | + * assembles and returns the html structure for tabs |
|
18 | + * |
|
19 | + * @static |
|
20 | + * @param array $tabs_contents an array of the content for each tab [required] |
|
21 | + * @param array $tabs_names a numerically indexed array of names for each tab [optional] |
|
22 | + * - if this isn't included then we use the indexes for $tabs_content as the tab names) |
|
23 | + * @param bool $small_tabs |
|
24 | + * @param bool $tabs_content |
|
25 | + * @return string the assembled html string containing the tabbed content for display. |
|
26 | + * @throws EE_Error |
|
27 | + */ |
|
28 | + public static function display($tabs_contents, $tabs_names = [], $small_tabs = true, $tabs_content = true) |
|
29 | + { |
|
30 | 30 | |
31 | - // first check if $tabs_names is not empty then the count must match the count of $tabs_content otherwise we've got a problem houston |
|
32 | - if (! empty($tabs_names) && (count((array) $tabs_names) != count((array) $tabs_content))) { |
|
33 | - throw new EE_Error( |
|
34 | - esc_html__('The count for $tabs_names and $tabs_content does not match.', 'event_espresso') |
|
35 | - ); |
|
36 | - } |
|
31 | + // first check if $tabs_names is not empty then the count must match the count of $tabs_content otherwise we've got a problem houston |
|
32 | + if (! empty($tabs_names) && (count((array) $tabs_names) != count((array) $tabs_content))) { |
|
33 | + throw new EE_Error( |
|
34 | + esc_html__('The count for $tabs_names and $tabs_content does not match.', 'event_espresso') |
|
35 | + ); |
|
36 | + } |
|
37 | 37 | |
38 | - // make sure we've got incoming data setup properly |
|
39 | - $tabs = ! empty($tabs_names) |
|
40 | - ? (array) $tabs_names |
|
41 | - : array_keys((array) $tabs_contents); |
|
42 | - $tabs_content = ! empty($tabs_names) |
|
43 | - ? array_combine((array) $tabs_names, (array) $tabs_content) |
|
44 | - : $tabs_contents; |
|
38 | + // make sure we've got incoming data setup properly |
|
39 | + $tabs = ! empty($tabs_names) |
|
40 | + ? (array) $tabs_names |
|
41 | + : array_keys((array) $tabs_contents); |
|
42 | + $tabs_content = ! empty($tabs_names) |
|
43 | + ? array_combine((array) $tabs_names, (array) $tabs_content) |
|
44 | + : $tabs_contents; |
|
45 | 45 | |
46 | - $tabs_html = ''; |
|
47 | - $tabs_content_html = ''; |
|
46 | + $tabs_html = ''; |
|
47 | + $tabs_content_html = ''; |
|
48 | 48 | |
49 | - $index = 0; |
|
50 | - foreach ($tabs as $tab) { |
|
51 | - $active = $index === 0; |
|
52 | - $tabs_html .= self::tab($tab, $active); |
|
53 | - $tabs_content_html .= self::tab_content($tab, $tabs_content[ $tab ], $active); |
|
54 | - $index++; |
|
55 | - } |
|
49 | + $index = 0; |
|
50 | + foreach ($tabs as $tab) { |
|
51 | + $active = $index === 0; |
|
52 | + $tabs_html .= self::tab($tab, $active); |
|
53 | + $tabs_content_html .= self::tab_content($tab, $tabs_content[ $tab ], $active); |
|
54 | + $index++; |
|
55 | + } |
|
56 | 56 | |
57 | - $tabs_class = $small_tabs ? ' ee-nav-tabs-small' : ''; |
|
57 | + $tabs_class = $small_tabs ? ' ee-nav-tabs-small' : ''; |
|
58 | 58 | |
59 | - return " |
|
59 | + return " |
|
60 | 60 | <div class='ee-nav-tabs{$tabs_class}'> |
61 | 61 | <h2 class='nav-tab-wrapper'>{$tabs_html}</h2> |
62 | 62 | {$tabs_content_html} |
63 | 63 | </div> |
64 | 64 | "; |
65 | - } |
|
65 | + } |
|
66 | 66 | |
67 | 67 | |
68 | - /** |
|
69 | - * display_admin_nav_tabs |
|
70 | - * this returns the properly formatted tab html for EE_Admin_Pages. |
|
71 | - * We are expecting an array of tabs in the following format |
|
72 | - * array( |
|
73 | - * 'nav_tab_name' => array( |
|
74 | - * 'url' => 'url for tab', |
|
75 | - * 'link_text' => 'tab text', |
|
76 | - * 'css_class' => 'tab class' //including the nav-tab-active class if its active |
|
77 | - * ) |
|
78 | - * ) |
|
79 | - * |
|
80 | - * @access public |
|
81 | - * @static |
|
82 | - * @param string[][] $nav_tabs tab array for nav tabs |
|
83 | - * @return string |
|
84 | - * @throws EE_Error |
|
85 | - */ |
|
86 | - public static function display_admin_nav_tabs($nav_tabs = []) |
|
87 | - { |
|
88 | - if (empty($nav_tabs)) { |
|
89 | - throw new EE_Error( |
|
90 | - esc_html__('Nav Tabs cannot be generated because the tab array is missing', 'event_espresso') |
|
91 | - ); |
|
92 | - } |
|
93 | - $tab_content = ''; |
|
94 | - foreach ($nav_tabs as $slug => $tab) { |
|
95 | - $tab_content .= self::tab($slug, false, $tab['link_text'], $tab['url'], $tab['css_class']); |
|
96 | - } |
|
97 | - $aria_label = esc_attr__('Secondary menu', 'event_espresso'); |
|
98 | - return " |
|
68 | + /** |
|
69 | + * display_admin_nav_tabs |
|
70 | + * this returns the properly formatted tab html for EE_Admin_Pages. |
|
71 | + * We are expecting an array of tabs in the following format |
|
72 | + * array( |
|
73 | + * 'nav_tab_name' => array( |
|
74 | + * 'url' => 'url for tab', |
|
75 | + * 'link_text' => 'tab text', |
|
76 | + * 'css_class' => 'tab class' //including the nav-tab-active class if its active |
|
77 | + * ) |
|
78 | + * ) |
|
79 | + * |
|
80 | + * @access public |
|
81 | + * @static |
|
82 | + * @param string[][] $nav_tabs tab array for nav tabs |
|
83 | + * @return string |
|
84 | + * @throws EE_Error |
|
85 | + */ |
|
86 | + public static function display_admin_nav_tabs($nav_tabs = []) |
|
87 | + { |
|
88 | + if (empty($nav_tabs)) { |
|
89 | + throw new EE_Error( |
|
90 | + esc_html__('Nav Tabs cannot be generated because the tab array is missing', 'event_espresso') |
|
91 | + ); |
|
92 | + } |
|
93 | + $tab_content = ''; |
|
94 | + foreach ($nav_tabs as $slug => $tab) { |
|
95 | + $tab_content .= self::tab($slug, false, $tab['link_text'], $tab['url'], $tab['css_class']); |
|
96 | + } |
|
97 | + $aria_label = esc_attr__('Secondary menu', 'event_espresso'); |
|
98 | + return " |
|
99 | 99 | <nav class='nav-tab-wrapper wp-clearfix' aria-label='{$aria_label}'> |
100 | 100 | {$tab_content} |
101 | 101 | </nav> |
102 | 102 | "; |
103 | - } |
|
103 | + } |
|
104 | 104 | |
105 | 105 | |
106 | - /** |
|
107 | - * this simply returns a single tab given a tab name & content |
|
108 | - * |
|
109 | - * @param string $name name of tab |
|
110 | - * @param bool $active true=tab active, false=tab not active |
|
111 | - * @param bool|string $nice_name if string given then this value will be used for the tab link text. |
|
112 | - * @param bool|string $url If url given then tabs will be generated linking to the url. |
|
113 | - * @param bool|string $css If string given then the generated tab will include that as the class. |
|
114 | - * @return string html for tab |
|
115 | - */ |
|
116 | - private static function tab($name, $active = false, $nice_name = false, $url = false, $css = false) |
|
117 | - { |
|
118 | - $nice_name = $nice_name ?: esc_html(ucwords(str_replace(['_', '-'], ' ', $name))); |
|
119 | - $name = self::generateTadID($name); |
|
120 | - $class = $css ? ' ' . esc_attr($css) : ''; |
|
121 | - $class .= $active ? ' nav-tab-active' : ''; |
|
122 | - $url = $url ?: '#' . esc_attr($name); |
|
123 | - return " |
|
106 | + /** |
|
107 | + * this simply returns a single tab given a tab name & content |
|
108 | + * |
|
109 | + * @param string $name name of tab |
|
110 | + * @param bool $active true=tab active, false=tab not active |
|
111 | + * @param bool|string $nice_name if string given then this value will be used for the tab link text. |
|
112 | + * @param bool|string $url If url given then tabs will be generated linking to the url. |
|
113 | + * @param bool|string $css If string given then the generated tab will include that as the class. |
|
114 | + * @return string html for tab |
|
115 | + */ |
|
116 | + private static function tab($name, $active = false, $nice_name = false, $url = false, $css = false) |
|
117 | + { |
|
118 | + $nice_name = $nice_name ?: esc_html(ucwords(str_replace(['_', '-'], ' ', $name))); |
|
119 | + $name = self::generateTadID($name); |
|
120 | + $class = $css ? ' ' . esc_attr($css) : ''; |
|
121 | + $class .= $active ? ' nav-tab-active' : ''; |
|
122 | + $url = $url ?: '#' . esc_attr($name); |
|
123 | + return " |
|
124 | 124 | <a class='nav-tab{$class}' rel='{$name}' href='{$url}'> |
125 | 125 | $nice_name |
126 | 126 | </a> |
127 | 127 | "; |
128 | - } |
|
128 | + } |
|
129 | 129 | |
130 | 130 | |
131 | - /** |
|
132 | - * @param string $tab_name |
|
133 | - * @return string |
|
134 | - * @since 4.10.14.p |
|
135 | - */ |
|
136 | - private static function generateTadID($tab_name) |
|
137 | - { |
|
138 | - return 'ee-tab-' . esc_attr(str_replace(' ', '-', $tab_name)); |
|
139 | - } |
|
131 | + /** |
|
132 | + * @param string $tab_name |
|
133 | + * @return string |
|
134 | + * @since 4.10.14.p |
|
135 | + */ |
|
136 | + private static function generateTadID($tab_name) |
|
137 | + { |
|
138 | + return 'ee-tab-' . esc_attr(str_replace(' ', '-', $tab_name)); |
|
139 | + } |
|
140 | 140 | |
141 | 141 | |
142 | - /** |
|
143 | - * this just returns the properly formatted tab content for our tab box. |
|
144 | - * |
|
145 | - * @param string $name name of tab (used for selector) |
|
146 | - * @param string $tab_content content of tab |
|
147 | - * @param bool $active |
|
148 | - * @return string html for content area |
|
149 | - */ |
|
150 | - private static function tab_content($name, $tab_content, $active = false) |
|
151 | - { |
|
152 | - $class = $active ? '' : ' hidden'; |
|
153 | - $name = self::generateTadID($name); |
|
154 | - return " |
|
142 | + /** |
|
143 | + * this just returns the properly formatted tab content for our tab box. |
|
144 | + * |
|
145 | + * @param string $name name of tab (used for selector) |
|
146 | + * @param string $tab_content content of tab |
|
147 | + * @param bool $active |
|
148 | + * @return string html for content area |
|
149 | + */ |
|
150 | + private static function tab_content($name, $tab_content, $active = false) |
|
151 | + { |
|
152 | + $class = $active ? '' : ' hidden'; |
|
153 | + $name = self::generateTadID($name); |
|
154 | + return " |
|
155 | 155 | <div class='nav-tab-content{$class}' id='{$name}'> |
156 | 156 | {$tab_content} |
157 | 157 | <div style='clear:both'></div> |
158 | 158 | </div>"; |
159 | - } |
|
159 | + } |
|
160 | 160 | |
161 | 161 | |
162 | 162 | |
163 | - /** HORIZONTAL TEXT LINKS **/ |
|
163 | + /** HORIZONTAL TEXT LINKS **/ |
|
164 | 164 | |
165 | - /** |
|
166 | - * This will take in an array of link items and spit out a formatted list of links that can be used to navigate to |
|
167 | - * items. There is a corresponding js file that can be loaded to dynamically display containers with the same id as |
|
168 | - * the href -ref. |
|
169 | - * |
|
170 | - * @param string[] $item_array formatted array of items. Format: |
|
171 | - * array( |
|
172 | - * 'label' => esc_html__('localized label displayed'), |
|
173 | - * 'class' => 'class_for_item', |
|
174 | - * 'href' => '#some_item_id', //url/bookmark for item. If you include a bookmark |
|
175 | - * the js will used this to show the container div. |
|
176 | - * 'title' => esc_html__('localized text for the title attribute of the link'), |
|
177 | - * 'slug' => 'slug_used_for_reference' |
|
178 | - * ) |
|
179 | - * @param string $container_class class used for main container |
|
180 | - * @param string $sep you can add in what is used as a separator between each link (or leave blank for |
|
181 | - * none) |
|
182 | - * @param string $default You can include a string for the item that will receive the "item_display" class |
|
183 | - * for the js. |
|
184 | - * @return string a html snippet of of all the formatted link elements. |
|
185 | - */ |
|
186 | - public static function tab_text_links(array $item_array, $container_class = '', $sep = '|', $default = '') |
|
187 | - { |
|
188 | - $item_array = apply_filters('FHEE__EEH_Tabbed_Content__tab_text_links', $item_array, $container_class); |
|
189 | - if (! is_array($item_array) || empty($item_array)) { |
|
190 | - return false; // get out we don't have even the basic thing we need! |
|
191 | - } |
|
165 | + /** |
|
166 | + * This will take in an array of link items and spit out a formatted list of links that can be used to navigate to |
|
167 | + * items. There is a corresponding js file that can be loaded to dynamically display containers with the same id as |
|
168 | + * the href -ref. |
|
169 | + * |
|
170 | + * @param string[] $item_array formatted array of items. Format: |
|
171 | + * array( |
|
172 | + * 'label' => esc_html__('localized label displayed'), |
|
173 | + * 'class' => 'class_for_item', |
|
174 | + * 'href' => '#some_item_id', //url/bookmark for item. If you include a bookmark |
|
175 | + * the js will used this to show the container div. |
|
176 | + * 'title' => esc_html__('localized text for the title attribute of the link'), |
|
177 | + * 'slug' => 'slug_used_for_reference' |
|
178 | + * ) |
|
179 | + * @param string $container_class class used for main container |
|
180 | + * @param string $sep you can add in what is used as a separator between each link (or leave blank for |
|
181 | + * none) |
|
182 | + * @param string $default You can include a string for the item that will receive the "item_display" class |
|
183 | + * for the js. |
|
184 | + * @return string a html snippet of of all the formatted link elements. |
|
185 | + */ |
|
186 | + public static function tab_text_links(array $item_array, $container_class = '', $sep = '|', $default = '') |
|
187 | + { |
|
188 | + $item_array = apply_filters('FHEE__EEH_Tabbed_Content__tab_text_links', $item_array, $container_class); |
|
189 | + if (! is_array($item_array) || empty($item_array)) { |
|
190 | + return false; // get out we don't have even the basic thing we need! |
|
191 | + } |
|
192 | 192 | |
193 | - $defaults = [ |
|
194 | - 'label' => esc_html__('Item', 'event_espresso'), |
|
195 | - 'class' => '', |
|
196 | - 'href' => '', |
|
197 | - 'title' => esc_attr__('Link for Item', 'event_espresso'), |
|
198 | - 'slug' => 'item_slug', |
|
199 | - ]; |
|
200 | - $container_class = ! empty($container_class) ? ' ' . esc_attr($container_class) : ''; |
|
201 | - $list = ''; |
|
202 | - $list_length = count($item_array); |
|
203 | - // if we're' adding separators, set $current to 1, otherwise set it to list length + 1 |
|
204 | - // then we'll increment $current while looping and only add separators if $current is < list length |
|
205 | - // (if we aren't adding separators $current will always be > list length cuz it started at list length + 1) |
|
206 | - $current = empty($sep) ? $list_length + 1 : 1; |
|
207 | - foreach ($item_array as $item) { |
|
208 | - $item = wp_parse_args($item, $defaults); |
|
209 | - $item['class'] .= $default === $item['slug'] ? ' item_display' : ''; |
|
210 | - $list .= self::textLinkItem($item); |
|
211 | - $list .= $current < $list_length ? self::textLinkSeparator($sep) : ''; |
|
212 | - $current++; |
|
213 | - } |
|
193 | + $defaults = [ |
|
194 | + 'label' => esc_html__('Item', 'event_espresso'), |
|
195 | + 'class' => '', |
|
196 | + 'href' => '', |
|
197 | + 'title' => esc_attr__('Link for Item', 'event_espresso'), |
|
198 | + 'slug' => 'item_slug', |
|
199 | + ]; |
|
200 | + $container_class = ! empty($container_class) ? ' ' . esc_attr($container_class) : ''; |
|
201 | + $list = ''; |
|
202 | + $list_length = count($item_array); |
|
203 | + // if we're' adding separators, set $current to 1, otherwise set it to list length + 1 |
|
204 | + // then we'll increment $current while looping and only add separators if $current is < list length |
|
205 | + // (if we aren't adding separators $current will always be > list length cuz it started at list length + 1) |
|
206 | + $current = empty($sep) ? $list_length + 1 : 1; |
|
207 | + foreach ($item_array as $item) { |
|
208 | + $item = wp_parse_args($item, $defaults); |
|
209 | + $item['class'] .= $default === $item['slug'] ? ' item_display' : ''; |
|
210 | + $list .= self::textLinkItem($item); |
|
211 | + $list .= $current < $list_length ? self::textLinkSeparator($sep) : ''; |
|
212 | + $current++; |
|
213 | + } |
|
214 | 214 | |
215 | - return " |
|
215 | + return " |
|
216 | 216 | <ul class='ee-text-links{$container_class}'>{$list}</ul> |
217 | 217 | "; |
218 | - } |
|
218 | + } |
|
219 | 219 | |
220 | 220 | |
221 | - /** |
|
222 | - * @param string[] $item |
|
223 | - * @return string |
|
224 | - */ |
|
225 | - private static function textLinkItem(array $item) |
|
226 | - { |
|
227 | - $class = $item['class'] ? esc_attr($item['class']) : ''; |
|
228 | - $label = esc_html($item['label']); |
|
229 | - $href = $item['href'] ? esc_attr($item['href']) : ''; |
|
230 | - $title = esc_attr($item['title']); |
|
221 | + /** |
|
222 | + * @param string[] $item |
|
223 | + * @return string |
|
224 | + */ |
|
225 | + private static function textLinkItem(array $item) |
|
226 | + { |
|
227 | + $class = $item['class'] ? esc_attr($item['class']) : ''; |
|
228 | + $label = esc_html($item['label']); |
|
229 | + $href = $item['href'] ? esc_attr($item['href']) : ''; |
|
230 | + $title = esc_attr($item['title']); |
|
231 | 231 | |
232 | 232 | |
233 | - $link = ! empty($href) |
|
234 | - ? " |
|
233 | + $link = ! empty($href) |
|
234 | + ? " |
|
235 | 235 | <a class='ee-text-link' href='#{$href}' title='{$title}'> |
236 | 236 | {$label} |
237 | 237 | </a> |
238 | 238 | " |
239 | - : $label; |
|
240 | - return " |
|
239 | + : $label; |
|
240 | + return " |
|
241 | 241 | <li class='ee-text-link-li {$class}'>{$link}</li> |
242 | 242 | "; |
243 | - } |
|
243 | + } |
|
244 | 244 | |
245 | 245 | |
246 | - /** |
|
247 | - * @param string $separator |
|
248 | - * @return string |
|
249 | - * @since 4.10.14.p |
|
250 | - */ |
|
251 | - private static function textLinkSeparator($separator) |
|
252 | - { |
|
253 | - $separator = esc_html($separator); |
|
254 | - return " |
|
246 | + /** |
|
247 | + * @param string $separator |
|
248 | + * @return string |
|
249 | + * @since 4.10.14.p |
|
250 | + */ |
|
251 | + private static function textLinkSeparator($separator) |
|
252 | + { |
|
253 | + $separator = esc_html($separator); |
|
254 | + return " |
|
255 | 255 | <li class='ee-text-link-sep'>{$separator}</li> |
256 | 256 | "; |
257 | - } |
|
257 | + } |
|
258 | 258 | } |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | public static function instance() |
36 | 36 | { |
37 | 37 | // check if class object is instantiated |
38 | - if (self::$_instance === null or ! is_object(self::$_instance) or ! ( self::$_instance instanceof EEH_Qtip_Loader )) { |
|
38 | + if (self::$_instance === null or ! is_object(self::$_instance) or ! (self::$_instance instanceof EEH_Qtip_Loader)) { |
|
39 | 39 | self::$_instance = new self(); |
40 | 40 | } |
41 | 41 | return self::$_instance; |
@@ -66,25 +66,25 @@ discard block |
||
66 | 66 | */ |
67 | 67 | public function register_and_enqueue() |
68 | 68 | { |
69 | - $qtips_js = !defined('SCRIPT_DEBUG') ? EE_THIRD_PARTY_URL . 'qtip/jquery.qtip.min.js' : EE_THIRD_PARTY_URL . 'qtip/jquery.qtip.js'; |
|
70 | - $qtip_map = EE_THIRD_PARTY_URL . 'qtip/jquery.qtip.min.map'; |
|
71 | - $qtipcss = !defined('SCRIPT_DEBUG') ? EE_THIRD_PARTY_URL . 'qtip/jquery.qtip.min.css' : EE_THIRD_PARTY_URL . 'qtip/jquery.qtip.css'; |
|
69 | + $qtips_js = ! defined('SCRIPT_DEBUG') ? EE_THIRD_PARTY_URL . 'qtip/jquery.qtip.min.js' : EE_THIRD_PARTY_URL.'qtip/jquery.qtip.js'; |
|
70 | + $qtip_map = EE_THIRD_PARTY_URL.'qtip/jquery.qtip.min.map'; |
|
71 | + $qtipcss = ! defined('SCRIPT_DEBUG') ? EE_THIRD_PARTY_URL . 'qtip/jquery.qtip.min.css' : EE_THIRD_PARTY_URL.'qtip/jquery.qtip.css'; |
|
72 | 72 | |
73 | 73 | wp_register_script('qtip-map', $qtip_map, array(), '3', true); |
74 | 74 | wp_register_script('qtip', $qtips_js, array('jquery'), '3.0.3', true); |
75 | - wp_register_script('ee-qtip-helper', EE_HELPERS_ASSETS . 'ee-qtip-helper.js', array('qtip', 'jquery-cookie'), EVENT_ESPRESSO_VERSION, true); |
|
75 | + wp_register_script('ee-qtip-helper', EE_HELPERS_ASSETS.'ee-qtip-helper.js', array('qtip', 'jquery-cookie'), EVENT_ESPRESSO_VERSION, true); |
|
76 | 76 | |
77 | 77 | wp_register_style('qtip-css', $qtipcss, array(), '2.2'); |
78 | 78 | |
79 | 79 | // k now let's see if there are any registered qtips. If there are, then we need to setup the localized script for ee-qtip-helper.js (and enqueue ee-qtip-helper.js of course!) |
80 | - if (!empty($this->_qtips)) { |
|
80 | + if ( ! empty($this->_qtips)) { |
|
81 | 81 | wp_enqueue_script('ee-qtip-helper'); |
82 | 82 | wp_enqueue_style('qtip-css'); |
83 | 83 | $qtips = array(); |
84 | 84 | foreach ($this->_qtips as $qtip) { |
85 | 85 | $qts = $qtip->get_tips(); |
86 | 86 | foreach ($qts as $qt) { |
87 | - if (! $qt instanceof EE_Qtip) { |
|
87 | + if ( ! $qt instanceof EE_Qtip) { |
|
88 | 88 | continue; |
89 | 89 | } |
90 | 90 | $qtips[] = array( |
@@ -94,8 +94,8 @@ discard block |
||
94 | 94 | ); |
95 | 95 | } |
96 | 96 | } |
97 | - if (!empty($qtips)) { |
|
98 | - wp_localize_script('ee-qtip-helper', 'EE_QTIP_HELPER', array( 'qtips' => $qtips )); |
|
97 | + if ( ! empty($qtips)) { |
|
98 | + wp_localize_script('ee-qtip-helper', 'EE_QTIP_HELPER', array('qtips' => $qtips)); |
|
99 | 99 | } |
100 | 100 | } else { |
101 | 101 | // qtips has been requested without any registration (so assuming its just directly used in the admin). |
@@ -154,11 +154,11 @@ discard block |
||
154 | 154 | // before doing anything we have to make sure that EE_Qtip_Config parent is required. |
155 | 155 | EE_Registry::instance()->load_lib('Qtip_Config', array(), true); |
156 | 156 | |
157 | - if (!empty($paths)) { |
|
157 | + if ( ! empty($paths)) { |
|
158 | 158 | $paths = (array) $paths; |
159 | 159 | foreach ($paths as $path) { |
160 | - $path = $path . $config . '.lib.php'; |
|
161 | - if (!is_readable($path)) { |
|
160 | + $path = $path.$config.'.lib.php'; |
|
161 | + if ( ! is_readable($path)) { |
|
162 | 162 | continue; |
163 | 163 | } else { |
164 | 164 | require_once $path; |
@@ -167,9 +167,9 @@ discard block |
||
167 | 167 | } |
168 | 168 | |
169 | 169 | // does class exist at this point? If it does then let's instantiate. If it doesn't then let's continue with other paths. |
170 | - if (!class_exists($config)) { |
|
171 | - $path = EE_LIBRARIES . 'qtips/' . $config . '.lib.php'; |
|
172 | - if (!is_readable($path)) { |
|
170 | + if ( ! class_exists($config)) { |
|
171 | + $path = EE_LIBRARIES.'qtips/'.$config.'.lib.php'; |
|
172 | + if ( ! is_readable($path)) { |
|
173 | 173 | throw new EE_Error(sprintf(esc_html__('Unable to load the Qtip Config registered for this page (%s) because none of the file paths attempted are readable. Please check the spelling of the paths you\'ve used in the registration', 'event_espresso'), $config)); |
174 | 174 | } else { |
175 | 175 | require_once $path; |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | } |
178 | 178 | |
179 | 179 | // now we attempt a class_exists one more time. |
180 | - if (!class_exists($config)) { |
|
180 | + if ( ! class_exists($config)) { |
|
181 | 181 | throw new EE_Error(sprintf(esc_html__('The Qtip_Config class being registered (%s) does not exist, please check the spelling.', 'event_espresso'), $config)); |
182 | 182 | } |
183 | 183 | |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | $qtip = $a->newInstance(); |
187 | 187 | |
188 | 188 | // verify that $qtip is a valid object |
189 | - if (! $qtip instanceof EE_Qtip_Config) { |
|
189 | + if ( ! $qtip instanceof EE_Qtip_Config) { |
|
190 | 190 | throw new EE_Error(sprintf(esc_html__('The class given for the Qtip loader (%1$s) is not a child of the %2$sEE_Qtip_Config%3$s class. Please make sure you are extending EE_Qtip_Config.', 'event_espresso'), $config, '<strong>', '</strong>')); |
191 | 191 | } |
192 | 192 | |
@@ -229,11 +229,11 @@ discard block |
||
229 | 229 | $qts = $qtip->get_tips(); |
230 | 230 | $content = array(); |
231 | 231 | foreach ($qts as $qt) { |
232 | - if (! $qt instanceof EE_Qtip) { |
|
232 | + if ( ! $qt instanceof EE_Qtip) { |
|
233 | 233 | continue; |
234 | 234 | } |
235 | - $content[] = '<div class="ee-qtip-helper-content hidden" id="' . esc_attr($qt->content_id) . '">' . |
|
236 | - $qt->content . '</div>'; |
|
235 | + $content[] = '<div class="ee-qtip-helper-content hidden" id="'.esc_attr($qt->content_id).'">'. |
|
236 | + $qt->content.'</div>'; |
|
237 | 237 | } |
238 | 238 | |
239 | 239 | return implode('<br />', $content); |
@@ -11,230 +11,230 @@ |
||
11 | 11 | */ |
12 | 12 | class EEH_Qtip_Loader extends EEH_Base |
13 | 13 | { |
14 | - /** |
|
15 | - * EEH_Qtip_Loader Object |
|
16 | - * @var EEH_Qtip_Loader |
|
17 | - * @access private |
|
18 | - */ |
|
19 | - private static $_instance = null; |
|
20 | - |
|
21 | - /** |
|
22 | - * array of qtip config objects |
|
23 | - * @var EE_Qtip_Config[] |
|
24 | - */ |
|
25 | - private $_qtips = array(); |
|
26 | - |
|
27 | - |
|
28 | - |
|
29 | - /** |
|
30 | - *@singleton method used to instantiate class object |
|
31 | - *@access public |
|
32 | - *@return EEH_Qtip_Loader instance |
|
33 | - */ |
|
34 | - public static function instance() |
|
35 | - { |
|
36 | - // check if class object is instantiated |
|
37 | - if (self::$_instance === null or ! is_object(self::$_instance) or ! ( self::$_instance instanceof EEH_Qtip_Loader )) { |
|
38 | - self::$_instance = new self(); |
|
39 | - } |
|
40 | - return self::$_instance; |
|
41 | - } |
|
42 | - |
|
43 | - |
|
44 | - |
|
45 | - /** |
|
46 | - *private constructor to prevent direct creation |
|
47 | - * @Constructor |
|
48 | - * @access private |
|
49 | - * @return \EEH_Qtip_Loader |
|
50 | - */ |
|
51 | - private function __construct() |
|
52 | - { |
|
53 | - // let's just make sure this is instantiated in the right place. |
|
54 | - if (did_action('wp_print_styles') || did_action('admin_head')) { |
|
55 | - EE_Error::doing_it_wrong('EEH_Qtip_Loader', esc_html__('This helper must be instantiated before or within a callback for the WordPress wp_enqueue_scripts hook action hook.', 'event_espresso'), '4.1'); |
|
56 | - } |
|
57 | - } |
|
58 | - |
|
59 | - |
|
60 | - /** |
|
61 | - * Call this from wp_enqueue_scripts or admin_enqueue_scripts to setup and enqueue the qtip library |
|
62 | - * |
|
63 | - * @access public |
|
64 | - * @return void |
|
65 | - */ |
|
66 | - public function register_and_enqueue() |
|
67 | - { |
|
68 | - $qtips_js = !defined('SCRIPT_DEBUG') ? EE_THIRD_PARTY_URL . 'qtip/jquery.qtip.min.js' : EE_THIRD_PARTY_URL . 'qtip/jquery.qtip.js'; |
|
69 | - $qtip_map = EE_THIRD_PARTY_URL . 'qtip/jquery.qtip.min.map'; |
|
70 | - $qtipcss = !defined('SCRIPT_DEBUG') ? EE_THIRD_PARTY_URL . 'qtip/jquery.qtip.min.css' : EE_THIRD_PARTY_URL . 'qtip/jquery.qtip.css'; |
|
71 | - |
|
72 | - wp_register_script('qtip-map', $qtip_map, array(), '3', true); |
|
73 | - wp_register_script('qtip', $qtips_js, array('jquery'), '3.0.3', true); |
|
74 | - wp_register_script('ee-qtip-helper', EE_HELPERS_ASSETS . 'ee-qtip-helper.js', array('qtip', 'jquery-cookie'), EVENT_ESPRESSO_VERSION, true); |
|
75 | - |
|
76 | - wp_register_style('qtip-css', $qtipcss, array(), '2.2'); |
|
77 | - |
|
78 | - // k now let's see if there are any registered qtips. If there are, then we need to setup the localized script for ee-qtip-helper.js (and enqueue ee-qtip-helper.js of course!) |
|
79 | - if (!empty($this->_qtips)) { |
|
80 | - wp_enqueue_script('ee-qtip-helper'); |
|
81 | - wp_enqueue_style('qtip-css'); |
|
82 | - $qtips = array(); |
|
83 | - foreach ($this->_qtips as $qtip) { |
|
84 | - $qts = $qtip->get_tips(); |
|
85 | - foreach ($qts as $qt) { |
|
86 | - if (! $qt instanceof EE_Qtip) { |
|
87 | - continue; |
|
88 | - } |
|
89 | - $qtips[] = array( |
|
90 | - 'content_id' => $qt->content_id, |
|
91 | - 'options' => $qt->options, |
|
92 | - 'target' => $qt->target, |
|
93 | - ); |
|
94 | - } |
|
95 | - } |
|
96 | - if (!empty($qtips)) { |
|
97 | - wp_localize_script('ee-qtip-helper', 'EE_QTIP_HELPER', array( 'qtips' => $qtips )); |
|
98 | - } |
|
99 | - } else { |
|
100 | - // qtips has been requested without any registration (so assuming its just directly used in the admin). |
|
101 | - wp_enqueue_script('qtip'); |
|
102 | - wp_enqueue_style('qtip-css'); |
|
103 | - } |
|
104 | - } |
|
105 | - |
|
106 | - |
|
107 | - |
|
108 | - /** |
|
109 | - * This simply registers the given qtip config and: |
|
110 | - * - adds it to the $_qtips property array. |
|
111 | - * - sets up the content containers for all qtips in the config, |
|
112 | - * - registers and enqueues the qtip scripts and styles. |
|
113 | - * |
|
114 | - * @access public |
|
115 | - * @param array $paths Array of paths to check for the EE_Qtip class. If present we check these path(s) first. If not present (empty array), then it's assumed it's either in core/libraries/qtips OR the file is already loaded. |
|
116 | - * @param string|array $configname name of the Qtip class (full class name is expected and will be used for looking for file, Qtip config classes must extend EE_Qtip_Config) [if this is an array, then we loop through the array to instantiate and setup the qtips] |
|
117 | - * @return void |
|
118 | - */ |
|
119 | - public function register($configname, $paths = array()) |
|
120 | - { |
|
121 | - |
|
122 | - // let's just make sure this is instantiated in the right place. |
|
123 | - if (did_action('wp_enqueue_scripts') || did_action('admin_enqueue_scripts')) { |
|
124 | - EE_Error::doing_it_wrong('EEH_Qtip_Loader->register()', esc_html__('EE_Qtip_Config objects must be registered before wp_enqueue_scripts is called.', 'event_espresso'), '4.1'); |
|
125 | - } |
|
126 | - |
|
127 | - $configname = (array) $configname; // typecast to array |
|
128 | - foreach ($configname as $config) { |
|
129 | - $this->_register($config, $paths); |
|
130 | - } |
|
131 | - |
|
132 | - // hook into appropriate footer |
|
133 | - $footer_action = is_admin() ? 'admin_footer' : 'wp_footer'; |
|
134 | - add_action($footer_action, array($this, 'setup_qtip'), 10); |
|
135 | - |
|
136 | - // make sure we "turn on" qtip js. |
|
137 | - add_filter('FHEE_load_qtip', '__return_true'); |
|
138 | - } |
|
139 | - |
|
140 | - |
|
141 | - |
|
142 | - /** |
|
143 | - * private utility for registering and setting up qtip config objects |
|
144 | - * |
|
145 | - * @access private |
|
146 | - * @param string $config the short name of the class (will be used to generate the expected classname) |
|
147 | - * @param array $paths array of paths to check (or if empty we check core/libraries/qtips or assume its loaded) |
|
148 | - * @throws EE_Error |
|
149 | - * @return void |
|
150 | - */ |
|
151 | - private function _register($config, $paths) |
|
152 | - { |
|
153 | - // before doing anything we have to make sure that EE_Qtip_Config parent is required. |
|
154 | - EE_Registry::instance()->load_lib('Qtip_Config', array(), true); |
|
155 | - |
|
156 | - if (!empty($paths)) { |
|
157 | - $paths = (array) $paths; |
|
158 | - foreach ($paths as $path) { |
|
159 | - $path = $path . $config . '.lib.php'; |
|
160 | - if (!is_readable($path)) { |
|
161 | - continue; |
|
162 | - } else { |
|
163 | - require_once $path; |
|
164 | - } |
|
165 | - } |
|
166 | - } |
|
167 | - |
|
168 | - // does class exist at this point? If it does then let's instantiate. If it doesn't then let's continue with other paths. |
|
169 | - if (!class_exists($config)) { |
|
170 | - $path = EE_LIBRARIES . 'qtips/' . $config . '.lib.php'; |
|
171 | - if (!is_readable($path)) { |
|
172 | - throw new EE_Error(sprintf(esc_html__('Unable to load the Qtip Config registered for this page (%s) because none of the file paths attempted are readable. Please check the spelling of the paths you\'ve used in the registration', 'event_espresso'), $config)); |
|
173 | - } else { |
|
174 | - require_once $path; |
|
175 | - } |
|
176 | - } |
|
177 | - |
|
178 | - // now we attempt a class_exists one more time. |
|
179 | - if (!class_exists($config)) { |
|
180 | - throw new EE_Error(sprintf(esc_html__('The Qtip_Config class being registered (%s) does not exist, please check the spelling.', 'event_espresso'), $config)); |
|
181 | - } |
|
182 | - |
|
183 | - // made it HERE? FINALLY, let's get things setup. |
|
184 | - $a = new ReflectionClass($config); |
|
185 | - $qtip = $a->newInstance(); |
|
186 | - |
|
187 | - // verify that $qtip is a valid object |
|
188 | - if (! $qtip instanceof EE_Qtip_Config) { |
|
189 | - throw new EE_Error(sprintf(esc_html__('The class given for the Qtip loader (%1$s) is not a child of the %2$sEE_Qtip_Config%3$s class. Please make sure you are extending EE_Qtip_Config.', 'event_espresso'), $config, '<strong>', '</strong>')); |
|
190 | - } |
|
191 | - |
|
192 | - $this->_qtips[] = $a->newInstance(); |
|
193 | - } |
|
194 | - |
|
195 | - |
|
196 | - |
|
197 | - /** |
|
198 | - * This takes care of generating the qtip content containers. |
|
199 | - * Output gets put in the appropriate page footer (depending on context (either admin_footer or wp_footer) ) |
|
200 | - * |
|
201 | - * @access public |
|
202 | - * @return void |
|
203 | - */ |
|
204 | - public function setup_qtip() |
|
205 | - { |
|
206 | - if (empty($this->_qtips)) { |
|
207 | - return; // no qtips! |
|
208 | - } |
|
209 | - |
|
210 | - $content = array(); |
|
211 | - |
|
212 | - foreach ($this->_qtips as $qtip) { |
|
213 | - $content[] = $this->_generate_content_container($qtip); |
|
214 | - } |
|
215 | - |
|
216 | - echo implode('<br />', $content); |
|
217 | - } |
|
218 | - |
|
219 | - |
|
220 | - /** |
|
221 | - * Generates a content container from a given EE_Qtip_Config object. |
|
222 | - * |
|
223 | - * @param EE_Qtip_Config $qtip |
|
224 | - * @return string (html content container for qtip); |
|
225 | - */ |
|
226 | - private function _generate_content_container($qtip) |
|
227 | - { |
|
228 | - $qts = $qtip->get_tips(); |
|
229 | - $content = array(); |
|
230 | - foreach ($qts as $qt) { |
|
231 | - if (! $qt instanceof EE_Qtip) { |
|
232 | - continue; |
|
233 | - } |
|
234 | - $content[] = '<div class="ee-qtip-helper-content hidden" id="' . esc_attr($qt->content_id) . '">' . |
|
235 | - $qt->content . '</div>'; |
|
236 | - } |
|
237 | - |
|
238 | - return implode('<br />', $content); |
|
239 | - } |
|
14 | + /** |
|
15 | + * EEH_Qtip_Loader Object |
|
16 | + * @var EEH_Qtip_Loader |
|
17 | + * @access private |
|
18 | + */ |
|
19 | + private static $_instance = null; |
|
20 | + |
|
21 | + /** |
|
22 | + * array of qtip config objects |
|
23 | + * @var EE_Qtip_Config[] |
|
24 | + */ |
|
25 | + private $_qtips = array(); |
|
26 | + |
|
27 | + |
|
28 | + |
|
29 | + /** |
|
30 | + *@singleton method used to instantiate class object |
|
31 | + *@access public |
|
32 | + *@return EEH_Qtip_Loader instance |
|
33 | + */ |
|
34 | + public static function instance() |
|
35 | + { |
|
36 | + // check if class object is instantiated |
|
37 | + if (self::$_instance === null or ! is_object(self::$_instance) or ! ( self::$_instance instanceof EEH_Qtip_Loader )) { |
|
38 | + self::$_instance = new self(); |
|
39 | + } |
|
40 | + return self::$_instance; |
|
41 | + } |
|
42 | + |
|
43 | + |
|
44 | + |
|
45 | + /** |
|
46 | + *private constructor to prevent direct creation |
|
47 | + * @Constructor |
|
48 | + * @access private |
|
49 | + * @return \EEH_Qtip_Loader |
|
50 | + */ |
|
51 | + private function __construct() |
|
52 | + { |
|
53 | + // let's just make sure this is instantiated in the right place. |
|
54 | + if (did_action('wp_print_styles') || did_action('admin_head')) { |
|
55 | + EE_Error::doing_it_wrong('EEH_Qtip_Loader', esc_html__('This helper must be instantiated before or within a callback for the WordPress wp_enqueue_scripts hook action hook.', 'event_espresso'), '4.1'); |
|
56 | + } |
|
57 | + } |
|
58 | + |
|
59 | + |
|
60 | + /** |
|
61 | + * Call this from wp_enqueue_scripts or admin_enqueue_scripts to setup and enqueue the qtip library |
|
62 | + * |
|
63 | + * @access public |
|
64 | + * @return void |
|
65 | + */ |
|
66 | + public function register_and_enqueue() |
|
67 | + { |
|
68 | + $qtips_js = !defined('SCRIPT_DEBUG') ? EE_THIRD_PARTY_URL . 'qtip/jquery.qtip.min.js' : EE_THIRD_PARTY_URL . 'qtip/jquery.qtip.js'; |
|
69 | + $qtip_map = EE_THIRD_PARTY_URL . 'qtip/jquery.qtip.min.map'; |
|
70 | + $qtipcss = !defined('SCRIPT_DEBUG') ? EE_THIRD_PARTY_URL . 'qtip/jquery.qtip.min.css' : EE_THIRD_PARTY_URL . 'qtip/jquery.qtip.css'; |
|
71 | + |
|
72 | + wp_register_script('qtip-map', $qtip_map, array(), '3', true); |
|
73 | + wp_register_script('qtip', $qtips_js, array('jquery'), '3.0.3', true); |
|
74 | + wp_register_script('ee-qtip-helper', EE_HELPERS_ASSETS . 'ee-qtip-helper.js', array('qtip', 'jquery-cookie'), EVENT_ESPRESSO_VERSION, true); |
|
75 | + |
|
76 | + wp_register_style('qtip-css', $qtipcss, array(), '2.2'); |
|
77 | + |
|
78 | + // k now let's see if there are any registered qtips. If there are, then we need to setup the localized script for ee-qtip-helper.js (and enqueue ee-qtip-helper.js of course!) |
|
79 | + if (!empty($this->_qtips)) { |
|
80 | + wp_enqueue_script('ee-qtip-helper'); |
|
81 | + wp_enqueue_style('qtip-css'); |
|
82 | + $qtips = array(); |
|
83 | + foreach ($this->_qtips as $qtip) { |
|
84 | + $qts = $qtip->get_tips(); |
|
85 | + foreach ($qts as $qt) { |
|
86 | + if (! $qt instanceof EE_Qtip) { |
|
87 | + continue; |
|
88 | + } |
|
89 | + $qtips[] = array( |
|
90 | + 'content_id' => $qt->content_id, |
|
91 | + 'options' => $qt->options, |
|
92 | + 'target' => $qt->target, |
|
93 | + ); |
|
94 | + } |
|
95 | + } |
|
96 | + if (!empty($qtips)) { |
|
97 | + wp_localize_script('ee-qtip-helper', 'EE_QTIP_HELPER', array( 'qtips' => $qtips )); |
|
98 | + } |
|
99 | + } else { |
|
100 | + // qtips has been requested without any registration (so assuming its just directly used in the admin). |
|
101 | + wp_enqueue_script('qtip'); |
|
102 | + wp_enqueue_style('qtip-css'); |
|
103 | + } |
|
104 | + } |
|
105 | + |
|
106 | + |
|
107 | + |
|
108 | + /** |
|
109 | + * This simply registers the given qtip config and: |
|
110 | + * - adds it to the $_qtips property array. |
|
111 | + * - sets up the content containers for all qtips in the config, |
|
112 | + * - registers and enqueues the qtip scripts and styles. |
|
113 | + * |
|
114 | + * @access public |
|
115 | + * @param array $paths Array of paths to check for the EE_Qtip class. If present we check these path(s) first. If not present (empty array), then it's assumed it's either in core/libraries/qtips OR the file is already loaded. |
|
116 | + * @param string|array $configname name of the Qtip class (full class name is expected and will be used for looking for file, Qtip config classes must extend EE_Qtip_Config) [if this is an array, then we loop through the array to instantiate and setup the qtips] |
|
117 | + * @return void |
|
118 | + */ |
|
119 | + public function register($configname, $paths = array()) |
|
120 | + { |
|
121 | + |
|
122 | + // let's just make sure this is instantiated in the right place. |
|
123 | + if (did_action('wp_enqueue_scripts') || did_action('admin_enqueue_scripts')) { |
|
124 | + EE_Error::doing_it_wrong('EEH_Qtip_Loader->register()', esc_html__('EE_Qtip_Config objects must be registered before wp_enqueue_scripts is called.', 'event_espresso'), '4.1'); |
|
125 | + } |
|
126 | + |
|
127 | + $configname = (array) $configname; // typecast to array |
|
128 | + foreach ($configname as $config) { |
|
129 | + $this->_register($config, $paths); |
|
130 | + } |
|
131 | + |
|
132 | + // hook into appropriate footer |
|
133 | + $footer_action = is_admin() ? 'admin_footer' : 'wp_footer'; |
|
134 | + add_action($footer_action, array($this, 'setup_qtip'), 10); |
|
135 | + |
|
136 | + // make sure we "turn on" qtip js. |
|
137 | + add_filter('FHEE_load_qtip', '__return_true'); |
|
138 | + } |
|
139 | + |
|
140 | + |
|
141 | + |
|
142 | + /** |
|
143 | + * private utility for registering and setting up qtip config objects |
|
144 | + * |
|
145 | + * @access private |
|
146 | + * @param string $config the short name of the class (will be used to generate the expected classname) |
|
147 | + * @param array $paths array of paths to check (or if empty we check core/libraries/qtips or assume its loaded) |
|
148 | + * @throws EE_Error |
|
149 | + * @return void |
|
150 | + */ |
|
151 | + private function _register($config, $paths) |
|
152 | + { |
|
153 | + // before doing anything we have to make sure that EE_Qtip_Config parent is required. |
|
154 | + EE_Registry::instance()->load_lib('Qtip_Config', array(), true); |
|
155 | + |
|
156 | + if (!empty($paths)) { |
|
157 | + $paths = (array) $paths; |
|
158 | + foreach ($paths as $path) { |
|
159 | + $path = $path . $config . '.lib.php'; |
|
160 | + if (!is_readable($path)) { |
|
161 | + continue; |
|
162 | + } else { |
|
163 | + require_once $path; |
|
164 | + } |
|
165 | + } |
|
166 | + } |
|
167 | + |
|
168 | + // does class exist at this point? If it does then let's instantiate. If it doesn't then let's continue with other paths. |
|
169 | + if (!class_exists($config)) { |
|
170 | + $path = EE_LIBRARIES . 'qtips/' . $config . '.lib.php'; |
|
171 | + if (!is_readable($path)) { |
|
172 | + throw new EE_Error(sprintf(esc_html__('Unable to load the Qtip Config registered for this page (%s) because none of the file paths attempted are readable. Please check the spelling of the paths you\'ve used in the registration', 'event_espresso'), $config)); |
|
173 | + } else { |
|
174 | + require_once $path; |
|
175 | + } |
|
176 | + } |
|
177 | + |
|
178 | + // now we attempt a class_exists one more time. |
|
179 | + if (!class_exists($config)) { |
|
180 | + throw new EE_Error(sprintf(esc_html__('The Qtip_Config class being registered (%s) does not exist, please check the spelling.', 'event_espresso'), $config)); |
|
181 | + } |
|
182 | + |
|
183 | + // made it HERE? FINALLY, let's get things setup. |
|
184 | + $a = new ReflectionClass($config); |
|
185 | + $qtip = $a->newInstance(); |
|
186 | + |
|
187 | + // verify that $qtip is a valid object |
|
188 | + if (! $qtip instanceof EE_Qtip_Config) { |
|
189 | + throw new EE_Error(sprintf(esc_html__('The class given for the Qtip loader (%1$s) is not a child of the %2$sEE_Qtip_Config%3$s class. Please make sure you are extending EE_Qtip_Config.', 'event_espresso'), $config, '<strong>', '</strong>')); |
|
190 | + } |
|
191 | + |
|
192 | + $this->_qtips[] = $a->newInstance(); |
|
193 | + } |
|
194 | + |
|
195 | + |
|
196 | + |
|
197 | + /** |
|
198 | + * This takes care of generating the qtip content containers. |
|
199 | + * Output gets put in the appropriate page footer (depending on context (either admin_footer or wp_footer) ) |
|
200 | + * |
|
201 | + * @access public |
|
202 | + * @return void |
|
203 | + */ |
|
204 | + public function setup_qtip() |
|
205 | + { |
|
206 | + if (empty($this->_qtips)) { |
|
207 | + return; // no qtips! |
|
208 | + } |
|
209 | + |
|
210 | + $content = array(); |
|
211 | + |
|
212 | + foreach ($this->_qtips as $qtip) { |
|
213 | + $content[] = $this->_generate_content_container($qtip); |
|
214 | + } |
|
215 | + |
|
216 | + echo implode('<br />', $content); |
|
217 | + } |
|
218 | + |
|
219 | + |
|
220 | + /** |
|
221 | + * Generates a content container from a given EE_Qtip_Config object. |
|
222 | + * |
|
223 | + * @param EE_Qtip_Config $qtip |
|
224 | + * @return string (html content container for qtip); |
|
225 | + */ |
|
226 | + private function _generate_content_container($qtip) |
|
227 | + { |
|
228 | + $qts = $qtip->get_tips(); |
|
229 | + $content = array(); |
|
230 | + foreach ($qts as $qt) { |
|
231 | + if (! $qt instanceof EE_Qtip) { |
|
232 | + continue; |
|
233 | + } |
|
234 | + $content[] = '<div class="ee-qtip-helper-content hidden" id="' . esc_attr($qt->content_id) . '">' . |
|
235 | + $qt->content . '</div>'; |
|
236 | + } |
|
237 | + |
|
238 | + return implode('<br />', $content); |
|
239 | + } |
|
240 | 240 | } |