WP_REST_Global_Styles_Controller::get_post
Get the post, if the ID is valid.
Метод класса: WP_REST_Global_Styles_Controller{}
Хуков нет.
Возвращает
WP_Post|WP_Error. Post object if ID is valid, WP_Error otherwise.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->get_post( $id );
- $id(int) (обязательный)
- Supplied ID.
Список изменений
| С версии 5.9.0 | Введена. |
Код WP_REST_Global_Styles_Controller::get_post() WP REST Global Styles Controller::get post WP 7.1
protected function get_post( $id ) {
$error = new WP_Error(
'rest_global_styles_not_found',
__( 'No global styles config exists with that ID.' ),
array( 'status' => 404 )
);
$id = (int) $id;
if ( $id <= 0 ) {
return $error;
}
$post = get_post( $id );
if ( empty( $post ) || empty( $post->ID ) || $this->post_type !== $post->post_type ) {
return $error;
}
return $post;
}