WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

WP_REST_Server::get_namespace_index() WP 4.4.0

Retrieves the index for a namespace.

Это метод класса: WP_REST_Server

Хуки из метода
Возвращает

WP_REST_Response/WP_Error. WP_REST_Response instance if the index was found, WP_Error if the namespace isn't set.

Использование

$WP_REST_Server = new WP_REST_Server();
$var = $WP_REST_Server->get_namespace_index( $request );
$request(WP_REST_Request) (обязательный)
REST request instance.

Список изменений

С версии 4.4.0 Введена.

Код WP REST Server::get namespace index: wp-includes/rest-api/class-wp-rest-server.php WP 5.2.2

<?php
public function get_namespace_index( $request ) {
	$namespace = $request['namespace'];

	if ( ! isset( $this->namespaces[ $namespace ] ) ) {
		return new WP_Error( 'rest_invalid_namespace', __( 'The specified namespace could not be found.' ), array( 'status' => 404 ) );
	}

	$routes    = $this->namespaces[ $namespace ];
	$endpoints = array_intersect_key( $this->get_routes(), $routes );

	$data     = array(
		'namespace' => $namespace,
		'routes'    => $this->get_data_for_routes( $endpoints, $request['context'] ),
	);
	$response = rest_ensure_response( $data );

	// Link to the root index.
	$response->add_link( 'up', rest_url( '/' ) );

	/**
	 * Filters the namespace index data.
	 *
	 * This typically is just the route data for the namespace, but you can
	 * add any data you'd like here.
	 *
	 * @since 4.4.0
	 *
	 * @param WP_REST_Response $response Response data.
	 * @param WP_REST_Request  $request  Request data. The namespace is passed as the 'namespace' parameter.
	 */
	return apply_filters( 'rest_namespace_index', $response, $request );
}