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
This commit is contained in:
Scott Taylor 2014-06-26 01:04:32 +00:00
parent 7e9cf1d2c0
commit 95f3506532
2 changed files with 10 additions and 3 deletions

View File

@ -488,7 +488,7 @@ if ( post_type_supports($post_type, 'editor') ) {
<?php wp_editor( $post->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,

View File

@ -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 = '<span class="wp-media-buttons-icon"></span> ';
echo '<a href="#" id="insert-media-button" class="button insert-media add_media" data-editor="' . esc_attr( $editor_id ) . '" title="' . esc_attr__( 'Add Media' ) . '">' . $img . __( 'Add Media' ) . '</a>';
printf( '<a href="#" id="insert-media-button-%d" class="button insert-media add_media" data-editor="%s" title="%s">%s</a>',
$instance,
esc_attr( $editor_id ),
esc_attr__( 'Add Media' ),
$img . __( 'Add Media' )
);
/**
* Filter the legacy (pre-3.5.0) media buttons.
*