ACF_Internal_Post_Type::update_post_active_status
Activates or deactivates an ACF post.
Метод класса: ACF_Internal_Post_Type{}
Хуки из метода
Возвращает
true|false.
Использование
$ACF_Internal_Post_Type = new ACF_Internal_Post_Type(); $ACF_Internal_Post_Type->update_post_active_status( $id, $activate );
- $id(int|строка) (обязательный)
- The ID of the ACF post to activate/deactivate.
- $activate(true|false)
- True if the post should be activated.
По умолчанию:true
Список изменений
| С версии 6.1 | Введена. |
Код ACF_Internal_Post_Type::update_post_active_status() ACF Internal Post Type::update post active status ACF 6.4.2
public function update_post_active_status( $id, $activate = true ) {
// Disable filters to ensure ACF loads data from DB.
acf_disable_filters();
$post = $this->get_post( $id );
if ( ! $post || ! $post['ID'] ) {
return false;
}
$post['active'] = (bool) $activate;
$updated_post = $this->update_post( $post );
/**
* Fires immediately after an ACF post has been made active/inactive.
*
* @since 6.0.0
*
* @param array $updated_post The updated ACF post array.
*/
do_action( "acf/update_{$this->hook_name}_active_status", $updated_post );
if ( ! isset( $updated_post['active'] ) || $activate !== $updated_post['active'] ) {
return false;
}
return true;
}