get_enclosed

Retrieve enclosures already enclosed for a post.

Description

(array) get_enclosed( (int) $post_id ); 

Returns (array)

List of enclosures.

Parameters (1)

0. $post_id (int)
The post id.

Usage

  1. if ( !function_exists( 'get_enclosed' ) ) { 
  2. require_once ABSPATH . WPINC . '/post.php'; 
  3.  
  4. // The post id. 
  5. $post_id = -1; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = get_enclosed($post_id); 
  9.  

Defined (1)

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

/wp-includes/post.php  
  1. function get_enclosed( $post_id ) { 
  2. $custom_fields = get_post_custom( $post_id ); 
  3. $pung = array(); 
  4. if ( !is_array( $custom_fields ) ) 
  5. return $pung; 
  6.  
  7. foreach ( $custom_fields as $key => $val ) { 
  8. if ( 'enclosure' != $key || !is_array( $val ) ) 
  9. continue; 
  10. foreach ( $val as $enc ) { 
  11. $enclosure = explode( "\n", $enc ); 
  12. $pung[] = trim( $enclosure[ 0 ] ); 
  13.  
  14. /** 
  15. * Filters the list of enclosures already enclosed for the given post. 
  16. * @since 2.0.0 
  17. * @param array $pung Array of enclosures for the given post. 
  18. * @param int $post_id Post ID. 
  19. */ 
  20. return apply_filters( 'get_enclosed', $pung, $post_id );