videopress_create_new_media_item

Create an empty videopress media item that will be filled out later by an xmlrpc callback from the VideoPress servers.

Description

(int|WP_Error) videopress_create_new_media_item( (string) $title, (null) $guid = null ); 

Returns (int|WP_Error)

Parameters (2)

0. $title (string)
The title.
1. $guid — Optional. (null) => null
The guid.

Usage

  1. if ( !function_exists( 'videopress_create_new_media_item' ) ) { 
  2. require_once '/modules/videopress/utility-functions.php'; 
  3.  
  4. // The title. 
  5. $title = ''; 
  6.  
  7. // The guid. 
  8. $guid = null; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = videopress_create_new_media_item($title, $guid); 
  12.  

Defined (1)

The function is defined in the following location(s).

/modules/videopress/utility-functions.php  
  1. function videopress_create_new_media_item( $title, $guid = null ) { 
  2. $post = array( 
  3. 'post_type' => 'attachment',  
  4. 'post_mime_type' => 'video/videopress',  
  5. 'post_title' => $title,  
  6. 'post_content' => '',  
  7. 'guid' => videopress_build_url( $guid ),  
  8. ); 
  9.  
  10. $media_id = wp_insert_post( $post ); 
  11.  
  12. add_post_meta( $media_id, 'videopress_status', 'initiated' ); 
  13.  
  14. add_post_meta( $media_id, 'videopress_guid', $guid ); 
  15.  
  16. return $media_id;