From b1f720c616e64fafc0392934b87da87790c37af9 Mon Sep 17 00:00:00 2001 From: Daryl Koopersmith Date: Tue, 20 Nov 2012 02:35:30 +0000 Subject: [PATCH] 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 --- wp-admin/includes/media.php | 2 ++ wp-admin/js/media-upload.js | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/wp-admin/includes/media.php b/wp-admin/includes/media.php index 478dfdd768..dce7e68fb6 100644 --- a/wp-admin/includes/media.php +++ b/wp-admin/includes/media.php @@ -391,6 +391,8 @@ function media_buttons($editor_id = 'content') { $img = ' '; + error_log( 'MEDIA_BUTTONS ' . print_r( func_get_args(), true ) ); + echo '' . $img . __( 'Add Media' ) . ''; echo '' . sprintf( $context, $img ) . ''; diff --git a/wp-admin/js/media-upload.js b/wp-admin/js/media-upload.js index f7528b1310..c33b7ef223 100644 --- a/wp-admin/js/media-upload.js +++ b/wp-admin/js/media-upload.js @@ -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 );