Ticket #15490: 15490.diff
File 15490.diff, 5.3 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
2081 2081 $screen_id = sanitize_key($_POST['screenid']); 2082 2082 else 2083 2083 $screen_id = 'site'; 2084 2084 2085 2085 if ( ! empty($_POST['data']) ) { 2086 2086 $data = (array) $_POST['data']; 2087 2087 // todo: how much to sanitize and preset and what to leave to be accessed from $data or $_POST..? … … 2107 2107 2108 2108 wp_send_json($response); 2109 2109 } 2110 2111 /** 2112 * Handles our oEmbed ajax request 2113 */ 2114 function wp_ajax_media_oembed() { 2115 2116 // @TODO verify our nonce 2117 // if ( ! ( isset( $_REQUEST['media_ajax_data'], $_REQUEST['oembed_url'] ) && wp_verify_nonce( $_REQUEST['media_ajax_data'], 'ajax_nonce' ) ) ) 2118 // die(); 2119 2120 // sanitize our search string 2121 $oembed_string = sanitize_text_field( $_REQUEST['oembed_url'] ); 2122 2123 $return = false; 2124 2125 if ( !empty( $oembed_string ) ) { 2126 global $post, $wp_embed; 2127 2128 $oembed_url = esc_url( $oembed_string ); 2129 // Post ID is needed to check for embeds 2130 $post = get_post( isset( $_REQUEST['post_id'] ) ? $_REQUEST['post_id'] : 0 ); 2131 // ping WordPress for an embed 2132 $check_embed = $wp_embed->run_shortcode( '[embed]'. $oembed_url .'[/embed]' ); 2133 // fallback that WordPress creates when no oEmbed was found 2134 $fallback = $wp_embed->maybe_make_link( $oembed_url ); 2135 2136 if ( $check_embed && $check_embed != $fallback ) 2137 // Embed data 2138 $return = $check_embed; 2139 else 2140 // no oEmbeds were found 2141 $return = false; 2142 } 2143 2144 // send back our encoded data 2145 echo json_encode( array( 'result' => $return ) ); 2146 die(); 2147 }