WP_Comment_Query::parse_order( string $order )

Parse an ‘order’ query variable and cast it to ASC or DESC as necessary.

Parameters

$order

(string) (Required) The 'order' query variable.

Return

(string) The sanitized 'order' query variable.

Source

File: wp-includes/class-wp-comment-query.php

protected function parse_order( $order ) {
		if ( ! is_string( $order ) || empty( $order ) ) {
			return 'DESC';
		}

		if ( 'ASC' === strtoupper( $order ) ) {
			return 'ASC';
		} else {
			return 'DESC';
		}
	}

Changelog

Version Description
4.2.0 Introduced.

© 2003–2021 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_comment_query/parse_order