WordPress.org

Make WordPress Core


Ignore:
Timestamp:
11/23/2011 07:06:52 PM (9 years ago)
Author:
nacin
Message:

Move WP_Editor to a _WP_Editors encapsulation.

  • WP_Editor will return in 3.4 as a one true API for editor instances. Stick to wp_editor() for now.
  • TinyMCE can now be forced on with tinymce = true. It defaults to the value for user_can_richedit().
  • Restores wp_default_editor(), wp_link_query(), wp_link_dialog(), wp_fullscreen_html().

fixes #19320.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/general-template.php

    r19406 r19420  
    17671767
    17681768/**
    1769  * Loads and initializes WP_Editor class (if needed), passes the settings for an instance of the editor
     1769 * Find out which editor should be displayed by default.
     1770 *
     1771 * Works out which of the two editors to display as the current editor for a
     1772 * user.
     1773 *
     1774 * @since 2.5.0
     1775 *
     1776 * @return string Either 'tinymce', or 'html', or 'test'
     1777 */
     1778function wp_default_editor() {
     1779    $r = user_can_richedit() ? 'tinymce' : 'html'; // defaults
     1780    if ( $user = wp_get_current_user() ) { // look for cookie
     1781        $ed = get_user_setting('editor', 'tinymce');
     1782        $r = ( in_array($ed, array('tinymce', 'html', 'test') ) ) ? $ed : $r;
     1783    }
     1784    return apply_filters( 'wp_default_editor', $r ); // filter
     1785}
     1786
     1787/**
     1788 * Renders an editor.
    17701789 *
    17711790 * Using this function is the proper way to output all needed components for both TinyMCE and Quicktags.
    1772  * WP_Editor shouldn't be instantiated separately as it keeps track of loaded scripts.
    1773  * See http://core.trac.wordpress.org/ticket/17144.
     1791 * _WP_Editors should not be used directly. See http://core.trac.wordpress.org/ticket/17144.
    17741792 *
    17751793 * NOTE: Once initialized the TinyMCE editor cannot be safely moved in the DOM. For that reason
     
    17841802 * @param string $content Initial content for the editor.
    17851803 * @param string $editor_id HTML ID attribute value for the textarea and TinyMCE. Can only be /[a-z]+/.
    1786  * @param array $settings See WP_Editor::editor().
     1804 * @param array $settings See _WP_Editors::editor().
    17871805 */
    17881806function wp_editor( $content, $editor_id, $settings = array() ) {
    1789     global $wp_editor;
    1790 
    1791     if ( !is_a($wp_editor, 'WP_Editor') ) {
     1807    if ( ! class_exists( '_WP_Editors' ) )
    17921808        require( ABSPATH . WPINC . '/class-wp-editor.php' );
    1793         $wp_editor = new WP_Editor;
    1794     }
    1795 
    1796     $wp_editor->editor($content, $editor_id, $settings);
     1809
     1810    _WP_Editors::editor($content, $editor_id, $settings);
    17971811}
    17981812
Note: See TracChangeset for help on using the changeset viewer.