$unique_id, 'product_desc'=>$product_desc, 'product_name'=>$product_name, 'item_id'=>$item_id, 'html'=>$html); $sql_data = array('%s','%s','%s'); $wpdb->insert( WPEJUNKIE_HTML_CODE_TABLE, $sql, $sql_data); return $wpdb->insert_id; } /********************************** ******* Update Item ***********************************/ //Updae the item function wpejunkie_item_update($unique_id){ global $wpdb; $product_name=esc_html($_REQUEST['product_name']); $product_desc=esc_html($_REQUEST['product_desc']); $item_id=esc_html($_REQUEST['item_id']); $html=esc_html($_REQUEST['html']); $wpdb->update(WPEJUNKIE_HTML_CODE_TABLE, array('product_name'=>$product_name, 'product_desc'=>$product_desc, 'html'=>$html), array( 'unique_id' => $unique_id ) ); return $unique_id; } /********************************** ******* Show Items Form ***********************************/ function wpejunkie_item_update_form($id = ''){ wp_tiny_mce( false , // true makes the editor "teeny" array( "editor_selector" => "theEditor"//This is the class name of your text field ) ); global $wpdb; $update_item = false; if ($_REQUEST['unique_id'] !='' || $id !=''){ $update_item = 'true'; $sql = "SELECT * FROM " . WPEJUNKIE_HTML_CODE_TABLE . " WHERE " . ($_REQUEST['unique_id'] == "" ? "id = '" . $id . "'" : "unique_id = '" . $_REQUEST['unique_id'] . "'"); $wpdb->query($sql); if ($wpdb->num_rows > 0 && $update_item = 'true') $items = $wpdb->get_results($sql); } ?>