From f3dd19c6e2130acca10ca7a0443f5bf8c4128a90 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Thu, 17 Sep 2015 05:55:25 +0000 Subject: [PATCH] Media: In `wp_ajax_send_attachment_to_editor()`, the fallback logic for `$html` should be tucked into an `else` statement so it isn't run needlessly and overwritten. Props tychay. Fixes #32072. Built from https://develop.svn.wordpress.org/trunk@34260 git-svn-id: http://core.svn.wordpress.org/trunk@34224 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/ajax-actions.php | 18 ++++++++++-------- wp-includes/version.php | 2 +- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/wp-admin/includes/ajax-actions.php b/wp-admin/includes/ajax-actions.php index 5f8c01f875..fc8bed3829 100644 --- a/wp-admin/includes/ajax-actions.php +++ b/wp-admin/includes/ajax-actions.php @@ -2491,13 +2491,10 @@ function wp_ajax_send_attachment_to_editor() { } } - $rel = $url = ''; - $html = isset( $attachment['post_title'] ) ? $attachment['post_title'] : ''; - if ( ! empty( $attachment['url'] ) ) { - $url = $attachment['url']; - if ( strpos( $url, 'attachment_id') || get_attachment_link( $id ) == $url ) - $rel = ' rel="attachment wp-att-' . $id . '"'; - $html = '' . $html . ''; + $rel = ''; + $url = empty( $attachment['url'] ) ? '' : $attachment['url']; + if ( strpos( $url, 'attachment_id') || get_attachment_link( $id ) == $url ) { + $rel = ' rel="attachment wp-att-' . $id . '"'; } remove_filter( 'media_send_to_editor', 'image_media_send_to_editor' ); @@ -2514,9 +2511,14 @@ function wp_ajax_send_attachment_to_editor() { } $title = ''; // We no longer insert title tags into tags, as they are redundant. - $html = get_image_send_to_editor( $id, $caption, $title, $align, $url, (bool) $rel, $size, $alt ); + $html = get_image_send_to_editor( $id, $caption, $title, $align, $url, $rel, $size, $alt ); } elseif ( wp_attachment_is( 'video', $post ) || wp_attachment_is( 'audio', $post ) ) { $html = stripslashes_deep( $_POST['html'] ); + } else { + $html = isset( $attachment['post_title'] ) ? $attachment['post_title'] : ''; + if ( ! empty( $url ) ) { + $html = '' . $html . ''; + } } /** This filter is documented in wp-admin/includes/media.php */ diff --git a/wp-includes/version.php b/wp-includes/version.php index 67385f453e..1f73231570 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.4-alpha-34259'; +$wp_version = '4.4-alpha-34260'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.