Make WordPress Core


Ignore:
Timestamp:
10/02/2008 04:30:14 PM (17 years ago)
Author:
azaozz
Message:

Update TinyMCE to 3.2.0 and remove compression, fixes #7827

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/post.php

    r9053 r9064  
    986986
    987987/**
    988  * Adds a trimmed down version of the tinyMCE editor used on the Write -> Post screen.
     988 * wp_tiny_mce() - adds the TinyMCE editor used on the Write and Edit screens.
     989 *
     990 * Has option to output a trimmed down version used in Press This.
    989991 *
    990992 * @package WordPress
    991  * @since 2.6.0
    992  */
    993 function wp_teeny_mce( $args = null ) {
    994     if ( !user_can_richedit() )
     993 * @since 2.7
     994 */
     995function wp_tiny_mce( $teeny = false ) {
     996    if ( ! user_can_richedit() )
    995997        return;
    996 
    997     $defaults = array(
    998         'buttons1' => 'bold,italic,underline,blockquote,separator,strikethrough,bullist,numlist,undo,redo,link,unlink'
     998   
     999    $baseurl = includes_url('js/tinymce');
     1000
     1001    $mce_css = $baseurl . '/wordpress.css';
     1002    $mce_css = apply_filters('mce_css', $mce_css);
     1003
     1004    $mce_locale = ( '' == get_locale() ) ? 'en' : strtolower( substr(get_locale(), 0, 2) ); // only ISO 639-1
     1005
     1006    /*
     1007    The following filter allows localization scripts to change the languages displayed in the spellchecker's drop-down menu.
     1008    By default it uses Google's spellchecker API, but can be configured to use PSpell/ASpell if installed on the server.
     1009    The + sign marks the default language. More information:
     1010    http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/spellchecker
     1011    */
     1012    $mce_spellchecker_languages = apply_filters('mce_spellchecker_languages', '+English=en,Danish=da,Dutch=nl,Finnish=fi,French=fr,German=de,Italian=it,Polish=pl,Portuguese=pt,Spanish=es,Swedish=sv');
     1013   
     1014    if ( $teeny ) {
     1015        $plugins = apply_filters( 'teeny_mce_plugins', array('safari', 'inlinepopups', 'media', 'autosave', 'fullscreen') );
     1016        $ext_plugins = '';
     1017    } else {
     1018        $plugins = array( 'safari', 'inlinepopups', 'autosave', 'spellchecker', 'paste', 'wordpress', 'media', 'fullscreen', 'wpeditimage' );
     1019   
     1020        /*
     1021        The following filter takes an associative array of external plugins for TinyMCE in the form 'plugin_name' => 'url'.
     1022        It adds the plugin's name to TinyMCE's plugins init and the call to PluginManager to load the plugin.
     1023        The url should be absolute and should include the js file name to be loaded. Example:
     1024        array( 'myplugin' => 'http://my-site.com/wp-content/plugins/myfolder/mce_plugin.js' )
     1025        If the plugin uses a button, it should be added with one of the "$mce_buttons" filters.
     1026        */
     1027        $mce_external_plugins = apply_filters('mce_external_plugins', array());
     1028       
     1029        $ext_plugins = "\n";
     1030        if ( ! empty($mce_external_plugins) ) {
     1031       
     1032            /*
     1033            The following filter loads external language files for TinyMCE plugins.
     1034            It takes an associative array 'plugin_name' => 'path', where path is the
     1035            include path to the file. The language file should follow the same format as
     1036            /tinymce/langs/wp-langs.php and should define a variable $strings that
     1037            holds all translated strings. Example:
     1038            $strings = 'tinyMCE.addI18n("' . $mce_locale . '.mypluginname_dlg",{tab_general:"General", ... })';
     1039            */
     1040            $mce_external_languages = apply_filters('mce_external_languages', array());
     1041       
     1042            $loaded_langs = array();
     1043            $strings = '';
     1044       
     1045            if ( ! empty($mce_external_languages) ) {
     1046                foreach ( $mce_external_languages as $name => $path ) {
     1047                    if ( is_file($path) && is_readable($path) ) {
     1048                        include_once($path);
     1049                        $ext_plugins .= $strings;
     1050                        $loaded_langs[] = $name;
     1051                    }
     1052                }
     1053            }
     1054       
     1055            foreach ( $mce_external_plugins as $name => $url ) {
     1056       
     1057                if ( is_ssl() ) $url = str_replace('http://', 'https://', $url);
     1058       
     1059                $plugins[] = '-' . $name;
     1060       
     1061                if ( in_array($name, $loaded_langs) ) {
     1062                    $plugurl = dirname($url);
     1063                    $ext_plugins .= 'tinyMCEPreInit.load_ext("' . $plugurl . '", "' . $mce_locale . '");' . "\n";
     1064                }
     1065                $ext_plugins .= 'tinymce.PluginManager.load("' . $name . '", "' . $url . '");' . "\n";
     1066            }
     1067        }
     1068    }
     1069   
     1070    $plugins = implode($plugins, ',');
     1071   
     1072    if ( $teeny ) {
     1073        $mce_buttons = apply_filters( 'teeny_mce_buttons', array('bold, italic, underline, blockquote, separator, strikethrough, bullist, numlist,justifyleft, justifycenter, justifyright, undo, redo, link, unlink, fullscreen') );
     1074        $mce_buttons = implode($mce_buttons, ',');
     1075        $mce_buttons_2 = $mce_buttons_3 = $mce_buttons_4 = '';
     1076    } else {
     1077        $mce_buttons = apply_filters('mce_buttons', array('bold', 'italic', 'strikethrough', '|', 'bullist', 'numlist', 'blockquote', '|', 'justifyleft', 'justifycenter', 'justifyright', '|', 'link', 'unlink', 'wp_more', '|', 'spellchecker', 'fullscreen', 'wp_adv' ));
     1078        $mce_buttons = implode($mce_buttons, ',');
     1079       
     1080        $mce_buttons_2 = apply_filters('mce_buttons_2', array('formatselect', 'underline', 'justifyfull', 'forecolor', '|', 'pastetext', 'pasteword', 'removeformat', '|', 'media', 'charmap', '|', 'outdent', 'indent', '|', 'undo', 'redo', 'wp_help' ));
     1081        $mce_buttons_2 = implode($mce_buttons_2, ',');
     1082       
     1083        $mce_buttons_3 = apply_filters('mce_buttons_3', array());
     1084        $mce_buttons_3 = implode($mce_buttons_3, ',');
     1085       
     1086        $mce_buttons_4 = apply_filters('mce_buttons_4', array());
     1087        $mce_buttons_4 = implode($mce_buttons_4, ',');
     1088    }
     1089    $no_captions = ( apply_filters( 'disable_captions', '' ) ) ? true : false;
     1090   
     1091    // TinyMCE init settings
     1092    $initArray = array (
     1093        'mode' => 'none',
     1094        'onpageload' => 'switchEditors.edInit',
     1095        'width' => '100%',
     1096        'theme' => 'advanced',
     1097        'skin' => 'wp_theme',
     1098        'theme_advanced_buttons1' => "$mce_buttons",
     1099        'theme_advanced_buttons2' => "$mce_buttons_2",
     1100        'theme_advanced_buttons3' => "$mce_buttons_3",
     1101        'theme_advanced_buttons4' => "$mce_buttons_4",
     1102        'language' => "$mce_locale",
     1103        'spellchecker_languages' => "$mce_spellchecker_languages",
     1104        'theme_advanced_toolbar_location' => 'top',
     1105        'theme_advanced_toolbar_align' => 'left',
     1106        'theme_advanced_statusbar_location' => 'bottom',
     1107        'theme_advanced_resizing' => true,
     1108        'theme_advanced_resize_horizontal' => false,
     1109        'dialog_type' => 'modal',
     1110        'relative_urls' => false,
     1111        'remove_script_host' => false,
     1112        'convert_urls' => false,
     1113        'apply_source_formatting' => false,
     1114        'remove_linebreaks' => true,
     1115        'paste_convert_middot_lists' => true,
     1116        'paste_remove_spans' => true,
     1117        'paste_remove_styles' => true,
     1118        'gecko_spellcheck' => true,
     1119        'entities' => '38,amp,60,lt,62,gt',
     1120        'accessibility_focus' => false,
     1121        'tab_focus' => ':next',
     1122        'content_css' => "$mce_css",
     1123        'save_callback' => 'switchEditors.saveCallback',
     1124        'wpeditimage_disable_captions' => $no_captions,
     1125        'plugins' => "$plugins",
     1126        'strict_loading_mode' => true
    9991127    );
    1000     $args = wp_parse_args( $args, $defaults );
    1001     if ( is_array( $args['buttons1'] ) )
    1002         $args['buttons1'] = join( ',', $args['buttons1'] );
    1003 
    1004     $language = ( '' == get_locale() ) ? 'en' : strtolower( substr(get_locale(), 0, 2) );
    1005 
    1006 ?>
    1007 
    1008 <script type="text/javascript" src="<?php echo clean_url( site_url( 'wp-includes/js/tinymce/tiny_mce.js' ) ); ?>"></script>
     1128   
     1129    // For people who really REALLY know what they're doing with TinyMCE
     1130    // You can modify initArray to add, remove, change elements of the config before tinyMCE.init
     1131    // Setting "valid_elements", "invalid_elements" and "extended_valid_elements" can be done through "tiny_mce_before_init".
     1132    // Best is to use the default cleanup by not specifying valid_elements, as TinyMCE contains full set of XHTML 1.0.
     1133    if ( $teeny ) {
     1134        $initArray = apply_filters('teeny_mce_before_init', $initArray);
     1135    } else {
     1136        $initArray = apply_filters('tiny_mce_before_init', $initArray);
     1137    }
     1138
     1139    $language = $initArray['language'];
     1140
     1141    $ver = apply_filters('tiny_mce_version', '200');
     1142/*
     1143    foreach ( $initArray as $v )
     1144        $ver .= $v;
     1145   
     1146    if ( ! empty($mce_external_plugins) ) {
     1147        foreach ( $mce_external_plugins as $n => $v )
     1148            $ver .= $n;
     1149    }
     1150   
     1151    $ver = md5( $ver );
     1152
     1153   
     1154    // Use cached translations file if exists
     1155    $langs_file = ABSPATH . WPINC . '/js/tinymce/langs/wp-langs-' . $language . '.js';
     1156
     1157    if ( is_file($langs_file) && is_readable($langs_file) ) {
     1158        if ( $ver != get_option('mce_refresh_check') ) {
     1159            @unlink($langs_file);
     1160            update_option('mce_refresh_check', $ver);
     1161        } else {
     1162            $lang = false;
     1163        }
     1164    }
     1165*/
     1166    if ( 'en' != $language )
     1167        include_once(ABSPATH . WPINC . '/js/tinymce/langs/wp-langs.php');
     1168
     1169    $mce_options = '';
     1170    foreach ( $initArray as $k => $v )
     1171        $mce_options .= $k . ':"' . $v . '", ';
     1172   
     1173    $mce_options = rtrim( trim($mce_options), '\n\r,' ); ?>
     1174
    10091175<script type="text/javascript">
    1010 /* <![CDATA[ */
     1176
     1177tinyMCEPreInit = {
     1178    base : "<?php echo $baseurl; ?>",
     1179    suffix : "",
     1180    query : "ver=<?php echo $ver; ?>",
     1181    mceInit : {<?php echo $mce_options; ?>},
     1182
     1183    go : function() {
     1184        var t = this, sl = tinymce.ScriptLoader, ln = t.mceInit.language, th = t.mceInit.theme, pl = t.mceInit.plugins;
     1185   
     1186        sl.markDone(t.base + '/langs/' + ln + '.js');
     1187   
     1188        sl.markDone(t.base + '/themes/' + th + '/langs/' + ln + '.js');
     1189        sl.markDone(t.base + '/themes/' + th + '/langs/' + ln + '_dlg.js');
     1190   
     1191        tinymce.each(pl.split(','), function(n) {
     1192            if (n && n.charAt(0) != '-') {
     1193                sl.markDone(t.base + '/plugins/' + n + '/langs/' + ln + '.js');
     1194                sl.markDone(t.base + '/plugins/' + n + '/langs/' + ln + '_dlg.js');
     1195            }
     1196        });
     1197    },
     1198   
     1199    load_ext : function(url,lang) {
     1200        var sl = tinymce.ScriptLoader;
     1201   
     1202        sl.markDone(url + '/langs/' + lang + '.js');
     1203        sl.markDone(url + '/langs/' + lang + '_dlg.js');
     1204    }
     1205};
     1206</script>
     1207<script type="text/javascript" src="<?php echo $baseurl; ?>/tiny_mce.js?ver=<?php echo $ver; ?>"></script>
     1208<?php if ( 'en' == $language ) { ?>
     1209    <script type="text/javascript" src="<?php echo $baseurl; ?>/langs/wp-langs-<?php echo $language; ?>.js?ver=<?php echo $ver; ?>"></script>
     1210<?php } ?>
     1211<script type="text/javascript">
     1212
     1213<?php if ( 'en' != $language && isset($lang) ) echo $lang; ?>
     1214<?php if ( $ext_plugins ) echo $ext_plugins; ?>
     1215   
     1216// Mark translations as done
     1217tinyMCEPreInit.go();
     1218
     1219// Init
     1220tinyMCE.init(tinyMCEPreInit.mceInit);
     1221
     1222</script>
     1223
    10111224<?php
    1012     // Add TinyMCE languages
    1013     @include_once( ABSPATH . WPINC . '/js/tinymce/langs/wp-langs.php' );
    1014 
    1015     if ( isset($strings) )
    1016         echo $strings;
    1017 
    1018 ?>
    1019     (function() {
    1020         var base = tinymce.baseURL, sl = tinymce.ScriptLoader, ln = "<?php echo $language; ?>";
    1021 
    1022         sl.markDone(base + '/langs/' + ln + '.js');
    1023         sl.markDone(base + '/themes/advanced/langs/' + ln + '.js');
    1024         sl.markDone(base + '/themes/advanced/langs/' + ln + '_dlg.js');
    1025     })();
    1026    
    1027     var wpTeenyMCEInit = function() {
    1028     tinyMCE.init({
    1029         mode: "textareas",
    1030         editor_selector: "mceEditor",
    1031         language : "<?php echo $language; ?>",
    1032         width: "100%",
    1033         theme : "advanced",
    1034         theme_advanced_buttons1 : "<?php echo $args['buttons1']; ?>",
    1035         theme_advanced_buttons2 : "",
    1036         theme_advanced_buttons3 : "",
    1037         theme_advanced_toolbar_location : "top",
    1038         theme_advanced_toolbar_align : "left",
    1039         theme_advanced_statusbar_location : "bottom",
    1040         theme_advanced_resizing : true,
    1041         theme_advanced_resize_horizontal : false,
    1042         skin : "wp_theme",
    1043         dialog_type : "modal",
    1044         relative_urls : false,
    1045         remove_script_host : false,
    1046         convert_urls : false,
    1047         apply_source_formatting : false,
    1048         remove_linebreaks : true,
    1049         accessibility_focus : false,
    1050         tab_focus : ":next",
    1051         plugins : "safari,inlinepopups",
    1052         entities : "38,amp,60,lt,62,gt",
    1053         force_p_newlines : true,
    1054         save_callback : 'switchEditors.saveCallback'
    1055     });
    1056     };
    1057     wpTeenyMCEInit();
    1058 /* ]]> */
    1059 </script>
    1060 
    1061 <?php
    1062 }
     1225}
Note: See TracChangeset for help on using the changeset viewer.