WP_REST_Comments_Controller::normalize_query_param() WordPress Method

The normalize_query_param() method is used to normalize a query parameter for a comments request. This is used to set up the query for comments retrieval.

WP_REST_Comments_Controller::normalize_query_param( string $query_param ) #

Prepends internal property prefix to query parameters to match our response fields.


Parameters

$query_param

(string)(Required)Query parameter.


Top ↑

Return

(string) The normalized query parameter.


Top ↑

Source

File: wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php

	protected function normalize_query_param( $query_param ) {
		$prefix = 'comment_';

		switch ( $query_param ) {
			case 'id':
				$normalized = $prefix . 'ID';
				break;
			case 'post':
				$normalized = $prefix . 'post_ID';
				break;
			case 'parent':
				$normalized = $prefix . 'parent';
				break;
			case 'include':
				$normalized = 'comment__in';
				break;
			default:
				$normalized = $prefix . $query_param;
				break;
		}

		return $normalized;
	}


Top ↑

Changelog

Changelog
VersionDescription
4.7.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.