WordPress.org

Make WordPress Core

Ticket #29808: 29808.9.diff

File 29808.9.diff, 4.8 KB (added by obenland, 5 years ago)

Comments navigation template

  • src/wp-includes/link-template.php

     
    25592559}
    25602560
    25612561/**
     2562 * Return navigation to next/previous set of comments when applicable.
     2563 *
     2564 * @since 4.1.0
     2565 *
     2566 * @param array $args {
     2567 *     Optional. Default comments navigation arguments.
     2568 *
     2569 *     @type string $prev_text Anchor text to display in the previous comments link. Default: `Older comments`.
     2570 *     @type string $next_text Anchor text to display in the next comments link. Default: `Newer comments`.
     2571 * }
     2572 * @return string Markup for comments links.
     2573 */
     2574function get_the_comments_navigation( $args = array() ) {
     2575        $navigation = '';
     2576
     2577        // Are there comments to navigate through?
     2578        if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) {
     2579                $args = wp_parse_args( $args, array(
     2580                        'prev_text' => __( 'Older comments' ),
     2581                        'next_text' => __( 'Newer comments' ),
     2582                ) );
     2583
     2584                $prev_link = get_previous_comments_link( $args['prev_text'] );
     2585                $next_link = get_next_comments_link( $args['next_text'] );
     2586
     2587                if ( $prev_link ) {
     2588                        $navigation .= '<div class="nav-previous">' . $prev_link . '</div>';
     2589                }
     2590
     2591                if ( $next_link ) {
     2592                        $navigation .= '<div class="nav-next">' . $next_link . '</div>';
     2593                }
     2594
     2595                $navigation = _navigation_markup( $navigation, 'comment-navigation', __( 'Comments navigation' ) );
     2596        }
     2597
     2598        return $navigation;
     2599}
     2600
     2601/**
     2602 * Display navigation to next/previous set of comments when applicable.
     2603 *
     2604 * @since 4.1.0
     2605 *
     2606 * @param array $args See {@see get_the_comments_navigation()} for available arguments.
     2607 */
     2608function the_comments_navigation( $args = array() ) {
     2609        echo get_the_comments_navigation( $args );
     2610}
     2611
     2612/**
     2613 * Return a paginated navigation to next/previous set of comments,
     2614 * when applicable.
     2615 *
     2616 * @since 4.1.0
     2617 *
     2618 * @param array $args {
     2619 *     Optional. Default pagination arguments.
     2620 *
     2621 *     @type string $base               URL to be used to create the paginated links.
     2622 *                                      Example: `http://example.com/all_posts.php%_%`
     2623 *                                      The `%_%` is required and will be replaced by the contents of the
     2624 *                                      'format' argument.
     2625 *                                      Default: Current page number link with appended `%_%`.
     2626 *     @type string $format             Used to replace the page number. Example: `?page=%#%`
     2627 *                                      The `%#%` is required and will be replaced with the page number.
     2628 *                                      Default: Current permalink format with appended `%#%`.
     2629 *     @type int    $total              The total amount of pages. Default: Value of 'max_num_pages' of current query.
     2630 *     @type int    $current            The current page number. Default: Value of 'paged' query var.
     2631 *     @type bool   $prev_next          Whether to include previous and next links. Default: true.
     2632 *     @type string $prev_text          Anchor text to display in the previous posts link. Default: `&laquo; Previous`.
     2633 *     @type string $next_text          Anchor text to display in the next posts link. Default: `Next &raquo;`.
     2634 *     @type bool   $show_all           Whether to show all pages.
     2635 *                                      Default: false, shows short list of the pages near the current page.
     2636 *     @type int    $end_size           Amount of numbers on either the start and the end list edges. Default: 1.
     2637 *     @type int    $mid_size           Amount of numbers to either side of current page but not including current page.
     2638 *                                      Default: 2.
     2639 *     @type array  $add_args           Query vars to be added to the links. Accepts an associative array of arguments.
     2640 *                                      Default: Empty array.
     2641 *     @type string $before_page_number Text to prepend to the anchor text. Default: Empty string.
     2642 *     @type string $after_page_number  Text to append to the anchor text. Default: Empty string.
     2643 * }
     2644 * @return string Markup for pagination links.
     2645 */
     2646function get_the_comments_pagination( $args = array() ) {
     2647        $navigation   = '';
     2648        $args['echo'] = false;
     2649
     2650        $links = paginate_comments_links( $args );
     2651
     2652        if ( $links ) {
     2653                $navigation = _navigation_markup( $links, 'comments-pagination', __( 'Comments navigation' ) );
     2654        }
     2655
     2656        return $navigation;
     2657}
     2658
     2659/**
     2660 * Display a paginated navigation to next/previous set of comments,
     2661 * when applicable.
     2662 *
     2663 * @since 4.1.0
     2664 *
     2665 * @param array $args See {@see get_the_comments_pagination()} for available arguments.
     2666 */
     2667function the_comments_pagination( $args = array() ) {
     2668        echo get_the_comments_pagination( $args );
     2669}
     2670
     2671/**
    25622672 * Retrieve the Press This bookmarklet link.
    25632673 *
    25642674 * Use this in 'a' element 'href' attribute.