WP_Comment_Query::parse_order()protectedWP 4.2.0

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

Method of the class: WP_Comment_Query{}

No Hooks.

Return

String. The sanitized 'order' query variable.

Usage

// protected - for code of main (parent) or child class
$result = $this->parse_order( $order );
$order(string) (required)
The 'order' query variable.

Changelog

Since 4.2.0 Introduced.

WP_Comment_Query::parse_order() code WP 6.4.3

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

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