ACF_Form_Post::allow_save_post() public ACF 5.3.8
Checks if the $post is allowed to be saved. Used to avoid triggering "acf/save_post" on dynamically created posts during save.
{} Это метод класса: ACF_Form_Post{}
Хуков нет.
Возвращает
true/false.
Использование
$ACF_Form_Post = new ACF_Form_Post(); $ACF_Form_Post->allow_save_post( $post );
- $post(WP_Post) (обязательный)
- The post to check.
Список изменений
С версии 5.3.8 | Введена. |
Код ACF_Form_Post::allow_save_post() ACF Form Post::allow save post ACF 5.9.1
function allow_save_post( $post ) {
// vars
$allow = true;
// restrict post types
$restrict = array( 'auto-draft', 'revision', 'acf-field', 'acf-field-group' );
if( in_array($post->post_type, $restrict) ) {
$allow = false;
}
// disallow if the $_POST ID value does not match the $post->ID
$form_post_id = (int) acf_maybe_get_POST('post_ID');
if( $form_post_id && $form_post_id !== $post->ID ) {
$allow = false;
}
// revision (preview)
if( $post->post_type == 'revision' ) {
// allow if doing preview and this $post is a child of the $_POST ID
if( acf_maybe_get_POST('wp-preview') == 'dopreview' && $form_post_id === $post->post_parent) {
$allow = true;
}
}
// return
return $allow;
}