Media: Improve media buttons on the front end.

* Use a less specific selector (the body, actually) to delegate opening the media dialog.
* Allow the editor ID to be the empty string so the `media_buttons` action can be called without arguments.

see #22284, #21390.


git-svn-id: http://core.svn.wordpress.org/trunk@22699 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Daryl Koopersmith 2012-11-20 02:35:30 +00:00
parent ded6e7ae57
commit b1f720c616
2 changed files with 4 additions and 2 deletions

View File

@ -391,6 +391,8 @@ function media_buttons($editor_id = 'content') {
$img = '<span class="wp-media-buttons-icon"></span> ';
error_log( 'MEDIA_BUTTONS ' . print_r( func_get_args(), true ) );
echo '<a href="#" class="button insert-media add_media" data-editor="' . esc_attr( $editor_id ) . '" title="' . esc_attr__( 'Add Media' ) . '">' . $img . __( 'Add Media' ) . '</a>';
echo '<a href="' . esc_url( get_upload_iframe_src() ) . '" class="thickbox add_media" id="' . esc_attr( $editor_id ) . '-add_media" title="' . esc_attr__( 'Add Media' ) . '" onclick="return false;">' . sprintf( $context, $img ) . '</a>';

View File

@ -434,7 +434,7 @@ var tb_position;
},
init: function() {
$('#wpbody').on('click', '.insert-media', function( event ) {
$(document.body).on('click', '.insert-media', function( event ) {
var $this = $(this),
editor = $this.data('editor'),
workflow;
@ -448,7 +448,7 @@ var tb_position;
// See: http://core.trac.wordpress.org/ticket/22445
$this.blur();
if ( ! editor )
if ( ! _.isString( editor ) )
return;
workflow = wp.media.editor.get( editor );