<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[19408] trunk: Restore back-compat with wp_tiny_mce(), see #19320</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg > ul, #logmsg > ol { margin-left: 0; margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://core.trac.wordpress.org/changeset/19408">19408</a></dd>
<dt>Author</dt> <dd>azaozz</dd>
<dt>Date</dt> <dd>2011-11-22 21:47:01 +0000 (Tue, 22 Nov 2011)</dd>
</dl>
<h3>Log Message</h3>
<pre>Restore back-compat with wp_tiny_mce(), see <a href="http://core.trac.wordpress.org/ticket/19320">#19320</a></pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadminincludesdeprecatedphp">trunk/wp-admin/includes/deprecated.php</a></li>
<li><a href="#trunkwpincludesclasswpeditorphp">trunk/wp-includes/class-wp-editor.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadminincludesdeprecatedphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/deprecated.php (19407 => 19408)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/deprecated.php        2011-11-22 21:35:08 UTC (rev 19407)
+++ trunk/wp-admin/includes/deprecated.php        2011-11-22 21:47:01 UTC (rev 19408)
</span><span class="lines">@@ -21,7 +21,7 @@
</span><span class="cx"> function tinymce_include() {
</span><span class="cx">         _deprecated_function( __FUNCTION__, '2.1', 'wp_editor()' );
</span><span class="cx">
</span><del>-        wp_editor('', 'content');
</del><ins>+        wp_tiny_mce();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><span class="lines">@@ -708,10 +708,30 @@
</span><span class="cx"> * @deprecated Use wp_editor()
</span><span class="cx"> * @see wp_editor()
</span><span class="cx"> */
</span><del>-function wp_tiny_mce() {
</del><ins>+function wp_tiny_mce( $teeny = false, $settings = false ) {
</ins><span class="cx">         _deprecated_function( __FUNCTION__, '3.3', 'wp_editor()' );
</span><span class="cx">
</span><del>-        wp_editor('', 'content');
</del><ins>+        global $wp_editor;
+        static $num = 1;
+
+        if ( !is_a($wp_editor, 'WP_Editor') ) {
+                if ( !class_exists('WP_Editor') )
+                        require_once( ABSPATH . WPINC . '/class-wp-editor.php' );
+
+                $wp_editor = new WP_Editor;
+        }
+
+        $editor_id = 'content' . $num;
+        ++$num;
+
+        $set = array(
+                'teeny' => $teeny,
+                'tinymce' => $settings ? $settings : true,
+                'quicktags' => false
+        );
+
+        $set = $wp_editor->parse_settings($editor_id, $set);
+        $wp_editor->editor_settings($editor_id, $set);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><span class="lines">@@ -853,4 +873,4 @@
</span><span class="cx"> function type_url_form_file() {
</span><span class="cx">         __deprecated_function( __FUNCTION__, '3.3', "wp_media_insert_url_form('file')" );
</span><span class="cx">         return wp_media_insert_url_form( 'file' );
</span><del>-}
</del><span class="cx">\ No newline at end of file
</span><ins>+}
</ins></span></pre></div>
<a id="trunkwpincludesclasswpeditorphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/class-wp-editor.php (19407 => 19408)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/class-wp-editor.php        2011-11-22 21:35:08 UTC (rev 19407)
+++ trunk/wp-includes/class-wp-editor.php        2011-11-22 21:47:01 UTC (rev 19408)
</span><span class="lines">@@ -1,18 +1,11 @@
</span><span class="cx"> <?php
</span><span class="cx"> /**
</span><del>- * Adds the WordPress editor used on the Write and Edit screens.
</del><ins>+ * Facilitates adding of the WordPress editor as used on the Write and Edit screens.
</ins><span class="cx"> *
</span><span class="cx"> * @package WordPress
</span><span class="cx"> * @since 3.3
</span><span class="cx"> *
</span><del>- * NOTE: Do not instantiate this class directly. Please use the wp_editor() function that will include the file
- * and instantiate the class if needed. If you want to extend this class use the 'init' or earlier action to do it
- * and call wp_editor() as usual when you need to output the HTML.
- *
- * Outputs the HTML and JavaScript for the WordPress editors, TinyMCE and Quicktags.
- * TinyMCE is loaded separately from other Javascript by using wp-tinymce.php. It outputs concatenated
- * pre-compressed version of the core and all default plugins. Additional plugins are loaded directly
- * by TinyMCE using non-blocking method.
</del><ins>+ * Private, not included by default. See wp_editor() in wp-includes/general-template.php.
</ins><span class="cx"> */
</span><span class="cx">
</span><span class="cx"> class WP_Editor {
</span><span class="lines">@@ -32,21 +25,14 @@
</span><span class="cx">         var $has_tinymce = false;
</span><span class="cx">         var $has_quicktags = false;
</span><span class="cx">         var $has_medialib = false;
</span><ins>+        var $editor_buttons_css = true;
</ins><span class="cx">
</span><span class="cx">         function __construct() {
</span><span class="cx">                 $this->can_richedit = user_can_richedit();
</span><span class="cx">                 $this->default_editor = $this->wp_default_editor();
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        /**
-         * Outputs the HTML and enqueues the JavaScript for a single instance of the editor.
-         *
-         * @param string $content The initial content of the editor.
-         * @param string $editor_id ID for the textarea and TinyMCE and Quicktags instances (can contain only ASCII letters and numbers).
-         * @param array $settings See below for description.
-         */
-        function editor( $content, $editor_id, $settings = array() ) {
-
</del><ins>+        function parse_settings($editor_id, $settings) {
</ins><span class="cx">                 $set = wp_parse_args( $settings, array(
</span><span class="cx">                         'wpautop' => true, // use wpautop?
</span><span class="cx">                         'media_buttons' => true, // show insert/upload button(s)
</span><span class="lines">@@ -63,6 +49,26 @@
</span><span class="cx">
</span><span class="cx">                 $this->this_tinymce = !empty($set['tinymce']) && $this->can_richedit;
</span><span class="cx">                 $this->this_quicktags = !empty($set['quicktags']);
</span><ins>+
+                if ( $this->this_tinymce )
+                        $this->has_tinymce = true;
+
+                if ( $this->this_quicktags )
+                        $this->has_quicktags = true;
+
+                return $set;
+        }
+
+        /**
+         * Outputs the HTML for a single instance of the editor.
+         *
+         * @param string $content The initial content of the editor.
+         * @param string $editor_id ID for the textarea and TinyMCE and Quicktags instances (can contain only ASCII letters and numbers).
+         * @param array $settings See WP_Editor::_parse_settings for description.
+         */
+        function editor( $content, $editor_id, $settings = array() ) {
+
+                $set = $this->parse_settings($editor_id, $settings);
</ins><span class="cx">                 $editor_class = ' class="' . trim( $set['editor_class'] . ' wp-editor-area' ) . '"';
</span><span class="cx">                 $tabindex = $set['tabindex'] ? ' tabindex="' . (int) $set['tabindex'] . '"' : '';
</span><span class="cx">                 $rows = ' rows="' . (int) $set['textarea_rows'] . '"';
</span><span class="lines">@@ -74,7 +80,6 @@
</span><span class="cx">
</span><span class="cx">                 if ( $this->this_quicktags && $this->this_tinymce ) {
</span><span class="cx">                         $switch_class = 'html-active';
</span><del>-                        $this->has_tinymce = $this->has_quicktags = true;
</del><span class="cx">
</span><span class="cx">                         if ( 'html' == $this->default_editor ) {
</span><span class="cx">                                 add_filter('the_editor_content', 'wp_htmledit_pre');
</span><span class="lines">@@ -85,18 +90,14 @@
</span><span class="cx">
</span><span class="cx">                         $buttons .= '<a id="' . $editor_id . '-html" class="hide-if-no-js wp-switch-editor switch-html" onclick="switchEditors.switchto(this);">' . __('HTML') . "</a>\n";
</span><span class="cx">                         $buttons .= '<a id="' . $editor_id . '-tmce" class="hide-if-no-js wp-switch-editor switch-tmce" onclick="switchEditors.switchto(this);">' . __('Visual') . "</a>\n";
</span><del>-                } else {
-                        if ( $this->this_tinymce )
-                                $this->has_tinymce = true;
-
-                        if ( $this->this_quicktags )
-                                $this->has_quicktags = true;
</del><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 echo '<div id="wp-' . $editor_id . '-wrap" class="wp-editor-wrap ' . $switch_class . '">';
</span><span class="cx">
</span><del>-                if ( empty($this->first_init) )
</del><ins>+                if ( $this->editor_buttons_css ) {
</ins><span class="cx">                         wp_print_styles('editor-buttons');
</span><ins>+                        $this->editor_buttons_css = false;
+                }
</ins><span class="cx">
</span><span class="cx">                 if ( !empty($set['editor_css']) )
</span><span class="cx">                         echo $set['editor_css'] . "\n";
</span><span class="lines">@@ -124,13 +125,6 @@
</span><span class="cx">                 printf($the_editor, $content);
</span><span class="cx">                 echo "\n</div>\n\n";
</span><span class="cx">
</span><del>-                if ( empty($this->first_init) ) {
-                        add_action( 'admin_print_footer_scripts', array($this, 'editor_js'), 50 );
-                        add_action( 'wp_print_footer_scripts', array($this, 'editor_js'), 50 );
-                        add_action( 'admin_footer', array($this, 'enqueue_scripts'), 1 );
-                        add_action( 'wp_footer', array($this, 'enqueue_scripts'), 1 );
-                }
-
</del><span class="cx">                 $this->editor_settings($editor_id, $set);
</span><span class="cx">         }
</span><span class="cx">
</span><span class="lines">@@ -138,6 +132,16 @@
</span><span class="cx">                 global $editor_styles;
</span><span class="cx">                 $first_run = false;
</span><span class="cx">
</span><ins>+                if ( empty($this->first_init) ) {
+                        if ( is_admin() ) {
+                                add_action( 'admin_print_footer_scripts', array($this, 'editor_js'), 50 );
+                                add_action( 'admin_footer', array($this, 'enqueue_scripts'), 1 );
+                        } else {
+                                add_action( 'wp_print_footer_scripts', array($this, 'editor_js'), 50 );
+                                add_action( 'wp_footer', array($this, 'enqueue_scripts'), 1 );
+                        }
+                }
+
</ins><span class="cx">                 if ( $this->this_quicktags ) {
</span><span class="cx">
</span><span class="cx">                         $qtInit = array(
</span><span class="lines">@@ -406,7 +410,6 @@
</span><span class="cx">                         }
</span><span class="cx">
</span><span class="cx">                         $this->mce_settings[$editor_id] = $mceInit;
</span><del>-                        $first_run = false;
</del><span class="cx">                 } // end if $this->this_tinymce
</span><span class="cx">         }
</span><span class="cx">
</span></span></pre>
</div>
</div>
</body>
</html>