From 2d2e825359754c310b229573e28db67a86893f0d Mon Sep 17 00:00:00 2001 From: azaozz Date: Tue, 18 Oct 2011 07:08:55 +0000 Subject: [PATCH] Add some more documentation and prevent fatal error if a plugin tries to use 'dfw' second time, see #17144 git-svn-id: http://svn.automattic.com/wordpress/trunk@18988 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/class-wp-editor.php | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/wp-includes/class-wp-editor.php b/wp-includes/class-wp-editor.php index 43da78938..60fadcf7f 100644 --- a/wp-includes/class-wp-editor.php +++ b/wp-includes/class-wp-editor.php @@ -5,6 +5,10 @@ * @package WordPress * @since 3.3 * + * NOTE: Do not instantiate this class directly. Please use the wp_editor() function that will include the file + * and instantiate the class if needed. If you want to extend this class use the 'init' or earlier action to do it + * and call wp_editor() as usual when you need to output the HTML. + * * Outputs the HTML and JavaScript for the WordPress editors, TinyMCE and Quicktags. * TinyMCE is loaded separately from other Javascript by using wp-tinymce.php. It outputs concatenated * pre-compressed version of the core and all default plugins. Additional plugins are loaded directly @@ -365,15 +369,15 @@ class WP_Editor { } if ( $set['dfw'] ) { - function replace_fullscreen(&$val) { - if ( $val == 'fullscreen' ) - $val = 'wp_fullscreen'; - } - - array_walk($mce_buttons, 'replace_fullscreen'); - array_walk($mce_buttons_2, 'replace_fullscreen'); - array_walk($mce_buttons_3, 'replace_fullscreen'); - array_walk($mce_buttons_4, 'replace_fullscreen'); + // replace the first 'fullscreen' with 'wp_fullscreen' + if ( ($key = array_search('fullscreen', $mce_buttons)) !== false ) + $mce_buttons[$key] = 'wp_fullscreen'; + elseif ( ($key = array_search('fullscreen', $mce_buttons_2)) !== false ) + $mce_buttons_2[$key] = 'wp_fullscreen'; + elseif ( ($key = array_search('fullscreen', $mce_buttons_3)) !== false ) + $mce_buttons_3[$key] = 'wp_fullscreen'; + elseif ( ($key = array_search('fullscreen', $mce_buttons_4)) !== false ) + $mce_buttons_4[$key] = 'wp_fullscreen'; } $mceInit = array (