Filter hook 'enclosure_links'

in WP Core File wp-includes/functions.php at line 944

View Source

enclosure_links

Filter Hook
Description
Filters the list of enclosure links before querying the database. Allows for the addition and/or removal of potential enclosures to save to postmeta before checking the database for existing enclosures.

Hook Information

File Location wp-includes/functions.php View on GitHub
Hook Type Filter
Line Number 944

Hook Parameters

Type Name Description
string[] $post_links An array of enclosure links.
int $post_id Post ID.

Usage Examples

Basic Usage
<?php
// Hook into enclosure_links
add_filter('enclosure_links', 'my_custom_filter', 10, 2);

function my_custom_filter($post_links, $post_id) {
    // Your custom filtering logic here
    return $post_links;
}

Source Code Context

wp-includes/functions.php:944 - How this hook is used in WordPress core
<?php
 939  	 * @since 4.4.0
 940  	 *
 941  	 * @param string[] $post_links An array of enclosure links.
 942  	 * @param int      $post_id    Post ID.
 943  	 */
 944  	$post_links = apply_filters( 'enclosure_links', $post_links, $post->ID );
 945  
 946  	foreach ( (array) $post_links as $url ) {
 947  		$url = strip_fragment_from_url( $url );
 948  
 949  		if ( '' !== $url && ! $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = 'enclosure' AND meta_value LIKE %s", $post->ID, $wpdb->esc_like( $url ) . '%' ) ) ) {

PHP Documentation

<?php
/**
	 * Filters the list of enclosure links before querying the database.
	 *
	 * Allows for the addition and/or removal of potential enclosures to save
	 * to postmeta before checking the database for existing enclosures.
	 *
	 * @since 4.4.0
	 *
	 * @param string[] $post_links An array of enclosure links.
	 * @param int      $post_id    Post ID.
	 */
Quick Info
  • Hook Type: Filter
  • Parameters: 2
  • File: wp-includes/functions.php
Related Hooks

Related hooks will be displayed here in future updates.