WP_REST_Server::get_index() public WP 4.4.0
Retrieves the site index.
This endpoint describes the capabilities of the site.
{} Это метод класса: WP_REST_Server{}
Хуки из метода
Возвращает
WP_REST_Response. The API root index data.
Использование
$WP_REST_Server = new WP_REST_Server(); $WP_REST_Server->get_index( $request );
- $request(массив) (обязательный)
Request.
- context(строка)
Context.
- context(строка)
Список изменений
С версии 4.4.0 | Введена. |
Код WP_REST_Server::get_index() WP REST Server::get index WP 5.6.2
public function get_index( $request ) {
// General site data.
$available = array(
'name' => get_option( 'blogname' ),
'description' => get_option( 'blogdescription' ),
'url' => get_option( 'siteurl' ),
'home' => home_url(),
'gmt_offset' => get_option( 'gmt_offset' ),
'timezone_string' => get_option( 'timezone_string' ),
'namespaces' => array_keys( $this->namespaces ),
'authentication' => array(),
'routes' => $this->get_data_for_routes( $this->get_routes(), $request['context'] ),
);
$response = new WP_REST_Response( $available );
$response->add_link( 'help', 'http://v2.wp-api.org/' );
/**
* Filters the REST API root index data.
*
* This contains the data describing the API. This includes information
* about supported authentication schemes, supported namespaces, routes
* available on the API, and a small amount of data about the site.
*
* @since 4.4.0
*
* @param WP_REST_Response $response Response data.
*/
return apply_filters( 'rest_index', $response );
}