WP_REST_Themes_Controller::get_items() public WP 5.0.0
Retrieves a collection of themes.
{} Это метод класса: WP_REST_Themes_Controller{}
Хуков нет.
Возвращает
WP_REST_Response/WP_Error
. Response object on success, or WP_Error object on failure.
Использование
$WP_REST_Themes_Controller = new WP_REST_Themes_Controller(); $WP_REST_Themes_Controller->get_items( $request );
- $request(WP_REST_Request) (обязательный)
- Full details about the request.
Список изменений
С версии 5.0.0 | Введена. |
Код WP_REST_Themes_Controller::get_items() WP REST Themes Controller::get items WP 5.7
public function get_items( $request ) {
$themes = array();
$active_themes = wp_get_themes();
$current_theme = wp_get_theme();
$status = $request['status'];
foreach ( $active_themes as $theme_name => $theme ) {
$theme_status = ( $this->is_same_theme( $theme, $current_theme ) ) ? 'active' : 'inactive';
if ( is_array( $status ) && ! in_array( $theme_status, $status, true ) ) {
continue;
}
$prepared = $this->prepare_item_for_response( $theme, $request );
$themes[] = $this->prepare_response_for_collection( $prepared );
}
$response = rest_ensure_response( $themes );
$response->header( 'X-WP-Total', count( $themes ) );
$response->header( 'X-WP-TotalPages', 1 );
return $response;
}