Ticket #14759: 14759.diff
File 14759.diff, 2.3 KB (added by , 9 years ago) |
---|
-
src/wp-admin/includes/ajax-actions.php
function wp_ajax_imgedit_preview() { 180 180 } 181 181 182 182 function wp_ajax_oembed_cache() { 183 global $wp_embed; 184 185 $return = ( $wp_embed->cache_oembed( $_GET['post'] ) ) ? '1' : '0'; 186 wp_die( $return ); 183 $GLOBALS['wp_embed']->cache_oembed( $_GET['post'] ); 184 wp_die( 0 ); 187 185 } 188 186 189 187 function wp_ajax_autocomplete_user() { -
src/wp-includes/class-wp-embed.php
class WP_Embed { 25 25 // Attempts to embed all URLs in a post 26 26 add_filter( 'the_content', array( $this, 'autoembed' ), 8 ); 27 27 28 // When a post is saved, invalidate the oEmbed cache29 add_action( 'pre_post_update', array( $this, 'delete_oembed_caches' ) );30 31 28 // After a post is saved, cache oEmbed items via AJAX 32 29 add_action( 'edit_form_advanced', array( $this, 'maybe_run_ajax_cache' ) ); 33 30 } … … class WP_Embed { 72 69 function maybe_run_ajax_cache() { 73 70 $post = get_post(); 74 71 75 if ( ! $post || empty( $_GET['message']) || 1 != $_GET['message'] )72 if ( ! $post || empty( $_GET['message'] ) ) { 76 73 return; 74 } 77 75 78 76 ?> 79 77 <script type="text/javascript"> … … class WP_Embed { 183 181 184 182 // Check for a cached result (stored in the post meta) 185 183 $cachekey = '_oembed_' . md5( $url . serialize( $attr ) ); 186 if ( $this->usecache ) { 187 $cache = get_post_meta( $post_ID, $cachekey, true ); 188 184 $cache = get_post_meta( $post_ID, $cachekey, true ); 185 if ( $this->usecache || 'publish' !== get_post_status( $post_ID ) ) { 189 186 // Failures are cached 190 187 if ( '{{unknown}}' === $cache ) 191 188 return $this->maybe_make_link( $url ); … … class WP_Embed { 219 216 $html = wp_oembed_get( $url, $attr ); 220 217 221 218 // Cache the result 222 $cache = ( $html ) ? $html : '{{unknown}}'; 223 update_post_meta( $post_ID, $cachekey, $cache ); 219 if ( $html ) { 220 update_post_meta( $post_ID, $cachekey, $html ); 221 } elseif ( ! $cache ) { 222 update_post_meta( $post_ID, $cachekey, '{{unknown}}' ); 223 } 224 224 225 225 // If there was a result, return it 226 226 if ( $html ) {