ACF_Admin_Taxonomy::save_post
Saves taxonomy data.
Method of the class: ACF_Admin_Taxonomy{}
No Hooks.
Returns
Int. $post_id
Usage
$ACF_Admin_Taxonomy = new ACF_Admin_Taxonomy(); $ACF_Admin_Taxonomy->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_Taxonomy::save_post() ACF Admin Taxonomy::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_taxonomy']['ID'] = $post_id;
$_POST['acf_taxonomy']['title'] = isset( $_POST['acf_taxonomy']['labels']['name'] ) ? $_POST['acf_taxonomy']['labels']['name'] : '';
if ( ! acf_get_setting( 'enable_meta_box_cb_edit' ) ) {
$_POST['acf_taxonomy']['meta_box_cb'] = '';
$_POST['acf_taxonomy']['meta_box_sanitize_cb'] = '';
if ( ! empty( $_POST['acf_taxonomy']['meta_box'] ) && 'custom' === $_POST['acf_taxonomy']['meta_box'] ) {
$_POST['acf_taxonomy']['meta_box'] = 'default';
}
$existing_post = acf_maybe_unserialize( $post->post_content );
if ( ! empty( $existing_post['meta_box'] ) ) {
$_POST['acf_taxonomy']['meta_box'] = $existing_post['meta_box'];
}
if ( ! empty( $existing_post['meta_box_cb'] ) ) {
$_POST['acf_taxonomy']['meta_box_cb'] = $existing_post['meta_box_cb'];
}
if ( ! empty( $existing_post['meta_box_sanitize_cb'] ) ) {
$_POST['acf_taxonomy']['meta_box_sanitize_cb'] = $existing_post['meta_box_sanitize_cb'];
}
}
// Save the taxonomy.
acf_update_internal_post_type( $_POST['acf_taxonomy'], $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;
}