'.__('Please enter video URL\'s.',"mu").'

'; else { $youTubeURLS = array_filter(explode("\n",$_REQUEST['videoURLs'])); foreach($youTubeURLS as $yt){ $vedioID = getVideoID($yt); if(checkYoutubeId($vedioID) == 1){ $xml = getVideoDetails($vedioID); if($xml->title != 'YouTube Videos') { // load up the array $videoDetails[$i]['videoURL'] = $yt; $videoDetails[$i]['title'] = $xml->title; $videoDetails[$i]['description'] = $xml->content; $videoDetails[$i++]['thumbnail'] = "http://i.ytimg.com/vi/".$vedioID."/0.jpg"; } } } } if(empty($videoDetails) && !empty($_REQUEST['videoURLs'])) echo '

'.__('Please enter valid video URL\'s.',"mu").'

'; } if(isset($_REQUEST['submitPostData']) && $_REQUEST['submitPostData'] ){ $totalCount = count($_REQUEST['muTitle']); $postCount = 0; for($i=1;$i<=$totalCount;$i++){ if(@in_array($i,$_REQUEST['muCheckBox'])){ $postTitle = trim($_REQUEST['muTitle'][$i]); $youTubeURL = trim($_REQUEST['muVideoURL'][$i]); $postDescription = trim($_REQUEST['description'][$i]); $postContent = $postDescription; $postTags = $_REQUEST['muTags'][$i]; $postCategories = @implode(',',$_REQUEST['mucategories'][$i]); $postThumbnail = $_REQUEST['muThumbnail'][$i]; $post = array( 'post_title' => wp_strip_all_tags($postTitle), 'post_content' => $postContent, 'post_category' => @explode(',',$postCategories), 'tags_input' => $postTags, 'post_status' => 'publish', 'post_author' => 1, 'post_type' => 'post' ); $post_id = wp_insert_post($post); $postCount++; $imageurl = $postThumbnail; $imageurl = stripslashes($imageurl); $uploads = wp_upload_dir(); $filename = wp_unique_filename( $uploads['path'], basename($imageurl), $unique_filename_callback = null ); $wp_filetype = wp_check_filetype($filename, null ); $fullpathfilename = $uploads['path'] . "/" . $filename; try { if ( !substr_count($wp_filetype['type'], "image") ) { throw new Exception( basename($imageurl) . ' is not a valid image. ' . $wp_filetype['type'] . '' ); } $image_string = fetch_image($imageurl); $fileSaved = file_put_contents($uploads['path'] . "/" . $filename, $image_string); if ( !$fileSaved ) { throw new Exception("The file cannot be saved."); } $attachment = array( 'post_mime_type' => $wp_filetype['type'], 'post_title' => preg_replace('/\.[^.]+$/', '', $filename), 'post_content' => '', 'post_status' => 'inherit', 'guid' => $uploads['url'] . "/" . $filename ); $attach_id = wp_insert_attachment( $attachment, $fullpathfilename, $post_id ); if ( !$attach_id ) { throw new Exception("Failed to save record into database."); } require_once(ABSPATH . "wp-admin" . '/includes/image.php'); $attach_data = wp_generate_attachment_metadata( $attach_id, $fullpathfilename ); wp_update_attachment_metadata( $attach_id, $attach_data ); update_post_meta($post_id,'_thumbnail_id',$attach_id); } catch (Exception $e) { $error = '

' . $e->getMessage() . '

'; } } } if($postCount > 0) echo '

'.__('Post(s) Added Successfully.',"mu").'

'; ?>

Paste youtube url's here (Each url in different line)

" name="submitYouTubeURLS" />

>

" name="submitPostData" />