function handle_meta_box_update() { global $wpdb; $table_name = $wpdb->prefix . TZELAN_TBL; $titles = $_REQUEST['metabox_title']; $text = $_REQUEST['metabox_text']; $metaboxid = $_REQUEST['metabox_id']; delete_metabox($metaboxid); foreach ($titles as $key => $title) { if (!empty($title)) { $wpdb->insert($table_name, array('metaboxid' => $metaboxid, 'title' => $title, 'content' => $text[$key])); } } $current_url = $_SERVER["REQUEST_URI"]; $redir_url = add_query_arg(array('updated' => '1'), $current_url); header("Location: " . $redir_url); }
function process_bulk_action() { //Detect when a bulk action is being triggered... if ('delete' === $this->current_action()) { // In our file that handles the request, verify the nonce. $nonce = esc_attr($_REQUEST['_wpnonce']); if (!wp_verify_nonce($nonce, 'tzelan_metabox')) { die('Go get a life script kiddies'); } else { delete_metabox(absint($_GET['metabox'])); wp_redirect(esc_url(add_query_arg())); exit; } } // If the delete bulk action is triggered if (isset($_POST['action']) && $_POST['action'] == 'bulk-delete' || isset($_POST['action2']) && $_POST['action2'] == 'bulk-delete') { $delete_ids = esc_sql($_POST['bulk-delete']); // loop over the array of record IDs and delete them foreach ($delete_ids as $id) { delete_metabox($id); } wp_redirect(esc_url(add_query_arg())); exit; } }