diff --git a/wp-admin/page-new.php b/wp-admin/page-new.php index f062435c9..134b9c555 100644 --- a/wp-admin/page-new.php +++ b/wp-admin/page-new.php @@ -5,7 +5,8 @@ $parent_file = 'post-new.php'; $editing = true; wp_enqueue_script('autosave'); wp_enqueue_script('page'); -wp_enqueue_script('editor'); +if ( user_can_richedit() ) + wp_enqueue_script('editor'); wp_enqueue_script('thickbox'); wp_enqueue_script('media-upload'); diff --git a/wp-admin/page.php b/wp-admin/page.php index 1a27998fd..71cfbe89b 100644 --- a/wp-admin/page.php +++ b/wp-admin/page.php @@ -53,7 +53,8 @@ case 'edit': } wp_enqueue_script('page'); - wp_enqueue_script('editor'); + if ( user_can_richedit() ) + wp_enqueue_script('editor'); wp_enqueue_script('thickbox'); wp_enqueue_script('media-upload'); diff --git a/wp-admin/post-new.php b/wp-admin/post-new.php index a322f4a70..593b0f4e1 100644 --- a/wp-admin/post-new.php +++ b/wp-admin/post-new.php @@ -5,7 +5,8 @@ $parent_file = 'post-new.php'; $editing = true; wp_enqueue_script('autosave'); wp_enqueue_script('post'); -wp_enqueue_script('editor'); +if ( user_can_richedit() ) + wp_enqueue_script('editor'); wp_enqueue_script('thickbox'); wp_enqueue_script('media-upload'); diff --git a/wp-admin/post.php b/wp-admin/post.php index 630f14278..cefb91b70 100644 --- a/wp-admin/post.php +++ b/wp-admin/post.php @@ -62,7 +62,8 @@ case 'edit': } wp_enqueue_script('post'); - wp_enqueue_script('editor'); + if ( user_can_richedit() ) + wp_enqueue_script('editor'); wp_enqueue_script('thickbox'); wp_enqueue_script('media-upload'); diff --git a/wp-admin/wp-admin.css b/wp-admin/wp-admin.css index 09009740e..f908f5e2a 100644 --- a/wp-admin/wp-admin.css +++ b/wp-admin/wp-admin.css @@ -260,16 +260,12 @@ input.delete:hover { color: #fff; } -#postdivrich #quicktags { +#postdivrich #quicktags, #postdiv #quicktags { background: #cee1ef; padding: 0; border: 0 none; } -#postdiv #quicktags { - padding-right: 6px; -} - #quicktags #ed_toolbar { padding: 0 2px; } diff --git a/wp-includes/general-template.php b/wp-includes/general-template.php index e56931f8b..a12f850e9 100644 --- a/wp-includes/general-template.php +++ b/wp-includes/general-template.php @@ -923,67 +923,40 @@ function the_editor($content, $id = 'content', $prev_id = 'title') { if (($rows < 3) || ($rows > 100)) $rows = 12; - $rows = "rows='$rows'"; - - if ( user_can_richedit() ) : - $wp_default_editor = wp_default_editor(); - $active = " class='active'"; - $inactive = " onclick='switchEditors.go(\"$id\");'"; - - if ( 'tinymce' == $wp_default_editor ) - add_filter('the_editor_content', 'wp_richedit_pre'); - else if ( 'html' == $wp_default_editor ) - add_filter('the_editor_content', 'wp_htmledit_pre'); - - // The following line moves the border so that the active button "attaches" to the toolbar. Only IE needs it. - ?> - - - \n"); $the_editor_content = apply_filters('the_editor_content', $content); @@ -991,13 +964,13 @@ function the_editor($content, $id = 'content', $prev_id = 'title') { printf($the_editor, $the_editor_content); ?> - - + // ]]> + + $url ) { $plugins[] = '-' . $name; - $url = $https ? str_replace('http://', 'https://', $url) : $url; + if ( $https ) str_replace('http://', 'https://', $url); $ext_plugins .= 'tinymce.PluginManager.load("' . $name . '", "' . $url . '");' . "\n"; } $plugins = implode($plugins, ','); -$mce_buttons = apply_filters('mce_buttons', array('bold', 'italic', 'strikethrough', '|', 'bullist', 'numlist', 'outdent', 'indent', '|', 'justifyleft', 'justifycenter', 'justifyright', '|', 'link', 'unlink', 'image', 'wp_more', '|', 'spellchecker', '|', 'wp_help', 'wp_adv' )); +$mce_buttons = apply_filters('mce_buttons', array('bold', 'italic', 'strikethrough', '|', 'bullist', 'numlist', 'outdent', 'indent', '|', 'justifyleft', 'justifycenter', 'justifyright', '|', 'link', 'unlink', 'image', 'wp_more', '|', 'spellchecker', 'fullscreen', 'wp_adv' )); $mce_buttons = implode($mce_buttons, ','); -$mce_buttons_2 = apply_filters('mce_buttons_2', array('formatselect', 'underline', 'justifyfull', 'forecolor', '|', 'pastetext', 'pasteword', '|', 'removeformat', 'cleanup', '|', 'media', 'charmap', 'blockquote', '|', 'undo', 'redo', 'fullscreen' )); +$mce_buttons_2 = apply_filters('mce_buttons_2', array('formatselect', 'underline', 'justifyfull', 'forecolor', '|', 'pastetext', 'pasteword', '|', 'removeformat', 'cleanup', '|', 'media', 'charmap', 'blockquote', '|', 'undo', 'redo', 'wp_help' )); $mce_buttons_2 = implode($mce_buttons_2, ','); $mce_buttons_3 = apply_filters('mce_buttons_3', array()); @@ -91,10 +91,6 @@ $mce_buttons_3 = implode($mce_buttons_3, ','); $mce_buttons_4 = apply_filters('mce_buttons_4', array()); $mce_buttons_4 = implode($mce_buttons_4, ','); -// all these browsers are now 100% supported, no need for this -//$mce_browsers = apply_filters('mce_browsers', array('msie', 'gecko', 'opera', 'safari')); -//$mce_browsers = implode($mce_browsers, ','); - $mce_locale = ( '' == get_locale() ) ? 'en' : strtolower( substr(get_locale(), 0, 2) ); // only ISO 639-1 // TinyMCE init settings @@ -114,13 +110,11 @@ $initArray = array ( 'theme_advanced_statusbar_location' => 'bottom', 'theme_advanced_resizing' => true, 'theme_advanced_resize_horizontal' => false, -// 'browsers' => "$mce_browsers", 'dialog_type' => 'modal', - 'convert_urls' => false, 'relative_urls' => false, 'remove_script_host' => false, 'fix_list_elements' => true, - 'fix_table_elements' => true, +// 'fix_table_elements' => true, 'gecko_spellcheck' => true, 'entities' => '38,amp,60,lt,62,gt', 'accessibility_focus' => false, @@ -131,7 +125,7 @@ $initArray = array ( // pass-through the settings for compression and caching, so they can be changed with "tiny_mce_before_init" 'disk_cache' => true, 'compress' => true, - 'del_old_cache' => true + 'old_cache_max' => '3' // number of cache files to keep ); if ( $valid_elements ) $initArray['valid_elements'] = $valid_elements; @@ -148,7 +142,7 @@ $mce_deprecated1 = ob_get_contents() || ''; ob_end_clean(); /* -// Do we need to support this? Most likely will breal TinyMCE 3... +// Do we need to support this? Most likely will break TinyMCE 3... ob_start(); do_action('tinymce_before_init'); $mce_deprecated2 = ob_get_contents() || ''; @@ -161,10 +155,10 @@ $cache_ext = '.js'; $disk_cache = ( ! isset($initArray['disk_cache']) || false == $initArray['disk_cache'] ) ? false : true; $compress = ( ! isset($initArray['compress']) || false == $initArray['compress'] ) ? false : true; -$del_old_cache = ( ! isset($initArray['del_old_cache']) || false == $initArray['del_old_cache'] ) ? false : true; +$old_cache_max = ( isset($initArray['old_cache_max']) ) ? (int) $initArray['old_cache_max'] : 0; -$initArray['disk_cache'] = $initArray['compress'] = $initArray['del_old_cache'] = null; -unset( $initArray['disk_cache'], $initArray['compress'], $initArray['del_old_cache'] ); +$initArray['disk_cache'] = $initArray['compress'] = $initArray['old_cache_max'] = null; +unset( $initArray['disk_cache'], $initArray['compress'], $initArray['old_cache_max'] ); $plugins = explode( ',', $initArray['plugins'] ); $theme = ( 'simple' == $initArray['theme'] ) ? 'simple' : 'advanced'; @@ -188,13 +182,16 @@ if ( $compress && isset($_SERVER['HTTP_ACCEPT_ENCODING']) ) { if ( $disk_cache && $cache_path ) { $ver = isset($_GET['ver']) ? (int) $_GET['ver'] : ''; - $cacheKey = $initArray['plugins'] . $language . $theme . $suffix . $ver; + $cacheKey = $suffix . $ver; + foreach ( $initArray as $v ) + $cacheKey .= $v; + foreach ( $custom_js as $file ) $cacheKey .= $file; $cacheKey = md5( $cacheKey ); - $cache_file = $cache_path . '/tiny_mce_' . $cacheKey . $cache_ext; + $cache_file = $cache_path . '/tinymce_' . $cacheKey . $cache_ext; } cache_javascript_headers(); @@ -209,13 +206,12 @@ if ( $disk_cache && file_exists($cache_file) ) { } foreach ( $initArray as $k => $v ) - $mce_options .= $k . ':"' . $v . '", '; + $mce_options .= $k . ':"' . $v . '",'; $mce_options .= $mce_deprecated1; $mce_options = rtrim( trim($mce_options), '\n\r,' ); -$content = 'var tinyMCEPreInit = { suffix : "' . $suffix . '", base : "' . $baseurl . '" };'; -$content .= 'var tinyMCE_GZ = { settings : { themes : "' . $theme . '", plugins : "' . $initArray['plugins'] . '", languages : "' . $language . '", debug : false, suffix : "' . $suffix . '" }, baseURL : "' . $baseurl . '" };'; +$content .= 'var tinyMCEPreInit = { settings : { themes : "' . $theme . '", plugins : "' . $initArray['plugins'] . '", languages : "' . $language . '", debug : false }, base : "' . $baseurl . '", suffix : "' . $suffix . '" };'; // Load patch $content .= getFileContents( 'tiny_mce_ext.js' ); @@ -224,7 +220,7 @@ $content .= getFileContents( 'tiny_mce_ext.js' ); $content .= getFileContents( 'tiny_mce' . $suffix . '.js' ); // Patch loading functions -$content .= 'tinyMCE_GZ.start();'; +$content .= 'tinyMCEPreInit.start();'; // Add all languages (WP) include_once( dirname(__FILE__).'/langs/wp-langs.php' ); @@ -247,26 +243,38 @@ $content .= $ext_plugins . 'tinyMCE.init({' . $mce_options . '});'; // $mce_depr // Generate GZIP'd content if ( '.gz' == $cache_ext ) { header('Content-Encoding: ' . $enc); - $cache_data = gzencode( $content, 9, FORCE_GZIP ); -} else - $cache_data = $content; + $content = gzencode( $content, 9, FORCE_GZIP ); +} // Stream to client -echo $cache_data; +echo $content; // Write file -if ( '' != $cacheKey ) { - if ( $del_old_cache ) { - $old_key = getFileContents('tiny_mce_compressed_key'); +if ( '' != $cacheKey && $cache_path ) { + if ( $old_cache_max ) { + $old_keys = getFileContents('tinymce_compressed_key' . $cache_ext); + + if ( '' != $old_keys ) { + $keys_ar = explode( "\n", $old_keys ); + if ( ($old_cache_max - 1) > count($old_keys_ar) ) + $old_keys_rem = array_slice( $keys_ar, ($old_cache_max - 1) ); + + foreach ( $old_keys_rem as $key ) { + $key = trim($key); + if ( 32 != strlen($key) ) continue; + $old_cache = $cache_path . '/tinymce_' . $key . $cache_ext; + @unlink($old_cache); + } + + array_unshift( $keys_ar, $cacheKey ); + $keys_ar = array_slice( $keys_ar, 0, $old_cache_max ); + $cacheKey = trim( implode( "\n", $keys_ar ) ); - if ( '' != $old_key ) { // && $old_key != $cacheKey - $old_cache = $cache_path . '/tiny_mce_' . $old_key . $cache_ext; - @unlink($old_cache); } - - putFileContents( 'tiny_mce_compressed_key', $cacheKey ); - } - putFileContents( $cache_file, $cache_data ); + putFileContents( 'tinymce_compressed_key' . $cache_ext, $cacheKey ); + } + + putFileContents( $cache_file, $content ); } ?> \ No newline at end of file diff --git a/wp-includes/js/tinymce/tiny_mce_ext.js b/wp-includes/js/tinymce/tiny_mce_ext.js index a738821fe..5a36c3e07 100644 --- a/wp-includes/js/tinymce/tiny_mce_ext.js +++ b/wp-includes/js/tinymce/tiny_mce_ext.js @@ -1,12 +1,11 @@ - -tinyMCE_GZ.start = function() { +tinyMCEPreInit.start = function() { var t = this, each = tinymce.each, s = t.settings, sl = tinymce.ScriptLoader, ln = s.languages.split(','); function load(u, sp) { var o; if (!sp) - u = t.baseURL + u; + u = t.base + u; o = {url : u, state : 2}; sl.queue.push(o); @@ -22,7 +21,7 @@ tinyMCE_GZ.start = function() { // Add themes with languages each(s.themes.split(','), function(n) { if (n) { - load('/themes/' + n + '/editor_template' + s.suffix + '.js'); + load('/themes/' + n + '/editor_template' + t.suffix + '.js'); each (ln, function(c) { if (c) @@ -34,7 +33,7 @@ tinyMCE_GZ.start = function() { // Add plugins with languages each(s.plugins.split(','), function(n) { if (n && n.charAt(0) != '-') { - load('/plugins/' + n + '/editor_plugin' + s.suffix + '.js'); + load('/plugins/' + n + '/editor_plugin' + t.suffix + '.js'); each (ln, function(c) { if (c) diff --git a/wp-includes/script-loader.php b/wp-includes/script-loader.php index 92fcb9358..7041f7606 100644 --- a/wp-includes/script-loader.php +++ b/wp-includes/script-loader.php @@ -29,9 +29,16 @@ class WP_Scripts { $this->add( 'colorpicker', '/wp-includes/js/colorpicker.js', false, '3517' ); - // Modify this version when tinyMCE plugins are changed - $mce_config = apply_filters('tiny_mce_config_url', '/wp-includes/js/tinymce/tiny_mce_config.php'); - $this->add( 'tiny_mce', $mce_config, false, '20080209' ); + // Let a plugin replace the visual editor + $visual_editor = apply_filters('visual_editor', array('tiny_mce')); + $this->add( 'editor', false, $visual_editor, '20080218' ); + + $this->add( 'editor_functions', '/wp-admin/js/editor.js', false, '20080208' ); + + // Modify this version when tinyMCE plugins are changed. + $mce_version = apply_filters('tiny_mce_version', '20080209'); + $this->add( 'tiny_mce', '/wp-includes/js/tinymce/tiny_mce_config.php', array('editor_functions'), $mce_version ); + $this->localize( 'tiny_mce', 'wpTinyMCEConfig', array( 'defaultEditor' => wp_default_editor() ) ); $this->add( 'prototype', '/wp-includes/js/prototype.js', false, '1.6'); @@ -474,12 +481,6 @@ function wp_prototype_before_jquery( $js_array ) { return $js_array; } -// These localizations require information that may not be loaded even by init -function wp_just_in_time_script_localization() { - wp_localize_script( 'tiny_mce', 'wpTinyMCEConfig', array( 'defaultEditor' => wp_default_editor() ) ); -} - -add_filter( 'wp_print_scripts', 'wp_just_in_time_script_localization' ); add_filter( 'print_scripts_array', 'wp_prototype_before_jquery' ); -?> +?> \ No newline at end of file