Plugin Directory

Changeset 917335


Ignore:
Timestamp:
05/19/2014 06:23:00 PM (12 years ago)
Author:
rafdizzle86
Message:

v2.3.3 patch - fixed wp-load.php include in html5video.php

Location:
smartpost-templates/trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • smartpost-templates/trunk/components/attachments/ajax/sp_postAttachmentsAJAX.php

    r914746 r917335  
    11<?php
    2 /*
     2/**
    33 * AJAX-Related functions for all
    44 * sp_postAttachments components. Functions are used
     
    77
    88if (!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(){
    1818
    1919            $nonce = $_POST['nonce'];
     
    4949            }
    5050            exit;
    51         }       
    52        
    53         static function attachmentsDeleteAttachmentAJAX(){
     51        }
     52
     53        /**
     54         * Deletes an attachment component
     55         */
     56        static function attachmentsDeleteAttachmentAJAX(){
    5457            $nonce = $_POST['nonce'];
    5558            if( !wp_verify_nonce($nonce, 'sp_nonce') ){
     
    5760                die('Security Check');
    5861            }
    59                
     62
    6063            if(!class_exists('sp_postAttachments')){
    6164                header("HTTP/1.0 409 Could not instantiate sp_postAttachments class.");
     
    7275                exit;
    7376            }
    74                
     77
    7578            $id = (int) $_POST['attachmentID'];
    7679            $compID = (int) $_POST['compID'];
     
    102105            echo json_encode( array('sucess' => true) );
    103106            exit;
    104         }
     107        }
    105108
    106109        /**
     
    182185            }
    183186            exit;
    184         }
    185     }
     187        }
     188    }
    186189}
  • smartpost-templates/trunk/components/attachments/sp_postAttachments.php

    r914746 r917335  
    3737         */
    3838        static function init(){
    39             require_once( dirname( __FILE__ ) . '/ajax/sp_postAttachmentsAJAX.php');
     39            require_once( dirname(__FILE__) . '/ajax/sp_postAttachmentsAJAX.php' );
    4040            sp_postAttachmentsAJAX::init();
    4141            self::enqueueCSS();
  • smartpost-templates/trunk/components/video/ajax/sp_postVideoAJAX.php

    r914770 r917335  
    7373            $compID = (int) $_POST['compID'];
    7474            $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{
    7689                echo json_encode( array( 'converted' => false ) );
    77             }else{
    78                 echo json_encode( array( 'converted' => true ) );
    7990            }
    8091            exit;
     
    8394        /**
    8495         * Handles video uploads using chunking.
    85          * @todo Do the conversion to mp4 and get rid of the original mov (?)
    8696         */
    8797        static function videoUploadAJAX(){
     
    107117            }
    108118
    109             $videoFilePath = sp_core::chunked_plupload( "sp_videoUpload" );
     119            $uploaded_video = sp_core::chunked_plupload( "sp_videoUpload" );
    110120
    111             if( file_exists( $videoFilePath ) ){
     121            if( file_exists( $uploaded_video ) ){
    112122
    113123                $compID = (int) $_POST['compID'];
     
    124134                }
    125135
     136                $sp_ffmpeg_path = get_site_option('sp_ffmpeg_path');
    126137                $html5_encoding = (bool) get_site_option( 'sp_html5_encoding' );
    127                 $sp_ffmpeg_path = get_site_option( 'sp_ffmpeg_path' );
    128138
    129139                if( $html5_encoding && !is_wp_error( $sp_ffmpeg_path ) ){
     140                    global $wpdb;
     141                    $script_path = dirname(dirname(__FILE__)) . '/html5video.php';
    130142
    131143                    $videoComponent->beingConverted = true;
     144                    $videoComponent->videoAttachmentIDs['uploaded_video'] = $uploaded_video;
    132145                    $videoComponent->update();
    133146
    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                    );
    135159
    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                     );
    148160
    149161                    if(DEBUG_SP_VIDEO){
     
    158170
    159171                    // Check to see that it's mp4 format
    160                     $ext = pathinfo($videoFilePath, PATHINFO_EXTENSION);
     172                    $ext = pathinfo($uploaded_video, PATHINFO_EXTENSION);
    161173                    if( $ext !== 'mp4' ){
    162                         unlink($videoFilePath);
     174                        unlink($uploaded_video);
    163175                        header( "HTTP/1.0 409 Error: only mp4 files are allowed to be uploaded when HTML5 encoding is not enabled!" );
    164176                        exit;
    165177                    }else{
    166178                        // 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() );
    168180                        $videoComponent->update();
    169181                    }
    170 
    171182                }
    172183                echo $videoComponent->renderPlayer();
    173184
    174             }else if( $videoFilePath !== false && !file_exists( $videoFilePath )  ){
     185            }else if( $uploaded_video !== false && !file_exists( $uploaded_video )  ){
    175186                header( "HTTP/1.0 409 There was an error with uploading the video. The video file could not be found." );
    176187            }
  • smartpost-templates/trunk/components/video/html5video.php

    r914746 r917335  
    11<?php
    22/**
    3  * User: ryagudin
    4  * Date: 8/14/13
    5  * Time: 1:17 PM
    63 * Converts a video file to .webm and .mp4 formats using ffmpeg.
     4 * Assumes that the server can use exec()
    75 */
    86
    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
     8define( 'DB_NAME', $argv[1] );
     9define( 'DB_USER', $argv[2] );
     10define( 'DB_HOST', $argv[3] );
     11define( 'DB_PASS', $argv[4] );
     12define( 'WP_DB_PREFIX', $argv[5] );
     13define( 'VID_FILE', $argv[6] );
     14define( 'COMP_ID', $argv[7] );
     15define( 'WIDTH', $argv[8] );
     16define( 'HEIGHT', $argv[9] );
     17define( 'FFMPEG_PATH', $argv[10] );
    1918
    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';
    2622
    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 );
     28if( $result !== 0 ){
     29    $ffprobe_error = 'ffprobe exited with an error: ' . print_r($ffprobe_output, true) . PHP_EOL;
     30    echo $ffprobe_error;
     31}else{
    8032    $rotationFilter = '';
    81     if( !empty($rotation) ){
     33    if( !empty( $rotation ) ){
    8234        switch( $rotation ){
    8335            case '-270':
     
    10456        }
    10557    }
     58}
    10659
    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';
    11668
    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     }
     69exec( $ffmpeg_cmd, $ffmpeg_output, $ffmpeg_result ); // .mp4 conversion
    12570
    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; }
     71if( $ffmpeg_result !== 0 ){
     72    $ffmpeg_error = 'ffmpeg exited with an error: ' . print_r($ffmpeg_output, true) . PHP_EOL;
     73    echo $ffmpeg_error;
    14774    exit(1);
    14875}
     76
     77// If we've successfully converted the video, then try and create a .png video thumbnail
     78if( 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);
     94if ($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 */
     103if (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
     110if( $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
     129exit(0);
  • smartpost-templates/trunk/components/video/js/sp_postVideo.js

    r914770 r917335  
    7272                    compID  : compID
    7373                },
    74                 max_file_size : '1gb',
     74                max_file_size : '2gb',
    7575                filters : videoFilters,
    7676                init: {
     
    113113
    114114                    FileUploaded: function(up, files, response) {
     115                        console.log( response );
    115116                        if(response){
    116117                            $('#videoProgBarContainer-' + compID).hide();
  • smartpost-templates/trunk/components/video/sp_postVideo.php

    r914746 r917335  
    1010
    1111        public $beingConverted = false;
     12        public $just_converted = false; // Flag signifying the conversion script just finished running
    1213        public $videoAttachmentIDs = array(); // An array of video attachment IDs, format: array('{video format}' => {attachment ID})
    13         public $errors = array();
    1414        public $description;
    1515
     
    2828
    2929            // Update any post component options
    30             $this->beingConverted     = $this->value->beingConverted;
     30            $this->beingConverted = $this->value->beingConverted;
    3131            $this->videoAttachmentIDs = $this->value->videoAttachmentIDs;
     32            $this->just_converted = $this->value->just_converted;
    3233            $this->description = $this->value->description;
    3334            $this->convertToHTML5  = get_site_option( 'sp_html5_encoding' );
     35
     36            $this->check_converted_video();
    3437        }
    3538
     
    146149         */
    147150        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 . '">';
    149152                $html .= '<div id="sp-video-desc-' . $this->ID . '" class="sp-video-desc">' . $this->description . '</div>';
    150153                $html .= $this->renderPlayer();
     
    154157
    155158        /**
    156          * !TODO: Use ffmpeg to create video thumbs
    157159         * @return string
    158160         */
     
    169171        function delete(){
    170172            global $wpdb;
    171 
    172173            if( !empty($this->videoAttachmentIDs) ){
    173174               foreach($this->videoAttachmentIDs as $attach_id){
     
    175176               }
    176177            }
    177 
    178178            $tableName = $wpdb->prefix . 'sp_postComponents';
    179179            return $wpdb->query($wpdb->prepare( "DELETE FROM $tableName WHERE id = %d", $this->ID ) );
    180180        }
    181 
    182         /**
    183          * @see parent::addMenuOptions()
    184          */
    185         protected function addMenuOptions(){
    186             return array();
    187         }
    188 
    189181
    190182        /**
     
    196188        function update(){
    197189            $videoData = new stdClass();
    198             $videoData->beingConverted     = (bool) $this->beingConverted;
     190            $videoData->beingConverted = (bool) $this->beingConverted;
    199191            $videoData->videoAttachmentIDs = $this->videoAttachmentIDs;
    200192            $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 );
    203195            return sp_core::updateVar('sp_postComponents', $this->ID, 'value', $videoData, '%s');
    204196        }
     
    211203        }
    212204
     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        }
    213236    }
    214237}
  • smartpost-templates/trunk/readme.txt

    r914746 r917335  
    33Donate link: http://rafilabs.com/
    44Tags: templates, forms, front end editor, video, ffmpeg, picture gallery, media, uploader
    5 Stable tag: 2.3.2
     5Stable tag: 2.3.3
    66Requires at least: 3.8
    77Tested up to: 3.9.1
     
    115115== Changelog ==
    116116
     117= 2.3.3 =
     118* Removes an include on wp-load.php for the video conversion script
     119
    117120= 2.3.2 =
    118121* Fixed an update bug that did not update WPMU sites correctly
  • smartpost-templates/trunk/smartpost.php

    r914746 r917335  
    1616define("SP_PLUGIN_PATH", plugins_url('/', __FILE__));
    1717define("SP_DEBUG", true); // Turns on useful errors that are dumped into the php error log for debugging
    18 define("SP_VERSION", "2.3.2");
     18define("SP_VERSION", "2.3.3");
    1919
    2020if ( !class_exists("smartpost") ){
  • smartpost-templates/trunk/sp_uninstall.php

    r914746 r917335  
    3636         */
    3737        public static function uninstall_sp_data(){
    38             error_log( 'uninstall_sp_data' );
    39 
    4038            global $wpdb;
    4139            // Save all SmartPost posts into HTML format
Note: See TracChangeset for help on using the changeset viewer.