/** * Handles saving a custom post as well as its custom fields and metadata. * * @return void * @author Jared Lang **/ function _save_meta_data($post_id, $meta_box) { // verify nonce if (!wp_verify_nonce($_POST['meta_box_nonce'], basename(__FILE__))) { return $post_id; } // check autosave if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { return $post_id; } // check permissions if ('page' == $_POST['post_type']) { if (!current_user_can('edit_page', $post_id)) { return $post_id; } } elseif (!current_user_can('edit_post', $post_id)) { return $post_id; } foreach ($meta_box['fields'] as $field) { switch ($field['type']) { case 'file': save_file($post_id, $field); break; default: save_default($post_id, $field); break; } } }
/** * Handles saving a custom post as well as its custom fields and metadata. * * @return void * @author Jared Lang * */ function _save_meta_data($post_id, $meta_box) { // verify nonce if (!wp_verify_nonce($_POST['meta_box_nonce'], basename(__FILE__))) { return $post_id; } // check autosave if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE || defined('DOING_AJAX') && DOING_AJAX || isset($_REQUEST['bulk_edit'])) { return $post_id; } // check permissions if ('page' == $_POST['post_type']) { if (!current_user_can('edit_page', $post_id)) { return $post_id; } } elseif (!current_user_can('edit_post', $post_id)) { return $post_id; } foreach ($meta_box['fields'] as $field) { save_default($post_id, $field); } }