@@ -14,7 +14,7 @@ |
||
| 14 | 14 | |
| 15 | 15 | <li data-datetime-row="<?php echo esc_attr($dtt_row); ?>" data-context="datetime-ticket" data-ticket-row="<?php echo esc_attr($tkt_row); ?>" |
| 16 | 16 | class="datetime-ticket clickable<?php echo $ticket_selected; |
| 17 | - echo $tkt_status_class; ?>"> |
|
| 17 | + echo $tkt_status_class; ?>"> |
|
| 18 | 18 | <input type="checkbox" name="datetime_ticket[<?php echo esc_attr($dtt_row); ?>][<?php echo esc_attr($tkt_row); ?>]" |
| 19 | 19 | class="datetime-ticket-checkbox" value="1"<?php echo $datetime_ticket_checked; ?>> |
| 20 | 20 | <span class="ee-icon ee-icon-tickets ticket-list-ticket-name"><?php echo $TKT_name; ?></span> |
@@ -5,43 +5,43 @@ |
||
| 5 | 5 | global $post; |
| 6 | 6 | ?> |
| 7 | 7 | <div class="venue-content"> |
| 8 | -<?php if ( apply_filters( 'FHEE__content_espresso_venues_details_template__display_entry_meta', TRUE )): ?> |
|
| 8 | +<?php if (apply_filters('FHEE__content_espresso_venues_details_template__display_entry_meta', TRUE)): ?> |
|
| 9 | 9 | <div class="entry-meta"> |
| 10 | - <span class="tags-links"><?php espresso_venue_categories( $post->ID, TRUE, TRUE ); ?></span> |
|
| 10 | + <span class="tags-links"><?php espresso_venue_categories($post->ID, TRUE, TRUE); ?></span> |
|
| 11 | 11 | <?php |
| 12 | - if ( ! post_password_required() && ( comments_open() || get_comments_number() ) ) : |
|
| 12 | + if ( ! post_password_required() && (comments_open() || get_comments_number())) : |
|
| 13 | 13 | ?> |
| 14 | - <span class="comments-link"><?php comments_popup_link( esc_html__( 'Leave a comment', 'event_espresso' ), esc_html__( '1 Comment', 'event_espresso' ), esc_html__( '% Comments', 'event_espresso' ) ); ?></span> |
|
| 14 | + <span class="comments-link"><?php comments_popup_link(esc_html__('Leave a comment', 'event_espresso'), esc_html__('1 Comment', 'event_espresso'), esc_html__('% Comments', 'event_espresso')); ?></span> |
|
| 15 | 15 | <?php |
| 16 | 16 | endif; |
| 17 | 17 | |
| 18 | - edit_post_link( esc_html__( 'Edit', 'event_espresso' ), '<span class="edit-link">', '</span>' ); |
|
| 18 | + edit_post_link(esc_html__('Edit', 'event_espresso'), '<span class="edit-link">', '</span>'); |
|
| 19 | 19 | ?> |
| 20 | 20 | </div> |
| 21 | 21 | <?php endif; ?> |
| 22 | 22 | |
| 23 | 23 | <h3 class="event-venues-h3 ee-event-h3"> |
| 24 | - <?php esc_html_e( 'Details', 'event_espresso' ); ?> |
|
| 24 | + <?php esc_html_e('Details', 'event_espresso'); ?> |
|
| 25 | 25 | </h3> |
| 26 | 26 | |
| 27 | - <?php if ( $venue_phone = espresso_venue_phone( $post->ID, FALSE )) : ?> |
|
| 27 | + <?php if ($venue_phone = espresso_venue_phone($post->ID, FALSE)) : ?> |
|
| 28 | 28 | <p> |
| 29 | - <span class="small-text"><strong><?php esc_html_e( 'Venue Phone:', 'event_espresso' ); ?> </strong></span><?php echo wp_kses($venue_phone, AllowedTags::getAllowedTags()); ?> |
|
| 29 | + <span class="small-text"><strong><?php esc_html_e('Venue Phone:', 'event_espresso'); ?> </strong></span><?php echo wp_kses($venue_phone, AllowedTags::getAllowedTags()); ?> |
|
| 30 | 30 | </p> |
| 31 | 31 | <?php endif; ?> |
| 32 | - <?php if ( $venue_website = espresso_venue_website( $post->ID, FALSE )) : ?> |
|
| 32 | + <?php if ($venue_website = espresso_venue_website($post->ID, FALSE)) : ?> |
|
| 33 | 33 | <p> |
| 34 | - <span class="small-text"><strong><?php esc_html_e( 'Venue Website:', 'event_espresso' ); ?> </strong></span><?php echo wp_kses($venue_website, AllowedTags::getAllowedTags()); ?> |
|
| 34 | + <span class="small-text"><strong><?php esc_html_e('Venue Website:', 'event_espresso'); ?> </strong></span><?php echo wp_kses($venue_website, AllowedTags::getAllowedTags()); ?> |
|
| 35 | 35 | </p> |
| 36 | 36 | <?php endif; ?> |
| 37 | 37 | <?php |
| 38 | - do_action( 'AHEE__content_espresso_venues_details_template__before_the_content', $post ); |
|
| 39 | - if ( is_archive() && has_excerpt( $post->ID )) { |
|
| 38 | + do_action('AHEE__content_espresso_venues_details_template__before_the_content', $post); |
|
| 39 | + if (is_archive() && has_excerpt($post->ID)) { |
|
| 40 | 40 | the_excerpt(); |
| 41 | 41 | } else { |
| 42 | 42 | the_content(); |
| 43 | 43 | } |
| 44 | - do_action( 'AHEE__content_espresso_venues_details_template__after_the_content', $post ); |
|
| 44 | + do_action('AHEE__content_espresso_venues_details_template__after_the_content', $post); |
|
| 45 | 45 | ?> |
| 46 | 46 | </div> |
| 47 | 47 | <!-- .venue-content --> |
@@ -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> |
@@ -15,11 +15,11 @@ |
||
| 15 | 15 | use EventEspresso\core\services\request\sanitizers\AllowedTags; |
| 16 | 16 | |
| 17 | 17 | $gravatar = $show_gravatar |
| 18 | - ? get_avatar( |
|
| 19 | - $contact->email(), |
|
| 20 | - (int) apply_filters('FHEE__loop-espresso_attendees-shortcode__template__avatar_size', 32) |
|
| 21 | - ) |
|
| 22 | - : ''; |
|
| 18 | + ? get_avatar( |
|
| 19 | + $contact->email(), |
|
| 20 | + (int) apply_filters('FHEE__loop-espresso_attendees-shortcode__template__avatar_size', 32) |
|
| 21 | + ) |
|
| 22 | + : ''; |
|
| 23 | 23 | ?> |
| 24 | 24 | <?php do_action( 'AHEE__content-espresso_event_attendees__before', $contact, $show_gravatar ); ?> |
| 25 | 25 | <li><?php echo wp_kses($gravatar . ' ' . $contact->full_name(true), AllowedTags::getAllowedTags()); ?></li> |
@@ -21,8 +21,8 @@ |
||
| 21 | 21 | ) |
| 22 | 22 | : ''; |
| 23 | 23 | ?> |
| 24 | -<?php do_action( 'AHEE__content-espresso_event_attendees__before', $contact, $show_gravatar ); ?> |
|
| 25 | -<li><?php echo wp_kses($gravatar . ' ' . $contact->full_name(true), AllowedTags::getAllowedTags()); ?></li> |
|
| 26 | -<?php do_action( 'AHEE__content-espresso_event_attendees__after', $contact, $show_gravatar ); ?> |
|
| 24 | +<?php do_action('AHEE__content-espresso_event_attendees__before', $contact, $show_gravatar); ?> |
|
| 25 | +<li><?php echo wp_kses($gravatar.' '.$contact->full_name(true), AllowedTags::getAllowedTags()); ?></li> |
|
| 26 | +<?php do_action('AHEE__content-espresso_event_attendees__after', $contact, $show_gravatar); ?> |
|
| 27 | 27 | |
| 28 | 28 | <!--<br >--> |
@@ -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> |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | EE_Question_Option::new_instance(['QSO_value' => false, 'QSO_desc' => esc_html__('No', 'event_espresso')]), |
| 111 | 111 | EE_Question_Option::new_instance(['QSO_value' => true, 'QSO_desc' => esc_html__('Yes', 'event_espresso')]), |
| 112 | 112 | ]; |
| 113 | - $sort_values = [ |
|
| 113 | + $sort_values = [ |
|
| 114 | 114 | EE_Question_Option::new_instance(['QSO_value' => 'ASC', 'QSO_desc' => esc_html__('ASC', 'event_espresso')]), |
| 115 | 115 | EE_Question_Option::new_instance(['QSO_value' => 'DESC', 'QSO_desc' => esc_html__('DESC', 'event_espresso')]), |
| 116 | 116 | ]; |
@@ -327,8 +327,8 @@ discard block |
||
| 327 | 327 | // Before widget (defined by themes). |
| 328 | 328 | echo wp_kses($before_widget, AllowedTags::getAllowedTags()); |
| 329 | 329 | // Display the widget title if one was input (before and after defined by themes). |
| 330 | - if (! empty($title)) { |
|
| 331 | - echo wp_kses($before_title . $title . $after_title, AllowedTags::getAllowedTags()); |
|
| 330 | + if ( ! empty($title)) { |
|
| 331 | + echo wp_kses($before_title.$title.$after_title, AllowedTags::getAllowedTags()); |
|
| 332 | 332 | } |
| 333 | 333 | echo wp_kses($this->widgetContent($post), AllowedTags::getAllowedTags()); |
| 334 | 334 | // After widget (defined by themes). |
@@ -347,7 +347,7 @@ discard block |
||
| 347 | 347 | */ |
| 348 | 348 | public function make_the_title_a_link($title) |
| 349 | 349 | { |
| 350 | - return '<a href="' . EEH_Event_View::event_archive_url() . '">' . $title . '</a>'; |
|
| 350 | + return '<a href="'.EEH_Event_View::event_archive_url().'">'.$title.'</a>'; |
|
| 351 | 351 | } |
| 352 | 352 | |
| 353 | 353 | |
@@ -428,7 +428,7 @@ discard block |
||
| 428 | 428 | foreach ($sizes as $image_size) { |
| 429 | 429 | $image_size = trim($image_size); |
| 430 | 430 | // no big images plz |
| 431 | - if (! in_array($image_size, ['large', 'post-thumbnail'])) { |
|
| 431 | + if ( ! in_array($image_size, ['large', 'post-thumbnail'])) { |
|
| 432 | 432 | $image_sizes[] = |
| 433 | 433 | EE_Question_Option::new_instance(['QSO_value' => $image_size, 'QSO_desc' => $image_size]); |
| 434 | 434 | } |
@@ -455,7 +455,7 @@ discard block |
||
| 455 | 455 | private function parseWidgetSettings(array $instance) |
| 456 | 456 | { |
| 457 | 457 | $this->title = isset($instance['title']) && ! empty($instance['title']) ? $instance['title'] : ''; |
| 458 | - $this->events_category = isset($instance['category_name']) && ! empty($instance['category_name']) |
|
| 458 | + $this->events_category = isset($instance['category_name']) && ! empty($instance['category_name']) |
|
| 459 | 459 | ? $instance['category_name'] |
| 460 | 460 | : false; |
| 461 | 461 | $this->show_expired = isset($instance['show_expired']) |
@@ -513,24 +513,24 @@ discard block |
||
| 513 | 513 | } |
| 514 | 514 | $list_items = ''; |
| 515 | 515 | foreach ($events as $event) { |
| 516 | - if ($event instanceof EE_Event && (! is_single() || $post->ID != $event->ID())) { |
|
| 516 | + if ($event instanceof EE_Event && ( ! is_single() || $post->ID != $event->ID())) { |
|
| 517 | 517 | $event_url = $this->eventUrl($event); |
| 518 | 518 | $list_items .= ' |
| 519 | - <li id="ee-upcoming-events-widget-li-' . absint($event->ID()) . '" |
|
| 519 | + <li id="ee-upcoming-events-widget-li-' . absint($event->ID()).'" |
|
| 520 | 520 | class="ee-upcoming-events-widget-li" |
| 521 | 521 | > |
| 522 | 522 | <h5 class="ee-upcoming-events-widget-title-h5"> |
| 523 | - <a class="ee-widget-event-name-a' . $this->linkClass($event) . '" href="' . $event_url . '"> |
|
| 524 | - ' . esc_html($event->name()) . ' |
|
| 523 | + <a class="ee-widget-event-name-a' . $this->linkClass($event).'" href="'.$event_url.'"> |
|
| 524 | + ' . esc_html($event->name()).' |
|
| 525 | 525 | </a> |
| 526 | 526 | </h5> |
| 527 | - ' . $this->eventWidgetContent($event, $event_url) . ' |
|
| 527 | + ' . $this->eventWidgetContent($event, $event_url).' |
|
| 528 | 528 | </li>'; |
| 529 | 529 | } |
| 530 | 530 | } |
| 531 | 531 | return ' |
| 532 | 532 | <ul class="ee-upcoming-events-widget-ul"> |
| 533 | - ' . $list_items . ' |
|
| 533 | + ' . $list_items.' |
|
| 534 | 534 | </ul>'; |
| 535 | 535 | } |
| 536 | 536 | |
@@ -562,7 +562,7 @@ discard block |
||
| 562 | 562 | return EEM_Event::instance()->get_all( |
| 563 | 563 | [ |
| 564 | 564 | $this->queryWhereParams(), |
| 565 | - 'limit' => '0,' . $this->limit, |
|
| 565 | + 'limit' => '0,'.$this->limit, |
|
| 566 | 566 | 'order_by' => 'Datetime.DTT_EVT_start', |
| 567 | 567 | 'order' => $this->order, |
| 568 | 568 | 'group_by' => 'EVT_ID', |
@@ -650,8 +650,8 @@ discard block |
||
| 650 | 650 | if (has_post_thumbnail($event->ID()) && $this->image_size != 'none') { |
| 651 | 651 | $content .= ' |
| 652 | 652 | <div class="ee-upcoming-events-widget-img-dv"> |
| 653 | - <a class="ee-upcoming-events-widget-img" href="' . $event_url . '"> |
|
| 654 | - ' . get_the_post_thumbnail($event->ID(), $this->image_size) . ' |
|
| 653 | + <a class="ee-upcoming-events-widget-img" href="' . $event_url.'"> |
|
| 654 | + ' . get_the_post_thumbnail($event->ID(), $this->image_size).' |
|
| 655 | 655 | </a> |
| 656 | 656 | </div>'; |
| 657 | 657 | } |
@@ -662,8 +662,8 @@ discard block |
||
| 662 | 662 | |
| 663 | 663 | if ($this->show_desc) { |
| 664 | 664 | $allowedtags = AllowedTags::getAllowedTags(); |
| 665 | - $desc = $event->short_description(25); |
|
| 666 | - $content .= $desc ? '<p style="margin-top: .5em">' . wp_kses($desc, $allowedtags) . '</p>' : ''; |
|
| 665 | + $desc = $event->short_description(25); |
|
| 666 | + $content .= $desc ? '<p style="margin-top: .5em">'.wp_kses($desc, $allowedtags).'</p>' : ''; |
|
| 667 | 667 | } |
| 668 | 668 | |
| 669 | 669 | return $content; |
@@ -679,11 +679,11 @@ discard block |
||
| 679 | 679 | */ |
| 680 | 680 | private function eventDates(EE_Event $event) |
| 681 | 681 | { |
| 682 | - $date_format = apply_filters( |
|
| 682 | + $date_format = apply_filters( |
|
| 683 | 683 | 'FHEE__espresso_event_date_range__date_format', |
| 684 | 684 | get_option('date_format') |
| 685 | 685 | ); |
| 686 | - $time_format = apply_filters( |
|
| 686 | + $time_format = apply_filters( |
|
| 687 | 687 | 'FHEE__espresso_event_date_range__time_format', |
| 688 | 688 | get_option('time_format') |
| 689 | 689 | ); |
@@ -12,109 +12,109 @@ discard block |
||
| 12 | 12 | */ |
| 13 | 13 | class EEW_Upcoming_Events extends EspressoWidget |
| 14 | 14 | { |
| 15 | - /** |
|
| 16 | - * @var string |
|
| 17 | - */ |
|
| 18 | - private $title; |
|
| 19 | - /** |
|
| 20 | - * @var string |
|
| 21 | - */ |
|
| 22 | - private $events_category; |
|
| 23 | - |
|
| 24 | - /** |
|
| 25 | - * @var bool |
|
| 26 | - */ |
|
| 27 | - private $show_expired; |
|
| 28 | - |
|
| 29 | - /** |
|
| 30 | - * @var string |
|
| 31 | - */ |
|
| 32 | - private $image_size; |
|
| 33 | - |
|
| 34 | - /** |
|
| 35 | - * @var bool |
|
| 36 | - */ |
|
| 37 | - private $show_desc; |
|
| 38 | - |
|
| 39 | - /** |
|
| 40 | - * @var bool |
|
| 41 | - */ |
|
| 42 | - private $show_dates; |
|
| 43 | - |
|
| 44 | - /** |
|
| 45 | - * @var string |
|
| 46 | - */ |
|
| 47 | - private $date_limit; |
|
| 48 | - |
|
| 49 | - /** |
|
| 50 | - * @var string |
|
| 51 | - */ |
|
| 52 | - private $date_range; |
|
| 53 | - |
|
| 54 | - /** |
|
| 55 | - * @var string |
|
| 56 | - */ |
|
| 57 | - private $limit; |
|
| 58 | - |
|
| 59 | - /** |
|
| 60 | - * @var string |
|
| 61 | - */ |
|
| 62 | - private $order; |
|
| 63 | - |
|
| 64 | - |
|
| 65 | - /** |
|
| 66 | - * Register widget with WordPress. |
|
| 67 | - */ |
|
| 68 | - public function __construct() |
|
| 69 | - { |
|
| 70 | - parent::__construct( |
|
| 71 | - esc_html__('Event Espresso Upcoming Events', 'event_espresso'), |
|
| 72 | - ['description' => esc_html__('A widget to display your upcoming events.', 'event_espresso')] |
|
| 73 | - ); |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - |
|
| 77 | - /** |
|
| 78 | - * Back-end widget form. |
|
| 79 | - * |
|
| 80 | - * @param array $instance Previously saved values from database. |
|
| 81 | - * @return void |
|
| 82 | - * @throws EE_Error |
|
| 83 | - * @throws ReflectionException |
|
| 84 | - * @see WP_Widget::form() |
|
| 85 | - */ |
|
| 86 | - public function form($instance) |
|
| 87 | - { |
|
| 88 | - |
|
| 89 | - EE_Registry::instance()->load_class('Question_Option', [], false, false, true); |
|
| 90 | - // Set up some default widget settings. |
|
| 91 | - $defaults = [ |
|
| 92 | - 'title' => esc_html__('Upcoming Events', 'event_espresso'), |
|
| 93 | - 'category_name' => '', |
|
| 94 | - 'show_expired' => 0, |
|
| 95 | - 'show_desc' => true, |
|
| 96 | - 'show_dates' => true, |
|
| 97 | - 'show_everywhere' => false, |
|
| 98 | - 'date_limit' => 2, |
|
| 99 | - 'limit' => 10, |
|
| 100 | - 'sort' => 'ASC', |
|
| 101 | - 'date_range' => false, |
|
| 102 | - 'image_size' => 'medium', |
|
| 103 | - ]; |
|
| 104 | - |
|
| 105 | - $instance = wp_parse_args((array) $instance, $defaults); |
|
| 106 | - // don't add HTML labels for EE_Form_Fields generated inputs |
|
| 107 | - add_filter('FHEE__EEH_Form_Fields__label_html', '__return_empty_string'); |
|
| 108 | - $yes_no_values = [ |
|
| 109 | - EE_Question_Option::new_instance(['QSO_value' => false, 'QSO_desc' => esc_html__('No', 'event_espresso')]), |
|
| 110 | - EE_Question_Option::new_instance(['QSO_value' => true, 'QSO_desc' => esc_html__('Yes', 'event_espresso')]), |
|
| 111 | - ]; |
|
| 112 | - $sort_values = [ |
|
| 113 | - EE_Question_Option::new_instance(['QSO_value' => 'ASC', 'QSO_desc' => esc_html__('ASC', 'event_espresso')]), |
|
| 114 | - EE_Question_Option::new_instance(['QSO_value' => 'DESC', 'QSO_desc' => esc_html__('DESC', 'event_espresso')]), |
|
| 115 | - ]; |
|
| 116 | - |
|
| 117 | - ?> |
|
| 15 | + /** |
|
| 16 | + * @var string |
|
| 17 | + */ |
|
| 18 | + private $title; |
|
| 19 | + /** |
|
| 20 | + * @var string |
|
| 21 | + */ |
|
| 22 | + private $events_category; |
|
| 23 | + |
|
| 24 | + /** |
|
| 25 | + * @var bool |
|
| 26 | + */ |
|
| 27 | + private $show_expired; |
|
| 28 | + |
|
| 29 | + /** |
|
| 30 | + * @var string |
|
| 31 | + */ |
|
| 32 | + private $image_size; |
|
| 33 | + |
|
| 34 | + /** |
|
| 35 | + * @var bool |
|
| 36 | + */ |
|
| 37 | + private $show_desc; |
|
| 38 | + |
|
| 39 | + /** |
|
| 40 | + * @var bool |
|
| 41 | + */ |
|
| 42 | + private $show_dates; |
|
| 43 | + |
|
| 44 | + /** |
|
| 45 | + * @var string |
|
| 46 | + */ |
|
| 47 | + private $date_limit; |
|
| 48 | + |
|
| 49 | + /** |
|
| 50 | + * @var string |
|
| 51 | + */ |
|
| 52 | + private $date_range; |
|
| 53 | + |
|
| 54 | + /** |
|
| 55 | + * @var string |
|
| 56 | + */ |
|
| 57 | + private $limit; |
|
| 58 | + |
|
| 59 | + /** |
|
| 60 | + * @var string |
|
| 61 | + */ |
|
| 62 | + private $order; |
|
| 63 | + |
|
| 64 | + |
|
| 65 | + /** |
|
| 66 | + * Register widget with WordPress. |
|
| 67 | + */ |
|
| 68 | + public function __construct() |
|
| 69 | + { |
|
| 70 | + parent::__construct( |
|
| 71 | + esc_html__('Event Espresso Upcoming Events', 'event_espresso'), |
|
| 72 | + ['description' => esc_html__('A widget to display your upcoming events.', 'event_espresso')] |
|
| 73 | + ); |
|
| 74 | + } |
|
| 75 | + |
|
| 76 | + |
|
| 77 | + /** |
|
| 78 | + * Back-end widget form. |
|
| 79 | + * |
|
| 80 | + * @param array $instance Previously saved values from database. |
|
| 81 | + * @return void |
|
| 82 | + * @throws EE_Error |
|
| 83 | + * @throws ReflectionException |
|
| 84 | + * @see WP_Widget::form() |
|
| 85 | + */ |
|
| 86 | + public function form($instance) |
|
| 87 | + { |
|
| 88 | + |
|
| 89 | + EE_Registry::instance()->load_class('Question_Option', [], false, false, true); |
|
| 90 | + // Set up some default widget settings. |
|
| 91 | + $defaults = [ |
|
| 92 | + 'title' => esc_html__('Upcoming Events', 'event_espresso'), |
|
| 93 | + 'category_name' => '', |
|
| 94 | + 'show_expired' => 0, |
|
| 95 | + 'show_desc' => true, |
|
| 96 | + 'show_dates' => true, |
|
| 97 | + 'show_everywhere' => false, |
|
| 98 | + 'date_limit' => 2, |
|
| 99 | + 'limit' => 10, |
|
| 100 | + 'sort' => 'ASC', |
|
| 101 | + 'date_range' => false, |
|
| 102 | + 'image_size' => 'medium', |
|
| 103 | + ]; |
|
| 104 | + |
|
| 105 | + $instance = wp_parse_args((array) $instance, $defaults); |
|
| 106 | + // don't add HTML labels for EE_Form_Fields generated inputs |
|
| 107 | + add_filter('FHEE__EEH_Form_Fields__label_html', '__return_empty_string'); |
|
| 108 | + $yes_no_values = [ |
|
| 109 | + EE_Question_Option::new_instance(['QSO_value' => false, 'QSO_desc' => esc_html__('No', 'event_espresso')]), |
|
| 110 | + EE_Question_Option::new_instance(['QSO_value' => true, 'QSO_desc' => esc_html__('Yes', 'event_espresso')]), |
|
| 111 | + ]; |
|
| 112 | + $sort_values = [ |
|
| 113 | + EE_Question_Option::new_instance(['QSO_value' => 'ASC', 'QSO_desc' => esc_html__('ASC', 'event_espresso')]), |
|
| 114 | + EE_Question_Option::new_instance(['QSO_value' => 'DESC', 'QSO_desc' => esc_html__('DESC', 'event_espresso')]), |
|
| 115 | + ]; |
|
| 116 | + |
|
| 117 | + ?> |
|
| 118 | 118 | |
| 119 | 119 | <!-- Widget Title: Text Input --> |
| 120 | 120 | |
@@ -151,32 +151,32 @@ discard block |
||
| 151 | 151 | <?php esc_html_e('Show Expired Events:', 'event_espresso'); ?> |
| 152 | 152 | </label> |
| 153 | 153 | <?php |
| 154 | - $show_expired_options = $yes_no_values; |
|
| 155 | - $show_expired_options[] = EE_Question_Option::new_instance( |
|
| 156 | - ['QSO_value' => 2, 'QSO_desc' => esc_html__('Show Only Expired', 'event_espresso')] |
|
| 157 | - ); |
|
| 158 | - echo EEH_Form_Fields::select( |
|
| 159 | - esc_html__('Show Expired Events:', 'event_espresso'), |
|
| 160 | - $instance['show_expired'], |
|
| 161 | - $show_expired_options, |
|
| 162 | - $this->fieldName('show_expired'), |
|
| 163 | - $this->fieldID('show_expired') |
|
| 164 | - ); |
|
| 165 | - ?> |
|
| 154 | + $show_expired_options = $yes_no_values; |
|
| 155 | + $show_expired_options[] = EE_Question_Option::new_instance( |
|
| 156 | + ['QSO_value' => 2, 'QSO_desc' => esc_html__('Show Only Expired', 'event_espresso')] |
|
| 157 | + ); |
|
| 158 | + echo EEH_Form_Fields::select( |
|
| 159 | + esc_html__('Show Expired Events:', 'event_espresso'), |
|
| 160 | + $instance['show_expired'], |
|
| 161 | + $show_expired_options, |
|
| 162 | + $this->fieldName('show_expired'), |
|
| 163 | + $this->fieldID('show_expired') |
|
| 164 | + ); |
|
| 165 | + ?> |
|
| 166 | 166 | </p> |
| 167 | 167 | <p> |
| 168 | 168 | <label for="<?php echo esc_attr($this->fieldID('sort')); ?>"> |
| 169 | 169 | <?php esc_html_e('Sort Events:', 'event_espresso'); ?> |
| 170 | 170 | </label> |
| 171 | 171 | <?php |
| 172 | - echo EEH_Form_Fields::select( |
|
| 173 | - esc_html__('Sort Events:', 'event_espresso'), |
|
| 174 | - $instance['sort'], |
|
| 175 | - $sort_values, |
|
| 176 | - $this->fieldName('sort'), |
|
| 177 | - $this->fieldID('sort') |
|
| 178 | - ); |
|
| 179 | - ?> |
|
| 172 | + echo EEH_Form_Fields::select( |
|
| 173 | + esc_html__('Sort Events:', 'event_espresso'), |
|
| 174 | + $instance['sort'], |
|
| 175 | + $sort_values, |
|
| 176 | + $this->fieldName('sort'), |
|
| 177 | + $this->fieldID('sort') |
|
| 178 | + ); |
|
| 179 | + ?> |
|
| 180 | 180 | </p> |
| 181 | 181 | <p> |
| 182 | 182 | <label for="<?php echo esc_attr($this->fieldID('image_size')); ?>"> |
@@ -190,42 +190,42 @@ discard block |
||
| 190 | 190 | <?php esc_html_e('Show Description:', 'event_espresso'); ?> |
| 191 | 191 | </label> |
| 192 | 192 | <?php |
| 193 | - echo EEH_Form_Fields::select( |
|
| 194 | - esc_html__('Show Description:', 'event_espresso'), |
|
| 195 | - $instance['show_desc'], |
|
| 196 | - $yes_no_values, |
|
| 197 | - $this->fieldName('show_desc'), |
|
| 198 | - $this->fieldID('show_desc') |
|
| 199 | - ); |
|
| 200 | - ?> |
|
| 193 | + echo EEH_Form_Fields::select( |
|
| 194 | + esc_html__('Show Description:', 'event_espresso'), |
|
| 195 | + $instance['show_desc'], |
|
| 196 | + $yes_no_values, |
|
| 197 | + $this->fieldName('show_desc'), |
|
| 198 | + $this->fieldID('show_desc') |
|
| 199 | + ); |
|
| 200 | + ?> |
|
| 201 | 201 | </p> |
| 202 | 202 | <p> |
| 203 | 203 | <label for="<?php echo esc_attr($this->fieldID('show_dates')); ?>"> |
| 204 | 204 | <?php esc_html_e('Show Dates:', 'event_espresso'); ?> |
| 205 | 205 | </label> |
| 206 | 206 | <?php |
| 207 | - echo EEH_Form_Fields::select( |
|
| 208 | - esc_html__('Show Dates:', 'event_espresso'), |
|
| 209 | - $instance['show_dates'], |
|
| 210 | - $yes_no_values, |
|
| 211 | - $this->fieldName('show_dates'), |
|
| 212 | - $this->fieldID('show_dates') |
|
| 213 | - ); |
|
| 214 | - ?> |
|
| 207 | + echo EEH_Form_Fields::select( |
|
| 208 | + esc_html__('Show Dates:', 'event_espresso'), |
|
| 209 | + $instance['show_dates'], |
|
| 210 | + $yes_no_values, |
|
| 211 | + $this->fieldName('show_dates'), |
|
| 212 | + $this->fieldID('show_dates') |
|
| 213 | + ); |
|
| 214 | + ?> |
|
| 215 | 215 | </p> |
| 216 | 216 | <p> |
| 217 | 217 | <label for="<?php echo esc_attr($this->fieldID('show_everywhere')); ?>"> |
| 218 | 218 | <?php esc_html_e('Show on all Pages:', 'event_espresso'); ?> |
| 219 | 219 | </label> |
| 220 | 220 | <?php |
| 221 | - echo EEH_Form_Fields::select( |
|
| 222 | - esc_html__('Show on all Pages:', 'event_espresso'), |
|
| 223 | - $instance['show_everywhere'], |
|
| 224 | - $yes_no_values, |
|
| 225 | - $this->fieldName('show_everywhere'), |
|
| 226 | - $this->fieldID('show_everywhere') |
|
| 227 | - ); |
|
| 228 | - ?> |
|
| 221 | + echo EEH_Form_Fields::select( |
|
| 222 | + esc_html__('Show on all Pages:', 'event_espresso'), |
|
| 223 | + $instance['show_everywhere'], |
|
| 224 | + $yes_no_values, |
|
| 225 | + $this->fieldName('show_everywhere'), |
|
| 226 | + $this->fieldID('show_everywhere') |
|
| 227 | + ); |
|
| 228 | + ?> |
|
| 229 | 229 | </p> |
| 230 | 230 | <p> |
| 231 | 231 | <label for="<?php echo esc_attr($this->fieldID('date_limit')); ?>"> |
@@ -243,278 +243,278 @@ discard block |
||
| 243 | 243 | <?php esc_html_e('Show Date Range:', 'event_espresso'); ?> |
| 244 | 244 | </label> |
| 245 | 245 | <?php |
| 246 | - echo EEH_Form_Fields::select( |
|
| 247 | - esc_html__('Show Date Range:', 'event_espresso'), |
|
| 248 | - $instance['date_range'], |
|
| 249 | - $yes_no_values, |
|
| 250 | - $this->fieldName('date_range'), |
|
| 251 | - $this->fieldID('date_range') |
|
| 252 | - ); |
|
| 253 | - ?> |
|
| 246 | + echo EEH_Form_Fields::select( |
|
| 247 | + esc_html__('Show Date Range:', 'event_espresso'), |
|
| 248 | + $instance['date_range'], |
|
| 249 | + $yes_no_values, |
|
| 250 | + $this->fieldName('date_range'), |
|
| 251 | + $this->fieldID('date_range') |
|
| 252 | + ); |
|
| 253 | + ?> |
|
| 254 | 254 | <span class="description"> |
| 255 | 255 | <br /> |
| 256 | 256 | <?php esc_html_e( |
| 257 | - 'This setting will replace the list of dates in the widget.', |
|
| 258 | - 'event_espresso' |
|
| 259 | - ); ?> |
|
| 257 | + 'This setting will replace the list of dates in the widget.', |
|
| 258 | + 'event_espresso' |
|
| 259 | + ); ?> |
|
| 260 | 260 | </span> |
| 261 | 261 | </p> |
| 262 | 262 | |
| 263 | 263 | <?php |
| 264 | - } |
|
| 265 | - |
|
| 266 | - |
|
| 267 | - /** |
|
| 268 | - * Sanitize widget form values as they are saved. |
|
| 269 | - * |
|
| 270 | - * @param array $new_instance Values just sent to be saved. |
|
| 271 | - * @param array $old_instance Previously saved values from database. |
|
| 272 | - * |
|
| 273 | - * @return array Updated safe values to be saved. |
|
| 274 | - * @see WP_Widget::update() |
|
| 275 | - * |
|
| 276 | - */ |
|
| 277 | - public function update($new_instance, $old_instance) |
|
| 278 | - { |
|
| 279 | - $instance = $old_instance; |
|
| 280 | - $instance['title'] = ! empty($new_instance['title']) ? strip_tags($new_instance['title']) : ''; |
|
| 281 | - $instance['category_name'] = $new_instance['category_name']; |
|
| 282 | - $instance['show_expired'] = $new_instance['show_expired']; |
|
| 283 | - $instance['limit'] = $new_instance['limit']; |
|
| 284 | - $instance['sort'] = $new_instance['sort']; |
|
| 285 | - $instance['image_size'] = $new_instance['image_size']; |
|
| 286 | - $instance['show_desc'] = $new_instance['show_desc']; |
|
| 287 | - $instance['show_dates'] = $new_instance['show_dates']; |
|
| 288 | - $instance['show_everywhere'] = $new_instance['show_everywhere']; |
|
| 289 | - $instance['date_limit'] = $new_instance['date_limit']; |
|
| 290 | - $instance['date_range'] = $new_instance['date_range']; |
|
| 291 | - return $instance; |
|
| 292 | - } |
|
| 293 | - |
|
| 294 | - |
|
| 295 | - /** |
|
| 296 | - * Front-end display of widget. |
|
| 297 | - * |
|
| 298 | - * @param array $args Widget arguments. |
|
| 299 | - * @param array $instance Saved values from database. |
|
| 300 | - * @throws EE_Error |
|
| 301 | - * @throws ReflectionException |
|
| 302 | - * @see WP_Widget::widget() |
|
| 303 | - * |
|
| 304 | - */ |
|
| 305 | - public function widget($args, $instance) |
|
| 306 | - { |
|
| 307 | - |
|
| 308 | - global $post; |
|
| 309 | - // make sure there is some kinda post object |
|
| 310 | - if ($post instanceof WP_Post) { |
|
| 311 | - $before_widget = ''; |
|
| 312 | - $before_title = ''; |
|
| 313 | - $after_title = ''; |
|
| 314 | - $after_widget = ''; |
|
| 315 | - // but NOT an events archives page, cuz that would be like two event lists on the same page |
|
| 316 | - $show_everywhere = ! isset($instance['show_everywhere']) || absint($instance['show_everywhere']); |
|
| 317 | - if ($show_everywhere || ! ($post->post_type == 'espresso_events' && is_archive())) { |
|
| 318 | - // let's use some of the event helper functions' |
|
| 319 | - // make separate vars out of attributes |
|
| 320 | - extract($args); |
|
| 321 | - |
|
| 322 | - // grab widget settings |
|
| 323 | - $this->parseWidgetSettings($instance); |
|
| 324 | - $title = $this->widgetTitle(); |
|
| 325 | - |
|
| 326 | - // Before widget (defined by themes). |
|
| 327 | - echo wp_kses($before_widget, AllowedTags::getAllowedTags()); |
|
| 328 | - // Display the widget title if one was input (before and after defined by themes). |
|
| 329 | - if (! empty($title)) { |
|
| 330 | - echo wp_kses($before_title . $title . $after_title, AllowedTags::getAllowedTags()); |
|
| 331 | - } |
|
| 332 | - echo wp_kses($this->widgetContent($post), AllowedTags::getAllowedTags()); |
|
| 333 | - // After widget (defined by themes). |
|
| 334 | - echo wp_kses($after_widget, AllowedTags::getAllowedTags()); |
|
| 335 | - } |
|
| 336 | - } |
|
| 337 | - } |
|
| 338 | - |
|
| 339 | - |
|
| 340 | - /** |
|
| 341 | - * make_the_title_a_link |
|
| 342 | - * callback for widget_title filter |
|
| 343 | - * |
|
| 344 | - * @param $title |
|
| 345 | - * @return string |
|
| 346 | - */ |
|
| 347 | - public function make_the_title_a_link($title) |
|
| 348 | - { |
|
| 349 | - return '<a href="' . EEH_Event_View::event_archive_url() . '">' . $title . '</a>'; |
|
| 350 | - } |
|
| 351 | - |
|
| 352 | - |
|
| 353 | - /** |
|
| 354 | - * @param string $field_name |
|
| 355 | - * @return string |
|
| 356 | - * @since 4.10.14.p |
|
| 357 | - */ |
|
| 358 | - public function fieldID($field_name) |
|
| 359 | - { |
|
| 360 | - return parent::get_field_id($field_name); |
|
| 361 | - } |
|
| 362 | - |
|
| 363 | - |
|
| 364 | - /** |
|
| 365 | - * @param string $field_name |
|
| 366 | - * @return string |
|
| 367 | - * @since 4.10.14.p |
|
| 368 | - */ |
|
| 369 | - public function fieldName($field_name) |
|
| 370 | - { |
|
| 371 | - return parent::get_field_name($field_name); |
|
| 372 | - } |
|
| 373 | - |
|
| 374 | - |
|
| 375 | - /** |
|
| 376 | - * @param array $instance |
|
| 377 | - * @throws EE_Error |
|
| 378 | - * @throws ReflectionException |
|
| 379 | - * @since 4.10.14.p |
|
| 380 | - */ |
|
| 381 | - private function eventCategoriesSelector(array $instance) |
|
| 382 | - { |
|
| 383 | - $event_categories = []; |
|
| 384 | - $categories = EEM_Term::instance()->get_all_ee_categories(true); |
|
| 385 | - if ($categories) { |
|
| 386 | - foreach ($categories as $category) { |
|
| 387 | - if ($category instanceof EE_Term) { |
|
| 388 | - $event_categories[] = |
|
| 389 | - EE_Question_Option::new_instance( |
|
| 390 | - [ |
|
| 391 | - 'QSO_value' => $category->get('slug'), |
|
| 392 | - 'QSO_desc' => $category->get('name'), |
|
| 393 | - ] |
|
| 394 | - ); |
|
| 395 | - } |
|
| 396 | - } |
|
| 397 | - } |
|
| 398 | - array_unshift( |
|
| 399 | - $event_categories, |
|
| 400 | - EE_Question_Option::new_instance( |
|
| 401 | - [ |
|
| 402 | - 'QSO_value' => '', |
|
| 403 | - 'QSO_desc' => esc_html__(' - display all - ', 'event_espresso'), |
|
| 404 | - ] |
|
| 405 | - ) |
|
| 406 | - ); |
|
| 407 | - echo EEH_Form_Fields::select( |
|
| 408 | - esc_html__('Event Category:', 'event_espresso'), |
|
| 409 | - $instance['category_name'], |
|
| 410 | - $event_categories, |
|
| 411 | - $this->fieldName('category_name'), |
|
| 412 | - $this->fieldID('category_name') |
|
| 413 | - ); |
|
| 414 | - } |
|
| 415 | - |
|
| 416 | - |
|
| 417 | - /** |
|
| 418 | - * @param array $instance |
|
| 419 | - * @since 4.10.14.p |
|
| 420 | - */ |
|
| 421 | - private function imageSizeSelector(array $instance) |
|
| 422 | - { |
|
| 423 | - $image_sizes = []; |
|
| 424 | - $sizes = get_intermediate_image_sizes(); |
|
| 425 | - if ($sizes) { |
|
| 426 | - // loop thru images and create option objects out of them |
|
| 427 | - foreach ($sizes as $image_size) { |
|
| 428 | - $image_size = trim($image_size); |
|
| 429 | - // no big images plz |
|
| 430 | - if (! in_array($image_size, ['large', 'post-thumbnail'])) { |
|
| 431 | - $image_sizes[] = |
|
| 432 | - EE_Question_Option::new_instance(['QSO_value' => $image_size, 'QSO_desc' => $image_size]); |
|
| 433 | - } |
|
| 434 | - } |
|
| 435 | - $image_sizes[] = |
|
| 436 | - EE_Question_Option::new_instance( |
|
| 437 | - ['QSO_value' => 'none', 'QSO_desc' => esc_html__('don\'t show images', 'event_espresso')] |
|
| 438 | - ); |
|
| 439 | - } |
|
| 440 | - echo EEH_Form_Fields::select( |
|
| 441 | - esc_html__('Image Size:', 'event_espresso'), |
|
| 442 | - $instance['image_size'], |
|
| 443 | - $image_sizes, |
|
| 444 | - $this->fieldName('image_size'), |
|
| 445 | - $this->fieldID('image_size') |
|
| 446 | - ); |
|
| 447 | - } |
|
| 448 | - |
|
| 449 | - |
|
| 450 | - /** |
|
| 451 | - * @param array $instance |
|
| 452 | - * @since 4.10.14.p |
|
| 453 | - */ |
|
| 454 | - private function parseWidgetSettings(array $instance) |
|
| 455 | - { |
|
| 456 | - $this->title = isset($instance['title']) && ! empty($instance['title']) ? $instance['title'] : ''; |
|
| 457 | - $this->events_category = isset($instance['category_name']) && ! empty($instance['category_name']) |
|
| 458 | - ? $instance['category_name'] |
|
| 459 | - : false; |
|
| 460 | - $this->show_expired = isset($instance['show_expired']) |
|
| 461 | - ? filter_var($instance['show_expired'], FILTER_VALIDATE_BOOLEAN) |
|
| 462 | - : 0; |
|
| 463 | - $this->image_size = isset($instance['image_size']) && ! empty($instance['image_size']) |
|
| 464 | - ? $instance['image_size'] |
|
| 465 | - : 'medium'; |
|
| 466 | - $this->show_desc = ! isset($instance['show_desc']) |
|
| 467 | - || filter_var($instance['show_desc'], FILTER_VALIDATE_BOOLEAN); |
|
| 468 | - $this->show_dates = ! isset($instance['show_dates']) |
|
| 469 | - || filter_var($instance['show_dates'], FILTER_VALIDATE_BOOLEAN); |
|
| 470 | - $this->date_limit = isset($instance['date_limit']) && ! empty($instance['date_limit']) |
|
| 471 | - ? $instance['date_limit'] |
|
| 472 | - : null; |
|
| 473 | - $this->date_range = isset($instance['date_range']) && ! empty($instance['date_range']) |
|
| 474 | - ? $instance['date_range'] |
|
| 475 | - : false; |
|
| 476 | - $this->limit = isset($instance['limit']) ? absint($instance['limit']) : 10; |
|
| 477 | - $this->order = isset($instance['sort']) && $instance['sort'] === 'DESC' |
|
| 478 | - ? 'DESC' |
|
| 479 | - : 'ASC'; |
|
| 480 | - } |
|
| 481 | - |
|
| 482 | - |
|
| 483 | - /** |
|
| 484 | - * @return mixed|void |
|
| 485 | - * @since 4.10.14.p |
|
| 486 | - */ |
|
| 487 | - private function widgetTitle() |
|
| 488 | - { |
|
| 489 | - // add function to make the title a link |
|
| 490 | - add_filter('widget_title', [$this, 'make_the_title_a_link'], 15); |
|
| 491 | - // filter the title |
|
| 492 | - $title = apply_filters('widget_title', $this->title); |
|
| 493 | - // remove the function from the filter, so it does not affect other widgets |
|
| 494 | - remove_filter('widget_title', [$this, 'make_the_title_a_link'], 15); |
|
| 495 | - return $title; |
|
| 496 | - } |
|
| 497 | - |
|
| 498 | - |
|
| 499 | - /** |
|
| 500 | - * @param WP_Post $post |
|
| 501 | - * @return string |
|
| 502 | - * @throws EE_Error |
|
| 503 | - * @throws ReflectionException |
|
| 504 | - * @since 4.10.14.p |
|
| 505 | - */ |
|
| 506 | - private function widgetContent(WP_Post $post) |
|
| 507 | - { |
|
| 508 | - // run the query |
|
| 509 | - $events = $this->getUpcomingEvents(); |
|
| 510 | - if (empty($events)) { |
|
| 511 | - return ''; |
|
| 512 | - } |
|
| 513 | - $list_items = ''; |
|
| 514 | - foreach ($events as $event) { |
|
| 515 | - if ($event instanceof EE_Event && (! is_single() || $post->ID != $event->ID())) { |
|
| 516 | - $event_url = $this->eventUrl($event); |
|
| 517 | - $list_items .= ' |
|
| 264 | + } |
|
| 265 | + |
|
| 266 | + |
|
| 267 | + /** |
|
| 268 | + * Sanitize widget form values as they are saved. |
|
| 269 | + * |
|
| 270 | + * @param array $new_instance Values just sent to be saved. |
|
| 271 | + * @param array $old_instance Previously saved values from database. |
|
| 272 | + * |
|
| 273 | + * @return array Updated safe values to be saved. |
|
| 274 | + * @see WP_Widget::update() |
|
| 275 | + * |
|
| 276 | + */ |
|
| 277 | + public function update($new_instance, $old_instance) |
|
| 278 | + { |
|
| 279 | + $instance = $old_instance; |
|
| 280 | + $instance['title'] = ! empty($new_instance['title']) ? strip_tags($new_instance['title']) : ''; |
|
| 281 | + $instance['category_name'] = $new_instance['category_name']; |
|
| 282 | + $instance['show_expired'] = $new_instance['show_expired']; |
|
| 283 | + $instance['limit'] = $new_instance['limit']; |
|
| 284 | + $instance['sort'] = $new_instance['sort']; |
|
| 285 | + $instance['image_size'] = $new_instance['image_size']; |
|
| 286 | + $instance['show_desc'] = $new_instance['show_desc']; |
|
| 287 | + $instance['show_dates'] = $new_instance['show_dates']; |
|
| 288 | + $instance['show_everywhere'] = $new_instance['show_everywhere']; |
|
| 289 | + $instance['date_limit'] = $new_instance['date_limit']; |
|
| 290 | + $instance['date_range'] = $new_instance['date_range']; |
|
| 291 | + return $instance; |
|
| 292 | + } |
|
| 293 | + |
|
| 294 | + |
|
| 295 | + /** |
|
| 296 | + * Front-end display of widget. |
|
| 297 | + * |
|
| 298 | + * @param array $args Widget arguments. |
|
| 299 | + * @param array $instance Saved values from database. |
|
| 300 | + * @throws EE_Error |
|
| 301 | + * @throws ReflectionException |
|
| 302 | + * @see WP_Widget::widget() |
|
| 303 | + * |
|
| 304 | + */ |
|
| 305 | + public function widget($args, $instance) |
|
| 306 | + { |
|
| 307 | + |
|
| 308 | + global $post; |
|
| 309 | + // make sure there is some kinda post object |
|
| 310 | + if ($post instanceof WP_Post) { |
|
| 311 | + $before_widget = ''; |
|
| 312 | + $before_title = ''; |
|
| 313 | + $after_title = ''; |
|
| 314 | + $after_widget = ''; |
|
| 315 | + // but NOT an events archives page, cuz that would be like two event lists on the same page |
|
| 316 | + $show_everywhere = ! isset($instance['show_everywhere']) || absint($instance['show_everywhere']); |
|
| 317 | + if ($show_everywhere || ! ($post->post_type == 'espresso_events' && is_archive())) { |
|
| 318 | + // let's use some of the event helper functions' |
|
| 319 | + // make separate vars out of attributes |
|
| 320 | + extract($args); |
|
| 321 | + |
|
| 322 | + // grab widget settings |
|
| 323 | + $this->parseWidgetSettings($instance); |
|
| 324 | + $title = $this->widgetTitle(); |
|
| 325 | + |
|
| 326 | + // Before widget (defined by themes). |
|
| 327 | + echo wp_kses($before_widget, AllowedTags::getAllowedTags()); |
|
| 328 | + // Display the widget title if one was input (before and after defined by themes). |
|
| 329 | + if (! empty($title)) { |
|
| 330 | + echo wp_kses($before_title . $title . $after_title, AllowedTags::getAllowedTags()); |
|
| 331 | + } |
|
| 332 | + echo wp_kses($this->widgetContent($post), AllowedTags::getAllowedTags()); |
|
| 333 | + // After widget (defined by themes). |
|
| 334 | + echo wp_kses($after_widget, AllowedTags::getAllowedTags()); |
|
| 335 | + } |
|
| 336 | + } |
|
| 337 | + } |
|
| 338 | + |
|
| 339 | + |
|
| 340 | + /** |
|
| 341 | + * make_the_title_a_link |
|
| 342 | + * callback for widget_title filter |
|
| 343 | + * |
|
| 344 | + * @param $title |
|
| 345 | + * @return string |
|
| 346 | + */ |
|
| 347 | + public function make_the_title_a_link($title) |
|
| 348 | + { |
|
| 349 | + return '<a href="' . EEH_Event_View::event_archive_url() . '">' . $title . '</a>'; |
|
| 350 | + } |
|
| 351 | + |
|
| 352 | + |
|
| 353 | + /** |
|
| 354 | + * @param string $field_name |
|
| 355 | + * @return string |
|
| 356 | + * @since 4.10.14.p |
|
| 357 | + */ |
|
| 358 | + public function fieldID($field_name) |
|
| 359 | + { |
|
| 360 | + return parent::get_field_id($field_name); |
|
| 361 | + } |
|
| 362 | + |
|
| 363 | + |
|
| 364 | + /** |
|
| 365 | + * @param string $field_name |
|
| 366 | + * @return string |
|
| 367 | + * @since 4.10.14.p |
|
| 368 | + */ |
|
| 369 | + public function fieldName($field_name) |
|
| 370 | + { |
|
| 371 | + return parent::get_field_name($field_name); |
|
| 372 | + } |
|
| 373 | + |
|
| 374 | + |
|
| 375 | + /** |
|
| 376 | + * @param array $instance |
|
| 377 | + * @throws EE_Error |
|
| 378 | + * @throws ReflectionException |
|
| 379 | + * @since 4.10.14.p |
|
| 380 | + */ |
|
| 381 | + private function eventCategoriesSelector(array $instance) |
|
| 382 | + { |
|
| 383 | + $event_categories = []; |
|
| 384 | + $categories = EEM_Term::instance()->get_all_ee_categories(true); |
|
| 385 | + if ($categories) { |
|
| 386 | + foreach ($categories as $category) { |
|
| 387 | + if ($category instanceof EE_Term) { |
|
| 388 | + $event_categories[] = |
|
| 389 | + EE_Question_Option::new_instance( |
|
| 390 | + [ |
|
| 391 | + 'QSO_value' => $category->get('slug'), |
|
| 392 | + 'QSO_desc' => $category->get('name'), |
|
| 393 | + ] |
|
| 394 | + ); |
|
| 395 | + } |
|
| 396 | + } |
|
| 397 | + } |
|
| 398 | + array_unshift( |
|
| 399 | + $event_categories, |
|
| 400 | + EE_Question_Option::new_instance( |
|
| 401 | + [ |
|
| 402 | + 'QSO_value' => '', |
|
| 403 | + 'QSO_desc' => esc_html__(' - display all - ', 'event_espresso'), |
|
| 404 | + ] |
|
| 405 | + ) |
|
| 406 | + ); |
|
| 407 | + echo EEH_Form_Fields::select( |
|
| 408 | + esc_html__('Event Category:', 'event_espresso'), |
|
| 409 | + $instance['category_name'], |
|
| 410 | + $event_categories, |
|
| 411 | + $this->fieldName('category_name'), |
|
| 412 | + $this->fieldID('category_name') |
|
| 413 | + ); |
|
| 414 | + } |
|
| 415 | + |
|
| 416 | + |
|
| 417 | + /** |
|
| 418 | + * @param array $instance |
|
| 419 | + * @since 4.10.14.p |
|
| 420 | + */ |
|
| 421 | + private function imageSizeSelector(array $instance) |
|
| 422 | + { |
|
| 423 | + $image_sizes = []; |
|
| 424 | + $sizes = get_intermediate_image_sizes(); |
|
| 425 | + if ($sizes) { |
|
| 426 | + // loop thru images and create option objects out of them |
|
| 427 | + foreach ($sizes as $image_size) { |
|
| 428 | + $image_size = trim($image_size); |
|
| 429 | + // no big images plz |
|
| 430 | + if (! in_array($image_size, ['large', 'post-thumbnail'])) { |
|
| 431 | + $image_sizes[] = |
|
| 432 | + EE_Question_Option::new_instance(['QSO_value' => $image_size, 'QSO_desc' => $image_size]); |
|
| 433 | + } |
|
| 434 | + } |
|
| 435 | + $image_sizes[] = |
|
| 436 | + EE_Question_Option::new_instance( |
|
| 437 | + ['QSO_value' => 'none', 'QSO_desc' => esc_html__('don\'t show images', 'event_espresso')] |
|
| 438 | + ); |
|
| 439 | + } |
|
| 440 | + echo EEH_Form_Fields::select( |
|
| 441 | + esc_html__('Image Size:', 'event_espresso'), |
|
| 442 | + $instance['image_size'], |
|
| 443 | + $image_sizes, |
|
| 444 | + $this->fieldName('image_size'), |
|
| 445 | + $this->fieldID('image_size') |
|
| 446 | + ); |
|
| 447 | + } |
|
| 448 | + |
|
| 449 | + |
|
| 450 | + /** |
|
| 451 | + * @param array $instance |
|
| 452 | + * @since 4.10.14.p |
|
| 453 | + */ |
|
| 454 | + private function parseWidgetSettings(array $instance) |
|
| 455 | + { |
|
| 456 | + $this->title = isset($instance['title']) && ! empty($instance['title']) ? $instance['title'] : ''; |
|
| 457 | + $this->events_category = isset($instance['category_name']) && ! empty($instance['category_name']) |
|
| 458 | + ? $instance['category_name'] |
|
| 459 | + : false; |
|
| 460 | + $this->show_expired = isset($instance['show_expired']) |
|
| 461 | + ? filter_var($instance['show_expired'], FILTER_VALIDATE_BOOLEAN) |
|
| 462 | + : 0; |
|
| 463 | + $this->image_size = isset($instance['image_size']) && ! empty($instance['image_size']) |
|
| 464 | + ? $instance['image_size'] |
|
| 465 | + : 'medium'; |
|
| 466 | + $this->show_desc = ! isset($instance['show_desc']) |
|
| 467 | + || filter_var($instance['show_desc'], FILTER_VALIDATE_BOOLEAN); |
|
| 468 | + $this->show_dates = ! isset($instance['show_dates']) |
|
| 469 | + || filter_var($instance['show_dates'], FILTER_VALIDATE_BOOLEAN); |
|
| 470 | + $this->date_limit = isset($instance['date_limit']) && ! empty($instance['date_limit']) |
|
| 471 | + ? $instance['date_limit'] |
|
| 472 | + : null; |
|
| 473 | + $this->date_range = isset($instance['date_range']) && ! empty($instance['date_range']) |
|
| 474 | + ? $instance['date_range'] |
|
| 475 | + : false; |
|
| 476 | + $this->limit = isset($instance['limit']) ? absint($instance['limit']) : 10; |
|
| 477 | + $this->order = isset($instance['sort']) && $instance['sort'] === 'DESC' |
|
| 478 | + ? 'DESC' |
|
| 479 | + : 'ASC'; |
|
| 480 | + } |
|
| 481 | + |
|
| 482 | + |
|
| 483 | + /** |
|
| 484 | + * @return mixed|void |
|
| 485 | + * @since 4.10.14.p |
|
| 486 | + */ |
|
| 487 | + private function widgetTitle() |
|
| 488 | + { |
|
| 489 | + // add function to make the title a link |
|
| 490 | + add_filter('widget_title', [$this, 'make_the_title_a_link'], 15); |
|
| 491 | + // filter the title |
|
| 492 | + $title = apply_filters('widget_title', $this->title); |
|
| 493 | + // remove the function from the filter, so it does not affect other widgets |
|
| 494 | + remove_filter('widget_title', [$this, 'make_the_title_a_link'], 15); |
|
| 495 | + return $title; |
|
| 496 | + } |
|
| 497 | + |
|
| 498 | + |
|
| 499 | + /** |
|
| 500 | + * @param WP_Post $post |
|
| 501 | + * @return string |
|
| 502 | + * @throws EE_Error |
|
| 503 | + * @throws ReflectionException |
|
| 504 | + * @since 4.10.14.p |
|
| 505 | + */ |
|
| 506 | + private function widgetContent(WP_Post $post) |
|
| 507 | + { |
|
| 508 | + // run the query |
|
| 509 | + $events = $this->getUpcomingEvents(); |
|
| 510 | + if (empty($events)) { |
|
| 511 | + return ''; |
|
| 512 | + } |
|
| 513 | + $list_items = ''; |
|
| 514 | + foreach ($events as $event) { |
|
| 515 | + if ($event instanceof EE_Event && (! is_single() || $post->ID != $event->ID())) { |
|
| 516 | + $event_url = $this->eventUrl($event); |
|
| 517 | + $list_items .= ' |
|
| 518 | 518 | <li id="ee-upcoming-events-widget-li-' . absint($event->ID()) . '" |
| 519 | 519 | class="ee-upcoming-events-widget-li" |
| 520 | 520 | > |
@@ -525,194 +525,194 @@ discard block |
||
| 525 | 525 | </h5> |
| 526 | 526 | ' . $this->eventWidgetContent($event, $event_url) . ' |
| 527 | 527 | </li>'; |
| 528 | - } |
|
| 529 | - } |
|
| 530 | - return ' |
|
| 528 | + } |
|
| 529 | + } |
|
| 530 | + return ' |
|
| 531 | 531 | <ul class="ee-upcoming-events-widget-ul"> |
| 532 | 532 | ' . $list_items . ' |
| 533 | 533 | </ul>'; |
| 534 | - } |
|
| 535 | - |
|
| 536 | - |
|
| 537 | - /** |
|
| 538 | - * @param EE_Event $event |
|
| 539 | - * @return string|null |
|
| 540 | - * @throws EE_Error |
|
| 541 | - * @since 4.10.14.p |
|
| 542 | - */ |
|
| 543 | - private function eventUrl(EE_Event $event) |
|
| 544 | - { |
|
| 545 | - return esc_url_raw( |
|
| 546 | - apply_filters( |
|
| 547 | - 'FHEE_EEW_Upcoming_Events__widget__event_url', |
|
| 548 | - $event->get_permalink(), |
|
| 549 | - $event |
|
| 550 | - ) |
|
| 551 | - ); |
|
| 552 | - } |
|
| 553 | - |
|
| 554 | - |
|
| 555 | - /** |
|
| 556 | - * @return EE_Base_Class[] |
|
| 557 | - * @throws EE_Error |
|
| 558 | - */ |
|
| 559 | - private function getUpcomingEvents() |
|
| 560 | - { |
|
| 561 | - return EEM_Event::instance()->get_all( |
|
| 562 | - [ |
|
| 563 | - $this->queryWhereParams(), |
|
| 564 | - 'limit' => '0,' . $this->limit, |
|
| 565 | - 'order_by' => 'Datetime.DTT_EVT_start', |
|
| 566 | - 'order' => $this->order, |
|
| 567 | - 'group_by' => 'EVT_ID', |
|
| 568 | - ] |
|
| 569 | - ); |
|
| 570 | - } |
|
| 571 | - |
|
| 572 | - |
|
| 573 | - /** |
|
| 574 | - * @return mixed|void |
|
| 575 | - * @throws EE_Error |
|
| 576 | - * @since 4.10.14.p |
|
| 577 | - */ |
|
| 578 | - private function queryWhereParams() |
|
| 579 | - { |
|
| 580 | - // start to build our where clause |
|
| 581 | - $where = [ |
|
| 582 | - 'status' => ['IN', ['publish', 'sold_out']], |
|
| 583 | - ]; |
|
| 584 | - // add category |
|
| 585 | - if ($this->events_category) { |
|
| 586 | - $where['Term_Taxonomy.taxonomy'] = 'espresso_event_categories'; |
|
| 587 | - $where['Term_Taxonomy.Term.slug'] = $this->events_category; |
|
| 588 | - } |
|
| 589 | - // if NOT expired then we want events that start today or in the future |
|
| 590 | - // if NOT show expired then we want events that start today or in the future |
|
| 591 | - if ($this->show_expired == 0) { |
|
| 592 | - $where['Datetime.DTT_EVT_end'] = [ |
|
| 593 | - '>=', |
|
| 594 | - EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'), |
|
| 595 | - ]; |
|
| 596 | - } |
|
| 597 | - // if show ONLY expired we want events that ended prior to today |
|
| 598 | - if ($this->show_expired == 2) { |
|
| 599 | - $where['Datetime.DTT_EVT_end'] = [ |
|
| 600 | - '<=', |
|
| 601 | - EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start'), |
|
| 602 | - ]; |
|
| 603 | - } |
|
| 604 | - // allow $where to be filtered |
|
| 605 | - return apply_filters('FHEE__EEW_Upcoming_Events__widget__where', $where, $this->events_category, $this->show_expired); |
|
| 606 | - } |
|
| 607 | - |
|
| 608 | - |
|
| 609 | - /** |
|
| 610 | - * @param EE_Event $event |
|
| 611 | - * @return string |
|
| 612 | - * @throws EE_Error |
|
| 613 | - * @throws ReflectionException |
|
| 614 | - * @since 4.10.14.p |
|
| 615 | - */ |
|
| 616 | - private function linkClass(EE_Event $event) |
|
| 617 | - { |
|
| 618 | - // how big is the event name ? |
|
| 619 | - $name_length = strlen($event->name()); |
|
| 620 | - switch ($name_length) { |
|
| 621 | - case $name_length > 70: |
|
| 622 | - return ' three-line'; |
|
| 623 | - case $name_length > 35: |
|
| 624 | - return ' two-line'; |
|
| 625 | - } |
|
| 626 | - return ' one-line'; |
|
| 627 | - } |
|
| 628 | - |
|
| 629 | - |
|
| 630 | - /** |
|
| 631 | - * @param EE_Event $event |
|
| 632 | - * @param string $event_url |
|
| 633 | - * @return mixed|string|void |
|
| 634 | - * @throws EE_Error |
|
| 635 | - * @throws ReflectionException |
|
| 636 | - * @since 4.10.14.p |
|
| 637 | - */ |
|
| 638 | - private function eventWidgetContent(EE_Event $event, $event_url = '') |
|
| 639 | - { |
|
| 640 | - if (post_password_required($event->ID())) { |
|
| 641 | - return apply_filters( |
|
| 642 | - 'FHEE_EEW_Upcoming_Events__widget__password_form', |
|
| 643 | - get_the_password_form($event->ID()), |
|
| 644 | - $event |
|
| 645 | - ); |
|
| 646 | - } |
|
| 647 | - |
|
| 648 | - $content = ''; |
|
| 649 | - if (has_post_thumbnail($event->ID()) && $this->image_size != 'none') { |
|
| 650 | - $content .= ' |
|
| 534 | + } |
|
| 535 | + |
|
| 536 | + |
|
| 537 | + /** |
|
| 538 | + * @param EE_Event $event |
|
| 539 | + * @return string|null |
|
| 540 | + * @throws EE_Error |
|
| 541 | + * @since 4.10.14.p |
|
| 542 | + */ |
|
| 543 | + private function eventUrl(EE_Event $event) |
|
| 544 | + { |
|
| 545 | + return esc_url_raw( |
|
| 546 | + apply_filters( |
|
| 547 | + 'FHEE_EEW_Upcoming_Events__widget__event_url', |
|
| 548 | + $event->get_permalink(), |
|
| 549 | + $event |
|
| 550 | + ) |
|
| 551 | + ); |
|
| 552 | + } |
|
| 553 | + |
|
| 554 | + |
|
| 555 | + /** |
|
| 556 | + * @return EE_Base_Class[] |
|
| 557 | + * @throws EE_Error |
|
| 558 | + */ |
|
| 559 | + private function getUpcomingEvents() |
|
| 560 | + { |
|
| 561 | + return EEM_Event::instance()->get_all( |
|
| 562 | + [ |
|
| 563 | + $this->queryWhereParams(), |
|
| 564 | + 'limit' => '0,' . $this->limit, |
|
| 565 | + 'order_by' => 'Datetime.DTT_EVT_start', |
|
| 566 | + 'order' => $this->order, |
|
| 567 | + 'group_by' => 'EVT_ID', |
|
| 568 | + ] |
|
| 569 | + ); |
|
| 570 | + } |
|
| 571 | + |
|
| 572 | + |
|
| 573 | + /** |
|
| 574 | + * @return mixed|void |
|
| 575 | + * @throws EE_Error |
|
| 576 | + * @since 4.10.14.p |
|
| 577 | + */ |
|
| 578 | + private function queryWhereParams() |
|
| 579 | + { |
|
| 580 | + // start to build our where clause |
|
| 581 | + $where = [ |
|
| 582 | + 'status' => ['IN', ['publish', 'sold_out']], |
|
| 583 | + ]; |
|
| 584 | + // add category |
|
| 585 | + if ($this->events_category) { |
|
| 586 | + $where['Term_Taxonomy.taxonomy'] = 'espresso_event_categories'; |
|
| 587 | + $where['Term_Taxonomy.Term.slug'] = $this->events_category; |
|
| 588 | + } |
|
| 589 | + // if NOT expired then we want events that start today or in the future |
|
| 590 | + // if NOT show expired then we want events that start today or in the future |
|
| 591 | + if ($this->show_expired == 0) { |
|
| 592 | + $where['Datetime.DTT_EVT_end'] = [ |
|
| 593 | + '>=', |
|
| 594 | + EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'), |
|
| 595 | + ]; |
|
| 596 | + } |
|
| 597 | + // if show ONLY expired we want events that ended prior to today |
|
| 598 | + if ($this->show_expired == 2) { |
|
| 599 | + $where['Datetime.DTT_EVT_end'] = [ |
|
| 600 | + '<=', |
|
| 601 | + EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start'), |
|
| 602 | + ]; |
|
| 603 | + } |
|
| 604 | + // allow $where to be filtered |
|
| 605 | + return apply_filters('FHEE__EEW_Upcoming_Events__widget__where', $where, $this->events_category, $this->show_expired); |
|
| 606 | + } |
|
| 607 | + |
|
| 608 | + |
|
| 609 | + /** |
|
| 610 | + * @param EE_Event $event |
|
| 611 | + * @return string |
|
| 612 | + * @throws EE_Error |
|
| 613 | + * @throws ReflectionException |
|
| 614 | + * @since 4.10.14.p |
|
| 615 | + */ |
|
| 616 | + private function linkClass(EE_Event $event) |
|
| 617 | + { |
|
| 618 | + // how big is the event name ? |
|
| 619 | + $name_length = strlen($event->name()); |
|
| 620 | + switch ($name_length) { |
|
| 621 | + case $name_length > 70: |
|
| 622 | + return ' three-line'; |
|
| 623 | + case $name_length > 35: |
|
| 624 | + return ' two-line'; |
|
| 625 | + } |
|
| 626 | + return ' one-line'; |
|
| 627 | + } |
|
| 628 | + |
|
| 629 | + |
|
| 630 | + /** |
|
| 631 | + * @param EE_Event $event |
|
| 632 | + * @param string $event_url |
|
| 633 | + * @return mixed|string|void |
|
| 634 | + * @throws EE_Error |
|
| 635 | + * @throws ReflectionException |
|
| 636 | + * @since 4.10.14.p |
|
| 637 | + */ |
|
| 638 | + private function eventWidgetContent(EE_Event $event, $event_url = '') |
|
| 639 | + { |
|
| 640 | + if (post_password_required($event->ID())) { |
|
| 641 | + return apply_filters( |
|
| 642 | + 'FHEE_EEW_Upcoming_Events__widget__password_form', |
|
| 643 | + get_the_password_form($event->ID()), |
|
| 644 | + $event |
|
| 645 | + ); |
|
| 646 | + } |
|
| 647 | + |
|
| 648 | + $content = ''; |
|
| 649 | + if (has_post_thumbnail($event->ID()) && $this->image_size != 'none') { |
|
| 650 | + $content .= ' |
|
| 651 | 651 | <div class="ee-upcoming-events-widget-img-dv"> |
| 652 | 652 | <a class="ee-upcoming-events-widget-img" href="' . $event_url . '"> |
| 653 | 653 | ' . get_the_post_thumbnail($event->ID(), $this->image_size) . ' |
| 654 | 654 | </a> |
| 655 | 655 | </div>'; |
| 656 | - } |
|
| 657 | - |
|
| 658 | - if ($this->show_dates) { |
|
| 659 | - $content .= $this->eventDates($event); |
|
| 660 | - } |
|
| 661 | - |
|
| 662 | - if ($this->show_desc) { |
|
| 663 | - $allowedtags = AllowedTags::getAllowedTags(); |
|
| 664 | - $desc = $event->short_description(25); |
|
| 665 | - $content .= $desc ? '<p style="margin-top: .5em">' . wp_kses($desc, $allowedtags) . '</p>' : ''; |
|
| 666 | - } |
|
| 667 | - |
|
| 668 | - return $content; |
|
| 669 | - } |
|
| 670 | - |
|
| 671 | - |
|
| 672 | - /** |
|
| 673 | - * @param EE_Event $event |
|
| 674 | - * @return string |
|
| 675 | - * @throws EE_Error |
|
| 676 | - * @throws ReflectionException |
|
| 677 | - * @since 4.10.14.p |
|
| 678 | - */ |
|
| 679 | - private function eventDates(EE_Event $event) |
|
| 680 | - { |
|
| 681 | - $date_format = apply_filters( |
|
| 682 | - 'FHEE__espresso_event_date_range__date_format', |
|
| 683 | - get_option('date_format') |
|
| 684 | - ); |
|
| 685 | - $time_format = apply_filters( |
|
| 686 | - 'FHEE__espresso_event_date_range__time_format', |
|
| 687 | - get_option('time_format') |
|
| 688 | - ); |
|
| 689 | - $single_date_format = apply_filters( |
|
| 690 | - 'FHEE__espresso_event_date_range__single_date_format', |
|
| 691 | - get_option('date_format') |
|
| 692 | - ); |
|
| 693 | - $single_time_format = apply_filters( |
|
| 694 | - 'FHEE__espresso_event_date_range__single_time_format', |
|
| 695 | - get_option('time_format') |
|
| 696 | - ); |
|
| 697 | - if ($this->date_range == true) { |
|
| 698 | - return espresso_event_date_range( |
|
| 699 | - $date_format, |
|
| 700 | - $time_format, |
|
| 701 | - $single_date_format, |
|
| 702 | - $single_time_format, |
|
| 703 | - $event->ID(), |
|
| 704 | - false |
|
| 705 | - ); |
|
| 706 | - } |
|
| 707 | - return espresso_list_of_event_dates( |
|
| 708 | - $event->ID(), |
|
| 709 | - $date_format, |
|
| 710 | - $time_format, |
|
| 711 | - false, |
|
| 712 | - null, |
|
| 713 | - true, |
|
| 714 | - true, |
|
| 715 | - $this->date_limit |
|
| 716 | - ); |
|
| 717 | - } |
|
| 656 | + } |
|
| 657 | + |
|
| 658 | + if ($this->show_dates) { |
|
| 659 | + $content .= $this->eventDates($event); |
|
| 660 | + } |
|
| 661 | + |
|
| 662 | + if ($this->show_desc) { |
|
| 663 | + $allowedtags = AllowedTags::getAllowedTags(); |
|
| 664 | + $desc = $event->short_description(25); |
|
| 665 | + $content .= $desc ? '<p style="margin-top: .5em">' . wp_kses($desc, $allowedtags) . '</p>' : ''; |
|
| 666 | + } |
|
| 667 | + |
|
| 668 | + return $content; |
|
| 669 | + } |
|
| 670 | + |
|
| 671 | + |
|
| 672 | + /** |
|
| 673 | + * @param EE_Event $event |
|
| 674 | + * @return string |
|
| 675 | + * @throws EE_Error |
|
| 676 | + * @throws ReflectionException |
|
| 677 | + * @since 4.10.14.p |
|
| 678 | + */ |
|
| 679 | + private function eventDates(EE_Event $event) |
|
| 680 | + { |
|
| 681 | + $date_format = apply_filters( |
|
| 682 | + 'FHEE__espresso_event_date_range__date_format', |
|
| 683 | + get_option('date_format') |
|
| 684 | + ); |
|
| 685 | + $time_format = apply_filters( |
|
| 686 | + 'FHEE__espresso_event_date_range__time_format', |
|
| 687 | + get_option('time_format') |
|
| 688 | + ); |
|
| 689 | + $single_date_format = apply_filters( |
|
| 690 | + 'FHEE__espresso_event_date_range__single_date_format', |
|
| 691 | + get_option('date_format') |
|
| 692 | + ); |
|
| 693 | + $single_time_format = apply_filters( |
|
| 694 | + 'FHEE__espresso_event_date_range__single_time_format', |
|
| 695 | + get_option('time_format') |
|
| 696 | + ); |
|
| 697 | + if ($this->date_range == true) { |
|
| 698 | + return espresso_event_date_range( |
|
| 699 | + $date_format, |
|
| 700 | + $time_format, |
|
| 701 | + $single_date_format, |
|
| 702 | + $single_time_format, |
|
| 703 | + $event->ID(), |
|
| 704 | + false |
|
| 705 | + ); |
|
| 706 | + } |
|
| 707 | + return espresso_list_of_event_dates( |
|
| 708 | + $event->ID(), |
|
| 709 | + $date_format, |
|
| 710 | + $time_format, |
|
| 711 | + false, |
|
| 712 | + null, |
|
| 713 | + true, |
|
| 714 | + true, |
|
| 715 | + $this->date_limit |
|
| 716 | + ); |
|
| 717 | + } |
|
| 718 | 718 | } |
@@ -19,38 +19,38 @@ discard block |
||
| 19 | 19 | */ |
| 20 | 20 | function ee_recurse_into_array_for_display($data, $depth = 0, $td = true) |
| 21 | 21 | { |
| 22 | - if (is_object($data) || $data instanceof __PHP_Incomplete_Class) { |
|
| 23 | - // is_object($incomplete_class) actually returns false, hence why we check for it |
|
| 24 | - $data = json_decode(json_encode($data), true); |
|
| 25 | - } |
|
| 26 | - if (empty($data)) { |
|
| 27 | - return; |
|
| 28 | - } |
|
| 29 | - if (is_array($data)) { |
|
| 30 | - $depth++; |
|
| 31 | - ksort($data, SORT_NATURAL | SORT_FLAG_CASE); |
|
| 32 | - if (EEH_Array::is_associative_array($data)) { ?> |
|
| 22 | + if (is_object($data) || $data instanceof __PHP_Incomplete_Class) { |
|
| 23 | + // is_object($incomplete_class) actually returns false, hence why we check for it |
|
| 24 | + $data = json_decode(json_encode($data), true); |
|
| 25 | + } |
|
| 26 | + if (empty($data)) { |
|
| 27 | + return; |
|
| 28 | + } |
|
| 29 | + if (is_array($data)) { |
|
| 30 | + $depth++; |
|
| 31 | + ksort($data, SORT_NATURAL | SORT_FLAG_CASE); |
|
| 32 | + if (EEH_Array::is_associative_array($data)) { ?> |
|
| 33 | 33 | <table class='ee-system-stati ee-system-stati-<?php echo absint($depth); ?>'> |
| 34 | 34 | <tbody> |
| 35 | 35 | <?php foreach ($data as $data_key => $data_value) { |
| 36 | - // if the value is a single element array with no key, |
|
| 37 | - // and the value is a primitive (not an array, object, etc.) |
|
| 38 | - if ( |
|
| 39 | - is_array($data_value) |
|
| 40 | - && count($data_value) === 1 |
|
| 41 | - && empty(key($data_value)) |
|
| 42 | - && is_scalar(reset($data_value)) |
|
| 43 | - ) { |
|
| 44 | - ?> |
|
| 36 | + // if the value is a single element array with no key, |
|
| 37 | + // and the value is a primitive (not an array, object, etc.) |
|
| 38 | + if ( |
|
| 39 | + is_array($data_value) |
|
| 40 | + && count($data_value) === 1 |
|
| 41 | + && empty(key($data_value)) |
|
| 42 | + && is_scalar(reset($data_value)) |
|
| 43 | + ) { |
|
| 44 | + ?> |
|
| 45 | 45 | <tr> |
| 46 | 46 | <td class="ee-system-stati-value" colspan="2"> |
| 47 | 47 | <?php echo esc_html(reset($data_value)); ?> |
| 48 | 48 | </td> |
| 49 | 49 | </tr> |
| 50 | 50 | <?php |
| 51 | - continue; |
|
| 52 | - } |
|
| 53 | - ?> |
|
| 51 | + continue; |
|
| 52 | + } |
|
| 53 | + ?> |
|
| 54 | 54 | <tr> |
| 55 | 55 | <td class='ee-system-stati-key'> |
| 56 | 56 | <span class="ee-system-stati-label"> |
@@ -65,31 +65,31 @@ discard block |
||
| 65 | 65 | <?php if (is_scalar($data_value)) { ?> |
| 66 | 66 | <?php ee_recurse_into_array_for_display($data_value, $depth); ?> |
| 67 | 67 | <?php } else { |
| 68 | - if (is_array($data_value) && count($data_value) === 1) { |
|
| 69 | - // verify that values have been set |
|
| 70 | - $keys_only = empty( |
|
| 71 | - array_filter( |
|
| 72 | - array_values($data_value), |
|
| 73 | - function ($v) { |
|
| 74 | - return $v !== null && (is_array($v) || trim($v) !== ''); |
|
| 75 | - } |
|
| 76 | - ) |
|
| 77 | - ); |
|
| 78 | - // if the array only consists of keys (no values) |
|
| 79 | - if ($keys_only) { |
|
| 80 | - // then use keys for values |
|
| 81 | - $data_value = array_keys($data_value); |
|
| 82 | - // but if there is only one value now |
|
| 83 | - if (count($data_value) === 1) { |
|
| 84 | - // then pass that single value back into this function |
|
| 85 | - // this prevents extra empty layers of nothing being added to the output |
|
| 86 | - ee_recurse_into_array_for_display(reset($data_value), $depth); |
|
| 87 | - // need to finish the row off though |
|
| 88 | - echo '</tr>'; |
|
| 89 | - continue; |
|
| 90 | - } |
|
| 91 | - } |
|
| 92 | - } ?> |
|
| 68 | + if (is_array($data_value) && count($data_value) === 1) { |
|
| 69 | + // verify that values have been set |
|
| 70 | + $keys_only = empty( |
|
| 71 | + array_filter( |
|
| 72 | + array_values($data_value), |
|
| 73 | + function ($v) { |
|
| 74 | + return $v !== null && (is_array($v) || trim($v) !== ''); |
|
| 75 | + } |
|
| 76 | + ) |
|
| 77 | + ); |
|
| 78 | + // if the array only consists of keys (no values) |
|
| 79 | + if ($keys_only) { |
|
| 80 | + // then use keys for values |
|
| 81 | + $data_value = array_keys($data_value); |
|
| 82 | + // but if there is only one value now |
|
| 83 | + if (count($data_value) === 1) { |
|
| 84 | + // then pass that single value back into this function |
|
| 85 | + // this prevents extra empty layers of nothing being added to the output |
|
| 86 | + ee_recurse_into_array_for_display(reset($data_value), $depth); |
|
| 87 | + // need to finish the row off though |
|
| 88 | + echo '</tr>'; |
|
| 89 | + continue; |
|
| 90 | + } |
|
| 91 | + } |
|
| 92 | + } ?> |
|
| 93 | 93 | <td class="ee-system-stati-sub-values"> |
| 94 | 94 | <?php ee_recurse_into_array_for_display($data_value, $depth); ?> |
| 95 | 95 | </td> |
@@ -107,19 +107,19 @@ discard block |
||
| 107 | 107 | <?php } ?> |
| 108 | 108 | </ul> |
| 109 | 109 | <?php } else { |
| 110 | - // there's no key (label) and there's only one value, |
|
| 111 | - // so let's just pass that value back into this function, |
|
| 112 | - // but reset the depth back to where it was. |
|
| 113 | - // this prevents extra empty layers of nothing being added to the output |
|
| 114 | - $depth--; |
|
| 115 | - ee_recurse_into_array_for_display(reset($data), $depth, false); |
|
| 116 | - } |
|
| 117 | - } else { |
|
| 118 | - echo ($td ? '<td class="ee-system-stati-value">' : ''); |
|
| 119 | - // simple value |
|
| 120 | - echo wp_kses($data, AllowedTags::getAllowedTags()); |
|
| 121 | - echo ($td ? '</td>' : ''); |
|
| 122 | - } |
|
| 110 | + // there's no key (label) and there's only one value, |
|
| 111 | + // so let's just pass that value back into this function, |
|
| 112 | + // but reset the depth back to where it was. |
|
| 113 | + // this prevents extra empty layers of nothing being added to the output |
|
| 114 | + $depth--; |
|
| 115 | + ee_recurse_into_array_for_display(reset($data), $depth, false); |
|
| 116 | + } |
|
| 117 | + } else { |
|
| 118 | + echo ($td ? '<td class="ee-system-stati-value">' : ''); |
|
| 119 | + // simple value |
|
| 120 | + echo wp_kses($data, AllowedTags::getAllowedTags()); |
|
| 121 | + echo ($td ? '</td>' : ''); |
|
| 122 | + } |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | ?> |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | */ |
| 126 | 126 | private function setName($name) |
| 127 | 127 | { |
| 128 | - if (! is_string($name)) { |
|
| 128 | + if ( ! is_string($name)) { |
|
| 129 | 129 | throw new InvalidDataTypeException('$name', $name, 'string'); |
| 130 | 130 | } |
| 131 | 131 | $this->name = sanitize_key($name); |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | */ |
| 148 | 148 | private function setMessage($message) |
| 149 | 149 | { |
| 150 | - if (! is_string($message)) { |
|
| 150 | + if ( ! is_string($message)) { |
|
| 151 | 151 | throw new InvalidDataTypeException('$message', $message, 'string'); |
| 152 | 152 | } |
| 153 | 153 | $allowedtags = AllowedTags::getAllowedTags(); |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | */ |
| 189 | 189 | private function setCapability($capability) |
| 190 | 190 | { |
| 191 | - if (! is_string($capability)) { |
|
| 191 | + if ( ! is_string($capability)) { |
|
| 192 | 192 | throw new InvalidDataTypeException('$capability', $capability, 'string'); |
| 193 | 193 | } |
| 194 | 194 | $this->capability = ! empty($capability) ? $capability : 'manage_options'; |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | */ |
| 211 | 211 | private function setCapContext($cap_context) |
| 212 | 212 | { |
| 213 | - if (! is_string($cap_context)) { |
|
| 213 | + if ( ! is_string($cap_context)) { |
|
| 214 | 214 | throw new InvalidDataTypeException('$cap_context', $cap_context, 'string'); |
| 215 | 215 | } |
| 216 | 216 | $this->cap_context = ! empty($cap_context) ? $cap_context : 'view persistent admin notice'; |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | */ |
| 242 | 242 | public function getCapCheck() |
| 243 | 243 | { |
| 244 | - if (! $this->cap_check instanceof CapCheckInterface) { |
|
| 244 | + if ( ! $this->cap_check instanceof CapCheckInterface) { |
|
| 245 | 245 | $this->setCapCheck( |
| 246 | 246 | new CapCheck( |
| 247 | 247 | $this->capability, |
@@ -322,10 +322,10 @@ discard block |
||
| 322 | 322 | */ |
| 323 | 323 | public function confirmRegistered() |
| 324 | 324 | { |
| 325 | - if (! apply_filters('PersistentAdminNoticeManager__registerAndSaveNotices__complete', false)) { |
|
| 325 | + if ( ! apply_filters('PersistentAdminNoticeManager__registerAndSaveNotices__complete', false)) { |
|
| 326 | 326 | PersistentAdminNoticeManager::loadRegisterAndSaveNotices(); |
| 327 | 327 | } |
| 328 | - if (! $this->registered && WP_DEBUG) { |
|
| 328 | + if ( ! $this->registered && WP_DEBUG) { |
|
| 329 | 329 | throw new DomainException( |
| 330 | 330 | sprintf( |
| 331 | 331 | esc_html__( |
@@ -25,315 +25,315 @@ |
||
| 25 | 25 | */ |
| 26 | 26 | class PersistentAdminNotice implements RequiresCapCheckInterface |
| 27 | 27 | { |
| 28 | - /** |
|
| 29 | - * @var string $name |
|
| 30 | - */ |
|
| 31 | - protected $name = ''; |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * @var string $message |
|
| 35 | - */ |
|
| 36 | - protected $message = ''; |
|
| 37 | - |
|
| 38 | - /** |
|
| 39 | - * @var boolean $force_update |
|
| 40 | - */ |
|
| 41 | - protected $force_update = false; |
|
| 42 | - |
|
| 43 | - /** |
|
| 44 | - * @var string $capability |
|
| 45 | - */ |
|
| 46 | - protected $capability = 'manage_options'; |
|
| 47 | - |
|
| 48 | - /** |
|
| 49 | - * @var string $cap_context |
|
| 50 | - */ |
|
| 51 | - protected $cap_context = 'view persistent admin notice'; |
|
| 52 | - |
|
| 53 | - /** |
|
| 54 | - * @var boolean $dismissed |
|
| 55 | - */ |
|
| 56 | - protected $dismissed = false; |
|
| 57 | - |
|
| 58 | - /** |
|
| 59 | - * @var CapCheckInterface $cap_check |
|
| 60 | - */ |
|
| 61 | - protected $cap_check; |
|
| 62 | - |
|
| 63 | - /** |
|
| 64 | - * if true, then this notice will be deleted from the database |
|
| 65 | - * |
|
| 66 | - * @var boolean $purge |
|
| 67 | - */ |
|
| 68 | - protected $purge = false; |
|
| 69 | - |
|
| 70 | - /** |
|
| 71 | - * gets set to true if notice is successfully registered with the PersistentAdminNoticeManager |
|
| 72 | - * if false, and WP_DEBUG is on, then an exception will be thrown in the admin footer |
|
| 73 | - * |
|
| 74 | - * @var boolean $registered |
|
| 75 | - */ |
|
| 76 | - private $registered = false; |
|
| 77 | - |
|
| 78 | - |
|
| 79 | - /** |
|
| 80 | - * PersistentAdminNotice constructor |
|
| 81 | - * |
|
| 82 | - * @param string $name [required] the name, or key of the Persistent Admin Notice to be stored |
|
| 83 | - * @param string $message [required] the message to be stored persistently until dismissed |
|
| 84 | - * @param bool $force_update enforce the reappearance of a persistent message |
|
| 85 | - * @param string $capability user capability required to view this notice |
|
| 86 | - * @param string $cap_context description for why the cap check is being performed |
|
| 87 | - * @param bool $dismissed whether or not the user has already dismissed/viewed this notice |
|
| 88 | - * @throws InvalidDataTypeException |
|
| 89 | - */ |
|
| 90 | - public function __construct( |
|
| 91 | - $name, |
|
| 92 | - $message, |
|
| 93 | - $force_update = false, |
|
| 94 | - $capability = 'manage_options', |
|
| 95 | - $cap_context = 'view persistent admin notice', |
|
| 96 | - $dismissed = false |
|
| 97 | - ) { |
|
| 98 | - $this->setName($name); |
|
| 99 | - $this->setMessage($message); |
|
| 100 | - $this->setForceUpdate($force_update); |
|
| 101 | - $this->setCapability($capability); |
|
| 102 | - $this->setCapContext($cap_context); |
|
| 103 | - $this->setDismissed($dismissed); |
|
| 104 | - add_action( |
|
| 105 | - 'AHEE__EventEspresso_core_services_notifications_PersistentAdminNoticeManager__registerNotices', |
|
| 106 | - array($this, 'registerPersistentAdminNotice') |
|
| 107 | - ); |
|
| 108 | - add_action('shutdown', array($this, 'confirmRegistered'), 999); |
|
| 109 | - } |
|
| 110 | - |
|
| 111 | - |
|
| 112 | - /** |
|
| 113 | - * @return string |
|
| 114 | - */ |
|
| 115 | - public function getName() |
|
| 116 | - { |
|
| 117 | - return $this->name; |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - |
|
| 121 | - /** |
|
| 122 | - * @param string $name |
|
| 123 | - * @throws InvalidDataTypeException |
|
| 124 | - */ |
|
| 125 | - private function setName($name) |
|
| 126 | - { |
|
| 127 | - if (! is_string($name)) { |
|
| 128 | - throw new InvalidDataTypeException('$name', $name, 'string'); |
|
| 129 | - } |
|
| 130 | - $this->name = sanitize_key($name); |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - |
|
| 134 | - /** |
|
| 135 | - * @return string |
|
| 136 | - */ |
|
| 137 | - public function getMessage() |
|
| 138 | - { |
|
| 139 | - return $this->message; |
|
| 140 | - } |
|
| 141 | - |
|
| 142 | - |
|
| 143 | - /** |
|
| 144 | - * @param string $message |
|
| 145 | - * @throws InvalidDataTypeException |
|
| 146 | - */ |
|
| 147 | - private function setMessage($message) |
|
| 148 | - { |
|
| 149 | - if (! is_string($message)) { |
|
| 150 | - throw new InvalidDataTypeException('$message', $message, 'string'); |
|
| 151 | - } |
|
| 152 | - $allowedtags = AllowedTags::getAllowedTags(); |
|
| 153 | - $this->message = wp_kses($message, $allowedtags); |
|
| 154 | - } |
|
| 155 | - |
|
| 156 | - |
|
| 157 | - /** |
|
| 158 | - * @return bool |
|
| 159 | - */ |
|
| 160 | - public function getForceUpdate() |
|
| 161 | - { |
|
| 162 | - return $this->force_update; |
|
| 163 | - } |
|
| 164 | - |
|
| 165 | - |
|
| 166 | - /** |
|
| 167 | - * @param bool $force_update |
|
| 168 | - */ |
|
| 169 | - private function setForceUpdate($force_update) |
|
| 170 | - { |
|
| 171 | - $this->force_update = filter_var($force_update, FILTER_VALIDATE_BOOLEAN); |
|
| 172 | - } |
|
| 173 | - |
|
| 174 | - |
|
| 175 | - /** |
|
| 176 | - * @return string |
|
| 177 | - */ |
|
| 178 | - public function getCapability() |
|
| 179 | - { |
|
| 180 | - return $this->capability; |
|
| 181 | - } |
|
| 182 | - |
|
| 183 | - |
|
| 184 | - /** |
|
| 185 | - * @param string $capability |
|
| 186 | - * @throws InvalidDataTypeException |
|
| 187 | - */ |
|
| 188 | - private function setCapability($capability) |
|
| 189 | - { |
|
| 190 | - if (! is_string($capability)) { |
|
| 191 | - throw new InvalidDataTypeException('$capability', $capability, 'string'); |
|
| 192 | - } |
|
| 193 | - $this->capability = ! empty($capability) ? $capability : 'manage_options'; |
|
| 194 | - } |
|
| 195 | - |
|
| 196 | - |
|
| 197 | - /** |
|
| 198 | - * @return string |
|
| 199 | - */ |
|
| 200 | - public function getCapContext() |
|
| 201 | - { |
|
| 202 | - return $this->cap_context; |
|
| 203 | - } |
|
| 204 | - |
|
| 205 | - |
|
| 206 | - /** |
|
| 207 | - * @param string $cap_context |
|
| 208 | - * @throws InvalidDataTypeException |
|
| 209 | - */ |
|
| 210 | - private function setCapContext($cap_context) |
|
| 211 | - { |
|
| 212 | - if (! is_string($cap_context)) { |
|
| 213 | - throw new InvalidDataTypeException('$cap_context', $cap_context, 'string'); |
|
| 214 | - } |
|
| 215 | - $this->cap_context = ! empty($cap_context) ? $cap_context : 'view persistent admin notice'; |
|
| 216 | - } |
|
| 217 | - |
|
| 218 | - |
|
| 219 | - /** |
|
| 220 | - * @return bool |
|
| 221 | - */ |
|
| 222 | - public function getDismissed() |
|
| 223 | - { |
|
| 224 | - return $this->dismissed; |
|
| 225 | - } |
|
| 226 | - |
|
| 227 | - |
|
| 228 | - /** |
|
| 229 | - * @param bool $dismissed |
|
| 230 | - */ |
|
| 231 | - public function setDismissed($dismissed) |
|
| 232 | - { |
|
| 233 | - $this->dismissed = filter_var($dismissed, FILTER_VALIDATE_BOOLEAN); |
|
| 234 | - } |
|
| 235 | - |
|
| 236 | - |
|
| 237 | - /** |
|
| 238 | - * @return CapCheckInterface |
|
| 239 | - * @throws InvalidDataTypeException |
|
| 240 | - */ |
|
| 241 | - public function getCapCheck() |
|
| 242 | - { |
|
| 243 | - if (! $this->cap_check instanceof CapCheckInterface) { |
|
| 244 | - $this->setCapCheck( |
|
| 245 | - new CapCheck( |
|
| 246 | - $this->capability, |
|
| 247 | - $this->cap_context |
|
| 248 | - ) |
|
| 249 | - ); |
|
| 250 | - } |
|
| 251 | - return $this->cap_check; |
|
| 252 | - } |
|
| 253 | - |
|
| 254 | - |
|
| 255 | - /** |
|
| 256 | - * @param CapCheckInterface $cap_check |
|
| 257 | - */ |
|
| 258 | - private function setCapCheck(CapCheckInterface $cap_check) |
|
| 259 | - { |
|
| 260 | - $this->cap_check = $cap_check; |
|
| 261 | - } |
|
| 262 | - |
|
| 263 | - |
|
| 264 | - /** |
|
| 265 | - * @return bool |
|
| 266 | - */ |
|
| 267 | - public function getPurge() |
|
| 268 | - { |
|
| 269 | - return $this->purge; |
|
| 270 | - } |
|
| 271 | - |
|
| 272 | - |
|
| 273 | - /** |
|
| 274 | - * @param bool $purge |
|
| 275 | - */ |
|
| 276 | - public function setPurge($purge) |
|
| 277 | - { |
|
| 278 | - $this->purge = filter_var($purge, FILTER_VALIDATE_BOOLEAN); |
|
| 279 | - } |
|
| 280 | - |
|
| 281 | - |
|
| 282 | - /** |
|
| 283 | - * given a valid PersistentAdminNotice Collection, |
|
| 284 | - * this notice will be added if it is not already found in the collection (using its name as the identifier) |
|
| 285 | - * if an existing notice is found that has already been dismissed, |
|
| 286 | - * but we are overriding with a forced update, then we will toggle its dismissed state, |
|
| 287 | - * so that the notice is displayed again |
|
| 288 | - * |
|
| 289 | - * @param Collection $persistent_admin_notice_collection |
|
| 290 | - * @throws InvalidEntityException |
|
| 291 | - * @throws InvalidDataTypeException |
|
| 292 | - * @throws DuplicateCollectionIdentifierException |
|
| 293 | - */ |
|
| 294 | - public function registerPersistentAdminNotice(Collection $persistent_admin_notice_collection) |
|
| 295 | - { |
|
| 296 | - if ($this->registered) { |
|
| 297 | - return; |
|
| 298 | - } |
|
| 299 | - // first check if this notice has already been added to the collection |
|
| 300 | - if ($persistent_admin_notice_collection->has($this->name)) { |
|
| 301 | - /** @var PersistentAdminNotice $existing */ |
|
| 302 | - $existing = $persistent_admin_notice_collection->get($this->name); |
|
| 303 | - // we don't need to add it again (we can't actually) |
|
| 304 | - // but if it has already been dismissed, and we are overriding with a forced update |
|
| 305 | - if ($existing->getDismissed() && $this->getForceUpdate()) { |
|
| 306 | - // then toggle the notice's dismissed state to true |
|
| 307 | - // so that it gets displayed again |
|
| 308 | - $existing->setDismissed(false); |
|
| 309 | - // and make sure the message is set |
|
| 310 | - $existing->setMessage($this->message); |
|
| 311 | - } |
|
| 312 | - } else { |
|
| 313 | - $persistent_admin_notice_collection->add($this, $this->name); |
|
| 314 | - } |
|
| 315 | - $this->registered = true; |
|
| 316 | - } |
|
| 317 | - |
|
| 318 | - |
|
| 319 | - /** |
|
| 320 | - * @throws Exception |
|
| 321 | - */ |
|
| 322 | - public function confirmRegistered() |
|
| 323 | - { |
|
| 324 | - if (! apply_filters('PersistentAdminNoticeManager__registerAndSaveNotices__complete', false)) { |
|
| 325 | - PersistentAdminNoticeManager::loadRegisterAndSaveNotices(); |
|
| 326 | - } |
|
| 327 | - if (! $this->registered && WP_DEBUG) { |
|
| 328 | - throw new DomainException( |
|
| 329 | - sprintf( |
|
| 330 | - esc_html__( |
|
| 331 | - 'The "%1$s" PersistentAdminNotice was not successfully registered. Please ensure that it is being created prior to either the "admin_notices" or "network_admin_notices" hooks being triggered.', |
|
| 332 | - 'event_espresso' |
|
| 333 | - ), |
|
| 334 | - $this->name |
|
| 335 | - ) |
|
| 336 | - ); |
|
| 337 | - } |
|
| 338 | - } |
|
| 28 | + /** |
|
| 29 | + * @var string $name |
|
| 30 | + */ |
|
| 31 | + protected $name = ''; |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * @var string $message |
|
| 35 | + */ |
|
| 36 | + protected $message = ''; |
|
| 37 | + |
|
| 38 | + /** |
|
| 39 | + * @var boolean $force_update |
|
| 40 | + */ |
|
| 41 | + protected $force_update = false; |
|
| 42 | + |
|
| 43 | + /** |
|
| 44 | + * @var string $capability |
|
| 45 | + */ |
|
| 46 | + protected $capability = 'manage_options'; |
|
| 47 | + |
|
| 48 | + /** |
|
| 49 | + * @var string $cap_context |
|
| 50 | + */ |
|
| 51 | + protected $cap_context = 'view persistent admin notice'; |
|
| 52 | + |
|
| 53 | + /** |
|
| 54 | + * @var boolean $dismissed |
|
| 55 | + */ |
|
| 56 | + protected $dismissed = false; |
|
| 57 | + |
|
| 58 | + /** |
|
| 59 | + * @var CapCheckInterface $cap_check |
|
| 60 | + */ |
|
| 61 | + protected $cap_check; |
|
| 62 | + |
|
| 63 | + /** |
|
| 64 | + * if true, then this notice will be deleted from the database |
|
| 65 | + * |
|
| 66 | + * @var boolean $purge |
|
| 67 | + */ |
|
| 68 | + protected $purge = false; |
|
| 69 | + |
|
| 70 | + /** |
|
| 71 | + * gets set to true if notice is successfully registered with the PersistentAdminNoticeManager |
|
| 72 | + * if false, and WP_DEBUG is on, then an exception will be thrown in the admin footer |
|
| 73 | + * |
|
| 74 | + * @var boolean $registered |
|
| 75 | + */ |
|
| 76 | + private $registered = false; |
|
| 77 | + |
|
| 78 | + |
|
| 79 | + /** |
|
| 80 | + * PersistentAdminNotice constructor |
|
| 81 | + * |
|
| 82 | + * @param string $name [required] the name, or key of the Persistent Admin Notice to be stored |
|
| 83 | + * @param string $message [required] the message to be stored persistently until dismissed |
|
| 84 | + * @param bool $force_update enforce the reappearance of a persistent message |
|
| 85 | + * @param string $capability user capability required to view this notice |
|
| 86 | + * @param string $cap_context description for why the cap check is being performed |
|
| 87 | + * @param bool $dismissed whether or not the user has already dismissed/viewed this notice |
|
| 88 | + * @throws InvalidDataTypeException |
|
| 89 | + */ |
|
| 90 | + public function __construct( |
|
| 91 | + $name, |
|
| 92 | + $message, |
|
| 93 | + $force_update = false, |
|
| 94 | + $capability = 'manage_options', |
|
| 95 | + $cap_context = 'view persistent admin notice', |
|
| 96 | + $dismissed = false |
|
| 97 | + ) { |
|
| 98 | + $this->setName($name); |
|
| 99 | + $this->setMessage($message); |
|
| 100 | + $this->setForceUpdate($force_update); |
|
| 101 | + $this->setCapability($capability); |
|
| 102 | + $this->setCapContext($cap_context); |
|
| 103 | + $this->setDismissed($dismissed); |
|
| 104 | + add_action( |
|
| 105 | + 'AHEE__EventEspresso_core_services_notifications_PersistentAdminNoticeManager__registerNotices', |
|
| 106 | + array($this, 'registerPersistentAdminNotice') |
|
| 107 | + ); |
|
| 108 | + add_action('shutdown', array($this, 'confirmRegistered'), 999); |
|
| 109 | + } |
|
| 110 | + |
|
| 111 | + |
|
| 112 | + /** |
|
| 113 | + * @return string |
|
| 114 | + */ |
|
| 115 | + public function getName() |
|
| 116 | + { |
|
| 117 | + return $this->name; |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + |
|
| 121 | + /** |
|
| 122 | + * @param string $name |
|
| 123 | + * @throws InvalidDataTypeException |
|
| 124 | + */ |
|
| 125 | + private function setName($name) |
|
| 126 | + { |
|
| 127 | + if (! is_string($name)) { |
|
| 128 | + throw new InvalidDataTypeException('$name', $name, 'string'); |
|
| 129 | + } |
|
| 130 | + $this->name = sanitize_key($name); |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + |
|
| 134 | + /** |
|
| 135 | + * @return string |
|
| 136 | + */ |
|
| 137 | + public function getMessage() |
|
| 138 | + { |
|
| 139 | + return $this->message; |
|
| 140 | + } |
|
| 141 | + |
|
| 142 | + |
|
| 143 | + /** |
|
| 144 | + * @param string $message |
|
| 145 | + * @throws InvalidDataTypeException |
|
| 146 | + */ |
|
| 147 | + private function setMessage($message) |
|
| 148 | + { |
|
| 149 | + if (! is_string($message)) { |
|
| 150 | + throw new InvalidDataTypeException('$message', $message, 'string'); |
|
| 151 | + } |
|
| 152 | + $allowedtags = AllowedTags::getAllowedTags(); |
|
| 153 | + $this->message = wp_kses($message, $allowedtags); |
|
| 154 | + } |
|
| 155 | + |
|
| 156 | + |
|
| 157 | + /** |
|
| 158 | + * @return bool |
|
| 159 | + */ |
|
| 160 | + public function getForceUpdate() |
|
| 161 | + { |
|
| 162 | + return $this->force_update; |
|
| 163 | + } |
|
| 164 | + |
|
| 165 | + |
|
| 166 | + /** |
|
| 167 | + * @param bool $force_update |
|
| 168 | + */ |
|
| 169 | + private function setForceUpdate($force_update) |
|
| 170 | + { |
|
| 171 | + $this->force_update = filter_var($force_update, FILTER_VALIDATE_BOOLEAN); |
|
| 172 | + } |
|
| 173 | + |
|
| 174 | + |
|
| 175 | + /** |
|
| 176 | + * @return string |
|
| 177 | + */ |
|
| 178 | + public function getCapability() |
|
| 179 | + { |
|
| 180 | + return $this->capability; |
|
| 181 | + } |
|
| 182 | + |
|
| 183 | + |
|
| 184 | + /** |
|
| 185 | + * @param string $capability |
|
| 186 | + * @throws InvalidDataTypeException |
|
| 187 | + */ |
|
| 188 | + private function setCapability($capability) |
|
| 189 | + { |
|
| 190 | + if (! is_string($capability)) { |
|
| 191 | + throw new InvalidDataTypeException('$capability', $capability, 'string'); |
|
| 192 | + } |
|
| 193 | + $this->capability = ! empty($capability) ? $capability : 'manage_options'; |
|
| 194 | + } |
|
| 195 | + |
|
| 196 | + |
|
| 197 | + /** |
|
| 198 | + * @return string |
|
| 199 | + */ |
|
| 200 | + public function getCapContext() |
|
| 201 | + { |
|
| 202 | + return $this->cap_context; |
|
| 203 | + } |
|
| 204 | + |
|
| 205 | + |
|
| 206 | + /** |
|
| 207 | + * @param string $cap_context |
|
| 208 | + * @throws InvalidDataTypeException |
|
| 209 | + */ |
|
| 210 | + private function setCapContext($cap_context) |
|
| 211 | + { |
|
| 212 | + if (! is_string($cap_context)) { |
|
| 213 | + throw new InvalidDataTypeException('$cap_context', $cap_context, 'string'); |
|
| 214 | + } |
|
| 215 | + $this->cap_context = ! empty($cap_context) ? $cap_context : 'view persistent admin notice'; |
|
| 216 | + } |
|
| 217 | + |
|
| 218 | + |
|
| 219 | + /** |
|
| 220 | + * @return bool |
|
| 221 | + */ |
|
| 222 | + public function getDismissed() |
|
| 223 | + { |
|
| 224 | + return $this->dismissed; |
|
| 225 | + } |
|
| 226 | + |
|
| 227 | + |
|
| 228 | + /** |
|
| 229 | + * @param bool $dismissed |
|
| 230 | + */ |
|
| 231 | + public function setDismissed($dismissed) |
|
| 232 | + { |
|
| 233 | + $this->dismissed = filter_var($dismissed, FILTER_VALIDATE_BOOLEAN); |
|
| 234 | + } |
|
| 235 | + |
|
| 236 | + |
|
| 237 | + /** |
|
| 238 | + * @return CapCheckInterface |
|
| 239 | + * @throws InvalidDataTypeException |
|
| 240 | + */ |
|
| 241 | + public function getCapCheck() |
|
| 242 | + { |
|
| 243 | + if (! $this->cap_check instanceof CapCheckInterface) { |
|
| 244 | + $this->setCapCheck( |
|
| 245 | + new CapCheck( |
|
| 246 | + $this->capability, |
|
| 247 | + $this->cap_context |
|
| 248 | + ) |
|
| 249 | + ); |
|
| 250 | + } |
|
| 251 | + return $this->cap_check; |
|
| 252 | + } |
|
| 253 | + |
|
| 254 | + |
|
| 255 | + /** |
|
| 256 | + * @param CapCheckInterface $cap_check |
|
| 257 | + */ |
|
| 258 | + private function setCapCheck(CapCheckInterface $cap_check) |
|
| 259 | + { |
|
| 260 | + $this->cap_check = $cap_check; |
|
| 261 | + } |
|
| 262 | + |
|
| 263 | + |
|
| 264 | + /** |
|
| 265 | + * @return bool |
|
| 266 | + */ |
|
| 267 | + public function getPurge() |
|
| 268 | + { |
|
| 269 | + return $this->purge; |
|
| 270 | + } |
|
| 271 | + |
|
| 272 | + |
|
| 273 | + /** |
|
| 274 | + * @param bool $purge |
|
| 275 | + */ |
|
| 276 | + public function setPurge($purge) |
|
| 277 | + { |
|
| 278 | + $this->purge = filter_var($purge, FILTER_VALIDATE_BOOLEAN); |
|
| 279 | + } |
|
| 280 | + |
|
| 281 | + |
|
| 282 | + /** |
|
| 283 | + * given a valid PersistentAdminNotice Collection, |
|
| 284 | + * this notice will be added if it is not already found in the collection (using its name as the identifier) |
|
| 285 | + * if an existing notice is found that has already been dismissed, |
|
| 286 | + * but we are overriding with a forced update, then we will toggle its dismissed state, |
|
| 287 | + * so that the notice is displayed again |
|
| 288 | + * |
|
| 289 | + * @param Collection $persistent_admin_notice_collection |
|
| 290 | + * @throws InvalidEntityException |
|
| 291 | + * @throws InvalidDataTypeException |
|
| 292 | + * @throws DuplicateCollectionIdentifierException |
|
| 293 | + */ |
|
| 294 | + public function registerPersistentAdminNotice(Collection $persistent_admin_notice_collection) |
|
| 295 | + { |
|
| 296 | + if ($this->registered) { |
|
| 297 | + return; |
|
| 298 | + } |
|
| 299 | + // first check if this notice has already been added to the collection |
|
| 300 | + if ($persistent_admin_notice_collection->has($this->name)) { |
|
| 301 | + /** @var PersistentAdminNotice $existing */ |
|
| 302 | + $existing = $persistent_admin_notice_collection->get($this->name); |
|
| 303 | + // we don't need to add it again (we can't actually) |
|
| 304 | + // but if it has already been dismissed, and we are overriding with a forced update |
|
| 305 | + if ($existing->getDismissed() && $this->getForceUpdate()) { |
|
| 306 | + // then toggle the notice's dismissed state to true |
|
| 307 | + // so that it gets displayed again |
|
| 308 | + $existing->setDismissed(false); |
|
| 309 | + // and make sure the message is set |
|
| 310 | + $existing->setMessage($this->message); |
|
| 311 | + } |
|
| 312 | + } else { |
|
| 313 | + $persistent_admin_notice_collection->add($this, $this->name); |
|
| 314 | + } |
|
| 315 | + $this->registered = true; |
|
| 316 | + } |
|
| 317 | + |
|
| 318 | + |
|
| 319 | + /** |
|
| 320 | + * @throws Exception |
|
| 321 | + */ |
|
| 322 | + public function confirmRegistered() |
|
| 323 | + { |
|
| 324 | + if (! apply_filters('PersistentAdminNoticeManager__registerAndSaveNotices__complete', false)) { |
|
| 325 | + PersistentAdminNoticeManager::loadRegisterAndSaveNotices(); |
|
| 326 | + } |
|
| 327 | + if (! $this->registered && WP_DEBUG) { |
|
| 328 | + throw new DomainException( |
|
| 329 | + sprintf( |
|
| 330 | + esc_html__( |
|
| 331 | + 'The "%1$s" PersistentAdminNotice was not successfully registered. Please ensure that it is being created prior to either the "admin_notices" or "network_admin_notices" hooks being triggered.', |
|
| 332 | + 'event_espresso' |
|
| 333 | + ), |
|
| 334 | + $this->name |
|
| 335 | + ) |
|
| 336 | + ); |
|
| 337 | + } |
|
| 338 | + } |
|
| 339 | 339 | } |
@@ -1,875 +1,875 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | /** |
| 4 | - * |
|
| 5 | - * Class EEH_HTML |
|
| 6 | - * |
|
| 4 | + * |
|
| 5 | + * Class EEH_HTML |
|
| 6 | + * |
|
| 7 | 7 | * Sometimes when writing PHP you need to generate some standard HTML, |
| 8 | 8 | * but either not enough to warrant creating a template file, |
| 9 | 9 | * or the amount of PHP conditionals and/or loops peppered throughout the HTML |
| 10 | 10 | * just make it really ugly and difficult to read. |
| 11 | 11 | * This class simply adds a bunch of methods for generating basic HTML tags. |
| 12 | 12 | * Most of the methods have the same name as the HTML tag they generate, and most have the same set of parameters. |
| 13 | - * |
|
| 14 | - * @package Event Espresso |
|
| 15 | - * @subpackage core |
|
| 16 | - * @author Brent Christensen |
|
| 17 | - * |
|
| 18 | - * |
|
| 19 | - */ |
|
| 13 | + * |
|
| 14 | + * @package Event Espresso |
|
| 15 | + * @subpackage core |
|
| 16 | + * @author Brent Christensen |
|
| 17 | + * |
|
| 18 | + * |
|
| 19 | + */ |
|
| 20 | 20 | class EEH_HTML |
| 21 | 21 | { |
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * instance of the EEH_Autoloader object |
|
| 25 | - * @var $_instance |
|
| 26 | - * @access private |
|
| 27 | - */ |
|
| 28 | - private static $_instance; |
|
| 29 | - |
|
| 30 | - /** |
|
| 31 | - * @var array $_indent |
|
| 32 | - * @access private |
|
| 33 | - */ |
|
| 34 | - private static $_indent = array(); |
|
| 35 | - |
|
| 36 | - |
|
| 37 | - |
|
| 38 | - /** |
|
| 39 | - * @singleton method used to instantiate class object |
|
| 40 | - * @access public |
|
| 41 | - * @return EEH_HTML |
|
| 42 | - */ |
|
| 43 | - public static function instance() |
|
| 44 | - { |
|
| 45 | - // check if class object is instantiated, and instantiated properly |
|
| 46 | - if (! self::$_instance instanceof EEH_HTML) { |
|
| 47 | - self::$_instance = new EEH_HTML(); |
|
| 48 | - } |
|
| 49 | - return self::$_instance; |
|
| 50 | - } |
|
| 51 | - |
|
| 52 | - |
|
| 53 | - |
|
| 54 | - /** |
|
| 55 | - * class constructor |
|
| 56 | - * |
|
| 57 | - * @access private |
|
| 58 | - * @return \EEH_HTML |
|
| 59 | - */ |
|
| 60 | - private function __construct() |
|
| 61 | - { |
|
| 62 | - // set some initial formatting for table indentation |
|
| 63 | - EEH_HTML::$_indent = array( |
|
| 64 | - 'table' => 0, |
|
| 65 | - 'thead' => 1, |
|
| 66 | - 'tbody' => 1, |
|
| 67 | - 'tr' => 2, |
|
| 68 | - 'th' => 3, |
|
| 69 | - 'td' => 3, |
|
| 70 | - 'div' => 0, |
|
| 71 | - 'h1' => 0, |
|
| 72 | - 'h2' => 0, |
|
| 73 | - 'h3' => 0, |
|
| 74 | - 'h4' => 0, |
|
| 75 | - 'h5' => 0, |
|
| 76 | - 'h6' => 0, |
|
| 77 | - 'p' => 0, |
|
| 78 | - 'ul' => 0, |
|
| 79 | - 'li' => 1 |
|
| 80 | - ); |
|
| 81 | - } |
|
| 82 | - |
|
| 83 | - |
|
| 84 | - |
|
| 85 | - /** |
|
| 86 | - * Generates an opening HTML <XX> tag and adds any passed attributes |
|
| 87 | - * if passed content, it will also add that, as well as the closing </XX> tag |
|
| 88 | - * |
|
| 89 | - * @access protected |
|
| 90 | - * @param string $tag |
|
| 91 | - * @param string $content - inserted after opening tag, and appends closing tag, otherwise tag is left open |
|
| 92 | - * @param string $id - html id attribute |
|
| 93 | - * @param string $class - html class attribute |
|
| 94 | - * @param string $style - html style attribute for applying inline styles |
|
| 95 | - * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
|
| 96 | - * @param bool $force_close |
|
| 97 | - * @return string |
|
| 98 | - */ |
|
| 99 | - protected static function _open_tag( |
|
| 100 | - $tag = 'div', |
|
| 101 | - $content = '', |
|
| 102 | - $id = '', |
|
| 103 | - $class = '', |
|
| 104 | - $style = '', |
|
| 105 | - $other_attributes = '', |
|
| 106 | - $force_close = false |
|
| 107 | - ) { |
|
| 108 | - $attributes = ! empty($id) ? ' id="' . EEH_HTML::sanitize_id($id) . '"' : ''; |
|
| 109 | - $attributes .= ! empty($class) ? ' class="' . $class . '"' : ''; |
|
| 110 | - $attributes .= ! empty($style) ? ' style="' . $style . '"' : ''; |
|
| 111 | - $attributes .= ! empty($other_attributes) ? ' ' . $other_attributes : ''; |
|
| 112 | - $html = EEH_HTML::nl(0, $tag) . '<' . $tag . $attributes . '>'; |
|
| 113 | - $html .= ! empty($content) ? EEH_HTML::nl(1, $tag) . $content : ''; |
|
| 114 | - $indent = ! empty($content) || $force_close ? true : false; |
|
| 115 | - $html .= ! empty($content) || $force_close ? EEH_HTML::_close_tag($tag, $id, $class, $indent) : ''; |
|
| 116 | - return $html; |
|
| 117 | - } |
|
| 118 | - |
|
| 119 | - |
|
| 120 | - |
|
| 121 | - /** |
|
| 122 | - * Generates HTML closing </XX> tag - if passed the id or class attribute |
|
| 123 | - * used for the opening tag, will append a comment |
|
| 124 | - * |
|
| 23 | + /** |
|
| 24 | + * instance of the EEH_Autoloader object |
|
| 25 | + * @var $_instance |
|
| 26 | + * @access private |
|
| 27 | + */ |
|
| 28 | + private static $_instance; |
|
| 29 | + |
|
| 30 | + /** |
|
| 31 | + * @var array $_indent |
|
| 32 | + * @access private |
|
| 33 | + */ |
|
| 34 | + private static $_indent = array(); |
|
| 35 | + |
|
| 36 | + |
|
| 37 | + |
|
| 38 | + /** |
|
| 39 | + * @singleton method used to instantiate class object |
|
| 40 | + * @access public |
|
| 41 | + * @return EEH_HTML |
|
| 42 | + */ |
|
| 43 | + public static function instance() |
|
| 44 | + { |
|
| 45 | + // check if class object is instantiated, and instantiated properly |
|
| 46 | + if (! self::$_instance instanceof EEH_HTML) { |
|
| 47 | + self::$_instance = new EEH_HTML(); |
|
| 48 | + } |
|
| 49 | + return self::$_instance; |
|
| 50 | + } |
|
| 51 | + |
|
| 52 | + |
|
| 53 | + |
|
| 54 | + /** |
|
| 55 | + * class constructor |
|
| 56 | + * |
|
| 57 | + * @access private |
|
| 58 | + * @return \EEH_HTML |
|
| 59 | + */ |
|
| 60 | + private function __construct() |
|
| 61 | + { |
|
| 62 | + // set some initial formatting for table indentation |
|
| 63 | + EEH_HTML::$_indent = array( |
|
| 64 | + 'table' => 0, |
|
| 65 | + 'thead' => 1, |
|
| 66 | + 'tbody' => 1, |
|
| 67 | + 'tr' => 2, |
|
| 68 | + 'th' => 3, |
|
| 69 | + 'td' => 3, |
|
| 70 | + 'div' => 0, |
|
| 71 | + 'h1' => 0, |
|
| 72 | + 'h2' => 0, |
|
| 73 | + 'h3' => 0, |
|
| 74 | + 'h4' => 0, |
|
| 75 | + 'h5' => 0, |
|
| 76 | + 'h6' => 0, |
|
| 77 | + 'p' => 0, |
|
| 78 | + 'ul' => 0, |
|
| 79 | + 'li' => 1 |
|
| 80 | + ); |
|
| 81 | + } |
|
| 82 | + |
|
| 83 | + |
|
| 84 | + |
|
| 85 | + /** |
|
| 86 | + * Generates an opening HTML <XX> tag and adds any passed attributes |
|
| 87 | + * if passed content, it will also add that, as well as the closing </XX> tag |
|
| 88 | + * |
|
| 89 | + * @access protected |
|
| 90 | + * @param string $tag |
|
| 91 | + * @param string $content - inserted after opening tag, and appends closing tag, otherwise tag is left open |
|
| 92 | + * @param string $id - html id attribute |
|
| 93 | + * @param string $class - html class attribute |
|
| 94 | + * @param string $style - html style attribute for applying inline styles |
|
| 95 | + * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
|
| 96 | + * @param bool $force_close |
|
| 97 | + * @return string |
|
| 98 | + */ |
|
| 99 | + protected static function _open_tag( |
|
| 100 | + $tag = 'div', |
|
| 101 | + $content = '', |
|
| 102 | + $id = '', |
|
| 103 | + $class = '', |
|
| 104 | + $style = '', |
|
| 105 | + $other_attributes = '', |
|
| 106 | + $force_close = false |
|
| 107 | + ) { |
|
| 108 | + $attributes = ! empty($id) ? ' id="' . EEH_HTML::sanitize_id($id) . '"' : ''; |
|
| 109 | + $attributes .= ! empty($class) ? ' class="' . $class . '"' : ''; |
|
| 110 | + $attributes .= ! empty($style) ? ' style="' . $style . '"' : ''; |
|
| 111 | + $attributes .= ! empty($other_attributes) ? ' ' . $other_attributes : ''; |
|
| 112 | + $html = EEH_HTML::nl(0, $tag) . '<' . $tag . $attributes . '>'; |
|
| 113 | + $html .= ! empty($content) ? EEH_HTML::nl(1, $tag) . $content : ''; |
|
| 114 | + $indent = ! empty($content) || $force_close ? true : false; |
|
| 115 | + $html .= ! empty($content) || $force_close ? EEH_HTML::_close_tag($tag, $id, $class, $indent) : ''; |
|
| 116 | + return $html; |
|
| 117 | + } |
|
| 118 | + |
|
| 119 | + |
|
| 120 | + |
|
| 121 | + /** |
|
| 122 | + * Generates HTML closing </XX> tag - if passed the id or class attribute |
|
| 123 | + * used for the opening tag, will append a comment |
|
| 124 | + * |
|
| 125 | 125 | *@access protected |
| 126 | - * @param string $tag |
|
| 127 | - * @param string $id - html id attribute |
|
| 128 | - * @param string $class - html class attribute |
|
| 129 | - * @param bool $indent |
|
| 130 | - * @return string |
|
| 131 | - */ |
|
| 132 | - protected static function _close_tag($tag = 'div', $id = '', $class = '', $indent = true) |
|
| 133 | - { |
|
| 134 | - $comment = ''; |
|
| 135 | - if ($id) { |
|
| 136 | - $comment = EEH_HTML::comment('close ' . $id) . EEH_HTML::nl(0, $tag); |
|
| 137 | - } elseif ($class) { |
|
| 138 | - $comment = EEH_HTML::comment('close ' . $class) . EEH_HTML::nl(0, $tag); |
|
| 139 | - } |
|
| 140 | - $html = $indent ? EEH_HTML::nl(-1, $tag) : ''; |
|
| 141 | - $html .= '</' . $tag . '>' . $comment; |
|
| 142 | - return $html; |
|
| 143 | - } |
|
| 144 | - |
|
| 145 | - |
|
| 146 | - |
|
| 147 | - /** |
|
| 148 | - * div - generates HTML opening <div> tag and adds any passed attributes |
|
| 149 | - * to add an id use: echo EEH_HTML::div( 'this is some content', 'footer' ); |
|
| 150 | - * to add a class use: echo EEH_HTML::div( 'this is some content', '', 'float_left' ); |
|
| 151 | - * to add a both an id and a class use: echo EEH_HTML::div( 'this is some content', 'footer', 'float_left' ); |
|
| 152 | - * |
|
| 153 | - * @param string $content - inserted after opening tag, and appends closing tag, otherwise tag is left open |
|
| 154 | - * @param string $id - html id attribute |
|
| 155 | - * @param string $class - html class attribute |
|
| 156 | - * @param string $style - html style attribute for applying inline styles |
|
| 157 | - * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
|
| 158 | - * @return string |
|
| 159 | - */ |
|
| 160 | - public static function div($content = '', $id = '', $class = '', $style = '', $other_attributes = '') |
|
| 161 | - { |
|
| 162 | - return EEH_HTML::_open_tag('div', $content, $id, $class, $style, $other_attributes); |
|
| 163 | - } |
|
| 164 | - |
|
| 165 | - |
|
| 166 | - |
|
| 167 | - /** |
|
| 168 | - * Generates HTML closing </div> tag - if passed the id or class attribute used for the opening div tag, will append a comment |
|
| 169 | - * usage: echo EEH_HTML::divx(); |
|
| 170 | - * |
|
| 171 | - * @param string $id - html id attribute |
|
| 172 | - * @param string $class - html class attribute |
|
| 173 | - * @return string |
|
| 174 | - */ |
|
| 175 | - public static function divx($id = '', $class = '') |
|
| 176 | - { |
|
| 177 | - return EEH_HTML::_close_tag('div', $id, $class); |
|
| 178 | - } |
|
| 179 | - |
|
| 180 | - |
|
| 181 | - |
|
| 182 | - /** |
|
| 183 | - * Generates HTML <h1></h1> tags, inserts content, and adds any passed attributes |
|
| 184 | - * usage: echo EEH_HTML::h1( 'This is a Heading' ); |
|
| 185 | - * |
|
| 186 | - * @param string $content - inserted after opening tag, and appends closing tag, otherwise tag is left open |
|
| 187 | - * @param string $id - html id attribute |
|
| 188 | - * @param string $class - html class attribute |
|
| 189 | - * @param string $style - html style attribute for applying inline styles |
|
| 190 | - * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
|
| 191 | - * @return string |
|
| 192 | - */ |
|
| 193 | - public static function h1($content = '', $id = '', $class = '', $style = '', $other_attributes = '') |
|
| 194 | - { |
|
| 195 | - return EEH_HTML::_open_tag('h1', $content, $id, $class, $style, $other_attributes, true); |
|
| 196 | - } |
|
| 197 | - |
|
| 198 | - |
|
| 199 | - |
|
| 200 | - /** |
|
| 201 | - * Generates HTML <h2></h2> tags, inserts content, and adds any passed attributes |
|
| 202 | - * usage: echo EEH_HTML::h2( 'This is a Heading' ); |
|
| 203 | - * |
|
| 204 | - * @param string $content - inserted after opening tag, and appends closing tag, otherwise tag is left open |
|
| 205 | - * @param string $id - html id attribute |
|
| 206 | - * @param string $class - html class attribute |
|
| 207 | - * @param string $style - html style attribute for applying inline styles |
|
| 208 | - * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
|
| 209 | - * @return string |
|
| 210 | - */ |
|
| 211 | - public static function h2($content = '', $id = '', $class = '', $style = '', $other_attributes = '') |
|
| 212 | - { |
|
| 213 | - return EEH_HTML::_open_tag('h2', $content, $id, $class, $style, $other_attributes, true); |
|
| 214 | - } |
|
| 215 | - |
|
| 216 | - |
|
| 217 | - |
|
| 218 | - /** |
|
| 219 | - * Generates HTML <h3></h3> tags, inserts content, and adds any passed attributes |
|
| 220 | - * usage: echo EEH_HTML::h3( 'This is a Heading' ); |
|
| 221 | - * |
|
| 222 | - * @param string $content - inserted after opening tag, and appends closing tag, otherwise tag is left open |
|
| 223 | - * @param string $id - html id attribute |
|
| 224 | - * @param string $class - html class attribute |
|
| 225 | - * @param string $style - html style attribute for applying inline styles |
|
| 226 | - * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
|
| 227 | - * @return string |
|
| 228 | - */ |
|
| 229 | - public static function h3($content = '', $id = '', $class = '', $style = '', $other_attributes = '') |
|
| 230 | - { |
|
| 231 | - return EEH_HTML::_open_tag('h3', $content, $id, $class, $style, $other_attributes, true); |
|
| 232 | - } |
|
| 233 | - |
|
| 234 | - |
|
| 235 | - |
|
| 236 | - /** |
|
| 237 | - * Generates HTML <h4></h4> tags, inserts content, and adds any passed attributes |
|
| 238 | - * usage: echo EEH_HTML::h4( 'This is a Heading' ); |
|
| 239 | - * |
|
| 240 | - * @param string $content - inserted after opening tag, and appends closing tag, otherwise tag is left open |
|
| 241 | - * @param string $id - html id attribute |
|
| 242 | - * @param string $class - html class attribute |
|
| 243 | - * @param string $style - html style attribute for applying inline styles |
|
| 244 | - * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
|
| 245 | - * @return string |
|
| 246 | - */ |
|
| 247 | - public static function h4($content = '', $id = '', $class = '', $style = '', $other_attributes = '') |
|
| 248 | - { |
|
| 249 | - return EEH_HTML::_open_tag('h4', $content, $id, $class, $style, $other_attributes, true); |
|
| 250 | - } |
|
| 251 | - |
|
| 252 | - |
|
| 253 | - |
|
| 254 | - /** |
|
| 255 | - * Generates HTML <h5></h5> tags, inserts content, and adds any passed attributes |
|
| 256 | - * usage: echo EEH_HTML::h5( 'This is a Heading' ); |
|
| 257 | - * |
|
| 258 | - * @param string $content - inserted after opening tag, and appends closing tag, otherwise tag is left open |
|
| 259 | - * @param string $id - html id attribute |
|
| 260 | - * @param string $class - html class attribute |
|
| 261 | - * @param string $style - html style attribute for applying inline styles |
|
| 262 | - * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
|
| 263 | - * @return string |
|
| 264 | - */ |
|
| 265 | - public static function h5($content = '', $id = '', $class = '', $style = '', $other_attributes = '') |
|
| 266 | - { |
|
| 267 | - return EEH_HTML::_open_tag('h5', $content, $id, $class, $style, $other_attributes, true); |
|
| 268 | - } |
|
| 269 | - |
|
| 270 | - |
|
| 271 | - |
|
| 272 | - /** |
|
| 273 | - * Generates HTML <h6></h6> tags, inserts content, and adds any passed attributes |
|
| 274 | - * usage: echo EEH_HTML::h6( 'This is a Heading' ); |
|
| 275 | - * |
|
| 276 | - * @param string $content - inserted after opening tag, and appends closing tag, otherwise tag is left open |
|
| 277 | - * @param string $id - html id attribute |
|
| 278 | - * @param string $class - html class attribute |
|
| 279 | - * @param string $style - html style attribute for applying inline styles |
|
| 280 | - * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
|
| 281 | - * @return string |
|
| 282 | - */ |
|
| 283 | - public static function h6($content = '', $id = '', $class = '', $style = '', $other_attributes = '') |
|
| 284 | - { |
|
| 285 | - return EEH_HTML::_open_tag('h6', $content, $id, $class, $style, $other_attributes, true); |
|
| 286 | - } |
|
| 287 | - |
|
| 288 | - |
|
| 289 | - |
|
| 290 | - /** |
|
| 291 | - * Generates HTML <p></p> tags, inserts content, and adds any passed attributes |
|
| 292 | - * usage: echo EEH_HTML::p( 'this is a paragraph' ); |
|
| 293 | - * |
|
| 294 | - * @param string $content - inserted after opening tag, and appends closing tag, otherwise tag is left open |
|
| 295 | - * @param string $id - html id attribute |
|
| 296 | - * @param string $class - html class attribute |
|
| 297 | - * @param string $style - html style attribute for applying inline styles |
|
| 298 | - * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
|
| 299 | - * @return string |
|
| 300 | - */ |
|
| 301 | - public static function p($content = '', $id = '', $class = '', $style = '', $other_attributes = '') |
|
| 302 | - { |
|
| 303 | - return EEH_HTML::_open_tag('p', $content, $id, $class, $style, $other_attributes, true); |
|
| 304 | - } |
|
| 305 | - |
|
| 306 | - |
|
| 307 | - |
|
| 308 | - /** |
|
| 309 | - * ul - generates HTML opening <ul> tag and adds any passed attributes |
|
| 310 | - * usage: echo EEH_HTML::ul( 'my-list-id', 'my-list-class' ); |
|
| 311 | - * |
|
| 312 | - * @param string $id - html id attribute |
|
| 313 | - * @param string $class - html class attribute |
|
| 314 | - * @param string $style - html style attribute for applying inline styles |
|
| 315 | - * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
|
| 316 | - * @return string |
|
| 317 | - */ |
|
| 318 | - public static function ul($id = '', $class = '', $style = '', $other_attributes = '') |
|
| 319 | - { |
|
| 320 | - return EEH_HTML::_open_tag('ul', '', $id, $class, $style, $other_attributes); |
|
| 321 | - } |
|
| 322 | - |
|
| 323 | - |
|
| 324 | - |
|
| 325 | - /** |
|
| 326 | - * Generates HTML closing </ul> tag - if passed the id or class attribute used for the opening ul tag, will append a comment |
|
| 327 | - * usage: echo EEH_HTML::ulx(); |
|
| 328 | - * |
|
| 329 | - * @param string $id - html id attribute |
|
| 330 | - * @param string $class - html class attribute |
|
| 331 | - * @return string |
|
| 332 | - */ |
|
| 333 | - public static function ulx($id = '', $class = '') |
|
| 334 | - { |
|
| 335 | - return EEH_HTML::_close_tag('ul', $id, $class); |
|
| 336 | - } |
|
| 337 | - |
|
| 338 | - |
|
| 339 | - |
|
| 340 | - /** |
|
| 341 | - * Generates HTML <li> tag, inserts content, and adds any passed attributes |
|
| 342 | - * if passed content, it will also add that, as well as the closing </li> tag |
|
| 343 | - * usage: echo EEH_HTML::li( 'this is a line item' ); |
|
| 344 | - * |
|
| 345 | - * @param string $id - html id attribute |
|
| 346 | - * @param string $class - html class attribute |
|
| 347 | - * @param string $style - html style attribute for applying inline styles |
|
| 348 | - * @param string $content - inserted after opening tag, and appends closing tag, otherwise tag is left open |
|
| 349 | - * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
|
| 350 | - * @return string |
|
| 351 | - */ |
|
| 352 | - public static function li($content = '', $id = '', $class = '', $style = '', $other_attributes = '') |
|
| 353 | - { |
|
| 354 | - return EEH_HTML::_open_tag('li', $content, $id, $class, $style, $other_attributes); |
|
| 355 | - } |
|
| 356 | - |
|
| 357 | - |
|
| 358 | - |
|
| 359 | - /** |
|
| 360 | - * Generates HTML closing </li> tag - if passed the id or class attribute used for the opening ul tag, will append a comment |
|
| 361 | - * usage: echo EEH_HTML::lix(); |
|
| 362 | - * |
|
| 363 | - * @param string $id - html id attribute |
|
| 364 | - * @param string $class - html class attribute |
|
| 365 | - * @return string |
|
| 366 | - */ |
|
| 367 | - public static function lix($id = '', $class = '') |
|
| 368 | - { |
|
| 369 | - return EEH_HTML::_close_tag('li', $id, $class); |
|
| 370 | - } |
|
| 371 | - |
|
| 372 | - |
|
| 373 | - |
|
| 374 | - /** |
|
| 375 | - * table - generates an HTML <table> tag and adds any passed attributes |
|
| 376 | - * usage: echo EEH_HTML::table(); |
|
| 377 | - * |
|
| 378 | - * @param string $content - inserted after opening tag, and appends closing tag, otherwise tag is left open |
|
| 379 | - * @param string $id - html id attribute |
|
| 380 | - * @param string $class - html class attribute |
|
| 381 | - * @param string $style - html style attribute for applying inline styles |
|
| 382 | - * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
|
| 383 | - * @return string |
|
| 384 | - */ |
|
| 385 | - public static function table($content = '', $id = '', $class = '', $style = '', $other_attributes = '') |
|
| 386 | - { |
|
| 387 | - return EEH_HTML::_open_tag('table', $content, $id, $class, $style, $other_attributes); |
|
| 388 | - } |
|
| 389 | - |
|
| 390 | - |
|
| 391 | - |
|
| 392 | - /** |
|
| 393 | - * tablex - generates an HTML </table> tag - if passed the id or class attribute used for the opening ul tag, will append a comment |
|
| 394 | - * |
|
| 395 | - * @param string $id - html id attribute |
|
| 396 | - * @param string $class - html class attribute |
|
| 397 | - * @return string |
|
| 398 | - */ |
|
| 399 | - public static function tablex($id = '', $class = '') |
|
| 400 | - { |
|
| 401 | - return EEH_HTML::_close_tag('table', $id, $class); |
|
| 402 | - } |
|
| 403 | - |
|
| 404 | - |
|
| 405 | - |
|
| 406 | - /** |
|
| 407 | - * thead - generates an HTML <thead> tag and adds any passed attributes |
|
| 408 | - * usage: echo EEH_HTML::thead(); |
|
| 409 | - * |
|
| 410 | - * @param string $content - inserted after opening tag, and appends closing tag, otherwise tag is left open |
|
| 411 | - * @param string $id - html id attribute |
|
| 412 | - * @param string $class - html class attribute |
|
| 413 | - * @param string $style - html style attribute for applying inline styles |
|
| 414 | - * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
|
| 415 | - * @return string |
|
| 416 | - */ |
|
| 417 | - public static function thead($content = '', $id = '', $class = '', $style = '', $other_attributes = '') |
|
| 418 | - { |
|
| 419 | - return EEH_HTML::_open_tag('thead', $content, $id, $class, $style, $other_attributes); |
|
| 420 | - } |
|
| 421 | - |
|
| 422 | - |
|
| 423 | - |
|
| 424 | - /** |
|
| 425 | - * theadx - generates an HTML </thead> tag - if passed the id or class attribute used for the opening ul tag, will append a comment |
|
| 426 | - * |
|
| 427 | - * @param string $id - html id attribute |
|
| 428 | - * @param string $class - html class attribute |
|
| 429 | - * @return string |
|
| 430 | - */ |
|
| 431 | - public static function theadx($id = '', $class = '') |
|
| 432 | - { |
|
| 433 | - return EEH_HTML::_close_tag('thead', $id, $class); |
|
| 434 | - } |
|
| 435 | - |
|
| 436 | - |
|
| 437 | - |
|
| 438 | - /** |
|
| 439 | - * tbody - generates an HTML <tbody> tag and adds any passed attributes |
|
| 440 | - * usage: echo EEH_HTML::tbody(); |
|
| 441 | - * |
|
| 442 | - * @param string $content - inserted after opening tag, and appends closing tag, otherwise tag is left open |
|
| 443 | - * @param string $id - html id attribute |
|
| 444 | - * @param string $class - html class attribute |
|
| 445 | - * @param string $style - html style attribute for applying inline styles |
|
| 446 | - * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
|
| 447 | - * @return string |
|
| 448 | - */ |
|
| 449 | - public static function tbody($content = '', $id = '', $class = '', $style = '', $other_attributes = '') |
|
| 450 | - { |
|
| 451 | - return EEH_HTML::_open_tag('tbody', $content, $id, $class, $style, $other_attributes); |
|
| 452 | - } |
|
| 453 | - |
|
| 454 | - |
|
| 455 | - |
|
| 456 | - /** |
|
| 457 | - * tbodyx - generates an HTML </tbody> tag - if passed the id or class attribute used for the opening ul tag, will append a comment |
|
| 458 | - * |
|
| 459 | - * @param string $id - html id attribute |
|
| 460 | - * @param string $class - html class attribute |
|
| 461 | - * @return string |
|
| 462 | - */ |
|
| 463 | - public static function tbodyx($id = '', $class = '') |
|
| 464 | - { |
|
| 465 | - return EEH_HTML::_close_tag('tbody', $id, $class); |
|
| 466 | - } |
|
| 467 | - |
|
| 468 | - |
|
| 469 | - |
|
| 470 | - /** |
|
| 471 | - * tr - generates an HTML <tr> tag and adds any passed attributes |
|
| 472 | - * usage: echo EEH_HTML::tr(); |
|
| 473 | - * |
|
| 474 | - * @param string $content - inserted after opening tag, and appends closing tag, otherwise tag is left open |
|
| 475 | - * @param string $id - html id attribute |
|
| 476 | - * @param string $class - html class attribute |
|
| 477 | - * @param string $style - html style attribute for applying inline styles |
|
| 478 | - * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
|
| 479 | - * @return string |
|
| 480 | - */ |
|
| 481 | - public static function tr($content = '', $id = '', $class = '', $style = '', $other_attributes = '') |
|
| 482 | - { |
|
| 483 | - return EEH_HTML::_open_tag('tr', $content, $id, $class, $style, $other_attributes); |
|
| 484 | - } |
|
| 485 | - |
|
| 486 | - |
|
| 487 | - |
|
| 488 | - /** |
|
| 489 | - * trx - generates an HTML </tr> tag - if passed the id or class attribute used for the opening ul tag, will append a comment |
|
| 490 | - * |
|
| 491 | - * @param string $id - html id attribute |
|
| 492 | - * @param string $class - html class attribute |
|
| 493 | - * @return string |
|
| 494 | - */ |
|
| 495 | - public static function trx($id = '', $class = '') |
|
| 496 | - { |
|
| 497 | - return EEH_HTML::_close_tag('tr', $id, $class); |
|
| 498 | - } |
|
| 499 | - |
|
| 500 | - |
|
| 501 | - |
|
| 502 | - /** |
|
| 503 | - * th - generates an HTML <th> tag and adds any passed attributes |
|
| 504 | - * usage: echo EEH_HTML::th(); |
|
| 505 | - * |
|
| 506 | - * @param string $content - inserted after opening tag, and appends closing tag, otherwise tag is left open |
|
| 507 | - * @param string $id - html id attribute |
|
| 508 | - * @param string $class - html class attribute |
|
| 509 | - * @param string $style - html style attribute for applying inline styles |
|
| 510 | - * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
|
| 511 | - * @return string |
|
| 512 | - */ |
|
| 513 | - public static function th($content = '', $id = '', $class = '', $style = '', $other_attributes = '') |
|
| 514 | - { |
|
| 515 | - return EEH_HTML::_open_tag('th', $content, $id, $class, $style, $other_attributes); |
|
| 516 | - } |
|
| 517 | - |
|
| 518 | - |
|
| 519 | - |
|
| 520 | - /** |
|
| 521 | - * thx - generates an HTML </th> tag - if passed the id or class attribute used for the opening ul tag, will append a comment |
|
| 522 | - * |
|
| 523 | - * @param string $id - html id attribute |
|
| 524 | - * @param string $class - html class attribute |
|
| 525 | - * @return string |
|
| 526 | - */ |
|
| 527 | - public static function thx($id = '', $class = '') |
|
| 528 | - { |
|
| 529 | - return EEH_HTML::_close_tag('th', $id, $class); |
|
| 530 | - } |
|
| 531 | - |
|
| 532 | - |
|
| 533 | - |
|
| 534 | - /** |
|
| 535 | - * td - generates an HTML <td> tag and adds any passed attributes |
|
| 536 | - * usage: echo EEH_HTML::td(); |
|
| 537 | - * |
|
| 538 | - * @param string $content - inserted after opening tag, and appends closing tag, otherwise tag is left open |
|
| 539 | - * @param string $id - html id attribute |
|
| 540 | - * @param string $class - html class attribute |
|
| 541 | - * @param string $style - html style attribute for applying inline styles |
|
| 542 | - * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
|
| 543 | - * @return string |
|
| 544 | - */ |
|
| 545 | - public static function td($content = '', $id = '', $class = '', $style = '', $other_attributes = '') |
|
| 546 | - { |
|
| 547 | - return EEH_HTML::_open_tag('td', $content, $id, $class, $style, $other_attributes); |
|
| 548 | - } |
|
| 549 | - |
|
| 550 | - |
|
| 551 | - |
|
| 552 | - /** |
|
| 553 | - * tdx - generates an HTML </td> tag - if passed the id or class attribute used for the opening ul tag, will append a comment |
|
| 554 | - * |
|
| 555 | - * @param string $id - html id attribute |
|
| 556 | - * @param string $class - html class attribute |
|
| 557 | - * @return string |
|
| 558 | - */ |
|
| 559 | - public static function tdx($id = '', $class = '') |
|
| 560 | - { |
|
| 561 | - return EEH_HTML::_close_tag('td', $id, $class); |
|
| 562 | - } |
|
| 563 | - |
|
| 564 | - |
|
| 565 | - |
|
| 566 | - /** |
|
| 567 | - * no_row - for generating a "hidden" table row, good for embedding tables within tables |
|
| 568 | - * generates a new table row with one td cell that spans however many columns you set |
|
| 569 | - * removes all styles from the tr and td |
|
| 570 | - * |
|
| 571 | - * @param string $content |
|
| 572 | - * @param int $colspan |
|
| 573 | - * @return string |
|
| 574 | - */ |
|
| 575 | - public static function no_row($content = '', $colspan = 2) |
|
| 576 | - { |
|
| 577 | - return EEH_HTML::tr( |
|
| 578 | - EEH_HTML::td($content, '', '', 'padding:0; border:none;', 'colspan="' . $colspan . '"'), |
|
| 579 | - '', |
|
| 580 | - '', |
|
| 581 | - 'padding:0; border:none;' |
|
| 582 | - ); |
|
| 583 | - } |
|
| 584 | - |
|
| 585 | - |
|
| 586 | - |
|
| 587 | - /** |
|
| 588 | - * Generates HTML <label></label> tags, inserts content, and adds any passed attributes |
|
| 589 | - * usage: echo EEH_HTML::span( 'this is some inline text' ); |
|
| 590 | - * |
|
| 591 | - * @access public |
|
| 592 | - * @param string $href URL to link to |
|
| 593 | - * @param string $link_text - the text that will become "hyperlinked" |
|
| 594 | - * @param string $title - html title attribute |
|
| 595 | - * @param string $id - html id attribute |
|
| 596 | - * @param string $class - html class attribute |
|
| 597 | - * @param string $style - html style attribute for applying inline styles |
|
| 598 | - * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
|
| 599 | - * @return string |
|
| 600 | - */ |
|
| 601 | - public static function link($href = '', $link_text = '', $title = '', $id = '', $class = '', $style = '', $other_attributes = '') |
|
| 602 | - { |
|
| 603 | - $link_text = ! empty($link_text) ? $link_text : $href; |
|
| 604 | - $attributes = ! empty($href) ? ' href="' . $href . '"' : ''; |
|
| 605 | - $attributes .= ! empty($id) ? ' id="' . EEH_HTML::sanitize_id($id) . '"' : ''; |
|
| 606 | - $attributes .= ! empty($class) ? ' class="' . $class . '"' : ''; |
|
| 607 | - $attributes .= ! empty($style) ? ' style="' . $style . '"' : ''; |
|
| 608 | - $attributes .= ! empty($title) ? ' title="' . esc_attr($title) . '"' : ''; |
|
| 609 | - $attributes .= ! empty($other_attributes) ? ' ' . $other_attributes : ''; |
|
| 610 | - return "<a{$attributes}>{$link_text}</a>"; |
|
| 611 | - } |
|
| 612 | - |
|
| 613 | - |
|
| 614 | - |
|
| 615 | - /** |
|
| 616 | - * img - generates an HTML <img> tag and adds any passed attributes |
|
| 617 | - * usage: echo EEH_HTML::img(); |
|
| 618 | - * |
|
| 619 | - * @param string $src - html src attribute ie: the path or URL to the image |
|
| 620 | - * @param string $alt - html alt attribute |
|
| 621 | - * @param string $id - html id attribute |
|
| 622 | - * @param string $class - html class attribute |
|
| 623 | - * @param string $style - html style attribute for applying inline styles |
|
| 624 | - * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
|
| 625 | - * @return string |
|
| 626 | - */ |
|
| 627 | - public static function img($src = '', $alt = '', $id = '', $class = '', $style = '', $other_attributes = '') |
|
| 628 | - { |
|
| 629 | - $attributes = ! empty($src) ? ' src="' . esc_url_raw($src) . '"' : ''; |
|
| 630 | - $attributes .= ! empty($alt) ? ' alt="' . esc_attr($alt) . '"' : ''; |
|
| 631 | - $attributes .= ! empty($id) ? ' id="' . EEH_HTML::sanitize_id($id) . '"' : ''; |
|
| 632 | - $attributes .= ! empty($class) ? ' class="' . $class . '"' : ''; |
|
| 633 | - $attributes .= ! empty($style) ? ' style="' . $style . '"' : ''; |
|
| 634 | - $attributes .= ! empty($other_attributes) ? ' ' . $other_attributes : ''; |
|
| 635 | - return '<img' . $attributes . '/>'; |
|
| 636 | - } |
|
| 637 | - |
|
| 638 | - |
|
| 639 | - |
|
| 640 | - /** |
|
| 641 | - * Generates HTML <label></label> tags, inserts content, and adds any passed attributes |
|
| 642 | - * usage: echo EEH_HTML::span( 'this is some inline text' ); |
|
| 643 | - * |
|
| 644 | - * @access protected |
|
| 645 | - * @param string $tag |
|
| 646 | - * @param string $content - inserted after opening tag, and appends closing tag, otherwise tag is left open |
|
| 647 | - * @param string $id - html id attribute |
|
| 648 | - * @param string $class - html class attribute |
|
| 649 | - * @param string $style - html style attribute for applying inline styles |
|
| 650 | - * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
|
| 651 | - * @return string |
|
| 652 | - */ |
|
| 653 | - protected static function _inline_tag($tag = 'span', $content = '', $id = '', $class = '', $style = '', $other_attributes = '') |
|
| 654 | - { |
|
| 655 | - $attributes = ! empty($id) ? ' id="' . EEH_HTML::sanitize_id($id) . '"' : ''; |
|
| 656 | - $attributes .= ! empty($class) ? ' class="' . $class . '"' : ''; |
|
| 657 | - $attributes .= ! empty($style) ? ' style="' . $style . '"' : ''; |
|
| 658 | - $attributes .= ! empty($other_attributes) ? ' ' . $other_attributes : ''; |
|
| 659 | - return '<' . $tag . ' ' . $attributes . '>' . $content . '</' . $tag . '>'; |
|
| 660 | - } |
|
| 661 | - |
|
| 662 | - |
|
| 663 | - |
|
| 664 | - /** |
|
| 665 | - * Generates HTML <label></label> tags, inserts content, and adds any passed attributes |
|
| 666 | - * usage: echo EEH_HTML::span( 'this is some inline text' ); |
|
| 667 | - * |
|
| 668 | - * @param string $content - inserted after opening tag, and appends closing tag, otherwise tag is left open |
|
| 669 | - * @param string $id - html id attribute |
|
| 670 | - * @param string $class - html class attribute |
|
| 671 | - * @param string $style - html style attribute for applying inline styles |
|
| 672 | - * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
|
| 673 | - * @return string |
|
| 674 | - */ |
|
| 675 | - public static function label($content = '', $id = '', $class = '', $style = '', $other_attributes = '') |
|
| 676 | - { |
|
| 677 | - return EEH_HTML::_inline_tag('label', $content, $id, $class, $style, $other_attributes); |
|
| 678 | - } |
|
| 679 | - |
|
| 680 | - |
|
| 681 | - |
|
| 682 | - /** |
|
| 683 | - * Generates HTML <span></span> tags, inserts content, and adds any passed attributes |
|
| 684 | - * usage: echo EEH_HTML::span( 'this is some inline text' ); |
|
| 685 | - * |
|
| 686 | - * @param string $content - inserted after opening tag, and appends closing tag, otherwise tag is left open |
|
| 687 | - * @param string $id - html id attribute |
|
| 688 | - * @param string $class - html class attribute |
|
| 689 | - * @param string $style - html style attribute for applying inline styles |
|
| 690 | - * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
|
| 691 | - * @return string |
|
| 692 | - */ |
|
| 693 | - public static function span($content = '', $id = '', $class = '', $style = '', $other_attributes = '') |
|
| 694 | - { |
|
| 695 | - return EEH_HTML::_inline_tag('span', $content, $id, $class, $style, $other_attributes); |
|
| 696 | - } |
|
| 697 | - |
|
| 698 | - |
|
| 699 | - |
|
| 700 | - /** |
|
| 701 | - * Generates HTML <span></span> tags, inserts content, and adds any passed attributes |
|
| 702 | - * usage: echo EEH_HTML::span( 'this is some inline text' ); |
|
| 703 | - * |
|
| 704 | - * @param string $content - inserted after opening tag, and appends closing tag, otherwise tag is left open |
|
| 705 | - * @param string $id - html id attribute |
|
| 706 | - * @param string $class - html class attribute |
|
| 707 | - * @param string $style - html style attribute for applying inline styles |
|
| 708 | - * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
|
| 709 | - * @return string |
|
| 710 | - */ |
|
| 711 | - public static function strong($content = '', $id = '', $class = '', $style = '', $other_attributes = '') |
|
| 712 | - { |
|
| 713 | - return EEH_HTML::_inline_tag('strong', $content, $id, $class, $style, $other_attributes); |
|
| 714 | - } |
|
| 715 | - |
|
| 716 | - |
|
| 717 | - |
|
| 718 | - /** |
|
| 719 | - * Generates an html <-- comment --> tag |
|
| 720 | - * usage: echo comment( 'this is a comment' ); |
|
| 721 | - * |
|
| 722 | - * @param string $comment |
|
| 723 | - * @return string |
|
| 724 | - */ |
|
| 725 | - public static function comment($comment = '') |
|
| 726 | - { |
|
| 727 | - return ! empty($comment) ? EEH_HTML::nl() . '<!-- ' . $comment . ' -->' : ''; |
|
| 728 | - } |
|
| 729 | - |
|
| 730 | - |
|
| 731 | - |
|
| 732 | - /** |
|
| 733 | - * br - generates a line break |
|
| 734 | - * |
|
| 735 | - * @param int $nmbr - the number of line breaks to return |
|
| 736 | - * @return string |
|
| 737 | - */ |
|
| 738 | - public static function br($nmbr = 1) |
|
| 739 | - { |
|
| 740 | - return str_repeat('<br />', $nmbr); |
|
| 741 | - } |
|
| 742 | - |
|
| 743 | - |
|
| 744 | - |
|
| 745 | - /** |
|
| 746 | - * nbsp - generates non-breaking space entities based on number supplied |
|
| 747 | - * |
|
| 748 | - * @param int $nmbr - the number of non-breaking spaces to return |
|
| 749 | - * @return string |
|
| 750 | - */ |
|
| 751 | - public static function nbsp($nmbr = 1) |
|
| 752 | - { |
|
| 753 | - return str_repeat(' ', $nmbr); |
|
| 754 | - } |
|
| 755 | - |
|
| 756 | - |
|
| 757 | - |
|
| 758 | - /** |
|
| 759 | - * sanitize_id |
|
| 760 | - * |
|
| 761 | - * functionally does the same as the wp_core function sanitize_key except it does NOT use |
|
| 762 | - * strtolower and allows capitals. |
|
| 763 | - * |
|
| 764 | - * @param string $id |
|
| 765 | - * @return string |
|
| 766 | - */ |
|
| 767 | - public static function sanitize_id($id = '') |
|
| 768 | - { |
|
| 769 | - $key = str_replace(' ', '-', trim($id)); |
|
| 770 | - return preg_replace('/[^a-zA-Z0-9_\-]/', '', $key); |
|
| 771 | - } |
|
| 772 | - |
|
| 773 | - |
|
| 774 | - |
|
| 775 | - /** |
|
| 776 | - * return a newline and tabs ("nl" stands for "new line") |
|
| 777 | - * |
|
| 778 | - * @param int $indent the number of tabs to ADD to the current indent (can be negative or zero) |
|
| 779 | - * @param string $tag |
|
| 780 | - * @return string - newline character plus # of indents passed (can be + or -) |
|
| 781 | - */ |
|
| 782 | - public static function nl($indent = 0, $tag = 'none') |
|
| 783 | - { |
|
| 784 | - $html = "\n"; |
|
| 785 | - EEH_HTML::indent($indent, $tag); |
|
| 786 | - for ($x = 0; $x < EEH_HTML::$_indent[ $tag ]; $x++) { |
|
| 787 | - $html .= "\t"; |
|
| 788 | - } |
|
| 789 | - return $html; |
|
| 790 | - } |
|
| 791 | - |
|
| 792 | - |
|
| 793 | - |
|
| 794 | - /** |
|
| 795 | - * Changes the indents used in EEH_HTML::nl. Often its convenient to change |
|
| 796 | - * the indentation level without actually creating a new line |
|
| 797 | - * |
|
| 798 | - * @param int $indent can be negative to decrease the indentation level |
|
| 799 | - * @param string $tag |
|
| 800 | - */ |
|
| 801 | - public static function indent($indent, $tag = 'none') |
|
| 802 | - { |
|
| 803 | - static $default_indentation = false; |
|
| 804 | - if (! $default_indentation) { |
|
| 805 | - EEH_HTML::_set_default_indentation(); |
|
| 806 | - $default_indentation = true; |
|
| 807 | - } |
|
| 808 | - if (! isset(EEH_HTML::$_indent[ $tag ])) { |
|
| 809 | - EEH_HTML::$_indent[ $tag ] = 0; |
|
| 810 | - } |
|
| 811 | - EEH_HTML::$_indent[ $tag ] += (int) $indent; |
|
| 812 | - EEH_HTML::$_indent[ $tag ] = EEH_HTML::$_indent[ $tag ] >= 0 ? EEH_HTML::$_indent[ $tag ] : 0; |
|
| 813 | - } |
|
| 814 | - |
|
| 815 | - |
|
| 816 | - /** |
|
| 817 | - * class _set_default_indentation |
|
| 818 | - * |
|
| 819 | - * @access private |
|
| 820 | - */ |
|
| 821 | - private static function _set_default_indentation() |
|
| 822 | - { |
|
| 823 | - // set some initial formatting for table indentation |
|
| 824 | - EEH_HTML::$_indent = array( |
|
| 825 | - 'none' => 0, |
|
| 826 | - 'form' => 0, |
|
| 827 | - 'radio' => 0, |
|
| 828 | - 'checkbox' => 0, |
|
| 829 | - 'select' => 0, |
|
| 830 | - 'option' => 0, |
|
| 831 | - 'optgroup' => 0, |
|
| 832 | - 'table' => 1, |
|
| 833 | - 'thead' => 2, |
|
| 834 | - 'tbody' => 2, |
|
| 835 | - 'tr' => 3, |
|
| 836 | - 'th' => 4, |
|
| 837 | - 'td' => 4, |
|
| 838 | - 'div' => 0, |
|
| 839 | - 'h1' => 0, |
|
| 840 | - 'h2' => 0, |
|
| 841 | - 'h3' => 0, |
|
| 842 | - 'h4' => 0, |
|
| 843 | - 'h5' => 0, |
|
| 844 | - 'h6' => 0, |
|
| 845 | - 'p' => 0, |
|
| 846 | - 'ul' => 0, |
|
| 847 | - 'li' => 1 |
|
| 848 | - ); |
|
| 849 | - } |
|
| 850 | - |
|
| 851 | - |
|
| 852 | - |
|
| 853 | - /** |
|
| 854 | - * Retrieves the list of tags considered "simple", that are probably safe for |
|
| 855 | - * use in inputs |
|
| 856 | - * @global array $allowedtags |
|
| 857 | - * @return array |
|
| 858 | - */ |
|
| 859 | - public static function get_simple_tags() |
|
| 860 | - { |
|
| 861 | - global $allowedtags; |
|
| 862 | - $tags_we_allow = array_merge_recursive( |
|
| 863 | - $allowedtags, |
|
| 864 | - [ |
|
| 865 | - 'ol' => [], |
|
| 866 | - 'ul' => [], |
|
| 867 | - 'li' => [], |
|
| 868 | - 'br' => [], |
|
| 869 | - 'p' => [], |
|
| 870 | - 'a' => ['target'] |
|
| 871 | - ] |
|
| 872 | - ); |
|
| 873 | - return apply_filters('FHEE__EEH_HTML__get_simple_tags', $tags_we_allow); |
|
| 874 | - } |
|
| 126 | + * @param string $tag |
|
| 127 | + * @param string $id - html id attribute |
|
| 128 | + * @param string $class - html class attribute |
|
| 129 | + * @param bool $indent |
|
| 130 | + * @return string |
|
| 131 | + */ |
|
| 132 | + protected static function _close_tag($tag = 'div', $id = '', $class = '', $indent = true) |
|
| 133 | + { |
|
| 134 | + $comment = ''; |
|
| 135 | + if ($id) { |
|
| 136 | + $comment = EEH_HTML::comment('close ' . $id) . EEH_HTML::nl(0, $tag); |
|
| 137 | + } elseif ($class) { |
|
| 138 | + $comment = EEH_HTML::comment('close ' . $class) . EEH_HTML::nl(0, $tag); |
|
| 139 | + } |
|
| 140 | + $html = $indent ? EEH_HTML::nl(-1, $tag) : ''; |
|
| 141 | + $html .= '</' . $tag . '>' . $comment; |
|
| 142 | + return $html; |
|
| 143 | + } |
|
| 144 | + |
|
| 145 | + |
|
| 146 | + |
|
| 147 | + /** |
|
| 148 | + * div - generates HTML opening <div> tag and adds any passed attributes |
|
| 149 | + * to add an id use: echo EEH_HTML::div( 'this is some content', 'footer' ); |
|
| 150 | + * to add a class use: echo EEH_HTML::div( 'this is some content', '', 'float_left' ); |
|
| 151 | + * to add a both an id and a class use: echo EEH_HTML::div( 'this is some content', 'footer', 'float_left' ); |
|
| 152 | + * |
|
| 153 | + * @param string $content - inserted after opening tag, and appends closing tag, otherwise tag is left open |
|
| 154 | + * @param string $id - html id attribute |
|
| 155 | + * @param string $class - html class attribute |
|
| 156 | + * @param string $style - html style attribute for applying inline styles |
|
| 157 | + * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
|
| 158 | + * @return string |
|
| 159 | + */ |
|
| 160 | + public static function div($content = '', $id = '', $class = '', $style = '', $other_attributes = '') |
|
| 161 | + { |
|
| 162 | + return EEH_HTML::_open_tag('div', $content, $id, $class, $style, $other_attributes); |
|
| 163 | + } |
|
| 164 | + |
|
| 165 | + |
|
| 166 | + |
|
| 167 | + /** |
|
| 168 | + * Generates HTML closing </div> tag - if passed the id or class attribute used for the opening div tag, will append a comment |
|
| 169 | + * usage: echo EEH_HTML::divx(); |
|
| 170 | + * |
|
| 171 | + * @param string $id - html id attribute |
|
| 172 | + * @param string $class - html class attribute |
|
| 173 | + * @return string |
|
| 174 | + */ |
|
| 175 | + public static function divx($id = '', $class = '') |
|
| 176 | + { |
|
| 177 | + return EEH_HTML::_close_tag('div', $id, $class); |
|
| 178 | + } |
|
| 179 | + |
|
| 180 | + |
|
| 181 | + |
|
| 182 | + /** |
|
| 183 | + * Generates HTML <h1></h1> tags, inserts content, and adds any passed attributes |
|
| 184 | + * usage: echo EEH_HTML::h1( 'This is a Heading' ); |
|
| 185 | + * |
|
| 186 | + * @param string $content - inserted after opening tag, and appends closing tag, otherwise tag is left open |
|
| 187 | + * @param string $id - html id attribute |
|
| 188 | + * @param string $class - html class attribute |
|
| 189 | + * @param string $style - html style attribute for applying inline styles |
|
| 190 | + * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
|
| 191 | + * @return string |
|
| 192 | + */ |
|
| 193 | + public static function h1($content = '', $id = '', $class = '', $style = '', $other_attributes = '') |
|
| 194 | + { |
|
| 195 | + return EEH_HTML::_open_tag('h1', $content, $id, $class, $style, $other_attributes, true); |
|
| 196 | + } |
|
| 197 | + |
|
| 198 | + |
|
| 199 | + |
|
| 200 | + /** |
|
| 201 | + * Generates HTML <h2></h2> tags, inserts content, and adds any passed attributes |
|
| 202 | + * usage: echo EEH_HTML::h2( 'This is a Heading' ); |
|
| 203 | + * |
|
| 204 | + * @param string $content - inserted after opening tag, and appends closing tag, otherwise tag is left open |
|
| 205 | + * @param string $id - html id attribute |
|
| 206 | + * @param string $class - html class attribute |
|
| 207 | + * @param string $style - html style attribute for applying inline styles |
|
| 208 | + * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
|
| 209 | + * @return string |
|
| 210 | + */ |
|
| 211 | + public static function h2($content = '', $id = '', $class = '', $style = '', $other_attributes = '') |
|
| 212 | + { |
|
| 213 | + return EEH_HTML::_open_tag('h2', $content, $id, $class, $style, $other_attributes, true); |
|
| 214 | + } |
|
| 215 | + |
|
| 216 | + |
|
| 217 | + |
|
| 218 | + /** |
|
| 219 | + * Generates HTML <h3></h3> tags, inserts content, and adds any passed attributes |
|
| 220 | + * usage: echo EEH_HTML::h3( 'This is a Heading' ); |
|
| 221 | + * |
|
| 222 | + * @param string $content - inserted after opening tag, and appends closing tag, otherwise tag is left open |
|
| 223 | + * @param string $id - html id attribute |
|
| 224 | + * @param string $class - html class attribute |
|
| 225 | + * @param string $style - html style attribute for applying inline styles |
|
| 226 | + * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
|
| 227 | + * @return string |
|
| 228 | + */ |
|
| 229 | + public static function h3($content = '', $id = '', $class = '', $style = '', $other_attributes = '') |
|
| 230 | + { |
|
| 231 | + return EEH_HTML::_open_tag('h3', $content, $id, $class, $style, $other_attributes, true); |
|
| 232 | + } |
|
| 233 | + |
|
| 234 | + |
|
| 235 | + |
|
| 236 | + /** |
|
| 237 | + * Generates HTML <h4></h4> tags, inserts content, and adds any passed attributes |
|
| 238 | + * usage: echo EEH_HTML::h4( 'This is a Heading' ); |
|
| 239 | + * |
|
| 240 | + * @param string $content - inserted after opening tag, and appends closing tag, otherwise tag is left open |
|
| 241 | + * @param string $id - html id attribute |
|
| 242 | + * @param string $class - html class attribute |
|
| 243 | + * @param string $style - html style attribute for applying inline styles |
|
| 244 | + * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
|
| 245 | + * @return string |
|
| 246 | + */ |
|
| 247 | + public static function h4($content = '', $id = '', $class = '', $style = '', $other_attributes = '') |
|
| 248 | + { |
|
| 249 | + return EEH_HTML::_open_tag('h4', $content, $id, $class, $style, $other_attributes, true); |
|
| 250 | + } |
|
| 251 | + |
|
| 252 | + |
|
| 253 | + |
|
| 254 | + /** |
|
| 255 | + * Generates HTML <h5></h5> tags, inserts content, and adds any passed attributes |
|
| 256 | + * usage: echo EEH_HTML::h5( 'This is a Heading' ); |
|
| 257 | + * |
|
| 258 | + * @param string $content - inserted after opening tag, and appends closing tag, otherwise tag is left open |
|
| 259 | + * @param string $id - html id attribute |
|
| 260 | + * @param string $class - html class attribute |
|
| 261 | + * @param string $style - html style attribute for applying inline styles |
|
| 262 | + * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
|
| 263 | + * @return string |
|
| 264 | + */ |
|
| 265 | + public static function h5($content = '', $id = '', $class = '', $style = '', $other_attributes = '') |
|
| 266 | + { |
|
| 267 | + return EEH_HTML::_open_tag('h5', $content, $id, $class, $style, $other_attributes, true); |
|
| 268 | + } |
|
| 269 | + |
|
| 270 | + |
|
| 271 | + |
|
| 272 | + /** |
|
| 273 | + * Generates HTML <h6></h6> tags, inserts content, and adds any passed attributes |
|
| 274 | + * usage: echo EEH_HTML::h6( 'This is a Heading' ); |
|
| 275 | + * |
|
| 276 | + * @param string $content - inserted after opening tag, and appends closing tag, otherwise tag is left open |
|
| 277 | + * @param string $id - html id attribute |
|
| 278 | + * @param string $class - html class attribute |
|
| 279 | + * @param string $style - html style attribute for applying inline styles |
|
| 280 | + * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
|
| 281 | + * @return string |
|
| 282 | + */ |
|
| 283 | + public static function h6($content = '', $id = '', $class = '', $style = '', $other_attributes = '') |
|
| 284 | + { |
|
| 285 | + return EEH_HTML::_open_tag('h6', $content, $id, $class, $style, $other_attributes, true); |
|
| 286 | + } |
|
| 287 | + |
|
| 288 | + |
|
| 289 | + |
|
| 290 | + /** |
|
| 291 | + * Generates HTML <p></p> tags, inserts content, and adds any passed attributes |
|
| 292 | + * usage: echo EEH_HTML::p( 'this is a paragraph' ); |
|
| 293 | + * |
|
| 294 | + * @param string $content - inserted after opening tag, and appends closing tag, otherwise tag is left open |
|
| 295 | + * @param string $id - html id attribute |
|
| 296 | + * @param string $class - html class attribute |
|
| 297 | + * @param string $style - html style attribute for applying inline styles |
|
| 298 | + * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
|
| 299 | + * @return string |
|
| 300 | + */ |
|
| 301 | + public static function p($content = '', $id = '', $class = '', $style = '', $other_attributes = '') |
|
| 302 | + { |
|
| 303 | + return EEH_HTML::_open_tag('p', $content, $id, $class, $style, $other_attributes, true); |
|
| 304 | + } |
|
| 305 | + |
|
| 306 | + |
|
| 307 | + |
|
| 308 | + /** |
|
| 309 | + * ul - generates HTML opening <ul> tag and adds any passed attributes |
|
| 310 | + * usage: echo EEH_HTML::ul( 'my-list-id', 'my-list-class' ); |
|
| 311 | + * |
|
| 312 | + * @param string $id - html id attribute |
|
| 313 | + * @param string $class - html class attribute |
|
| 314 | + * @param string $style - html style attribute for applying inline styles |
|
| 315 | + * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
|
| 316 | + * @return string |
|
| 317 | + */ |
|
| 318 | + public static function ul($id = '', $class = '', $style = '', $other_attributes = '') |
|
| 319 | + { |
|
| 320 | + return EEH_HTML::_open_tag('ul', '', $id, $class, $style, $other_attributes); |
|
| 321 | + } |
|
| 322 | + |
|
| 323 | + |
|
| 324 | + |
|
| 325 | + /** |
|
| 326 | + * Generates HTML closing </ul> tag - if passed the id or class attribute used for the opening ul tag, will append a comment |
|
| 327 | + * usage: echo EEH_HTML::ulx(); |
|
| 328 | + * |
|
| 329 | + * @param string $id - html id attribute |
|
| 330 | + * @param string $class - html class attribute |
|
| 331 | + * @return string |
|
| 332 | + */ |
|
| 333 | + public static function ulx($id = '', $class = '') |
|
| 334 | + { |
|
| 335 | + return EEH_HTML::_close_tag('ul', $id, $class); |
|
| 336 | + } |
|
| 337 | + |
|
| 338 | + |
|
| 339 | + |
|
| 340 | + /** |
|
| 341 | + * Generates HTML <li> tag, inserts content, and adds any passed attributes |
|
| 342 | + * if passed content, it will also add that, as well as the closing </li> tag |
|
| 343 | + * usage: echo EEH_HTML::li( 'this is a line item' ); |
|
| 344 | + * |
|
| 345 | + * @param string $id - html id attribute |
|
| 346 | + * @param string $class - html class attribute |
|
| 347 | + * @param string $style - html style attribute for applying inline styles |
|
| 348 | + * @param string $content - inserted after opening tag, and appends closing tag, otherwise tag is left open |
|
| 349 | + * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
|
| 350 | + * @return string |
|
| 351 | + */ |
|
| 352 | + public static function li($content = '', $id = '', $class = '', $style = '', $other_attributes = '') |
|
| 353 | + { |
|
| 354 | + return EEH_HTML::_open_tag('li', $content, $id, $class, $style, $other_attributes); |
|
| 355 | + } |
|
| 356 | + |
|
| 357 | + |
|
| 358 | + |
|
| 359 | + /** |
|
| 360 | + * Generates HTML closing </li> tag - if passed the id or class attribute used for the opening ul tag, will append a comment |
|
| 361 | + * usage: echo EEH_HTML::lix(); |
|
| 362 | + * |
|
| 363 | + * @param string $id - html id attribute |
|
| 364 | + * @param string $class - html class attribute |
|
| 365 | + * @return string |
|
| 366 | + */ |
|
| 367 | + public static function lix($id = '', $class = '') |
|
| 368 | + { |
|
| 369 | + return EEH_HTML::_close_tag('li', $id, $class); |
|
| 370 | + } |
|
| 371 | + |
|
| 372 | + |
|
| 373 | + |
|
| 374 | + /** |
|
| 375 | + * table - generates an HTML <table> tag and adds any passed attributes |
|
| 376 | + * usage: echo EEH_HTML::table(); |
|
| 377 | + * |
|
| 378 | + * @param string $content - inserted after opening tag, and appends closing tag, otherwise tag is left open |
|
| 379 | + * @param string $id - html id attribute |
|
| 380 | + * @param string $class - html class attribute |
|
| 381 | + * @param string $style - html style attribute for applying inline styles |
|
| 382 | + * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
|
| 383 | + * @return string |
|
| 384 | + */ |
|
| 385 | + public static function table($content = '', $id = '', $class = '', $style = '', $other_attributes = '') |
|
| 386 | + { |
|
| 387 | + return EEH_HTML::_open_tag('table', $content, $id, $class, $style, $other_attributes); |
|
| 388 | + } |
|
| 389 | + |
|
| 390 | + |
|
| 391 | + |
|
| 392 | + /** |
|
| 393 | + * tablex - generates an HTML </table> tag - if passed the id or class attribute used for the opening ul tag, will append a comment |
|
| 394 | + * |
|
| 395 | + * @param string $id - html id attribute |
|
| 396 | + * @param string $class - html class attribute |
|
| 397 | + * @return string |
|
| 398 | + */ |
|
| 399 | + public static function tablex($id = '', $class = '') |
|
| 400 | + { |
|
| 401 | + return EEH_HTML::_close_tag('table', $id, $class); |
|
| 402 | + } |
|
| 403 | + |
|
| 404 | + |
|
| 405 | + |
|
| 406 | + /** |
|
| 407 | + * thead - generates an HTML <thead> tag and adds any passed attributes |
|
| 408 | + * usage: echo EEH_HTML::thead(); |
|
| 409 | + * |
|
| 410 | + * @param string $content - inserted after opening tag, and appends closing tag, otherwise tag is left open |
|
| 411 | + * @param string $id - html id attribute |
|
| 412 | + * @param string $class - html class attribute |
|
| 413 | + * @param string $style - html style attribute for applying inline styles |
|
| 414 | + * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
|
| 415 | + * @return string |
|
| 416 | + */ |
|
| 417 | + public static function thead($content = '', $id = '', $class = '', $style = '', $other_attributes = '') |
|
| 418 | + { |
|
| 419 | + return EEH_HTML::_open_tag('thead', $content, $id, $class, $style, $other_attributes); |
|
| 420 | + } |
|
| 421 | + |
|
| 422 | + |
|
| 423 | + |
|
| 424 | + /** |
|
| 425 | + * theadx - generates an HTML </thead> tag - if passed the id or class attribute used for the opening ul tag, will append a comment |
|
| 426 | + * |
|
| 427 | + * @param string $id - html id attribute |
|
| 428 | + * @param string $class - html class attribute |
|
| 429 | + * @return string |
|
| 430 | + */ |
|
| 431 | + public static function theadx($id = '', $class = '') |
|
| 432 | + { |
|
| 433 | + return EEH_HTML::_close_tag('thead', $id, $class); |
|
| 434 | + } |
|
| 435 | + |
|
| 436 | + |
|
| 437 | + |
|
| 438 | + /** |
|
| 439 | + * tbody - generates an HTML <tbody> tag and adds any passed attributes |
|
| 440 | + * usage: echo EEH_HTML::tbody(); |
|
| 441 | + * |
|
| 442 | + * @param string $content - inserted after opening tag, and appends closing tag, otherwise tag is left open |
|
| 443 | + * @param string $id - html id attribute |
|
| 444 | + * @param string $class - html class attribute |
|
| 445 | + * @param string $style - html style attribute for applying inline styles |
|
| 446 | + * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
|
| 447 | + * @return string |
|
| 448 | + */ |
|
| 449 | + public static function tbody($content = '', $id = '', $class = '', $style = '', $other_attributes = '') |
|
| 450 | + { |
|
| 451 | + return EEH_HTML::_open_tag('tbody', $content, $id, $class, $style, $other_attributes); |
|
| 452 | + } |
|
| 453 | + |
|
| 454 | + |
|
| 455 | + |
|
| 456 | + /** |
|
| 457 | + * tbodyx - generates an HTML </tbody> tag - if passed the id or class attribute used for the opening ul tag, will append a comment |
|
| 458 | + * |
|
| 459 | + * @param string $id - html id attribute |
|
| 460 | + * @param string $class - html class attribute |
|
| 461 | + * @return string |
|
| 462 | + */ |
|
| 463 | + public static function tbodyx($id = '', $class = '') |
|
| 464 | + { |
|
| 465 | + return EEH_HTML::_close_tag('tbody', $id, $class); |
|
| 466 | + } |
|
| 467 | + |
|
| 468 | + |
|
| 469 | + |
|
| 470 | + /** |
|
| 471 | + * tr - generates an HTML <tr> tag and adds any passed attributes |
|
| 472 | + * usage: echo EEH_HTML::tr(); |
|
| 473 | + * |
|
| 474 | + * @param string $content - inserted after opening tag, and appends closing tag, otherwise tag is left open |
|
| 475 | + * @param string $id - html id attribute |
|
| 476 | + * @param string $class - html class attribute |
|
| 477 | + * @param string $style - html style attribute for applying inline styles |
|
| 478 | + * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
|
| 479 | + * @return string |
|
| 480 | + */ |
|
| 481 | + public static function tr($content = '', $id = '', $class = '', $style = '', $other_attributes = '') |
|
| 482 | + { |
|
| 483 | + return EEH_HTML::_open_tag('tr', $content, $id, $class, $style, $other_attributes); |
|
| 484 | + } |
|
| 485 | + |
|
| 486 | + |
|
| 487 | + |
|
| 488 | + /** |
|
| 489 | + * trx - generates an HTML </tr> tag - if passed the id or class attribute used for the opening ul tag, will append a comment |
|
| 490 | + * |
|
| 491 | + * @param string $id - html id attribute |
|
| 492 | + * @param string $class - html class attribute |
|
| 493 | + * @return string |
|
| 494 | + */ |
|
| 495 | + public static function trx($id = '', $class = '') |
|
| 496 | + { |
|
| 497 | + return EEH_HTML::_close_tag('tr', $id, $class); |
|
| 498 | + } |
|
| 499 | + |
|
| 500 | + |
|
| 501 | + |
|
| 502 | + /** |
|
| 503 | + * th - generates an HTML <th> tag and adds any passed attributes |
|
| 504 | + * usage: echo EEH_HTML::th(); |
|
| 505 | + * |
|
| 506 | + * @param string $content - inserted after opening tag, and appends closing tag, otherwise tag is left open |
|
| 507 | + * @param string $id - html id attribute |
|
| 508 | + * @param string $class - html class attribute |
|
| 509 | + * @param string $style - html style attribute for applying inline styles |
|
| 510 | + * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
|
| 511 | + * @return string |
|
| 512 | + */ |
|
| 513 | + public static function th($content = '', $id = '', $class = '', $style = '', $other_attributes = '') |
|
| 514 | + { |
|
| 515 | + return EEH_HTML::_open_tag('th', $content, $id, $class, $style, $other_attributes); |
|
| 516 | + } |
|
| 517 | + |
|
| 518 | + |
|
| 519 | + |
|
| 520 | + /** |
|
| 521 | + * thx - generates an HTML </th> tag - if passed the id or class attribute used for the opening ul tag, will append a comment |
|
| 522 | + * |
|
| 523 | + * @param string $id - html id attribute |
|
| 524 | + * @param string $class - html class attribute |
|
| 525 | + * @return string |
|
| 526 | + */ |
|
| 527 | + public static function thx($id = '', $class = '') |
|
| 528 | + { |
|
| 529 | + return EEH_HTML::_close_tag('th', $id, $class); |
|
| 530 | + } |
|
| 531 | + |
|
| 532 | + |
|
| 533 | + |
|
| 534 | + /** |
|
| 535 | + * td - generates an HTML <td> tag and adds any passed attributes |
|
| 536 | + * usage: echo EEH_HTML::td(); |
|
| 537 | + * |
|
| 538 | + * @param string $content - inserted after opening tag, and appends closing tag, otherwise tag is left open |
|
| 539 | + * @param string $id - html id attribute |
|
| 540 | + * @param string $class - html class attribute |
|
| 541 | + * @param string $style - html style attribute for applying inline styles |
|
| 542 | + * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
|
| 543 | + * @return string |
|
| 544 | + */ |
|
| 545 | + public static function td($content = '', $id = '', $class = '', $style = '', $other_attributes = '') |
|
| 546 | + { |
|
| 547 | + return EEH_HTML::_open_tag('td', $content, $id, $class, $style, $other_attributes); |
|
| 548 | + } |
|
| 549 | + |
|
| 550 | + |
|
| 551 | + |
|
| 552 | + /** |
|
| 553 | + * tdx - generates an HTML </td> tag - if passed the id or class attribute used for the opening ul tag, will append a comment |
|
| 554 | + * |
|
| 555 | + * @param string $id - html id attribute |
|
| 556 | + * @param string $class - html class attribute |
|
| 557 | + * @return string |
|
| 558 | + */ |
|
| 559 | + public static function tdx($id = '', $class = '') |
|
| 560 | + { |
|
| 561 | + return EEH_HTML::_close_tag('td', $id, $class); |
|
| 562 | + } |
|
| 563 | + |
|
| 564 | + |
|
| 565 | + |
|
| 566 | + /** |
|
| 567 | + * no_row - for generating a "hidden" table row, good for embedding tables within tables |
|
| 568 | + * generates a new table row with one td cell that spans however many columns you set |
|
| 569 | + * removes all styles from the tr and td |
|
| 570 | + * |
|
| 571 | + * @param string $content |
|
| 572 | + * @param int $colspan |
|
| 573 | + * @return string |
|
| 574 | + */ |
|
| 575 | + public static function no_row($content = '', $colspan = 2) |
|
| 576 | + { |
|
| 577 | + return EEH_HTML::tr( |
|
| 578 | + EEH_HTML::td($content, '', '', 'padding:0; border:none;', 'colspan="' . $colspan . '"'), |
|
| 579 | + '', |
|
| 580 | + '', |
|
| 581 | + 'padding:0; border:none;' |
|
| 582 | + ); |
|
| 583 | + } |
|
| 584 | + |
|
| 585 | + |
|
| 586 | + |
|
| 587 | + /** |
|
| 588 | + * Generates HTML <label></label> tags, inserts content, and adds any passed attributes |
|
| 589 | + * usage: echo EEH_HTML::span( 'this is some inline text' ); |
|
| 590 | + * |
|
| 591 | + * @access public |
|
| 592 | + * @param string $href URL to link to |
|
| 593 | + * @param string $link_text - the text that will become "hyperlinked" |
|
| 594 | + * @param string $title - html title attribute |
|
| 595 | + * @param string $id - html id attribute |
|
| 596 | + * @param string $class - html class attribute |
|
| 597 | + * @param string $style - html style attribute for applying inline styles |
|
| 598 | + * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
|
| 599 | + * @return string |
|
| 600 | + */ |
|
| 601 | + public static function link($href = '', $link_text = '', $title = '', $id = '', $class = '', $style = '', $other_attributes = '') |
|
| 602 | + { |
|
| 603 | + $link_text = ! empty($link_text) ? $link_text : $href; |
|
| 604 | + $attributes = ! empty($href) ? ' href="' . $href . '"' : ''; |
|
| 605 | + $attributes .= ! empty($id) ? ' id="' . EEH_HTML::sanitize_id($id) . '"' : ''; |
|
| 606 | + $attributes .= ! empty($class) ? ' class="' . $class . '"' : ''; |
|
| 607 | + $attributes .= ! empty($style) ? ' style="' . $style . '"' : ''; |
|
| 608 | + $attributes .= ! empty($title) ? ' title="' . esc_attr($title) . '"' : ''; |
|
| 609 | + $attributes .= ! empty($other_attributes) ? ' ' . $other_attributes : ''; |
|
| 610 | + return "<a{$attributes}>{$link_text}</a>"; |
|
| 611 | + } |
|
| 612 | + |
|
| 613 | + |
|
| 614 | + |
|
| 615 | + /** |
|
| 616 | + * img - generates an HTML <img> tag and adds any passed attributes |
|
| 617 | + * usage: echo EEH_HTML::img(); |
|
| 618 | + * |
|
| 619 | + * @param string $src - html src attribute ie: the path or URL to the image |
|
| 620 | + * @param string $alt - html alt attribute |
|
| 621 | + * @param string $id - html id attribute |
|
| 622 | + * @param string $class - html class attribute |
|
| 623 | + * @param string $style - html style attribute for applying inline styles |
|
| 624 | + * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
|
| 625 | + * @return string |
|
| 626 | + */ |
|
| 627 | + public static function img($src = '', $alt = '', $id = '', $class = '', $style = '', $other_attributes = '') |
|
| 628 | + { |
|
| 629 | + $attributes = ! empty($src) ? ' src="' . esc_url_raw($src) . '"' : ''; |
|
| 630 | + $attributes .= ! empty($alt) ? ' alt="' . esc_attr($alt) . '"' : ''; |
|
| 631 | + $attributes .= ! empty($id) ? ' id="' . EEH_HTML::sanitize_id($id) . '"' : ''; |
|
| 632 | + $attributes .= ! empty($class) ? ' class="' . $class . '"' : ''; |
|
| 633 | + $attributes .= ! empty($style) ? ' style="' . $style . '"' : ''; |
|
| 634 | + $attributes .= ! empty($other_attributes) ? ' ' . $other_attributes : ''; |
|
| 635 | + return '<img' . $attributes . '/>'; |
|
| 636 | + } |
|
| 637 | + |
|
| 638 | + |
|
| 639 | + |
|
| 640 | + /** |
|
| 641 | + * Generates HTML <label></label> tags, inserts content, and adds any passed attributes |
|
| 642 | + * usage: echo EEH_HTML::span( 'this is some inline text' ); |
|
| 643 | + * |
|
| 644 | + * @access protected |
|
| 645 | + * @param string $tag |
|
| 646 | + * @param string $content - inserted after opening tag, and appends closing tag, otherwise tag is left open |
|
| 647 | + * @param string $id - html id attribute |
|
| 648 | + * @param string $class - html class attribute |
|
| 649 | + * @param string $style - html style attribute for applying inline styles |
|
| 650 | + * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
|
| 651 | + * @return string |
|
| 652 | + */ |
|
| 653 | + protected static function _inline_tag($tag = 'span', $content = '', $id = '', $class = '', $style = '', $other_attributes = '') |
|
| 654 | + { |
|
| 655 | + $attributes = ! empty($id) ? ' id="' . EEH_HTML::sanitize_id($id) . '"' : ''; |
|
| 656 | + $attributes .= ! empty($class) ? ' class="' . $class . '"' : ''; |
|
| 657 | + $attributes .= ! empty($style) ? ' style="' . $style . '"' : ''; |
|
| 658 | + $attributes .= ! empty($other_attributes) ? ' ' . $other_attributes : ''; |
|
| 659 | + return '<' . $tag . ' ' . $attributes . '>' . $content . '</' . $tag . '>'; |
|
| 660 | + } |
|
| 661 | + |
|
| 662 | + |
|
| 663 | + |
|
| 664 | + /** |
|
| 665 | + * Generates HTML <label></label> tags, inserts content, and adds any passed attributes |
|
| 666 | + * usage: echo EEH_HTML::span( 'this is some inline text' ); |
|
| 667 | + * |
|
| 668 | + * @param string $content - inserted after opening tag, and appends closing tag, otherwise tag is left open |
|
| 669 | + * @param string $id - html id attribute |
|
| 670 | + * @param string $class - html class attribute |
|
| 671 | + * @param string $style - html style attribute for applying inline styles |
|
| 672 | + * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
|
| 673 | + * @return string |
|
| 674 | + */ |
|
| 675 | + public static function label($content = '', $id = '', $class = '', $style = '', $other_attributes = '') |
|
| 676 | + { |
|
| 677 | + return EEH_HTML::_inline_tag('label', $content, $id, $class, $style, $other_attributes); |
|
| 678 | + } |
|
| 679 | + |
|
| 680 | + |
|
| 681 | + |
|
| 682 | + /** |
|
| 683 | + * Generates HTML <span></span> tags, inserts content, and adds any passed attributes |
|
| 684 | + * usage: echo EEH_HTML::span( 'this is some inline text' ); |
|
| 685 | + * |
|
| 686 | + * @param string $content - inserted after opening tag, and appends closing tag, otherwise tag is left open |
|
| 687 | + * @param string $id - html id attribute |
|
| 688 | + * @param string $class - html class attribute |
|
| 689 | + * @param string $style - html style attribute for applying inline styles |
|
| 690 | + * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
|
| 691 | + * @return string |
|
| 692 | + */ |
|
| 693 | + public static function span($content = '', $id = '', $class = '', $style = '', $other_attributes = '') |
|
| 694 | + { |
|
| 695 | + return EEH_HTML::_inline_tag('span', $content, $id, $class, $style, $other_attributes); |
|
| 696 | + } |
|
| 697 | + |
|
| 698 | + |
|
| 699 | + |
|
| 700 | + /** |
|
| 701 | + * Generates HTML <span></span> tags, inserts content, and adds any passed attributes |
|
| 702 | + * usage: echo EEH_HTML::span( 'this is some inline text' ); |
|
| 703 | + * |
|
| 704 | + * @param string $content - inserted after opening tag, and appends closing tag, otherwise tag is left open |
|
| 705 | + * @param string $id - html id attribute |
|
| 706 | + * @param string $class - html class attribute |
|
| 707 | + * @param string $style - html style attribute for applying inline styles |
|
| 708 | + * @param string $other_attributes - additional attributes like "colspan", inline JS, "rel" tags, etc |
|
| 709 | + * @return string |
|
| 710 | + */ |
|
| 711 | + public static function strong($content = '', $id = '', $class = '', $style = '', $other_attributes = '') |
|
| 712 | + { |
|
| 713 | + return EEH_HTML::_inline_tag('strong', $content, $id, $class, $style, $other_attributes); |
|
| 714 | + } |
|
| 715 | + |
|
| 716 | + |
|
| 717 | + |
|
| 718 | + /** |
|
| 719 | + * Generates an html <-- comment --> tag |
|
| 720 | + * usage: echo comment( 'this is a comment' ); |
|
| 721 | + * |
|
| 722 | + * @param string $comment |
|
| 723 | + * @return string |
|
| 724 | + */ |
|
| 725 | + public static function comment($comment = '') |
|
| 726 | + { |
|
| 727 | + return ! empty($comment) ? EEH_HTML::nl() . '<!-- ' . $comment . ' -->' : ''; |
|
| 728 | + } |
|
| 729 | + |
|
| 730 | + |
|
| 731 | + |
|
| 732 | + /** |
|
| 733 | + * br - generates a line break |
|
| 734 | + * |
|
| 735 | + * @param int $nmbr - the number of line breaks to return |
|
| 736 | + * @return string |
|
| 737 | + */ |
|
| 738 | + public static function br($nmbr = 1) |
|
| 739 | + { |
|
| 740 | + return str_repeat('<br />', $nmbr); |
|
| 741 | + } |
|
| 742 | + |
|
| 743 | + |
|
| 744 | + |
|
| 745 | + /** |
|
| 746 | + * nbsp - generates non-breaking space entities based on number supplied |
|
| 747 | + * |
|
| 748 | + * @param int $nmbr - the number of non-breaking spaces to return |
|
| 749 | + * @return string |
|
| 750 | + */ |
|
| 751 | + public static function nbsp($nmbr = 1) |
|
| 752 | + { |
|
| 753 | + return str_repeat(' ', $nmbr); |
|
| 754 | + } |
|
| 755 | + |
|
| 756 | + |
|
| 757 | + |
|
| 758 | + /** |
|
| 759 | + * sanitize_id |
|
| 760 | + * |
|
| 761 | + * functionally does the same as the wp_core function sanitize_key except it does NOT use |
|
| 762 | + * strtolower and allows capitals. |
|
| 763 | + * |
|
| 764 | + * @param string $id |
|
| 765 | + * @return string |
|
| 766 | + */ |
|
| 767 | + public static function sanitize_id($id = '') |
|
| 768 | + { |
|
| 769 | + $key = str_replace(' ', '-', trim($id)); |
|
| 770 | + return preg_replace('/[^a-zA-Z0-9_\-]/', '', $key); |
|
| 771 | + } |
|
| 772 | + |
|
| 773 | + |
|
| 774 | + |
|
| 775 | + /** |
|
| 776 | + * return a newline and tabs ("nl" stands for "new line") |
|
| 777 | + * |
|
| 778 | + * @param int $indent the number of tabs to ADD to the current indent (can be negative or zero) |
|
| 779 | + * @param string $tag |
|
| 780 | + * @return string - newline character plus # of indents passed (can be + or -) |
|
| 781 | + */ |
|
| 782 | + public static function nl($indent = 0, $tag = 'none') |
|
| 783 | + { |
|
| 784 | + $html = "\n"; |
|
| 785 | + EEH_HTML::indent($indent, $tag); |
|
| 786 | + for ($x = 0; $x < EEH_HTML::$_indent[ $tag ]; $x++) { |
|
| 787 | + $html .= "\t"; |
|
| 788 | + } |
|
| 789 | + return $html; |
|
| 790 | + } |
|
| 791 | + |
|
| 792 | + |
|
| 793 | + |
|
| 794 | + /** |
|
| 795 | + * Changes the indents used in EEH_HTML::nl. Often its convenient to change |
|
| 796 | + * the indentation level without actually creating a new line |
|
| 797 | + * |
|
| 798 | + * @param int $indent can be negative to decrease the indentation level |
|
| 799 | + * @param string $tag |
|
| 800 | + */ |
|
| 801 | + public static function indent($indent, $tag = 'none') |
|
| 802 | + { |
|
| 803 | + static $default_indentation = false; |
|
| 804 | + if (! $default_indentation) { |
|
| 805 | + EEH_HTML::_set_default_indentation(); |
|
| 806 | + $default_indentation = true; |
|
| 807 | + } |
|
| 808 | + if (! isset(EEH_HTML::$_indent[ $tag ])) { |
|
| 809 | + EEH_HTML::$_indent[ $tag ] = 0; |
|
| 810 | + } |
|
| 811 | + EEH_HTML::$_indent[ $tag ] += (int) $indent; |
|
| 812 | + EEH_HTML::$_indent[ $tag ] = EEH_HTML::$_indent[ $tag ] >= 0 ? EEH_HTML::$_indent[ $tag ] : 0; |
|
| 813 | + } |
|
| 814 | + |
|
| 815 | + |
|
| 816 | + /** |
|
| 817 | + * class _set_default_indentation |
|
| 818 | + * |
|
| 819 | + * @access private |
|
| 820 | + */ |
|
| 821 | + private static function _set_default_indentation() |
|
| 822 | + { |
|
| 823 | + // set some initial formatting for table indentation |
|
| 824 | + EEH_HTML::$_indent = array( |
|
| 825 | + 'none' => 0, |
|
| 826 | + 'form' => 0, |
|
| 827 | + 'radio' => 0, |
|
| 828 | + 'checkbox' => 0, |
|
| 829 | + 'select' => 0, |
|
| 830 | + 'option' => 0, |
|
| 831 | + 'optgroup' => 0, |
|
| 832 | + 'table' => 1, |
|
| 833 | + 'thead' => 2, |
|
| 834 | + 'tbody' => 2, |
|
| 835 | + 'tr' => 3, |
|
| 836 | + 'th' => 4, |
|
| 837 | + 'td' => 4, |
|
| 838 | + 'div' => 0, |
|
| 839 | + 'h1' => 0, |
|
| 840 | + 'h2' => 0, |
|
| 841 | + 'h3' => 0, |
|
| 842 | + 'h4' => 0, |
|
| 843 | + 'h5' => 0, |
|
| 844 | + 'h6' => 0, |
|
| 845 | + 'p' => 0, |
|
| 846 | + 'ul' => 0, |
|
| 847 | + 'li' => 1 |
|
| 848 | + ); |
|
| 849 | + } |
|
| 850 | + |
|
| 851 | + |
|
| 852 | + |
|
| 853 | + /** |
|
| 854 | + * Retrieves the list of tags considered "simple", that are probably safe for |
|
| 855 | + * use in inputs |
|
| 856 | + * @global array $allowedtags |
|
| 857 | + * @return array |
|
| 858 | + */ |
|
| 859 | + public static function get_simple_tags() |
|
| 860 | + { |
|
| 861 | + global $allowedtags; |
|
| 862 | + $tags_we_allow = array_merge_recursive( |
|
| 863 | + $allowedtags, |
|
| 864 | + [ |
|
| 865 | + 'ol' => [], |
|
| 866 | + 'ul' => [], |
|
| 867 | + 'li' => [], |
|
| 868 | + 'br' => [], |
|
| 869 | + 'p' => [], |
|
| 870 | + 'a' => ['target'] |
|
| 871 | + ] |
|
| 872 | + ); |
|
| 873 | + return apply_filters('FHEE__EEH_HTML__get_simple_tags', $tags_we_allow); |
|
| 874 | + } |
|
| 875 | 875 | } |