From 0a5781da6ec659a0a1bd61fc95da238e2e434975 Mon Sep 17 00:00:00 2001 From: ryan Date: Sun, 6 Jan 2008 19:01:32 +0000 Subject: [PATCH] Remember last editor chosen. Props mdawaffe. fixes #3978 git-svn-id: http://svn.automattic.com/wordpress/trunk@6567 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/edit-form-advanced.php | 2 +- wp-admin/edit-form.php | 2 +- wp-admin/edit-page-form.php | 2 +- wp-admin/wp-admin.css | 4 -- wp-includes/general-template.php | 39 ++++++++++++++----- .../plugins/wordpress/editor_plugin.js | 15 +++++++ wp-includes/js/tinymce/tiny_mce_config.php | 7 ++++ wp-includes/script-loader.php | 5 ++- 8 files changed, 57 insertions(+), 19 deletions(-) diff --git a/wp-admin/edit-form-advanced.php b/wp-admin/edit-form-advanced.php index 3fd4d94fbc..a59d3fad43 100644 --- a/wp-admin/edit-form-advanced.php +++ b/wp-admin/edit-form-advanced.php @@ -50,7 +50,7 @@ if (empty($post->post_status)) $post->post_status = 'draft'; ?> - + diff --git a/wp-admin/edit-form.php b/wp-admin/edit-form.php index 00e4932b31..df37430086 100644 --- a/wp-admin/edit-form.php +++ b/wp-admin/edit-form.php @@ -6,7 +6,7 @@ - + - + +
+ + - \n"); + $the_editor = apply_filters('the_editor', "
\n"); $the_editor_content = apply_filters('the_editor_content', $content); printf($the_editor, $the_editor_content); diff --git a/wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js b/wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js index 5d7db79ee4..8d5f25774e 100644 --- a/wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js +++ b/wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js @@ -523,6 +523,7 @@ function switchEditors(id) { pdr.style.height = 'auto'; pdr.style.overflow = 'display'; } + wpSetDefaultEditor( 'html' ); } else { edToggle(P, H); edCloseAllTags(); // :-( @@ -557,6 +558,7 @@ function switchEditors(id) { pdr.style.height = 'auto'; pdr.style.overflow = 'display'; } + wpSetDefaultEditor( 'tinymce' ); } } @@ -568,6 +570,19 @@ function edToggle(A, B) { A.onclick = null; } +function wpSetDefaultEditor( editor ) { + try { + editor = escape( editor.toString() ); + } catch(err) { + editor = 'tinymce'; + } + + var userID = document.getElementById('user-id'); + var date = new Date(); + date.setTime(date.getTime()+(10*365*24*60*60*1000)); + document.cookie = "wordpress_editor_" + userID.value + "=" + editor + "; expires=" + date.toGMTString(); +} + function wpautop(pee) { pee = pee + "\n\n"; pee = pee.replace(new RegExp('
\\s*
', 'gi'), "\n\n"); diff --git a/wp-includes/js/tinymce/tiny_mce_config.php b/wp-includes/js/tinymce/tiny_mce_config.php index 983ea86ec5..361783a8ee 100644 --- a/wp-includes/js/tinymce/tiny_mce_config.php +++ b/wp-includes/js/tinymce/tiny_mce_config.php @@ -54,9 +54,16 @@ $mce_locale = ( '' == get_locale() ) ? 'en' : strtolower(get_locale()); ?> +wpEditorInit = function() { + // Activate tinyMCE if it's the user's default editor + if ( ( 'undefined' == typeof wpTinyMCEConfig ) || 'tinymce' == wpTinyMCEConfig.defaultEditor ) + tinyMCE.execCommand("mceAddControl", true, 'content'); +}; + initArray = { mode : "specific_textareas", editor_selector : "mceEditor", + oninit : "wpEditorInit", width : "100%", theme : "advanced", theme_advanced_buttons1 : "", diff --git a/wp-includes/script-loader.php b/wp-includes/script-loader.php index 7df3400af8..8811d34945 100644 --- a/wp-includes/script-loader.php +++ b/wp-includes/script-loader.php @@ -31,10 +31,11 @@ class WP_Scripts { $this->add( 'colorpicker', '/wp-includes/js/colorpicker.js', false, '3517' ); // Modify this version when tinyMCE plugins are changed - $this->add( 'tiny_mce', '/wp-includes/js/tinymce/tiny_mce_gzip.php', false, '20080103' ); + $this->add( 'tiny_mce', '/wp-includes/js/tinymce/tiny_mce_gzip.php', false, '20080105' ); $mce_config = apply_filters('tiny_mce_config_url', '/wp-includes/js/tinymce/tiny_mce_config.php'); - $this->add( 'wp_tiny_mce', $mce_config, array('tiny_mce'), '20070528' ); + $this->add( 'wp_tiny_mce', $mce_config, array('tiny_mce'), '20080105' ); + $this->localize( 'wp_tiny_mce', 'wpTinyMCEConfig', array( 'defaultEditor' => wp_default_editor() ) ); $this->add( 'prototype', '/wp-includes/js/prototype.js', false, '1.6');