ACF_Internal_Post_Type::get_post
Get an ACF CPT object as an array.
Метод класса: ACF_Internal_Post_Type{}
Хуки из метода
Возвращает
Массив|true|false. The main ACF array for the post, or false on failure.
Использование
$ACF_Internal_Post_Type = new ACF_Internal_Post_Type(); $ACF_Internal_Post_Type->get_post( $id );
- $id(int|WP_Post)
- The post ID being queried.
Список изменений
| С версии 6.1 | Введена. |
Код ACF_Internal_Post_Type::get_post() ACF Internal Post Type::get post ACF 6.4.2
public function get_post( $id = 0 ) {
// Allow WP_Post to be passed.
if ( is_object( $id ) ) {
$id = $id->ID;
}
// Check store.
$store = acf_get_store( $this->store );
if ( $store->has( $id ) ) {
return $store->get( $id );
}
if ( acf_is_local_internal_post_type( $id, $this->post_type ) ) {
$post = acf_get_local_internal_post_type( $id, $this->post_type );
} else {
$post = $this->get_raw_post( $id );
}
// Bail early if no post.
if ( ! $post ) {
return false;
}
$post = $this->validate_post( $post );
/**
* Filters the post array after it has been loaded.
*
* @date 12/02/2014
* @since 5.0.0
*
* @param array $post The post array.
*/
$post = apply_filters( "acf/load_{$this->hook_name}", $post );
// Store field group using aliases to also find via key, ID and name.
$store->set( $post['key'], $post );
$store->alias( $post['key'], $post['ID'] );
return $post;
}