Ticket #19320: 19320-3.patch
File 19320-3.patch, 8.2 KB (added by , 13 years ago) |
---|
-
wp-admin/admin-ajax.php
1129 1129 $args['s'] = stripslashes( $_POST['search'] ); 1130 1130 $args['pagenum'] = ! empty( $_POST['page'] ) ? absint( $_POST['page'] ) : 1; 1131 1131 1132 require(ABSPATH . WPINC . '/class-wp-editor.php');1133 $results = WP_Editor::wp_link_query( $args );1132 $wp_editor = _get_wp_editor(); 1133 $results = $wp_editor->wp_link_query( $args ); 1134 1134 1135 1135 if ( ! isset( $results ) ) 1136 1136 die( '0' ); -
wp-admin/includes/deprecated.php
711 711 function wp_tiny_mce( $teeny = false, $settings = false ) { 712 712 _deprecated_function( __FUNCTION__, '3.3', 'wp_editor()' ); 713 713 714 global $wp_editor;715 714 static $num = 1; 715 $wp_editor = _get_wp_editor(); 716 $editor_id = 'content' . $num++; 716 717 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 718 $set = array( 728 719 'teeny' => $teeny, 729 720 'tinymce' => $settings ? $settings : true, 730 721 'quicktags' => false 731 722 ); 732 723 733 $set = $wp_editor->parse_settings($editor_id, $set);734 724 $wp_editor->editor_settings($editor_id, $set); 735 725 } 736 726 -
wp-includes/class-wp-editor.php
8 8 * Private, not included by default. See wp_editor() in wp-includes/general-template.php. 9 9 */ 10 10 11 class WP_Editor {11 final class WP_Editor { 12 12 13 var $mce_settings = array(); 14 var $qt_settings = array(); 15 var $plugins = array(); 16 var $qt_buttons = array(); 17 var $mce_locale; 18 var $ext_plugins; 19 var $baseurl; 20 var $can_richedit; 21 var $default_editor; 22 var $first_init; 23 var $this_tinymce = false; 24 var $this_quicktags = false; 25 var $has_tinymce = false; 26 var $has_quicktags = false; 27 var $has_medialib = false; 28 var $editor_buttons_css = true; 13 private static $_instance = array(); 14 private $mce_settings = array(); 15 private $qt_settings = array(); 16 private $plugins = array(); 17 private $qt_buttons = array(); 18 private $mce_locale; 19 private $ext_plugins; 20 private $baseurl; 21 private $can_richedit; 22 private $default_editor; 23 private $first_init; 24 private $this_tinymce = false; 25 private $this_quicktags = false; 26 private $has_tinymce = false; 27 private $has_quicktags = false; 28 private $has_medialib = false; 29 private $editor_buttons_css = true; 29 30 30 function __construct() { 31 $this->can_richedit = user_can_richedit(); 32 $this->default_editor = $this->wp_default_editor(); 31 // Single instance only 32 public function __construct() { 33 $classname = __CLASS__; 34 if ( ! isset(self::$_instance[$classname]) ) { 35 self::$_instance[$classname] = $this; 36 $this->can_richedit = user_can_richedit(); 37 $this->default_editor = $this->wp_default_editor(); 38 } else { 39 throw new Exception('Multiple instances of WP_Editor are not allowed.'); 40 } 33 41 } 42 43 public function __clone() {} 34 44 35 function parse_settings($editor_id, $settings) {45 private function parse_settings($editor_id, $settings) { 36 46 $set = wp_parse_args( $settings, array( 37 47 'wpautop' => true, // use wpautop? 38 48 'media_buttons' => true, // show insert/upload button(s) … … 56 66 if ( $this->this_quicktags ) 57 67 $this->has_quicktags = true; 58 68 69 $set['_parset'] = 1; 59 70 return $set; 60 71 } 61 72 … … 66 77 * @param string $editor_id ID for the textarea and TinyMCE and Quicktags instances (can contain only ASCII letters and numbers). 67 78 * @param array $settings See WP_Editor::_parse_settings for description. 68 79 */ 69 function editor( $content, $editor_id, $settings = array() ) {80 public function editor( $content, $editor_id, $settings = array() ) { 70 81 71 82 $set = $this->parse_settings($editor_id, $settings); 72 83 $editor_class = ' class="' . trim( $set['editor_class'] . ' wp-editor-area' ) . '"'; … … 128 139 $this->editor_settings($editor_id, $set); 129 140 } 130 141 131 function editor_settings($editor_id, $set) {142 public function editor_settings($editor_id, $set) { 132 143 global $editor_styles; 133 144 $first_run = false; 134 145 146 if ( !array_key_exists($set['_parset']) ) 147 $set = $this->parse_settings($editor_id, $set); 148 135 149 if ( empty($this->first_init) ) { 136 150 if ( is_admin() ) { 137 151 add_action( 'admin_print_footer_scripts', array($this, 'editor_js'), 50 ); … … 413 427 } // end if $this->this_tinymce 414 428 } 415 429 416 function _parse_init($init) {430 private function _parse_init($init) { 417 431 $options = ''; 418 432 419 433 foreach ( $init as $k => $v ) { … … 441 455 * 442 456 * @return string Either 'tinymce', or 'html', or 'test' 443 457 */ 444 function wp_default_editor() {458 public function wp_default_editor() { 445 459 $r = user_can_richedit() ? 'tinymce' : 'html'; // defaults 446 460 if ( $user = wp_get_current_user() ) { // look for cookie 447 461 $ed = get_user_setting('editor', 'tinymce'); … … 450 464 return apply_filters( 'wp_default_editor', $r ); // filter 451 465 } 452 466 453 function enqueue_scripts() {467 public function enqueue_scripts() { 454 468 wp_enqueue_script('word-count'); 455 469 456 470 if ( $this->has_tinymce ) … … 474 488 } 475 489 } 476 490 477 function editor_js() {491 public function editor_js() { 478 492 global $tinymce_version, $concatenate_scripts, $compress_scripts; 479 493 480 494 /** … … 608 622 do_action('after_wp_tiny_mce', $this->mce_settings); 609 623 } 610 624 611 function wp_fullscreen_html() {625 public static function wp_fullscreen_html() { 612 626 global $content_width, $post; 613 627 614 628 $width = isset($content_width) && 800 > $content_width ? $content_width : 800; … … 705 719 * @param array $args Optional. Accepts 'pagenum' and 's' (search) arguments. 706 720 * @return array Results. 707 721 */ 708 function wp_link_query( $args = array() ) {722 public static function wp_link_query( $args = array() ) { 709 723 $pts = get_post_types( array( 'public' => true ), 'objects' ); 710 724 $pt_names = array_keys( $pts ); 711 725 … … 758 772 * 759 773 * @since 3.1.0 760 774 */ 761 function wp_link_dialog() {775 public static function wp_link_dialog() { 762 776 ?> 763 777 <div style="display:none;"> 764 778 <form id="wp-link" tabindex="-1"> -
wp-includes/deprecated.php
2628 2628 function wp_default_editor() { 2629 2629 _deprecated_function( __FUNCTION__, '3.3' ); 2630 2630 2631 global $wp_editor; 2632 if ( !is_a($wp_editor, 'WP_Editor') ) { 2633 require_once( ABSPATH . WPINC . '/class-wp-editor.php' ); 2634 $wp_editor = new WP_Editor; 2635 } 2636 2631 $wp_editor = _get_wp_editor(); 2637 2632 return $wp_editor->wp_default_editor(); 2638 2633 } 2639 2634 -
wp-includes/general-template.php
1786 1786 * @param array $settings See WP_Editor::editor(). 1787 1787 */ 1788 1788 function wp_editor( $content, $editor_id, $settings = array() ) { 1789 global $wp_editor; 1789 $wp_editor = _get_wp_editor(); 1790 $wp_editor->editor($content, $editor_id, $settings); 1791 } 1790 1792 1791 if ( !is_a($wp_editor, 'WP_Editor') ) { 1793 // private 1794 function _get_wp_editor() { 1795 static $instance; 1796 1797 if ( !is_a($instance, 'WP_Editor') ) { 1792 1798 require( ABSPATH . WPINC . '/class-wp-editor.php' ); 1793 $ wp_editor= new WP_Editor;1799 $instance = new WP_Editor; 1794 1800 } 1795 1801 1796 $wp_editor->editor($content, $editor_id, $settings);1802 return $instance; 1797 1803 } 1798 1804 1799 1805 /** -
wp-includes/js/tinymce/langs/wp-langs.php
1 1 <?php 2 2 3 // escape text only if it needs translating4 3 function mce_escape($text) { 5 global $wp_editor; 6 7 if ( 'en' == $wp_editor->mce_locale ) 8 return $text; 9 else 10 return esc_js($text); 4 return esc_js($text); 11 5 } 12 6 13 7 $lang = 'tinyMCE.addI18n({' . $this->mce_locale . ':{