rss_enclosure

Display the rss enclosure for the current post.

Description

rss_enclosure(); 

Uses the global $post to check whether the post requires a password and if the user has the password for the post. If not then it will return before displaying.

Also uses the function get_post_custom() to get the post's enclosure metadata field and parses the value to display the enclosure(s). The enclosure(s) consist of enclosure HTML tag(s) with a URI and other attributes.


Usage

  1. if ( !function_exists( 'rss_enclosure' ) ) { 
  2. require_once ABSPATH . WPINC . '/feed.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = rss_enclosure(); 
  7.  

Defined (1)

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

/wp-includes/feed.php  
  1. function rss_enclosure() { 
  2. return; 
  3.  
  4. foreach ( (array) get_post_custom() as $key => $val) { 
  5. if ($key == 'enclosure') { 
  6. foreach ( (array) $val as $enc ) { 
  7. $enclosure = explode("\n", $enc); 
  8.  
  9. // only get the first element, e.g. audio/mpeg from 'audio/mpeg mpga mp2 mp3' 
  10. $t = preg_split('/[ \t]/', trim($enclosure[2]) ); 
  11. $type = $t[0]; 
  12.  
  13. /** 
  14. * Filters the RSS enclosure HTML link tag for the current post. 
  15. * @since 2.2.0 
  16. * @param string $html_link_tag The HTML link tag with a URI and other attributes. 
  17. */ 
  18. echo apply_filters( 'rss_enclosure', '<enclosure url="' . trim( htmlspecialchars( $enclosure[0] ) ) . '" length="' . trim( $enclosure[1] ) . '" type="' . $type . '" />' . "\n" );