WordPress.org

Make WordPress Core

Changeset 48378


Ignore:
Timestamp:
07/07/2020 02:13:37 PM (3 months ago)
Author:
SergeyBiryukov
Message:

Themes: Allow passing a custom class to post and comment pagination functions.

This affects:

  • get_the_post_navigation()
  • get_the_posts_navigation()
  • get_the_posts_pagination()
  • get_the_comments_navigation()
  • get_the_comments_pagination()

Props jfarthing84, markparnell, davidbaumwald, SergeyBiryukov.
Fixes #39378.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/link-template.php

    r48197 r48378  
    25522552 * @since 4.4.0 Introduced the `in_same_term`, `excluded_terms`, and `taxonomy` arguments.
    25532553 * @since 5.3.0 Added the `aria_label` parameter.
     2554 * @since 5.5.0 Added the `class` parameter.
    25542555 *
    25552556 * @param array $args {
     
    25632564 *     @type string       $screen_reader_text Screen reader text for the nav element. Default 'Post navigation'.
    25642565 *     @type string       $aria_label         ARIA label text for the nav element. Default 'Posts'.
     2566 *     @type string       $class              Custom class for the nav element. Default 'post-navigation'.
    25652567 * }
    25662568 * @return string Markup for post links.
     
    25822584            'screen_reader_text' => __( 'Post navigation' ),
    25832585            'aria_label'         => __( 'Posts' ),
     2586            'class'              => 'post-navigation',
    25842587        )
    25852588    );
     
    26052608    // Only add markup if there's somewhere to navigate to.
    26062609    if ( $previous || $next ) {
    2607         $navigation = _navigation_markup( $previous . $next, 'post-navigation', $args['screen_reader_text'], $args['aria_label'] );
     2610        $navigation = _navigation_markup( $previous . $next, $args['class'], $args['screen_reader_text'], $args['aria_label'] );
    26082611    }
    26092612
     
    26282631 * @since 4.1.0
    26292632 * @since 5.3.0 Added the `aria_label` parameter.
     2633 * @since 5.5.0 Added the `class` parameter.
    26302634 *
    26312635 * @global WP_Query $wp_query WordPress Query object.
     
    26412645 *                                      Default 'Posts navigation'.
    26422646 *     @type string $aria_label         ARIA label text for the nav element. Default 'Posts'.
     2647 *     @type string $class              Custom class for the nav element. Default 'posts-navigation'.
    26432648 * }
    26442649 * @return string Markup for posts links.
     
    26612666                'screen_reader_text' => __( 'Posts navigation' ),
    26622667                'aria_label'         => __( 'Posts' ),
     2668                'class'              => 'posts-navigation',
    26632669            )
    26642670        );
     
    26752681        }
    26762682
    2677         $navigation = _navigation_markup( $navigation, 'posts-navigation', $args['screen_reader_text'], $args['aria_label'] );
     2683        $navigation = _navigation_markup( $navigation, $args['class'], $args['screen_reader_text'], $args['aria_label'] );
    26782684    }
    26792685
     
    26982704 * @since 4.1.0
    26992705 * @since 5.3.0 Added the `aria_label` parameter.
     2706 * @since 5.5.0 Added the `class` parameter.
    27002707 *
    27012708 * @param array $args {
     
    27052712 *                                      Default 'Posts navigation'.
    27062713 *     @type string $aria_label         ARIA label text for the nav element. Default 'Posts'.
     2714 *     @type string $class              Custom class for the nav element. Default 'pagination'.
    27072715 * }
    27082716 * @return string Markup for pagination links.
     
    27262734                'screen_reader_text' => __( 'Posts navigation' ),
    27272735                'aria_label'         => __( 'Posts' ),
     2736                'class'              => 'pagination',
    27282737            )
    27292738        );
     
    27382747
    27392748        if ( $links ) {
    2740             $navigation = _navigation_markup( $links, 'pagination', $args['screen_reader_text'], $args['aria_label'] );
     2749            $navigation = _navigation_markup( $links, $args['class'], $args['screen_reader_text'], $args['aria_label'] );
    27412750        }
    27422751    }
     
    27652774 *
    27662775 * @param string $links              Navigational links.
    2767  * @param string $class              Optional. Custom class for the nav element. Default: 'posts-navigation'.
    2768  * @param string $screen_reader_text Optional. Screen reader text for the nav element. Default: 'Posts navigation'.
    2769  * @param string $aria_label         Optional. ARIA label for the nav element. Default: same value as $screen_reader_text.
     2776 * @param string $class              Optional. Custom class for the nav element.
     2777 *                                   Default 'posts-navigation'.
     2778 * @param string $screen_reader_text Optional. Screen reader text for the nav element.
     2779 *                                   Default 'Posts navigation'.
     2780 * @param string $aria_label         Optional. ARIA label for the nav element.
     2781 *                                   Defaults to the value of `$screen_reader_text`.
    27702782 * @return string Navigation template tag.
    27712783 */
     
    30173029 * @since 4.4.0
    30183030 * @since 5.3.0 Added the `aria_label` parameter.
     3031 * @since 5.5.0 Added the `class` parameter.
    30193032 *
    30203033 * @param array $args {
     
    30273040 *     @type string $screen_reader_text Screen reader text for the nav element. Default 'Comments navigation'.
    30283041 *     @type string $aria_label         ARIA label text for the nav element. Default 'Comments'.
     3042 *     @type string $class              Custom class for the nav element. Default 'comment-navigation'.
    30293043 * }
    30303044 * @return string Markup for comments links.
     
    30473061                'screen_reader_text' => __( 'Comments navigation' ),
    30483062                'aria_label'         => __( 'Comments' ),
     3063                'class'              => 'comment-navigation',
    30493064            )
    30503065        );
     
    30613076        }
    30623077
    3063         $navigation = _navigation_markup( $navigation, 'comment-navigation', $args['screen_reader_text'], $args['aria_label'] );
     3078        $navigation = _navigation_markup( $navigation, $args['class'], $args['screen_reader_text'], $args['aria_label'] );
    30643079    }
    30653080
     
    30833098 * @since 4.4.0
    30843099 * @since 5.3.0 Added the `aria_label` parameter.
     3100 * @since 5.5.0 Added the `class` parameter.
    30853101 *
    30863102 * @see paginate_comments_links()
     
    30913107 *     @type string $screen_reader_text Screen reader text for the nav element. Default 'Comments navigation'.
    30923108 *     @type string $aria_label         ARIA label text for the nav element. Default 'Comments'.
     3109 *     @type string $class              Custom class for the nav element. Default 'comments-pagination'.
    30933110 * }
    30943111 * @return string Markup for pagination links.
     
    31073124            'screen_reader_text' => __( 'Comments navigation' ),
    31083125            'aria_label'         => __( 'Comments' ),
     3126            'class'              => 'comments-pagination',
    31093127        )
    31103128    );
     
    31193137
    31203138    if ( $links ) {
    3121         $navigation = _navigation_markup( $links, 'comments-pagination', $args['screen_reader_text'], $args['aria_label'] );
     3139        $navigation = _navigation_markup( $links, $args['class'], $args['screen_reader_text'], $args['aria_label'] );
    31223140    }
    31233141
Note: See TracChangeset for help on using the changeset viewer.