Normal save method to save all the fields in a metabox
Metabox and User Meta rely on this method
public save ( $object_id, $values ) |
/** * Hooks into the save hook for the user meta * * @author Gijs Jorissen * @since 1.5 * */ function save_user($user_id) { // Verify nonce if (!(isset($_POST['cuztom_nonce']) && wp_verify_nonce($_POST['cuztom_nonce'], 'cuztom_meta'))) { return; } $values = isset($_POST['cuztom']) ? $_POST['cuztom'] : array(); if (!empty($values)) { parent::save($user_id, $values); } }
/** * Hooks into the save hook for the newly registered Post Type * * @author Gijs Jorissen * @since 0.1 * */ function save_post($post_id) { // Deny the wordpress autosave function if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE || defined('DOING_AJAX') && DOING_AJAX) { return; } // Verify nonce if (!(isset($_POST['cuztom_nonce']) && wp_verify_nonce($_POST['cuztom_nonce'], 'cuztom_meta'))) { return; } // Is the post from the given post type? if (!in_array(get_post_type($post_id), array_merge($this->post_types, array('revision')))) { return; } // Is the current user capable to edit this post foreach ($this->post_types as $post_type) { if (!current_user_can(get_post_type_object($post_type)->cap->edit_post, $post_id)) { return; } } $values = isset($_POST['cuztom']) ? $_POST['cuztom'] : array(); if (!empty($values)) { parent::save($post_id, $values); } }