ACF_Admin_Post_type::save_postpublicACF 1.0.0

Saves post type data.

Method of the class: ACF_Admin_Post_type{}

No Hooks.

Returns

integer. $post_id

Usage

$ACF_Admin_Post_type = new ACF_Admin_Post_type();
$ACF_Admin_Post_type->save_post( $post_id, $post );
$post_id(int) (required)
The post ID.
$post(WP_Post) (required)
The post object.

Changelog

Since 1.0.0 Introduced.

ACF_Admin_Post_type::save_post() code ACF 6.8.8

public function save_post( $post_id, $post ) {
	if ( ! $this->verify_save_post( $post_id, $post ) ) {
		return $post_id;
	}

	// Disable filters to ensure ACF loads raw data from DB.
	acf_disable_filters();

	// phpcs:disable WordPress.Security.NonceVerification.Missing -- Validated in $this->verify_save_post() above.
	// phpcs:disable WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Sanitized when saved.
	$_POST['acf_post_type']['ID']    = $post_id;
	$_POST['acf_post_type']['title'] = isset( $_POST['acf_post_type']['labels']['name'] ) ? $_POST['acf_post_type']['labels']['name'] : '';

	if ( ! acf_get_setting( 'enable_meta_box_cb_edit' ) ) {
		$_POST['acf_post_type']['register_meta_box_cb'] = '';

		$existing_post = acf_maybe_unserialize( $post->post_content );
		if ( ! empty( $existing_post['register_meta_box_cb'] ) ) {
			$_POST['acf_post_type']['register_meta_box_cb'] = $existing_post['register_meta_box_cb'];
		}
	}

	// Save the post type.
	acf_update_internal_post_type( $_POST['acf_post_type'], $this->post_type ); // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Validated in verify_save_post
	// phpcs:enable WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
	// phpcs:enable WordPress.Security.NonceVerification.Missing

	return $post_id;
}