videopress_get_video_details

Get details about a specific video by GUID:.

Description

(object) videopress_get_video_details( $guid ); 

Returns (object)

Parameters (1)

0. $guid
The guid.

Usage

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

Defined (1)

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

/modules/videopress/utility-functions.php  
  1. function videopress_get_video_details( $guid ) { 
  2. if ( ! videopress_is_valid_guid( $guid ) ) { 
  3. return new WP_Error( 'bad-guid-format', __( 'Invalid Video GUID!', 'jetpack' ) ); 
  4.  
  5. $version = '1.1'; 
  6. $endpoint = sprintf( '/videos/%1$s', $guid ); 
  7. $query_url = sprintf( 
  8. 'https://public-api.wordpress.com/rest/v%1$s%2$s',  
  9. $version,  
  10. $endpoint 
  11. ); 
  12.  
  13. // Look for data in our transient. If nothing, let's make a new query. 
  14. $data_from_cache = get_transient( 'jetpack_videopress_' . $guid ); 
  15. if ( false === $data_from_cache ) { 
  16. $response = wp_remote_get( esc_url_raw( $query_url ) ); 
  17. $data = json_decode( wp_remote_retrieve_body( $response ) ); 
  18.  
  19. // Cache the response for an hour. 
  20. set_transient( 'jetpack_videopress_' . $guid, $data, HOUR_IN_SECONDS ); 
  21. } else { 
  22. $data = $data_from_cache; 
  23.  
  24. /** 
  25. * Allow functions to modify fetched video details. 
  26. * This filter allows third-party code to modify the return data 
  27. * about a given video. It may involve swapping some data out or 
  28. * adding new parameters. 
  29. * @since 4.0.0 
  30. * @param object $data The data returned by the WPCOM API. See: https://developer.wordpress.com/docs/api/1.1/get/videos/%24guid/ 
  31. * @param string $guid The GUID of the VideoPress video in question. 
  32. */ 
  33. return apply_filters( 'videopress_get_video_details', $data, $guid );