function save_wf_widget_metadata($post_id) { $post_type = get_post_type($post_id); if (!posttype_accepts_widgets($post_type)) { // v6.40 return; } if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { return $post_id; } if (!isset($_POST['post_title'])) { return; } if (!isset($_POST['list_of_deletes'])) { // v5.9 bail out if doing Quick Edit return; } $list_of_deletes = array_map('trim', explode("\n", $_POST['list_of_deletes'])); // trim appears to be necessary (to get rid of invisible "\r" perhaps?) $list_of_updates = array_map('trim', explode("\n", $_POST['list_of_updates'])); // Delete any customfields on the delete list if ($list_of_deletes[0] != '') { foreach ($list_of_deletes as $item_to_delete) { if (!in_array($item_to_delete, $list_of_updates)) { // no point in deleting it if it's going to be updated if (!delete_post_meta($post_id, $item_to_delete)) { // originally with trim //return new WP_Error('delete_cfield', __("Can't delete customfield: ".$item_to_delete)); echo "Can't delete customfield: " . $item_to_delete; } } } } // Update any customfields on the update list if ($list_of_updates[0] != '') { foreach ($list_of_updates as $item_to_update) { if (!update_post_meta($post_id, $item_to_update, $_POST[$item_to_update])) { //return new WP_Error('update_cfield', __("Problem updating customfield: ".$item_to_update)); //echo "Problem updating customfield: ".$item_to_update; // NB: returns false if value is unchanged - so can't check for genuine errors } } } }
function posttype_accepts_debugbox($postType) { // v6.52 return posttype_accepts_widgets($postType); }