Skip to content

Commit 13c72ba

Browse files
committed
Fix enqueueing of the right scripts when more than one instance of the editor, fix inserting images in full screen mode, see #17144
git-svn-id: https://develop.svn.wordpress.org/trunk@18799 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 2a7b8b4 commit 13c72ba

4 files changed

Lines changed: 26 additions & 11 deletions

File tree

wp-admin/js/media-upload.dev.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@ function send_to_editor(h) {
1212
} else if ( !qt ) {
1313
return false;
1414
}
15-
}
16-
17-
if ( !ed && mce && wpActiveEditor )
18-
ed = tinymce.get(wpActiveEditor);
15+
} else {
16+
if ( mce && tinymce.activeEditor && (tinymce.activeEditor.id == 'mce_fullscreen' || tinymce.activeEditor.id == 'wp_mce_fullscreen') )
17+
ed = tinymce.activeEditor;
18+
else
19+
ed = tinymce.get(wpActiveEditor);
20+
}
1921

2022
if ( ed && !ed.isHidden() ) {
2123
// restore caret position on IE

wp-admin/js/media-upload.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

wp-includes/class-wp-editor.php

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ class WP_Editor {
2525
var $first_init;
2626
var $this_tinymce = false;
2727
var $this_quicktags = false;
28+
var $has_tinymce = false;
29+
var $has_quicktags = false;
30+
var $has_medialib = false;
2831

2932
function __construct() {
3033
$this->can_richedit = user_can_richedit();
@@ -67,6 +70,7 @@ function editor( $content, $editor_id, $settings = array() ) {
6770

6871
if ( $this->this_quicktags && $this->this_tinymce ) {
6972
$switch_class = 'html-active';
73+
$this->has_tinymce = $this->has_quicktags = true;
7074

7175
if ( 'html' == $this->default_editor ) {
7276
add_filter('the_editor_content', 'wp_htmledit_pre');
@@ -77,6 +81,12 @@ function editor( $content, $editor_id, $settings = array() ) {
7781

7882
$buttons .= '<a id="' . $editor_id . '-html" class="hide-if-no-js wp-switch-editor switch-html" onclick="switchEditors.go(this);return false;">' . __('HTML') . "</a>\n";
7983
$buttons .= '<a id="' . $editor_id . '-tmce" class="hide-if-no-js wp-switch-editor switch-tmce" onclick="switchEditors.go(this);return false;">' . __('Visual') . "</a>\n";
84+
} else {
85+
if ( $this->this_tinymce )
86+
$this->has_tinymce = true;
87+
88+
if ( $this->this_quicktags )
89+
$this->has_quicktags = true;
8090
}
8191

8292
echo '<div id="wp-' . $editor_id . '-wrap" class="wp-editor-wrap ' . $switch_class . '">';
@@ -89,6 +99,8 @@ function editor( $content, $editor_id, $settings = array() ) {
8999
echo $buttons;
90100

91101
if ( $set['media_buttons'] ) {
102+
$this->has_medialib = true;
103+
92104
if ( !function_exists('media_buttons') )
93105
include(ABSPATH . 'wp-admin/includes/media.php');
94106

@@ -442,10 +454,10 @@ function enqueue_scripts() {
442454
wp_enqueue_script('word-count');
443455
wp_enqueue_style('editor-buttons');
444456

445-
if ( $this->this_tinymce )
457+
if ( $this->has_tinymce )
446458
wp_enqueue_script('editor');
447459

448-
if ( $this->this_quicktags )
460+
if ( $this->has_quicktags )
449461
wp_enqueue_script('quicktags');
450462

451463
if ( in_array('wplink', $this->plugins, true) || in_array('link', $this->qt_buttons, true) ) {
@@ -457,8 +469,10 @@ function enqueue_scripts() {
457469
if ( in_array('wpfullscreen', $this->plugins, true) || in_array('fullscreen', $this->qt_buttons, true) )
458470
wp_enqueue_script('wp-fullscreen');
459471

460-
add_thickbox();
461-
wp_enqueue_script('media-upload');
472+
if ( $this->has_medialib ) {
473+
add_thickbox();
474+
wp_enqueue_script('media-upload');
475+
}
462476
}
463477

464478
function editor_js() {
@@ -800,4 +814,3 @@ function wp_link_dialog() {
800814
}
801815
}
802816

803-

wp-includes/script-loader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ function wp_default_scripts( &$scripts ) {
276276

277277
$scripts->add( 'word-count', "/wp-admin/js/word-count$suffix.js", array( 'jquery' ), '20110515', 1 );
278278

279-
$scripts->add( 'media-upload', "/wp-admin/js/media-upload$suffix.js", array( 'thickbox' ), '20110922', 1 );
279+
$scripts->add( 'media-upload', "/wp-admin/js/media-upload$suffix.js", array( 'thickbox' ), '20110927', 1 );
280280

281281
if ( is_admin() ) {
282282
$scripts->add( 'ajaxcat', "/wp-admin/js/cat$suffix.js", array( 'wp-lists' ), '20090102' );

0 commit comments

Comments
 (0)