Make WordPress Core

Changeset 53142


Ignore:
Timestamp:
04/11/2022 04:33:51 PM (3 years ago)
Author:
gziolo
Message:

Editor: Update build_comment_query_vars_from_block from Gutenberg

Follow-up for [53138].
See #55505.

File:
1 edited

Legend:

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

    r53138 r53142  
    13931393    }
    13941394
    1395     $per_page     = get_option( 'comments_per_page' );
    1396     $default_page = get_option( 'default_comments_page' );
    1397 
    1398     if ( $per_page > 0 ) {
    1399         $comment_args['number'] = $per_page;
    1400 
    1401         $page = (int) get_query_var( 'cpage' );
    1402         if ( $page ) {
    1403             $comment_args['paged'] = $page;
    1404         } elseif ( 'oldest' === $default_page ) {
    1405             $comment_args['paged'] = 1;
    1406         } elseif ( 'newest' === $default_page ) {
    1407             $comment_args['paged'] = (int) ( new WP_Comment_Query( $comment_args ) )->max_num_pages;
    1408         }
    1409         // Set the `cpage` query var to ensure the previous and next pagination links are correct
    1410         // when inheriting the Discussion Settings.
    1411         if ( 0 === $page && isset( $comment_args['paged'] ) && $comment_args['paged'] > 0 ) {
    1412             set_query_var( 'cpage', $comment_args['paged'] );
     1395    if ( get_option( 'page_comments' ) === '1' || get_option( 'page_comments' ) === true ) {
     1396        $per_page     = get_option( 'comments_per_page' );
     1397        $default_page = get_option( 'default_comments_page' );
     1398        if ( $per_page > 0 ) {
     1399            $comment_args['number'] = $per_page;
     1400
     1401            $page = (int) get_query_var( 'cpage' );
     1402            if ( $page ) {
     1403                $comment_args['paged'] = $page;
     1404            } elseif ( 'oldest' === $default_page ) {
     1405                $comment_args['paged'] = 1;
     1406            } elseif ( 'newest' === $default_page ) {
     1407                $comment_args['paged'] = (int) ( new WP_Comment_Query( $comment_args ) )->max_num_pages;
     1408            }
     1409            // Set the `cpage` query var to ensure the previous and next pagination links are correct
     1410            // when inheriting the Discussion Settings.
     1411            if ( 0 === $page && isset( $comment_args['paged'] ) && $comment_args['paged'] > 0 ) {
     1412                set_query_var( 'cpage', $comment_args['paged'] );
     1413            }
    14131414        }
    14141415    }
Note: See TracChangeset for help on using the changeset viewer.