Changeset 12153 for trunk/wp-includes/media.php
- Timestamp:
- 11/06/2009 02:22:23 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/media.php
r12136 r12153 928 928 add_filter( 'the_content', array(&$this, 'autoembed'), 8 ); 929 929 930 // After a post is saved, invalidate the oEmbed cache 931 add_action( 'save_post', array(&$this, 'delete_oembed_caches') ); 932 930 933 // After a post is saved, cache oEmbed items via AJAX 931 934 add_action( 'edit_form_advanced', array(&$this, 'maybe_run_ajax_cache') ); … … 1049 1052 if ( preg_match( $handler['regex'], $url, $matches ) && is_callable( $handler['callback'] ) ) { 1050 1053 if ( false !== $return = call_user_func( $handler['callback'], $matches, $attr, $url, $rawattr ) ) 1051 return $return;1054 return apply_filters( 'embed_handler_html', $return, $url, $attr ); 1052 1055 } 1053 1056 } … … 1071 1074 1072 1075 if ( !empty($cache) ) 1073 return $cache;1076 return apply_filters( 'embed_oembed_html', $cache, $url, $attr ); 1074 1077 } 1075 1078 … … 1087 1090 // If there was a result, return it 1088 1091 if ( $html ) 1089 return $html;1092 return apply_filters( 'embed_oembed_html', $html, $url, $attr ); 1090 1093 } 1091 1094 1092 1095 // Still unknown 1093 1096 return $this->maybe_make_link( $url ); 1097 } 1098 1099 /** 1100 * Delete all oEmbed caches. 1101 * 1102 * @param int $post_ID Post ID to delete the caches for. 1103 */ 1104 function delete_oembed_caches( $post_ID ) { 1105 $post_metas = get_post_custom_keys( $post_ID ); 1106 if ( empty($post_metas) ) 1107 return; 1108 foreach( (array) $post_metas as $post_meta_key ) { 1109 if ( '_oembed_' == substr( $post_meta_key, 0, 8 ) ) 1110 delete_post_meta( $post_ID, $post_meta_key ); 1111 } 1094 1112 } 1095 1113 … … 1102 1120 $post = get_post( $post_ID ); 1103 1121 1104 // post_type check is incase of "save_post" usage1105 1122 if ( empty($post->ID) || !in_array( $post->post_type, apply_filters( 'embed_cache_oembed_types', array( 'post', 'page' ) ) ) ) 1106 1123 return; 1107 1108 // Dump existing caches1109 $post_metas = get_post_custom_keys( $post->ID );1110 foreach( $post_metas as $post_meta_key ) {1111 if ( '_oembed_' == substr( $post_meta_key, 0, 8 ) )1112 delete_post_meta( $post->ID, $post_meta_key );1113 }1114 1124 1115 1125 // Trigger a caching … … 1162 1172 */ 1163 1173 function maybe_make_link( $url ) { 1164 return ( $this->linkifunknown ) ? '<a href="' . esc_attr($url) . '">' . esc_html($url) . '</a>' : $url; 1174 $output = ( $this->linkifunknown ) ? '<a href="' . esc_attr($url) . '">' . esc_html($url) . '</a>' : $url; 1175 return apply_filters( 'embed_maybe_make_link', $output, $url ); 1165 1176 } 1166 1177 }
Note: See TracChangeset
for help on using the changeset viewer.