Make WordPress Core

Changeset 53520


Ignore:
Timestamp:
06/18/2022 03:36:20 PM (21 months ago)
Author:
SergeyBiryukov
Message:

Docs: Consistently declare the $wp_query global in link template functions.

This ensures that the global is explicitly declared and documented in:

  • get_next_posts_link()
  • get_posts_nav_link()
  • get_the_posts_navigation()
  • get_the_posts_pagination()
  • get_next_comments_link()

Follow-up to [30065].

Props mt8.biz, sabernhardt.
Fixes #43164.

File:
1 edited

Legend:

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

    r53455 r53520  
    27662766 */
    27672767function get_the_posts_navigation( $args = array() ) {
     2768    global $wp_query;
     2769
    27682770    $navigation = '';
    27692771
    27702772    // Don't print empty markup if there's only one page.
    2771     if ( $GLOBALS['wp_query']->max_num_pages > 1 ) {
     2773    if ( $wp_query->max_num_pages > 1 ) {
    27722774        // Make sure the nav element has an aria-label attribute: fallback to the screen reader text.
    27732775        if ( ! empty( $args['screen_reader_text'] ) && empty( $args['aria_label'] ) ) {
     
    28222824 * @since 5.5.0 Added the `class` parameter.
    28232825 *
     2826 * @global WP_Query $wp_query WordPress Query object.
     2827 *
    28242828 * @param array $args {
    28252829 *     Optional. Default pagination arguments, see paginate_links().
     
    28332837 */
    28342838function get_the_posts_pagination( $args = array() ) {
     2839    global $wp_query;
     2840
    28352841    $navigation = '';
    28362842
    28372843    // Don't print empty markup if there's only one page.
    2838     if ( $GLOBALS['wp_query']->max_num_pages > 1 ) {
     2844    if ( $wp_query->max_num_pages > 1 ) {
    28392845        // Make sure the nav element has an aria-label attribute: fallback to the screen reader text.
    28402846        if ( ! empty( $args['screen_reader_text'] ) && empty( $args['aria_label'] ) ) {
Note: See TracChangeset for help on using the changeset viewer.