From 646f11e78e8ef075372cf5966d52026faa570387 Mon Sep 17 00:00:00 2001 From: ryan Date: Wed, 13 May 2009 05:15:27 +0000 Subject: [PATCH] Remove stale enclosures. Props mystyman. fixes #6840 git-svn-id: http://svn.automattic.com/wordpress/trunk@11315 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/functions.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 1ab4ada932..648ce66da4 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -1060,7 +1060,8 @@ function debug_fclose( $fp ) { /** * Check content for video and audio links to add as enclosures. * - * Will not add enclosures that have already been added. This is called as + * Will not add enclosures that have already been added and will + * remove enclosures that are no longer in the post. This is called as * pingbacks and trackbacks. * * @package WordPress @@ -1091,6 +1092,12 @@ function do_enclose( $content, $post_ID ) { debug_fwrite( $log, 'Post contents:' ); debug_fwrite( $log, $content . "\n" ); + foreach ( $pung as $link_test ) { + if ( !in_array( $link_test, $post_links_temp[0] ) ) { // link no longer in post + $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = 'enclosure' AND meta_value LIKE (%s)", $post_ID, $link_test . '%') ); + } + } + foreach ( (array) $post_links_temp[0] as $link_test ) { if ( !in_array( $link_test, $pung ) ) { // If we haven't pung it already $test = parse_url( $link_test );