$fval){ if(is_array($fval)){ $update_data[$fkey] = array_map('advpsSanit',$fval); } else { $update_data[$fkey] = sanitize_text_field($fval); } } $update_data = serialize($update_data); //$q_upd = "update ".$wpdb->prefix."advps_optionset set opt_data = '".$update_data ."' where id =".$optID; $q_upd = $wpdb->prepare("update ".$wpdb->prefix."advps_optionset set opt_data = '%s' where id = %d",$update_data,$optID); if($wpdb->query($q_upd)){ $stsMgs = "Updated successfully."; } } elseif($_POST['advps_submit'] == 'Add'){ if ( !isset($_POST['advps_wpnonce']) || !wp_verify_nonce($_POST['advps_wpnonce'],'advps-checkauthnonce') ) { print 'Sorry, your nonce did not verify.'; exit; } $all_field = $_POST; $tem_list = array('one','two','three'); $template = sanitize_text_field($_POST['template']); if( ! in_array( $template, $tem_list )){ exit; } unset($all_field['template']); unset($all_field['advps_submit']); unset($all_field['advps_wpnonce']); unset($all_field['_wp_http_referer']); $postdata = array(); foreach($all_field as $fkey => $fval){ if(is_array($fval)){ $postdata[$fkey] = array_map('advpsSanit',$fval); } else { $postdata[$fkey] = sanitize_text_field($fval); } } $postdata = serialize($postdata); $q_add = $wpdb->prepare("insert into ".$wpdb->prefix."advps_optionset (template,opt_data) values(%s,%s)",$template,$postdata); if($wpdb->query($q_add)){ $stsMgs = "Added successfully."; } } } if(isset($_POST['advps_add_thumb'])){ if($_POST['advps_add_thumb'] == 'Add'){ if ( !isset($_POST['advps_wpnonce']) || !wp_verify_nonce($_POST['advps_wpnonce'],'advps-checkauthnonce') ) { print 'Sorry, your nonce did not verify.'; exit; } $thumb_name = sanitize_text_field($_POST['advps_thumb_name']); $width = sanitize_text_field($_POST['advps_thumb_width']); $height = sanitize_text_field($_POST['advps_thumb_height']); $crop = sanitize_text_field($_POST['advps_crop']); $q = $wpdb->prepare("insert into ".$wpdb->prefix."advps_thumbnail (thumb_name,width,height,crop) values(%s,%d,%d,%s)",$thumb_name,$width,$height,$crop); if($wpdb->query($q)){ $stsMgs = "Added successfully."; } } } if(isset($_POST['update_thumb'])){ if ( !isset($_POST['advps_wpnonce']) || !wp_verify_nonce($_POST['advps_wpnonce'],'advps-checkauthnonce') ) { print 'Sorry, your nonce did not verify.'; exit; } $thumb_id = sanitize_text_field($_POST['thumb_id']); $thumb_name = sanitize_text_field($_POST['advps_thumb_name']); $width = sanitize_text_field($_POST['advps_thumb_width']); $height = sanitize_text_field($_POST['advps_thumb_height']); $crop = sanitize_text_field($_POST['advps_crop']); $q = $wpdb->prepare("update ".$wpdb->prefix."advps_thumbnail set thumb_name = '%s',width = %d, height = %d, crop = '%s' where id = %d",$thumb_name,$width,$height,$crop,$thumb_id); if($wpdb->query($q)){ $stsMgs = "Updated successfully."; } } $q1 = "select id,opt_data from ".$wpdb->prefix."advps_optionset where template = 'one'"; $q2 = "select id,opt_data from ".$wpdb->prefix."advps_optionset where template = 'two'"; $q3 = "select id,opt_data from ".$wpdb->prefix."advps_optionset where template = 'three'"; $res1 = $wpdb->get_results($q1); $res2 = $wpdb->get_results($q2); $res3 = $wpdb->get_results($q3); $q_thumb = "select * from ".$wpdb->prefix."advps_thumbnail"; $res_thumb = $wpdb->get_results($q_thumb); $catList = get_categories(); $customPostTypes = get_post_types(array('public' => true, '_builtin' => false)); ?>