ID, 'guest-author', true ); if ( $author ) $name = $author; return $name; } //shortocde for the plugin add_shortcode('advance_guest_post', 'agp_form_shortcode'); //shortocde function function agp_form_shortcode(){ $guestpost = get_option('guestpost'); if ($guestpost == 'disable') { if(!is_user_logged_in()){ include ('login.php'); return $out; } global $current_user; } else { } if(isset( $_POST['agp_upload_image_form_submitted'] ) && wp_verify_nonce($_POST['agp_upload_image_form_submitted'], 'agp_upload_image_form') ){ $result = agp_parse_file_errors($_FILES['agp_image_file'], $_POST['agp_image_caption'],$_POST['agp_image_content'],$_POST['agp_image_author'],$_POST['excerpt'],$_POST['tags']); if($result['error']){ echo'
ERROR: ' . $result['error'] . '
'; echo'' . $post_deleted . ' images(s) deleted!
'; } } } ob_start(); echo agp_get_upload_image_form($agp_image_caption = $_POST['agp_image_caption'], $category = $_POST['category'], $agp_image_content = $_POST['agp_image_content'], $agp_image_author = $_POST['agp_image_author']); $editor_contents = ob_get_clean(); // Return the content you want to the calling function return $editor_contents; } // wordpress image upload function function agp_process_image($file, $post_id, $caption){ require_once(ABSPATH . "wp-admin" . '/includes/image.php'); require_once(ABSPATH . "wp-admin" . '/includes/file.php'); require_once(ABSPATH . "wp-admin" . '/includes/media.php'); $attachment_id = media_handle_upload($file, $post_id); update_post_meta($post_id, '_thumbnail_id', $attachment_id); $attachment_data = array( 'ID' => $attachment_id, 'post_excerpt' => $caption ); wp_update_post($attachment_data); return $attachment_id; } //this is error when any filed are empty function agp_parse_file_errors($file = '', $image_caption, $image_content, $image_author){ if ( 'require' == $featurerequire ) { $result = array(); $result['error'] = 0; if($file['error']){ $result['error'] = "No file uploaded or there was an upload error!"; return $result; } else { } } $posttitleenabledisables = get_option('posttitleenabledisables'); $postdiscriptionenabledisable = get_option('postdiscriptionenabledisable'); $postauthorenabledisable = get_option('postauthorenabledisable'); $postcategoryenabledisable = get_option('postcategoryenabledisable'); $uploadimageenabledisable = get_option('uploadimageenabledisable'); $productshortdiscription = get_option('productshortdiscription'); $posttile = get_option('posttitle'); $postdiscription = get_option('postdiscription'); $postcategory= get_option('postcategory'); $uploadimage= get_option('uploadimage'); $producttags = get_option('producttags'); $postauthor = get_option('postauthor'); $postcategory= get_option('postcategory'); $uploadimage= get_option('uploadimage'); $titlerequire = get_option('titlerequire'); $discriptionrequire = get_option('discriptionrequire'); $categoryrequire = get_option('categoryrequire'); $featurerequire = get_option('featurerequire'); $tagsrequire = get_option('tagsrequire'); $expertrequire = get_option('expertrequire'); if ( 'require' == $titlerequire ) { $image_caption = trim(preg_replace('/[^a-zA-Z0-9\s]+/', ' ', $image_caption)); if($image_caption == ''){ $result['error'] = "Please enter ".$posttile.""; return $result; } } else { } if ( 'require' == $discriptionrequire ) { $image_content = trim(preg_replace('/[^a-zA-Z0-9\s]+/', ' ', $image_content)); if($image_content == ''){ $result['error'] = "please enter ".$postdiscription.""; return $result; } } else { } if ( 'require' == $categoryrequire ) { $category = $_POST['category']; if($category == ''){ $result['error'] = "please enter ".$postcategory.""; return $result; } } else { } if ( 'require' == $tagsrequire ) { $tags = $_POST['tags']; if($tags == ''){ $result['error'] = "please enter ".$producttags.""; return $result; } } else { } if ( 'require' == $expertrequire ) { $excerpt = $_POST['excerpt']; if($excerpt == ''){ $result['error'] = "please enter ".$productshortdiscription.""; return $result; } } else { } if ($postauthorenabledisable == 'disable') { } else { $image_author = trim(preg_replace('/[^a-zA-Z0-9\s]+/', ' ', $image_author)); if($image_author == ''){ $result['error'] = "Please enter ".$postauthor.""; return $result; } } $result['caption'] = $image_caption; $result['content'] = $image_content; $result['author'] = $image_author; for($i=0; $i