Ticket #19320: 19320.patch
File 19320.patch, 6.5 KB (added by , 13 years ago) |
---|
-
wp-admin/includes/deprecated.php
21 21 function tinymce_include() { 22 22 _deprecated_function( __FUNCTION__, '2.1', 'wp_editor()' ); 23 23 24 wp_ editor('', 'content');24 wp_tiny_mce(); 25 25 } 26 26 27 27 /** … … 708 708 * @deprecated Use wp_editor() 709 709 * @see wp_editor() 710 710 */ 711 function wp_tiny_mce( ) {711 function wp_tiny_mce( $teeny = false, $settings = false ) { 712 712 _deprecated_function( __FUNCTION__, '3.3', 'wp_editor()' ); 713 713 714 wp_editor('', 'content'); 714 global $wp_editor; 715 static $num = 1; 716 717 if ( !is_a($wp_editor, 'WP_Editor') ) { 718 if ( !class_exists('WP_Editor') ) 719 require_once( ABSPATH . WPINC . '/class-wp-editor.php' ); 720 721 $wp_editor = new WP_Editor; 722 } 723 724 $editor_id = 'content' . $num; 725 ++$num; 726 727 $set = array( 728 'teeny' => $teeny, 729 'tinymce' => $settings ? $settings : true, 730 'quicktags' => false 731 ); 732 733 $set = $wp_editor->parse_settings($editor_id, $set); 734 $wp_editor->editor_settings($editor_id, $set); 715 735 } 716 736 717 737 /** … … 853 873 function type_url_form_file() { 854 874 __deprecated_function( __FUNCTION__, '3.3', "wp_media_insert_url_form('file')" ); 855 875 return wp_media_insert_url_form( 'file' ); 856 } 857 No newline at end of file 876 } -
wp-includes/class-wp-editor.php
1 1 <?php 2 2 /** 3 * Adds the WordPress editorused on the Write and Edit screens.3 * Facilitates adding of the WordPress editor as used on the Write and Edit screens. 4 4 * 5 5 * @package WordPress 6 6 * @since 3.3 7 7 * 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 * 12 * Outputs the HTML and JavaScript for the WordPress editors, TinyMCE and Quicktags. 13 * TinyMCE is loaded separately from other Javascript by using wp-tinymce.php. It outputs concatenated 14 * pre-compressed version of the core and all default plugins. Additional plugins are loaded directly 15 * by TinyMCE using non-blocking method. 8 * Private, not included by default. See wp_editor() in wp-includes/general-template.php. 16 9 */ 17 10 18 11 class WP_Editor { … … 32 25 var $has_tinymce = false; 33 26 var $has_quicktags = false; 34 27 var $has_medialib = false; 28 var $editor_buttons_css = true; 35 29 36 30 function __construct() { 37 31 $this->can_richedit = user_can_richedit(); 38 32 $this->default_editor = $this->wp_default_editor(); 39 33 } 40 34 41 /** 42 * Outputs the HTML and enqueues the JavaScript for a single instance of the editor. 43 * 44 * @param string $content The initial content of the editor. 45 * @param string $editor_id ID for the textarea and TinyMCE and Quicktags instances (can contain only ASCII letters and numbers). 46 * @param array $settings See below for description. 47 */ 48 function editor( $content, $editor_id, $settings = array() ) { 49 35 function parse_settings($editor_id, $settings) { 50 36 $set = wp_parse_args( $settings, array( 51 37 'wpautop' => true, // use wpautop? 52 38 'media_buttons' => true, // show insert/upload button(s) … … 63 49 64 50 $this->this_tinymce = !empty($set['tinymce']) && $this->can_richedit; 65 51 $this->this_quicktags = !empty($set['quicktags']); 52 53 if ( $this->this_tinymce ) 54 $this->has_tinymce = true; 55 56 if ( $this->this_quicktags ) 57 $this->has_quicktags = true; 58 59 return $set; 60 } 61 62 /** 63 * Outputs the HTML for a single instance of the editor. 64 * 65 * @param string $content The initial content of the editor. 66 * @param string $editor_id ID for the textarea and TinyMCE and Quicktags instances (can contain only ASCII letters and numbers). 67 * @param array $settings See WP_Editor::_parse_settings for description. 68 */ 69 function editor( $content, $editor_id, $settings = array() ) { 70 71 $set = $this->parse_settings($editor_id, $settings); 66 72 $editor_class = ' class="' . trim( $set['editor_class'] . ' wp-editor-area' ) . '"'; 67 73 $tabindex = $set['tabindex'] ? ' tabindex="' . (int) $set['tabindex'] . '"' : ''; 68 74 $rows = ' rows="' . (int) $set['textarea_rows'] . '"'; … … 74 80 75 81 if ( $this->this_quicktags && $this->this_tinymce ) { 76 82 $switch_class = 'html-active'; 77 $this->has_tinymce = $this->has_quicktags = true;78 83 79 84 if ( 'html' == $this->default_editor ) { 80 85 add_filter('the_editor_content', 'wp_htmledit_pre'); … … 85 90 86 91 $buttons .= '<a id="' . $editor_id . '-html" class="hide-if-no-js wp-switch-editor switch-html" onclick="switchEditors.switchto(this);">' . __('HTML') . "</a>\n"; 87 92 $buttons .= '<a id="' . $editor_id . '-tmce" class="hide-if-no-js wp-switch-editor switch-tmce" onclick="switchEditors.switchto(this);">' . __('Visual') . "</a>\n"; 88 } else {89 if ( $this->this_tinymce )90 $this->has_tinymce = true;91 92 if ( $this->this_quicktags )93 $this->has_quicktags = true;94 93 } 95 94 96 95 echo '<div id="wp-' . $editor_id . '-wrap" class="wp-editor-wrap ' . $switch_class . '">'; 97 96 98 if ( empty($this->first_init) )97 if ( $this->editor_buttons_css ) { 99 98 wp_print_styles('editor-buttons'); 99 $this->editor_buttons_css = false; 100 } 100 101 101 102 if ( !empty($set['editor_css']) ) 102 103 echo $set['editor_css'] . "\n"; … … 124 125 printf($the_editor, $content); 125 126 echo "\n</div>\n\n"; 126 127 127 if ( empty($this->first_init) ) {128 add_action( 'admin_print_footer_scripts', array($this, 'editor_js'), 50 );129 add_action( 'wp_print_footer_scripts', array($this, 'editor_js'), 50 );130 add_action( 'admin_footer', array($this, 'enqueue_scripts'), 1 );131 add_action( 'wp_footer', array($this, 'enqueue_scripts'), 1 );132 }133 134 128 $this->editor_settings($editor_id, $set); 135 129 } 136 130 … … 138 132 global $editor_styles; 139 133 $first_run = false; 140 134 135 if ( empty($this->first_init) ) { 136 if ( is_admin() ) { 137 add_action( 'admin_print_footer_scripts', array($this, 'editor_js'), 50 ); 138 add_action( 'admin_footer', array($this, 'enqueue_scripts'), 1 ); 139 } else { 140 add_action( 'wp_print_footer_scripts', array($this, 'editor_js'), 50 ); 141 add_action( 'wp_footer', array($this, 'enqueue_scripts'), 1 ); 142 } 143 } 144 141 145 if ( $this->this_quicktags ) { 142 146 143 147 $qtInit = array( … … 406 410 } 407 411 408 412 $this->mce_settings[$editor_id] = $mceInit; 409 $first_run = false;410 413 } // end if $this->this_tinymce 411 414 } 412 415