Plugin Directory

Changeset 2960317


Ignore:
Timestamp:
08/29/2023 11:49:20 PM (2 years ago)
Author:
parselearn
Message:

Fix warning when not set orderby for comment query

Location:
meta-optimizer
Files:
3 added
1 edited

Legend:

Unmodified
Added
Removed
  • meta-optimizer/trunk/inc/CommentQueries.php

    r2960316 r2960317  
    4040
    4141        // Change OrderBy
    42         $order = ( 'ASC' === strtoupper( $this->Queries->queryVars['order'] ) ) ? 'ASC' : 'DESC';
     42        $order = isset( $this->Queries->queryVars['order'] ) && ( 'ASC' === strtoupper( $this->Queries->queryVars['order'] ) ) ? 'ASC' : 'DESC';
    4343
    4444        // Disable ORDER BY with 'none', an empty array, or boolean false.
    45         if ( in_array( $this->Queries->queryVars['orderby'], array( 'none', array(), false ), true ) ) {
     45        if ( ! isset( $this->Queries->queryVars['orderby'] ) ||
     46             in_array( $this->Queries->queryVars['orderby'], array( 'none', array(), false ), true ) ) {
    4647            $orderby = '';
    4748        } elseif ( ! empty( $this->Queries->queryVars['orderby'] ) ) {
     
    139140     *
    140141     * @return string|false Value to use in the ORDER clause. False otherwise.
    141      * @global \wpdb  $wpdb    WordPress database abstraction object.
     142     * @global \wpdb $wpdb    WordPress database abstraction object.
    142143     *
    143144     * @copyright Base on WP_Comment_Query: parse_orderby method.
Note: See TracChangeset for help on using the changeset viewer.