| 2561 | * Return navigation to next/previous set of comments when applicable. |
| 2562 | * |
| 2563 | * @since 4.1.0 |
| 2564 | * |
| 2565 | * @param array $args { |
| 2566 | * Optional. Default comments navigation arguments. |
| 2567 | * |
| 2568 | * @type string $prev_text Anchor text to display in the previous comments link. Default: 'Older comments'. |
| 2569 | * @type string $next_text Anchor text to display in the next comments link. Default: 'Newer comments'. |
| 2570 | * @type string $screen_reader_text Screen reader text for nav element. Default: 'Comments navigation'. |
| 2571 | * } |
| 2572 | * @return string Markup for comments links. |
| 2573 | */ |
| 2574 | function 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 | 'screen_reader_text' => __( 'Comments navigation' ), |
| 2583 | ) ); |
| 2584 | |
| 2585 | $prev_link = get_previous_comments_link( $args['prev_text'] ); |
| 2586 | $next_link = get_next_comments_link( $args['next_text'] ); |
| 2587 | |
| 2588 | if ( $prev_link ) { |
| 2589 | $navigation .= '<div class="nav-previous">' . $prev_link . '</div>'; |
| 2590 | } |
| 2591 | |
| 2592 | if ( $next_link ) { |
| 2593 | $navigation .= '<div class="nav-next">' . $next_link . '</div>'; |
| 2594 | } |
| 2595 | |
| 2596 | $navigation = _navigation_markup( $navigation, 'comment-navigation', $args['screen_reader_text'] ); |
| 2597 | } |
| 2598 | |
| 2599 | return $navigation; |
| 2600 | } |
| 2601 | |
| 2602 | /** |
| 2603 | * Display navigation to next/previous set of comments when applicable. |
| 2604 | * |
| 2605 | * @since 4.1.0 |
| 2606 | * |
| 2607 | * @param array $args See {@see get_the_comments_navigation()} for available arguments. |
| 2608 | */ |
| 2609 | function the_comments_navigation( $args = array() ) { |
| 2610 | echo get_the_comments_navigation( $args ); |
| 2611 | } |
| 2612 | |
| 2613 | /** |
| 2614 | * Return a paginated navigation to next/previous set of comments, |
| 2615 | * when applicable. |
| 2616 | * |
| 2617 | * @since 4.1.0 |
| 2618 | * |
| 2619 | * @param array $args { |
| 2620 | * Optional. Default pagination arguments. {@see paginate_links()} |
| 2621 | * |
| 2622 | * @type string $screen_reader_text Screen reader text for nav element. Default: 'Comments navigation'. |
| 2623 | * } |
| 2624 | * @return string Markup for pagination links. |
| 2625 | */ |
| 2626 | function get_the_comments_pagination( $args = array() ) { |
| 2627 | $navigation = ''; |
| 2628 | $args = wp_parse_args( $args, array( |
| 2629 | 'screen_reader_text' => __( 'Comments navigation' ), |
| 2630 | ) ); |
| 2631 | $args['echo'] = false; |
| 2632 | |
| 2633 | // Make sure we get plain links, so we get a string we can work with. |
| 2634 | $args['type'] = 'plain'; |
| 2635 | |
| 2636 | $links = paginate_comments_links( $args ); |
| 2637 | |
| 2638 | if ( $links ) { |
| 2639 | $navigation = _navigation_markup( $links, 'comments-pagination', $args['screen_reader_text'] ); |
| 2640 | } |
| 2641 | |
| 2642 | return $navigation; |
| 2643 | } |
| 2644 | |
| 2645 | /** |
| 2646 | * Display a paginated navigation to next/previous set of comments, |
| 2647 | * when applicable. |
| 2648 | * |
| 2649 | * @since 4.1.0 |
| 2650 | * |
| 2651 | * @param array $args See {@see get_the_comments_pagination()} for available arguments. |
| 2652 | */ |
| 2653 | function the_comments_pagination( $args = array() ) { |
| 2654 | echo get_the_comments_pagination( $args ); |
| 2655 | } |
| 2656 | |
| 2657 | /** |