Ticket #10337: 10337.10.patch
File 10337.10.patch, 1.6 KB (added by , 14 years ago) |
---|
-
wp-includes/media.php
932 932 933 933 // After a post is saved, cache oEmbed items via AJAX 934 934 add_action( 'edit_form_advanced', array(&$this, 'maybe_run_ajax_cache') ); 935 936 // On theme switch, dump all oEmbed caches (since the theme width can change) 937 add_action( 'switch_theme', array(&$this, 'delete_all_oembed_caches') ); 935 938 } 936 939 937 940 /** … … 1097 1100 } 1098 1101 1099 1102 /** 1100 * Delete all oEmbed caches .1103 * Delete all oEmbed caches for a post. 1101 1104 * 1102 1105 * @param int $post_ID Post ID to delete the caches for. 1103 1106 */ … … 1112 1115 } 1113 1116 1114 1117 /** 1118 * Delete all oEmbed caches for all posts. 1119 */ 1120 function delete_all_oembed_caches() { 1121 // Based on delete_post_meta_by_key() 1122 global $wpdb; 1123 $post_ids = $wpdb->get_col( "SELECT DISTINCT post_id FROM $wpdb->postmeta WHERE meta_key LIKE '_oembed_%'" ); 1124 if ( $post_ids ) { 1125 $postmetaids = $wpdb->get_col( "SELECT meta_id FROM $wpdb->postmeta WHERE meta_key LIKE '_oembed_%'" ); 1126 $in = implode( ',', array_fill( 1, count($postmetaids), '%d' ) ); 1127 do_action( 'delete_postmeta', $postmetaids ); 1128 $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->postmeta WHERE meta_id IN($in)", $postmetaids ) ); 1129 do_action( 'deleted_postmeta', $postmetaids ); 1130 foreach ( $post_ids as $post_id ) 1131 wp_cache_delete( $post_id, 'post_meta' ); 1132 return true; 1133 } 1134 return false; 1135 } 1136 1137 /** 1115 1138 * Triggers a caching of all oEmbed results. 1116 1139 * 1117 1140 * @param int $post_ID Post ID to do the caching for.