Changeset 917335
- Timestamp:
- 05/19/2014 06:23:00 PM (12 years ago)
- Location:
- smartpost-templates/trunk
- Files:
-
- 9 edited
-
components/attachments/ajax/sp_postAttachmentsAJAX.php (modified) (7 diffs)
-
components/attachments/sp_postAttachments.php (modified) (1 diff)
-
components/video/ajax/sp_postVideoAJAX.php (modified) (5 diffs)
-
components/video/html5video.php (modified) (2 diffs)
-
components/video/js/sp_postVideo.js (modified) (2 diffs)
-
components/video/sp_postVideo.php (modified) (8 diffs)
-
readme.txt (modified) (2 diffs)
-
smartpost.php (modified) (1 diff)
-
sp_uninstall.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
smartpost-templates/trunk/components/attachments/ajax/sp_postAttachmentsAJAX.php
r914746 r917335 1 1 <?php 2 /* 2 /** 3 3 * AJAX-Related functions for all 4 4 * sp_postAttachments components. Functions are used … … 7 7 8 8 if (!class_exists("sp_postAttachmentsAJAX")) { 9 class sp_postAttachmentsAJAX{10 11 static function init(){12 add_action('wp_ajax_saveAttachmentsDescAJAX', array('sp_postAttachmentsAJAX', 'saveAttachmentsDescAJAX')); 13 add_action('wp_ajax_attachmentsUploadAJAX', array('sp_postAttachmentsAJAX', 'attachmentsUploadAJAX'));14 add_action('wp_ajax_attachmentsDeleteAttachmentAJAX', array('sp_postAttachmentsAJAX', 'attachmentsDeleteAttachmentAJAX')); 15 }16 17 function saveAttachmentsDescAJAX(){9 class sp_postAttachmentsAJAX{ 10 11 static function init(){ 12 add_action('wp_ajax_saveAttachmentsDescAJAX', array('sp_postAttachmentsAJAX', 'saveAttachmentsDescAJAX')); 13 add_action('wp_ajax_attachmentsUploadAJAX', array('sp_postAttachmentsAJAX', 'attachmentsUploadAJAX')); 14 add_action('wp_ajax_attachmentsDeleteAttachmentAJAX', array('sp_postAttachmentsAJAX', 'attachmentsDeleteAttachmentAJAX')); 15 } 16 17 function saveAttachmentsDescAJAX(){ 18 18 19 19 $nonce = $_POST['nonce']; … … 49 49 } 50 50 exit; 51 } 52 53 static function attachmentsDeleteAttachmentAJAX(){ 51 } 52 53 /** 54 * Deletes an attachment component 55 */ 56 static function attachmentsDeleteAttachmentAJAX(){ 54 57 $nonce = $_POST['nonce']; 55 58 if( !wp_verify_nonce($nonce, 'sp_nonce') ){ … … 57 60 die('Security Check'); 58 61 } 59 62 60 63 if(!class_exists('sp_postAttachments')){ 61 64 header("HTTP/1.0 409 Could not instantiate sp_postAttachments class."); … … 72 75 exit; 73 76 } 74 77 75 78 $id = (int) $_POST['attachmentID']; 76 79 $compID = (int) $_POST['compID']; … … 102 105 echo json_encode( array('sucess' => true) ); 103 106 exit; 104 }107 } 105 108 106 109 /** … … 182 185 } 183 186 exit; 184 }185 }187 } 188 } 186 189 } -
smartpost-templates/trunk/components/attachments/sp_postAttachments.php
r914746 r917335 37 37 */ 38 38 static function init(){ 39 require_once( dirname( __FILE__ ) . '/ajax/sp_postAttachmentsAJAX.php');39 require_once( dirname(__FILE__) . '/ajax/sp_postAttachmentsAJAX.php' ); 40 40 sp_postAttachmentsAJAX::init(); 41 41 self::enqueueCSS(); -
smartpost-templates/trunk/components/video/ajax/sp_postVideoAJAX.php
r914770 r917335 73 73 $compID = (int) $_POST['compID']; 74 74 $videoComponent = new sp_postVideo($compID); 75 if( $videoComponent->beingConverted ){ 75 76 // Check to if video conversion is over 77 if( !$videoComponent->beingConverted ){ 78 79 $video_info = $videoComponent->videoAttachmentIDs; 80 if( empty( $video_info ) ){ 81 header("HTTP/1.0 409 Could find uploaded video!"); 82 exit; 83 } 84 85 if( file_exists( $video_info['encoded_video'] ) ){ 86 echo json_encode( array( 'converted' => true ) ); 87 } 88 }else{ 76 89 echo json_encode( array( 'converted' => false ) ); 77 }else{78 echo json_encode( array( 'converted' => true ) );79 90 } 80 91 exit; … … 83 94 /** 84 95 * Handles video uploads using chunking. 85 * @todo Do the conversion to mp4 and get rid of the original mov (?)86 96 */ 87 97 static function videoUploadAJAX(){ … … 107 117 } 108 118 109 $ videoFilePath= sp_core::chunked_plupload( "sp_videoUpload" );119 $uploaded_video = sp_core::chunked_plupload( "sp_videoUpload" ); 110 120 111 if( file_exists( $ videoFilePath) ){121 if( file_exists( $uploaded_video ) ){ 112 122 113 123 $compID = (int) $_POST['compID']; … … 124 134 } 125 135 136 $sp_ffmpeg_path = get_site_option('sp_ffmpeg_path'); 126 137 $html5_encoding = (bool) get_site_option( 'sp_html5_encoding' ); 127 $sp_ffmpeg_path = get_site_option( 'sp_ffmpeg_path' );128 138 129 139 if( $html5_encoding && !is_wp_error( $sp_ffmpeg_path ) ){ 140 global $wpdb; 141 $script_path = dirname(dirname(__FILE__)) . '/html5video.php'; 130 142 131 143 $videoComponent->beingConverted = true; 144 $videoComponent->videoAttachmentIDs['uploaded_video'] = $uploaded_video; 132 145 $videoComponent->update(); 133 146 134 $script_path = dirname(dirname(__FILE__)) . '/html5video.php'; 147 $script_args = array( 148 'DB_NAME' => DB_NAME, 149 'DB_USER' => DB_USER, 150 'DB_HOST' => DB_HOST, 151 'DB_PASS' => DB_PASSWORD, 152 'WP_DB_PREFIX' => $wpdb->prefix, 153 'VID_FILE' => $uploaded_video, 154 'COMP_ID' => $compID, 155 'WIDTH' => get_site_option('sp_player_width'), 156 'HEIGHT' => get_site_option('sp_player_height'), 157 'FFMPEG_PATH' => $sp_ffmpeg_path 158 ); 135 159 136 $script_args = array(137 'BASE_PATH' => ABSPATH,138 'POST_ID' => $postID,139 'VID_FILE' => $videoFilePath,140 'COMP_ID' => $compID,141 'AUTH_ID' => get_current_user_id(),142 'WIDTH' => get_site_option('sp_player_width'),143 'HEIGHT' => get_site_option('sp_player_height'),144 'HTTP_HOST' => $_SERVER['HTTP_HOST'],145 'BLOG_ID' => get_current_blog_id(),146 'IS_WPMU' => is_multisite()147 );148 160 149 161 if(DEBUG_SP_VIDEO){ … … 158 170 159 171 // Check to see that it's mp4 format 160 $ext = pathinfo($ videoFilePath, PATHINFO_EXTENSION);172 $ext = pathinfo($uploaded_video, PATHINFO_EXTENSION); 161 173 if( $ext !== 'mp4' ){ 162 unlink($ videoFilePath);174 unlink($uploaded_video); 163 175 header( "HTTP/1.0 409 Error: only mp4 files are allowed to be uploaded when HTML5 encoding is not enabled!" ); 164 176 exit; 165 177 }else{ 166 178 // Create the attachment 167 $videoComponent->videoAttachmentIDs['mp4'] = sp_core::create_attachment( $ videoFilePath, $postID, '', get_current_user_id() );179 $videoComponent->videoAttachmentIDs['mp4'] = sp_core::create_attachment( $uploaded_video, $postID, '', get_current_user_id() ); 168 180 $videoComponent->update(); 169 181 } 170 171 182 } 172 183 echo $videoComponent->renderPlayer(); 173 184 174 }else if( $ videoFilePath !== false && !file_exists( $videoFilePath) ){185 }else if( $uploaded_video !== false && !file_exists( $uploaded_video ) ){ 175 186 header( "HTTP/1.0 409 There was an error with uploading the video. The video file could not be found." ); 176 187 } -
smartpost-templates/trunk/components/video/html5video.php
r914746 r917335 1 1 <?php 2 2 /** 3 * User: ryagudin4 * Date: 8/14/135 * Time: 1:17 PM6 3 * Converts a video file to .webm and .mp4 formats using ffmpeg. 4 * Assumes that the server can use exec() 7 5 */ 8 6 9 // Collect video info arguments 10 $ARGS = array( 11 'BASE_PATH' => $argv[1], // Base directory of WordPress 12 'POST_ID' => $argv[2], // The post ID of where the video was uploaded 13 'VID_FILE' => $argv[3], // Path of the file to be converted 14 'COMP_ID' => $argv[4], // The SmartPost component ID 15 'AUTH_ID' => $argv[5], // The author ID 16 'WIDTH' => $argv[6], // scaled video width 17 'HEIGHT' => $argv[7] // scaled video height 18 ); 7 // Collect args 8 define( 'DB_NAME', $argv[1] ); 9 define( 'DB_USER', $argv[2] ); 10 define( 'DB_HOST', $argv[3] ); 11 define( 'DB_PASS', $argv[4] ); 12 define( 'WP_DB_PREFIX', $argv[5] ); 13 define( 'VID_FILE', $argv[6] ); 14 define( 'COMP_ID', $argv[7] ); 15 define( 'WIDTH', $argv[8] ); 16 define( 'HEIGHT', $argv[9] ); 17 define( 'FFMPEG_PATH', $argv[10] ); 19 18 20 // Collect info on wpmu 21 $WPMU_ARGS = array( 22 'HTTP_HOST' => $argv[8], 23 'BLOG_ID' => $argv[9], 24 'IS_WPMU' => $argv[10] 25 ); 19 $errors = array(); 20 $video_file_info = pathinfo( VID_FILE ); 21 $video_encoded_name = $video_file_info['dirname'] . DIRECTORY_SEPARATOR . $video_file_info['filename'] . '_encoded'; 26 22 27 // If this is a WPMU instance, switch to the blog we're on 28 if( !empty( $WPMU_ARGS['IS_WPMU'] ) ){ 29 30 $_SERVER['HTTP_HOST'] = $WPMU_ARGS['HTTP_HOST']; 31 ini_set('display_errors', true); 32 define( 'BASE_PATH', $ARGS['BASE_PATH'] ); 33 global $wp, $wp_query, $wp_the_query, $wp_rewrite, $wp_did_header; 34 require( BASE_PATH . 'wp-load.php' ); 35 switch_to_blog( $WPMU_ARGS['BLOG_ID'] ); 36 37 } else { 38 require_once( $ARGS['BASE_PATH'] . 'wp-load.php' ); 39 } 40 41 // Get full ffmpeg path 42 $sp_ffmpeg_path = get_site_option('sp_ffmpeg_path'); 43 44 // Check that everything is in order before we start converting.. 45 if( $ARGS['VID_FILE'] && $ARGS['POST_ID'] && !is_wp_error( $sp_ffmpeg_path ) ){ 46 47 $file_info = pathinfo( $ARGS['VID_FILE'] ); 48 $name = $file_info['filename']; 49 $path = dirname( $ARGS['VID_FILE'] ); 50 51 $filename = $path . DIRECTORY_SEPARATOR . $name; 52 $filename_encoded = $path . DIRECTORY_SEPARATOR . $name . '_encoded'; 53 54 if(DEBUG_SP_VIDEO){ 55 echo 'ABSPATH: ' . $base_path . PHP_EOL; 56 echo 'name: ' . $name . PHP_EOL; 57 echo 'path: ' . $path . PHP_EOL; 58 echo 'filename: ' . $filename . PHP_EOL; 59 echo 'postID: ' . $ARGS['POST_ID'] . PHP_EOL; 60 echo 'compID: ' . $ARGS['COMP_ID'] . PHP_EOL; 61 } 62 63 $mp4_filename = $filename . '.mp4'; 64 $mp4_filename_encoded = $filename_encoded . '.mp4'; 65 $png_filename = $filename . '.png'; 66 $content = $filename; 67 68 $videoComponent = new sp_postVideo( $ARGS['COMP_ID'] ); 69 70 if( is_wp_error($videoComponent->errors) ){ 71 echo 'Could not instantiate sp_postVideo with component ID: ' . $ARGS['COMP_ID'] . ', ' . $videoComponent->errors->get_error_message(); 72 exit(); 73 } 74 75 /** 76 * Get the correct orientation of the quick time video if it exists 77 * @todo Check if ffprobe and grep are callable on the operating system 78 */ 79 $rotation = exec( $sp_ffmpeg_path . 'ffprobe -v quiet -show_streams ' . $ARGS['VID_FILE'] . ' | grep -o "rotate=[-]\?[0-9]\+" | grep -o "[-]\?[0-9]\+"' ); 23 /** 24 * Get the correct orientation of the quick time video if it exists 25 */ 26 $ffprobe_cmd = FFMPEG_PATH . 'ffprobe -v quiet -show_streams ' . VID_FILE . ' | grep -o "rotate=[-]\?[0-9]\+" | grep -o "[-]\?[0-9]\+"'; 27 $rotation = exec( $ffprobe_cmd, $ffprobe_output, $ffprobe_result ); 28 if( $result !== 0 ){ 29 $ffprobe_error = 'ffprobe exited with an error: ' . print_r($ffprobe_output, true) . PHP_EOL; 30 echo $ffprobe_error; 31 }else{ 80 32 $rotationFilter = ''; 81 if( !empty( $rotation) ){33 if( !empty( $rotation ) ){ 82 34 switch( $rotation ){ 83 35 case '-270': … … 104 56 } 105 57 } 58 } 106 59 107 /** 108 * -q:v - Use video quality 2 (where 0 is equivalent to input video, and 31 is worst quality). 109 * -vf - Scaling and padding for videos that are not in 16:9 ratios 110 * -y - automatically overwrite files 111 * -metadata:s:v:0 rotate=0 - Makes sure iOS/Mac devices don't unnecessarily rotate the video 112 */ 113 $filter = '"' . $rotationFilter . 'scale=iw*min(' . $ARGS['WIDTH'] . '/iw\,' . $ARGS['HEIGHT'] . '/ih):ih*min(' . $ARGS['WIDTH'] . '/iw\,' . $ARGS['HEIGHT'] . '/ih), pad=' . $ARGS['WIDTH'] . ':' . $ARGS['HEIGHT'] . ':(' . $ARGS['WIDTH'] . '-iw*min(' . $ARGS['WIDTH'] . '/iw\,' . $ARGS['HEIGHT'] . '/ih))/2:(' . $ARGS['HEIGHT'] . '-ih*min(' . $ARGS['WIDTH'] . '/iw\,' . $ARGS['HEIGHT'] . '/ih))/2"'; 114 system( $sp_ffmpeg_path . 'ffmpeg -i ' . $ARGS['VID_FILE'] . ' -qscale 2 -filter:v ' . $filter . ' -metadata:s:v:0 rotate=0 ' . $filename_encoded . '.mp4' ); // .mp4 conversion 115 $uploads = wp_upload_dir(); 60 /** 61 * -q:v - Use video quality 2 (where 0 is equivalent to input video, and 31 is worst quality). 62 * -vf - Scaling and padding for videos that are not in 16:9 ratios 63 * -y - automatically overwrite files 64 * -metadata:s:v:0 rotate=0 - Makes sure iOS/Mac devices don't unnecessarily rotate the video 65 */ 66 $filter = '"' . $rotationFilter . 'scale=iw*min(' . WIDTH . '/iw\,' . HEIGHT . '/ih):ih*min(' . WIDTH . '/iw\,' . HEIGHT . '/ih), pad=' . WIDTH . ':' . HEIGHT . ':(' . WIDTH . '-iw*min(' . WIDTH . '/iw\,' . HEIGHT . '/ih))/2:(' . HEIGHT . '-ih*min(' . WIDTH . '/iw\,' . HEIGHT . '/ih))/2"'; 67 $ffmpeg_cmd = FFMPEG_PATH . 'ffmpeg -i ' . VID_FILE . ' -qscale 2 -filter:v ' . $filter . ' -metadata:s:v:0 rotate=0 ' . $video_encoded_name . '.mp4'; 116 68 117 // Create a .mp4 attachment and a .png file based off the .mp4 file in case it got rotated 118 if( file_exists( $mp4_filename_encoded ) ){ 119 system( $sp_ffmpeg_path . 'ffmpeg -i ' . $mp4_filename_encoded . ' -f image2 -vframes 1 ' . $filename .'.png'); // Video thumb creation 120 $videoComponent->videoAttachmentIDs['mp4'] = sp_core::create_attachment( $mp4_filename_encoded, $ARGS['POST_ID'], $mp4_filename_encoded, $ARGS['AUTH_ID'] ); 121 }else{ 122 $videoComponent->errors['mp4'] = 'Could not find ' . $mp4_filename . '!' . PHP_EOL; 123 echo $videoComponent->errors['mp4']; 124 } 69 exec( $ffmpeg_cmd, $ffmpeg_output, $ffmpeg_result ); // .mp4 conversion 125 70 126 // Add a featured image if one doesn't already exist 127 if( file_exists( $png_filename ) ){ 128 $videoComponent->videoAttachmentIDs['img'] = sp_core::create_attachment( $png_filename, $ARGS['POST_ID'], $content, $ARGS['AUTH_ID'] ); 129 if( !has_post_thumbnail( $ARGS['POST_ID'] ) ){ 130 set_post_thumbnail( $ARGS['POST_ID'], $videoComponent->videoAttachmentIDs['img']); 131 } 132 }else{ 133 $videoComponent->errors['img'] = 'Could not find ' . $png_filename . '!' . PHP_EOL; 134 echo $videoComponent->errors['img']; 135 } 136 137 unlink( $ARGS['VID_FILE'] ); // Remove the original .mov or .avi files 138 $videoComponent->beingConverted = false; 139 $success = $videoComponent->update(); 140 141 exit(0); 142 } else { 143 if( empty( $ARGS['COMP_ID'] ) ){ echo 'COMP_ID argument not provided' . PHP_EOL; } 144 if( empty( $ARGS['VID_FILE'] ) ){ echo 'VID_FILE argument not provided' . PHP_EOL; } 145 if( empty( $ARGS['POST_ID'] ) ){ echo 'POST_ID argument not provided' . PHP_EOL; } 146 if( empty( $sp_ffmpeg_path ) ){ echo 'FFmpeg path not found' . PHP_EOL; } 71 if( $ffmpeg_result !== 0 ){ 72 $ffmpeg_error = 'ffmpeg exited with an error: ' . print_r($ffmpeg_output, true) . PHP_EOL; 73 echo $ffmpeg_error; 147 74 exit(1); 148 75 } 76 77 // If we've successfully converted the video, then try and create a .png video thumbnail 78 if( file_exists($video_encoded_name . '.mp4' ) ){ 79 $png_filename = $video_encoded_name . '.png'; 80 $ffmpeg_png_cmd = FFMPEG_PATH . 'ffmpeg -i ' . $video_encoded_name . '.mp4' . ' -f image2 -vframes 1 ' . $png_filename; 81 exec( $ffmpeg_png_cmd, $ffmpeg_png_output, $ffmpeg_png_status ); 82 83 if( $ffmpeg_png_status !== 0 ){ 84 echo 'Error: ffmpeg exited with an error: ' . print_r( $ffmpeg_png_output, true) . '. Command: ' . $ffmpeg_png_cmd; 85 } 86 }else{ 87 echo 'Error: converted vidoe file not found! Path: ' . $video_encoded_name . '.mp4'; 88 } 89 90 91 92 // Connect to the DB to update the user that conversion is complete 93 $mysqli = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME); 94 if ($mysqli->connect_error) { 95 echo 'Connect Error (' . $mysqli->connect_errno . ') ' . $mysqli->connect_error; 96 exit(1); 97 } 98 99 /* 100 * Use this instead of $connect_error if you need to ensure 101 * compatibility with PHP versions prior to 5.2.9 and 5.3.0. 102 */ 103 if (mysqli_connect_error()) { 104 echo 'Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error(); 105 exit(1); 106 } 107 108 $post_component_result = $mysqli->query( 'SELECT * FROM ' . WP_DB_PREFIX . 'sp_postComponents WHERE id=' . COMP_ID . ';' ); 109 110 if( $post_component_result->num_rows === 1 ){ 111 $post_component_obj = $post_component_result->fetch_object(); 112 113 $video_data = unserialize( $post_component_obj->value ); 114 $video_data->beingConverted = false; 115 $video_data->just_converted = true; 116 $video_data->videoAttachmentIDs['encoded_video'] = $video_encoded_name . '.mp4'; 117 $video_data->videoAttachmentIDs['png_file'] = $video_encoded_name . '.png'; 118 119 $update_sql = "UPDATE " . WP_DB_PREFIX . "sp_postComponents SET value='" . serialize( $video_data ) . "' WHERE id=" . COMP_ID . ";"; 120 $update_result = $mysqli->query( $update_sql ); 121 if( $update_result === false ){ 122 echo 'Query could not be run: ' .$update_sql; 123 exit(1); 124 } 125 } 126 127 $mysqli->close(); 128 129 exit(0); -
smartpost-templates/trunk/components/video/js/sp_postVideo.js
r914770 r917335 72 72 compID : compID 73 73 }, 74 max_file_size : ' 1gb',74 max_file_size : '2gb', 75 75 filters : videoFilters, 76 76 init: { … … 113 113 114 114 FileUploaded: function(up, files, response) { 115 console.log( response ); 115 116 if(response){ 116 117 $('#videoProgBarContainer-' + compID).hide(); -
smartpost-templates/trunk/components/video/sp_postVideo.php
r914746 r917335 10 10 11 11 public $beingConverted = false; 12 public $just_converted = false; // Flag signifying the conversion script just finished running 12 13 public $videoAttachmentIDs = array(); // An array of video attachment IDs, format: array('{video format}' => {attachment ID}) 13 public $errors = array();14 14 public $description; 15 15 … … 28 28 29 29 // Update any post component options 30 $this->beingConverted = $this->value->beingConverted;30 $this->beingConverted = $this->value->beingConverted; 31 31 $this->videoAttachmentIDs = $this->value->videoAttachmentIDs; 32 $this->just_converted = $this->value->just_converted; 32 33 $this->description = $this->value->description; 33 34 $this->convertToHTML5 = get_site_option( 'sp_html5_encoding' ); 35 36 $this->check_converted_video(); 34 37 } 35 38 … … 146 149 */ 147 150 function renderViewMode(){ 148 $html .= '<div id="sp_video-' . $this->ID . '" class="sp_video" data-compid="' . $this->ID . '">';151 $html = '<div id="sp_video-' . $this->ID . '" class="sp_video" data-compid="' . $this->ID . '">'; 149 152 $html .= '<div id="sp-video-desc-' . $this->ID . '" class="sp-video-desc">' . $this->description . '</div>'; 150 153 $html .= $this->renderPlayer(); … … 154 157 155 158 /** 156 * !TODO: Use ffmpeg to create video thumbs157 159 * @return string 158 160 */ … … 169 171 function delete(){ 170 172 global $wpdb; 171 172 173 if( !empty($this->videoAttachmentIDs) ){ 173 174 foreach($this->videoAttachmentIDs as $attach_id){ … … 175 176 } 176 177 } 177 178 178 $tableName = $wpdb->prefix . 'sp_postComponents'; 179 179 return $wpdb->query($wpdb->prepare( "DELETE FROM $tableName WHERE id = %d", $this->ID ) ); 180 180 } 181 182 /**183 * @see parent::addMenuOptions()184 */185 protected function addMenuOptions(){186 return array();187 }188 189 181 190 182 /** … … 196 188 function update(){ 197 189 $videoData = new stdClass(); 198 $videoData->beingConverted = (bool) $this->beingConverted;190 $videoData->beingConverted = (bool) $this->beingConverted; 199 191 $videoData->videoAttachmentIDs = $this->videoAttachmentIDs; 200 192 $videoData->description = $this->description; 201 $videoData-> errors = $this->errors;202 $videoData = maybe_serialize( $videoData);193 $videoData->just_converted = $this->just_converted; 194 $videoData = maybe_serialize( $videoData ); 203 195 return sp_core::updateVar('sp_postComponents', $this->ID, 'value', $videoData, '%s'); 204 196 } … … 211 203 } 212 204 205 /** 206 * Checks if an uploaded video was just converted and 207 * 1) Adds the converted video as an attachment 208 * 2) Adds the video thumb .png as an attachment 209 * 3) Deletes the original file 210 * 4) Sets the video thumb .png as the featured image if one was not already set 211 */ 212 function check_converted_video(){ 213 if( $this->just_converted ){ 214 215 // Add the encoded video as a new attachment 216 $encoded_video = $this->videoAttachmentIDs['encoded_video']; 217 $video_path_info = pathinfo( $encoded_video ); 218 $this->videoAttachmentIDs['mp4'] = sp_core::create_attachment( $encoded_video, $this->postID, $video_path_info['filename'] . '.mp4' ); 219 220 // Add the png as a new attachment 221 $png_filename = $this->videoAttachmentIDs['png_file']; 222 if( file_exists( $png_filename ) ){ 223 $this->videoAttachmentIDs['img'] = sp_core::create_attachment( $png_filename, $this->postID, $video_path_info['filename'] . '.png' ); 224 if( !has_post_thumbnail( $this->postID ) ){ 225 set_post_thumbnail( $this->postID, $this->videoAttachmentIDs['img']); 226 } 227 } 228 229 // Get rid of original uploaded file 230 unlink( $this->videoAttachmentIDs['uploaded_video'] ); 231 232 $this->just_converted = false; 233 $this->update(); 234 } 235 } 213 236 } 214 237 } -
smartpost-templates/trunk/readme.txt
r914746 r917335 3 3 Donate link: http://rafilabs.com/ 4 4 Tags: templates, forms, front end editor, video, ffmpeg, picture gallery, media, uploader 5 Stable tag: 2.3. 25 Stable tag: 2.3.3 6 6 Requires at least: 3.8 7 7 Tested up to: 3.9.1 … … 115 115 == Changelog == 116 116 117 = 2.3.3 = 118 * Removes an include on wp-load.php for the video conversion script 119 117 120 = 2.3.2 = 118 121 * Fixed an update bug that did not update WPMU sites correctly -
smartpost-templates/trunk/smartpost.php
r914746 r917335 16 16 define("SP_PLUGIN_PATH", plugins_url('/', __FILE__)); 17 17 define("SP_DEBUG", true); // Turns on useful errors that are dumped into the php error log for debugging 18 define("SP_VERSION", "2.3. 2");18 define("SP_VERSION", "2.3.3"); 19 19 20 20 if ( !class_exists("smartpost") ){ -
smartpost-templates/trunk/sp_uninstall.php
r914746 r917335 36 36 */ 37 37 public static function uninstall_sp_data(){ 38 error_log( 'uninstall_sp_data' );39 40 38 global $wpdb; 41 39 // Save all SmartPost posts into HTML format
Note: See TracChangeset
for help on using the changeset viewer.