From 95f350653201244e87eaf5daaa3651fa8a6704af Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Thu, 26 Jun 2014 01:04:32 +0000 Subject: [PATCH] In `media_buttons()`, add a static var `$instance` to increment the `id` attribute of `insert-media-button-%d` on each call. Props ericlewis. Fixes #28090. git-svn-id: https://develop.svn.wordpress.org/trunk@28837 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/edit-form-advanced.php | 2 +- src/wp-admin/includes/media.php | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/wp-admin/edit-form-advanced.php b/src/wp-admin/edit-form-advanced.php index 8dc481508f..84fcf601fd 100644 --- a/src/wp-admin/edit-form-advanced.php +++ b/src/wp-admin/edit-form-advanced.php @@ -488,7 +488,7 @@ if ( post_type_supports($post_type, 'editor') ) { post_content, 'content', array( 'dfw' => true, 'drag_drop_upload' => true, - 'tabfocus_elements' => 'insert-media-button,save-post', + 'tabfocus_elements' => 'insert-media-button-1,save-post', 'editor_height' => 360, 'tinymce' => array( 'resize' => false, diff --git a/src/wp-admin/includes/media.php b/src/wp-admin/includes/media.php index bc27afd751..fec570eb8a 100644 --- a/src/wp-admin/includes/media.php +++ b/src/wp-admin/includes/media.php @@ -514,6 +514,9 @@ document.body.className = document.body.className.replace('no-js', 'js'); * @param string $editor_id */ function media_buttons($editor_id = 'content') { + static $instance = 0; + $instance++; + $post = get_post(); if ( ! $post && ! empty( $GLOBALS['post_ID'] ) ) $post = $GLOBALS['post_ID']; @@ -524,8 +527,12 @@ function media_buttons($editor_id = 'content') { $img = ' '; - echo '' . $img . __( 'Add Media' ) . ''; - + printf( '%s', + $instance, + esc_attr( $editor_id ), + esc_attr__( 'Add Media' ), + $img . __( 'Add Media' ) + ); /** * Filter the legacy (pre-3.5.0) media buttons. *