get_upload_iframe_src

The WordPress Core get upload iframe src function.

Description

(string) get_upload_iframe_src( (constant) $type = null, (constant) $post_id = null, (null) $tab = null ); 

Returns (string)

Parameters (3)

0. $type — Optional. (constant) => null
The type.
1. $post_id — Optional. (constant) => null
The post id.
2. $tab — Optional. (null) => null
The tab.

Usage

  1. if ( !function_exists( 'get_upload_iframe_src' ) ) { 
  2. require_once ABSPATH . '/wp-admin/includes/media.php'; 
  3.  
  4. // The type. 
  5. $type = null; 
  6.  
  7. // The post id. 
  8. $post_id = null; 
  9.  
  10. // The tab. 
  11. $tab = null; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = get_upload_iframe_src($type, $post_id, $tab); 
  15.  

Defined (1)

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

/wp-admin/includes/media.php  
  1. function get_upload_iframe_src( $type = null, $post_id = null, $tab = null ) { 
  2. global $post_ID; 
  3.  
  4. if ( empty( $post_id ) ) 
  5. $post_id = $post_ID; 
  6.  
  7. $upload_iframe_src = add_query_arg( 'post_id', (int) $post_id, admin_url('media-upload.php') ); 
  8.  
  9. if ( $type && 'media' != $type ) 
  10. $upload_iframe_src = add_query_arg('type', $type, $upload_iframe_src); 
  11.  
  12. if ( ! empty( $tab ) ) 
  13. $upload_iframe_src = add_query_arg('tab', $tab, $upload_iframe_src); 
  14.  
  15. /** 
  16. * Filters the upload iframe source URL for a specific media type. 
  17. * The dynamic portion of the hook name, `$type`, refers to the type 
  18. * of media uploaded. 
  19. * @since 3.0.0 
  20. * @param string $upload_iframe_src The upload iframe source URL by type. 
  21. */ 
  22. $upload_iframe_src = apply_filters( "{$type}_upload_iframe_src", $upload_iframe_src ); 
  23.  
  24. return add_query_arg('TB_iframe', true, $upload_iframe_src);