Changeset 28919 for trunk/src/wp-admin/includes/ajax-actions.php
- Timestamp:
- 06/30/2014 05:48:16 AM (12 years ago)
- File:
-
- 1 edited
-
trunk/src/wp-admin/includes/ajax-actions.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/ajax-actions.php
r28892 r28919 2548 2548 } 2549 2549 2550 if ( empty( $_POST['shortcode'] ) || ! current_user_can( 'read_post', $post->ID ) ) { 2551 wp_send_json_error(); 2552 } 2553 2550 if ( empty( $_POST['shortcode'] ) || ! current_user_can( 'edit_post', $post->ID ) ) { 2551 wp_send_json_error(); 2552 } 2553 2554 $shortcode = $_POST['shortcode']; 2555 $url = str_replace( '[embed]', '', str_replace( '[/embed]', '', $shortcode ) ); 2556 $parsed = false; 2554 2557 setup_postdata( $post ); 2555 2558 2556 // If the URL cannot be embedded, return an eror message with wp_send_json_error() 2557 add_filter( 'embed_maybe_make_link', '_wpview_embed_error', 20, 2 ); 2558 2559 $parsed = $wp_embed->run_shortcode( $_POST['shortcode'] ); 2559 $wp_embed->return_false_on_fail = true; 2560 2561 if ( is_ssl() && preg_match( '%^\\[embed\\]http://%i', $shortcode ) ) { 2562 // Admin is ssl and the user pasted non-ssl URL. 2563 // Check if the provider supports ssl embeds and use that for the preview. 2564 $ssl_shortcode = preg_replace( '%^\\[embed\\]http://%i', '[embed]https://', $shortcode ); 2565 $parsed = $wp_embed->run_shortcode( $ssl_shortcode ); 2566 2567 if ( ! $parsed ) { 2568 $no_ssl_support = true; 2569 } 2570 } 2571 2572 if ( ! $parsed ) { 2573 $parsed = $wp_embed->run_shortcode( $shortcode ); 2574 } 2575 2576 if ( ! $parsed ) { 2577 wp_send_json_error( array( 2578 'type' => 'not-embeddable', 2579 'message' => sprintf( __( '%s failed to embed.' ), '<code>' . esc_url( $url ) . '</code>' ), 2580 ) ); 2581 } 2582 2583 // TODO: needed? 2560 2584 $parsed = do_shortcode( $parsed ); 2561 2585 2586 if ( ! empty( $no_ssl_support ) || ( is_ssl() && ( preg_match( '%<(iframe|script|embed) [^>]*src="http://%', $parsed ) || 2587 preg_match( '%<link [^>]*href="http://%', $parsed ) ) ) ) { 2588 // Admin is ssl and the embed is not. Iframes, scripts, and other "active content" will be blocked. 2589 wp_send_json_error( array( 2590 'type' => 'not-ssl', 2591 'message' => sprintf( __( 'Preview not available. %s cannot be embedded securely.' ), '<code>' . esc_url( $url ) . '</code>' ), 2592 ) ); 2593 } 2594 2562 2595 wp_send_json_success( $parsed ); 2563 2596 }
Note: See TracChangeset
for help on using the changeset viewer.