@@ -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-
0 commit comments