Beispiel #1
0
 /**
  *insert short code into the video post
  *@access public
  */
 public function wpvp_insert_video_into_post($html, $id, $attachment)
 {
     $helper = new WPVP_Helper();
     $width = $this->options['video_width'];
     $height = $this->options['video_height'];
     $options = $helper->wpvp_get_full_options();
     $ffmpeg_exists = $options['ffmpeg_exists'];
     $attachmentID = $id;
     $content = $html;
     $attachmentObj = get_post($attachmentID);
     $allowed_ext = array('mp4', 'flv');
     if ($helper->is_video($attachmentObj->post_mime_type) == 'video') {
         $postParentID = $attachmentObj->post_parent;
         $postParentObj = get_post($postParentID);
         $attachmentURI = wp_get_attachment_url($attachmentID);
         $attachmentPathInfo = pathinfo($attachmentURI);
         $attachExt = $attachmentPathInfo['extension'];
         //check for allowed extensions without ffmpeg
         if (!in_array($attachExt, $allowed_ext) && !$ffmpeg_exists) {
             $content = __('WPVP_ERROR: FFMPEG is not found on the server. Allowed extensions for the upload are mp4 and flv. Please convert the video and re-upload.');
         } else {
             //Video with attachment from Media Library
             $attachments = get_posts(array('post_type' => 'attachment', 'posts_per_page' => -1, 'post_parent' => $postParentID, 'post_mime_type' => 'image/jpeg'));
             if ($attachments) {
                 $imgAttachmentID = $attachments[0]->ID;
                 $imgAttachment = wp_get_attachment_url($imgAttachmentID);
             } else {
                 $imgAttachment = plugins_url('/images/', dirname(__FILE__)) . 'default_image.jpg';
             }
             $content = '[wpvp_player src=' . $attachmentURI . ' width=' . $width . ' height=' . $height . ' splash=' . $imgAttachment . ']';
         }
     }
     //Check post mime type = video
     return $content;
 }
Beispiel #2
0
 public function wpvp_attachment_save($data)
 {
     $helper = new WPVP_Helper();
     if ($helper->is_video($data['post_mime_type']) == 'video') {
         $parent_post = $data['post_parent'];
         $newdata = array('ID' => $parent_post, 'post_excerpt' => $data['post_content'], 'post_title' => $data['post_title'], 'tags_input' => $data['post_excerpt']);
         wp_update_post($newdata);
         return $data;
     } else {
         return $data;
     }
 }