From 0226a93d0aa84db1d03d7f6c8f92047c339cb886 Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Mon, 30 Dec 2013 19:17:11 +0000 Subject: [PATCH] Set wpActiveEditor as soon as any editor associated button is clicked, including Add Media, switching Text to Visual, etc. Fixes #26747. Built from https://develop.svn.wordpress.org/trunk@26881 git-svn-id: http://core.svn.wordpress.org/trunk@26764 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/class-wp-editor.php | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/wp-includes/class-wp-editor.php b/wp-includes/class-wp-editor.php index 7da0c55c21..264469d1cb 100644 --- a/wp-includes/class-wp-editor.php +++ b/wp-includes/class-wp-editor.php @@ -811,15 +811,28 @@ final class _WP_Editors { } } } - }()); + if ( typeof jQuery !== 'undefined' ) { + jQuery('.wp-editor-wrap').on( 'click.wp-editor', function() { + if ( this.id ) { + window.wpActiveEditor = this.id.slice( 3, -5 ); + } + }); + } else { + for ( qtId in tinyMCEPreInit.qtInit ) { + document.getElementById( 'wp-' + qtId + '-wrap' ).onclick = function() { + window.wpActiveEditor = this.id.slice( 3, -5 ); + } + } + } + }());