/** * Save post metadata when a post of {@see $this->post_type} is saved. * * @since 1.0.0 * * @param int $post_id The ID of the post. * @param WP_Post $post Post object * * @return void */ public function save_meta_boxes($post_id, $post) { if ($this->post_type !== $post->post_type) { return; } // If something wrong with nonce if (!array_key_exists($this->nonce_field, $_POST) || !wp_verify_nonce($_POST[$this->nonce_field], $this->nonce)) { return; } if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { return; } if (!current_user_can('edit_post', $post_id)) { return; } // Update price meta box if (array_key_exists($this->mb_price_name, $_POST)) { $meta_box_value = array_map(array('Appica_CPT_Pricings', 'sanitize_plans'), $_POST[$this->mb_price_name]); update_post_meta($post_id, $this->mb_price_name, $meta_box_value); unset($meta_box_value); } // Update button meta box if (array_key_exists($this->mb_button_name, $_POST)) { $meta_box_value = Appica_CPT_Pricings::sanitize_button($_POST[$this->mb_button_name]); update_post_meta($post_id, $this->mb_button_name, $meta_box_value); unset($meta_box_value); } // Update icon meta box if (array_key_exists($this->mb_icon_name, $_POST)) { $meta_box_value = sanitize_text_field($_POST[$this->mb_icon_name]); update_post_meta($post_id, $this->mb_icon_name, $meta_box_value); unset($meta_box_value); } }