Ticket #15490: 15490.2.diff
File 15490.2.diff, 5.0 KB (added by , 12 years ago) |
---|
-
wp-includes/js/media-views.js
4283 4283 */ 4284 4284 media.view.EmbedLink = media.view.Settings.extend({ 4285 4285 className: 'embed-link-settings', 4286 template: media.template('embed-link-settings') 4286 template: media.template('embed-link-settings'), 4287 4288 initialize: function() { 4289 this.model.on( 'change:url', this.updateoEmbed, this ); 4290 }, 4291 4292 updateoEmbed: function() { 4293 var oembedURL = this.model.get('url'), 4294 context = this.$el, 4295 mainInput = context.parents('.media-embed'), 4296 postID = media.view.settings.post.id; 4297 4298 $('.setting.title', context).show(); 4299 $('.embed-container', context).hide(); 4300 // clear out previous results 4301 $('.embed-container .embed-preview', context).html(''); 4302 4303 // only proceed with embed if the field contains more than 6 characters 4304 if (oembedURL.length < 6) 4305 return; 4306 4307 // show spinner 4308 $('.spinner', mainInput).show(); 4309 4310 setTimeout(function () { 4311 // check if they haven't typed in 500 ms 4312 if ( $('.embed-url input', mainInput).val() != oembedURL ) 4313 return; 4314 4315 $.ajax({ 4316 type : 'post', 4317 dataType : 'json', 4318 url : ajaxurl, 4319 data : { 4320 'action': 'media-oembed', 4321 'oembed_url': oembedURL, 4322 'post_id': postID 4323 // 'media_ajax_nonce': window.media_ajax_data.ajax_nonce 4324 }, 4325 success: function (response) { 4326 // hide spinner 4327 $('.spinner', mainInput).hide(); 4328 // if we have a response id 4329 if (typeof response.result !== 'undefined' && response.result) { 4330 // show our embed wrapper 4331 $('.embed-container', context).show(); 4332 // hide title input 4333 $('.setting.title', context).hide(); 4334 // and populate our results from ajax response 4335 $('.embed-container .embed-preview', context).html(response.result); 4336 } 4337 } 4338 }); 4339 }, 500); 4340 } 4341 4287 4342 }); 4288 4343 4289 4344 /** -
wp-includes/media-template.php
375 375 </script> 376 376 377 377 <script type="text/html" id="tmpl-embed-link-settings"> 378 <label class="setting ">378 <label class="setting title"> 379 379 <span><?php _e('Title'); ?></span> 380 380 <input type="text" class="alignment" data-setting="title" /> 381 381 </label> 382 <div class="embed-container" style="display: none;"> 383 <div class="embed-preview"> 384 </div> 385 <label class="setting embed-width"> 386 <span><?php _e('Width'); ?></span> 387 <input type="text" class="alignment" data-setting="embed-width" /> 388 </label> 389 <label class="setting embed-height"> 390 <span><?php _e('Height'); ?></span> 391 <input type="text" class="alignment" data-setting="embed-height" /> 392 </label> 393 </div> 382 394 </script> 383 395 384 396 <script type="text/html" id="tmpl-embed-image-settings"> -
wp-admin/admin-ajax.php
56 56 'save-widget', 'set-post-thumbnail', 'date_format', 'time_format', 'wp-fullscreen-save-post', 57 57 'wp-remove-post-lock', 'dismiss-wp-pointer', 'upload-attachment', 'get-attachment', 58 58 'query-attachments', 'save-attachment', 'save-attachment-compat', 'send-link-to-editor', 59 'send-attachment-to-editor', 'save-attachment-order', 'heartbeat' 59 'send-attachment-to-editor', 'save-attachment-order', 'heartbeat', 'media-oembed' 60 60 ); 61 61 62 62 // Register core Ajax calls. -
wp-admin/includes/ajax-actions.php
2269 2269 echo json_encode( $alltherevisions ); 2270 2270 exit(); 2271 2271 } 2272 2273 /** 2274 * Handles our oEmbed ajax request 2275 */ 2276 function wp_ajax_media_oembed() { 2277 2278 // @TODO verify our nonce 2279 // if ( ! ( isset( $_REQUEST['media_ajax_data'], $_REQUEST['oembed_url'] ) && wp_verify_nonce( $_REQUEST['media_ajax_data'], 'ajax_nonce' ) ) ) 2280 // die(); 2281 2282 // sanitize our search string 2283 $oembed_string = sanitize_text_field( $_REQUEST['oembed_url'] ); 2284 2285 $return = false; 2286 2287 if ( !empty( $oembed_string ) ) { 2288 global $post, $wp_embed; 2289 2290 $oembed_url = esc_url( $oembed_string ); 2291 // Post ID is needed to check for embeds 2292 $post = get_post( isset( $_REQUEST['post_id'] ) ? $_REQUEST['post_id'] : 0 ); 2293 // ping WordPress for an embed 2294 $check_embed = $wp_embed->run_shortcode( '[embed]'. $oembed_url .'[/embed]' ); 2295 // fallback that WordPress creates when no oEmbed was found 2296 $fallback = $wp_embed->maybe_make_link( $oembed_url ); 2297 2298 if ( $check_embed && $check_embed != $fallback ) 2299 // Embed data 2300 $return = $check_embed; 2301 else 2302 // no oEmbeds were found 2303 $return = false; 2304 } 2305 2306 // send back our encoded data 2307 echo json_encode( array( 'result' => $return ) ); 2308 die(); 2309 }