Skip to content

Commit b6b775e

Browse files
committed
Add some more documentation and prevent fatal error if a plugin tries to use 'dfw' second time, see #17144
git-svn-id: https://develop.svn.wordpress.org/trunk@18988 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 6bdce8d commit b6b775e

1 file changed

Lines changed: 13 additions & 9 deletions

File tree

wp-includes/class-wp-editor.php

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
* @package WordPress
66
* @since 3.3
77
*
8+
* NOTE: Do not instantiate this class directly. Please use the wp_editor() function that will include the file
9+
* and instantiate the class if needed. If you want to extend this class use the 'init' or earlier action to do it
10+
* and call wp_editor() as usual when you need to output the HTML.
11+
*
812
* Outputs the HTML and JavaScript for the WordPress editors, TinyMCE and Quicktags.
913
* TinyMCE is loaded separately from other Javascript by using wp-tinymce.php. It outputs concatenated
1014
* pre-compressed version of the core and all default plugins. Additional plugins are loaded directly
@@ -365,15 +369,15 @@ function editor_settings($editor_id, $set) {
365369
}
366370

367371
if ( $set['dfw'] ) {
368-
function replace_fullscreen(&$val) {
369-
if ( $val == 'fullscreen' )
370-
$val = 'wp_fullscreen';
371-
}
372-
373-
array_walk($mce_buttons, 'replace_fullscreen');
374-
array_walk($mce_buttons_2, 'replace_fullscreen');
375-
array_walk($mce_buttons_3, 'replace_fullscreen');
376-
array_walk($mce_buttons_4, 'replace_fullscreen');
372+
// replace the first 'fullscreen' with 'wp_fullscreen'
373+
if ( ($key = array_search('fullscreen', $mce_buttons)) !== false )
374+
$mce_buttons[$key] = 'wp_fullscreen';
375+
elseif ( ($key = array_search('fullscreen', $mce_buttons_2)) !== false )
376+
$mce_buttons_2[$key] = 'wp_fullscreen';
377+
elseif ( ($key = array_search('fullscreen', $mce_buttons_3)) !== false )
378+
$mce_buttons_3[$key] = 'wp_fullscreen';
379+
elseif ( ($key = array_search('fullscreen', $mce_buttons_4)) !== false )
380+
$mce_buttons_4[$key] = 'wp_fullscreen';
377381
}
378382

379383
$mceInit = array (

0 commit comments

Comments
 (0)