Changeset 18766 for trunk/wp-includes/class-wp-editor.php
- Timestamp:
- 09/24/2011 04:43:19 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/class-wp-editor.php
r18753 r18766 1 1 <?php 2 2 /** 3 * Adds the TinyMCEeditor used on the Write and Edit screens.3 * Adds the WordPress editor used on the Write and Edit screens. 4 4 * 5 5 * @package WordPress … … 17 17 var $qt_settings = array(); 18 18 var $plugins = array(); 19 var $qt_buttons = array(); 19 20 var $mce_locale; 20 21 var $ext_plugins; … … 49 50 'editor_class' => '', // add extra class(es) to the editor textarea 50 51 'teeny' => false, // output the minimal editor config used in Press This 51 'dfw' => false, // replace the default fullscreen with DFW (needs specific css)52 'dfw' => false, // replace the default fullscreen with DFW (needs specific DOM elements and css) 52 53 'tinymce' => true, // load TinyMCE, can be used to pass settings directly to TinyMCE using an array() 53 54 'quicktags' => true // load Quicktags, can be used to pass settings directly to Quicktags using an array() … … 65 66 $set['media_buttons'] = false; 66 67 67 if ( $this-> can_richedit && $this->this_quicktags && $this->this_tinymce ) {68 if ( $this->this_quicktags && $this->this_tinymce ) { 68 69 $switch_class = 'html-active'; 69 70 … … 99 100 } 100 101 101 $the_editor = apply_filters('the_editor', '<div id="wp-' . $editor_id . '-editor-container" class="wp-editor-container"><textarea' . $editor_class . $rows . $tabindex . ' "cols="40" name="' . $set['textarea_name'] . '" id="' . $editor_id . '">%s</textarea></div>');102 $the_editor = apply_filters('the_editor', '<div id="wp-' . $editor_id . '-editor-container" class="wp-editor-container"><textarea' . $editor_class . $rows . $tabindex . ' cols="40" name="' . $set['textarea_name'] . '" id="' . $editor_id . '">%s</textarea></div>'); 102 103 $content = apply_filters('the_editor_content', $content); 103 104 … … 115 116 } 116 117 117 function editor_settings($editor_id, $set tings) {118 function editor_settings($editor_id, $set) { 118 119 global $editor_styles; 119 120 $first_run = false; 120 121 121 122 if ( $this->this_quicktags ) { 122 $qtbuttons = apply_filters( 'quicktags_buttons', array(), $editor_id ); 123 $qtbuttons_disabled = apply_filters( 'quicktags_disabled_buttons', array(), $editor_id ); 123 $qt_buttons = array(); 124 124 125 125 $qtInit = array( 126 126 'id' => $editor_id, 127 'buttons' => implode($qtbuttons, ','),128 'disabled_buttons' => implode($qtbuttons_disabled, ',')127 'buttons' => '', 128 'disabled_buttons' => '' 129 129 ); 130 130 131 if ( is_array($settings['quicktags']) ) 132 $qtInit = array_merge($qtInit, $settings['quicktags']); 131 if ( is_array($set['quicktags']) ) 132 $qtInit = array_merge($qtInit, $set['quicktags']); 133 134 $qtInit = apply_filters( 'quicktags_settings', $qtInit, $editor_id ); 133 135 134 136 $this->qt_settings[$editor_id] = $qtInit; 137 138 if ( !empty($qtInit['buttons']) || !empty($qtInit['disabled_buttons']) ) { 139 if ( strpos( ',' . $qtInit['buttons'] . ',', ',link,' ) !== false ) 140 $qt_buttons[] = 'link'; 141 142 if ( strpos( ',' . $qtInit['disabled_buttons'] . ',', ',link,' ) !== false ) 143 $qt_buttons = array(); 144 } else { 145 $qt_buttons[] = 'link'; 146 } 147 148 if ( $set['dfw'] ) 149 $qt_buttons[] = 'fullscreen'; 150 151 $this->qt_buttons = array_merge( $this->qt_buttons, $qt_buttons ); 135 152 } 136 153 … … 144 161 $first_run = true; 145 162 146 if ( $set tings['teeny'] ) {163 if ( $set['teeny'] ) { 147 164 $this->plugins = $plugins = apply_filters( 'teeny_mce_plugins', array('inlinepopups', 'fullscreen', 'wordpress', 'wplink', 'wpdialogs'), $editor_id ); 148 165 $ext_plugins = ''; … … 193 210 $strings = $str1 = $str2 = ''; 194 211 if ( ! in_array($name, $loaded_langs) ) { 195 $path = str_replace( WP_CONTENT_URL, '', $plugurl );212 $path = str_replace( content_url(), '', $plugurl ); 196 213 $path = WP_CONTENT_DIR . $path . '/langs/'; 197 214 … … 231 248 } 232 249 233 if ( $set tings['dfw'] )250 if ( $set['dfw'] ) 234 251 $plugins[] = 'wpfullscreen'; 235 252 … … 326 343 } 327 344 328 if ( $set tings['teeny'] ) {345 if ( $set['teeny'] ) { 329 346 $mce_buttons = apply_filters( 'teeny_mce_buttons', array('bold', 'italic', 'underline', 'blockquote', 'separator', 'strikethrough', 'bullist', 'numlist', 'justifyleft', 'justifycenter', 'justifyright', 'undo', 'redo', 'link', 'unlink', 'fullscreen'), $editor_id ); 330 347 $mce_buttons_2 = $mce_buttons_3 = $mce_buttons_4 = array(); … … 336 353 } 337 354 338 if ( $set tings['dfw'] ) {355 if ( $set['dfw'] ) { 339 356 function replace_fullscreen(&$val) { 340 357 if ( $val == 'fullscreen' ) … … 350 367 $mceInit = array ( 351 368 'elements' => $editor_id, 352 'wpautop' => (bool) $set tings['wpautop'],353 'remove_linebreaks' => (bool) $set tings['wpautop'],354 'apply_source_formatting' => (bool) !$set tings['wpautop'],369 'wpautop' => (bool) $set['wpautop'], 370 'remove_linebreaks' => (bool) $set['wpautop'], 371 'apply_source_formatting' => (bool) !$set['wpautop'], 355 372 'theme_advanced_buttons1' => implode($mce_buttons, ','), 356 373 'theme_advanced_buttons2' => implode($mce_buttons_2, ','), … … 362 379 $mceInit = array_merge($this->first_init, $mceInit); 363 380 364 if ( is_array($set tings['tinymce']) )365 $mceInit = array_merge($mceInit, $set tings['tinymce']);381 if ( is_array($set['tinymce']) ) 382 $mceInit = array_merge($mceInit, $set['tinymce']); 366 383 367 384 // For people who really REALLY know what they're doing with TinyMCE … … 369 386 // Setting "valid_elements", "invalid_elements" and "extended_valid_elements" can be done through this filter. 370 387 // Best is to use the default cleanup by not specifying valid_elements, as TinyMCE contains full set of XHTML 1.0. 371 if ( $set tings['teeny'] ) {388 if ( $set['teeny'] ) { 372 389 $mceInit = apply_filters('teeny_mce_before_init', $mceInit, $editor_id); 373 390 } else { … … 423 440 424 441 function enqueue_scripts() { 425 wp_enqueue_script('quicktags');426 442 wp_enqueue_script('word-count'); 427 wp_enqueue_script('wplink');428 wp_enqueue_script('editor');429 443 wp_enqueue_style('editor-buttons'); 430 444 431 wp_enqueue_script('wpdialogs-popup'); 432 wp_enqueue_style('wp-jquery-ui-dialog'); 433 434 if ( in_array('wpfullscreen', $this->plugins, true) ) 445 if ( $this->this_tinymce ) 446 wp_enqueue_script('editor'); 447 448 if ( $this->this_quicktags ) 449 wp_enqueue_script('quicktags'); 450 451 if ( in_array('wplink', $this->plugins, true) || in_array('link', $this->qt_buttons, true) ) { 452 wp_enqueue_script('wplink'); 453 wp_enqueue_script('wpdialogs-popup'); 454 wp_enqueue_style('wp-jquery-ui-dialog'); 455 } 456 457 if ( in_array('wpfullscreen', $this->plugins, true) || in_array('fullscreen', $this->qt_buttons, true) ) 435 458 wp_enqueue_script('wp-fullscreen'); 436 459 … … 465 488 foreach ( $this->mce_settings as $editor_id => $init ) { 466 489 $options = $this->_parse_init( $init ); 467 $mceInit .= "'$editor_id':{$options}, \n";468 } 469 $mceInit = '{' . trim($mceInit, ' \n,') . '}';490 $mceInit .= "'$editor_id':{$options},"; 491 } 492 $mceInit = '{' . trim($mceInit, ',') . '}'; 470 493 } else { 471 494 $mceInit = '{}'; … … 475 498 foreach ( $this->qt_settings as $editor_id => $init ) { 476 499 $options = $this->_parse_init( $init ); 477 $qtInit .= "'$editor_id':{$options}, \n";478 } 479 $qtInit = '{' . trim($qtInit, ' \n,') . '}';500 $qtInit .= "'$editor_id':{$options},"; 501 } 502 $qtInit = '{' . trim($qtInit, ',') . '}'; 480 503 } else { 481 504 $qtInit = '{}'; … … 564 587 <?php 565 588 566 if ( in_array( 'wplink', $this->plugins, true) )589 if ( in_array('wplink', $this->plugins, true) || in_array('link', $this->qt_buttons, true) ) 567 590 $this->wp_link_dialog(); 568 591 569 if ( in_array( 'wpfullscreen', $this->plugins, true) )592 if ( in_array('wpfullscreen', $this->plugins, true) || in_array('fullscreen', $this->qt_buttons, true) ) 570 593 $this->wp_fullscreen_html(); 571 594
Note: See TracChangeset
for help on using the changeset viewer.