WordPress.org

Make WordPress Core

Ticket #22190: 22190.diff

File 22190.diff, 1.3 KB (added by nacin, 18 months ago)
  • wp-includes/class-wp-embed.php

     
    2525                // Attempts to embed all URLs in a post 
    2626                add_filter( 'the_content', array( $this, 'autoembed' ), 8 ); 
    2727 
    28                 // After a post is saved, invalidate the oEmbed cache 
    29                 add_action( 'save_post', array( $this, 'delete_oembed_caches' ) ); 
     28                // When a post is saved, invalidate the oEmbed cache 
     29                add_action( 'pre_post_update', array( $this, 'delete_oembed_caches' ) ); 
    3030 
    3131                // After a post is saved, cache oEmbed items via AJAX 
    3232                add_action( 'edit_form_advanced', array( $this, 'maybe_run_ajax_cache' ) ); 
     
    201201         * @param int $post_ID Post ID to delete the caches for. 
    202202         */ 
    203203        function delete_oembed_caches( $post_ID ) { 
    204                 $post_metas = get_post_custom_keys( $post_ID ); 
    205                 if ( empty($post_metas) ) 
     204                if ( ! $meta = get_post_meta( $post_ID ) ) 
    206205                        return; 
    207  
    208                 foreach( $post_metas as $post_meta_key ) { 
    209                         if ( '_oembed_' == substr( $post_meta_key, 0, 8 ) ) 
    210                                 delete_post_meta( $post_ID, $post_meta_key ); 
     206                foreach ( $meta as $key => $values ) { 
     207                        if ( '_oembed_' == substr( $key, 0, 8 ) ) 
     208                                delete_post_meta( $post_id, $key ); 
    211209                } 
    212210        } 
    213211