ACF_Form_Post::save_post
Triggers during the save_post to save the $_POST data.
Метод класса: ACF_Form_Post{}
Хуки из метода
Возвращает
integer.
Использование
$ACF_Form_Post = new ACF_Form_Post(); $ACF_Form_Post->save_post( $post_id, $post );
- $post_id(int) (обязательный)
- The post ID.
- $post(WP_Post) (обязательный)
- The post object.
Список изменений
| С версии 1.0.0 | Введена. |
Код ACF_Form_Post::save_post() ACF Form Post::save post ACF 6.8.8
public function save_post( $post_id, $post ) {
// Bail early if not allowed to save this post type.
if ( ! $this->allow_save_post( $post ) ) {
return $post_id;
}
/**
* Filters whether ACF_Form_Post::save_post() should bail without
* verifying the nonce or running acf_save_post(). Allows extensions
* to short-circuit the save when another handler is responsible for
* persisting field values for the current request.
*
* @since 6.8.1
*
* @param boolean $skip Whether to skip the save.
* @param integer $post_id The post ID being saved.
* @param WP_Post $post The post being saved.
*/
if ( apply_filters( 'acf/form-post/skip_save', false, $post_id, $post ) ) {
return $post_id;
}
// Verify nonce.
if ( ! acf_verify_nonce( 'post' ) ) {
return $post_id;
}
// Validate for published post (allow draft to save without validation).
if ( $post->post_status === 'publish' ) {
// Bail early if validation fails.
if ( ! acf_validate_save_post() ) {
return;
}
}
acf_save_post( $post_id );
// We handle revisions differently on WP 6.4+.
if ( version_compare( get_bloginfo( 'version' ), '6.4', '<' ) && post_type_supports( $post->post_type, 'revisions' ) ) {
acf_save_post_revision( $post_id );
}
return $post_id;
}