WP_REST_Font_Faces_Controller::get_parent_font_family_post
Get the parent font family, if the ID is valid.
Метод класса: WP_REST_Font_Faces_Controller{}
Хуков нет.
Возвращает
WP_Post|WP_Error. Post object if ID is valid, WP_Error otherwise.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->get_parent_font_family_post( $font_family_id );
- $font_family_id(int) (обязательный)
- Supplied ID.
Список изменений
| С версии 6.5.0 | Введена. |
Код WP_REST_Font_Faces_Controller::get_parent_font_family_post() WP REST Font Faces Controller::get parent font family post WP 7.0
protected function get_parent_font_family_post( $font_family_id ) {
$error = new WP_Error(
'rest_post_invalid_parent',
__( 'Invalid post parent ID.', 'default' ),
array( 'status' => 404 )
);
if ( (int) $font_family_id <= 0 ) {
return $error;
}
$font_family_post = get_post( (int) $font_family_id );
if ( empty( $font_family_post ) || empty( $font_family_post->ID )
|| 'wp_font_family' !== $font_family_post->post_type
) {
return $error;
}
return $font_family_post;
}