Make WordPress Core


Ignore:
Timestamp:
01/06/2008 07:01:32 PM (18 years ago)
Author:
ryan
Message:

Remember last editor chosen. Props mdawaffe. fixes #3978

File:
1 edited

Legend:

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

    r6544 r6567  
    908908}
    909909
     910function wp_default_editor() {
     911    $r = user_can_richedit() ? 'tinymce' : 'html'; // defaults
     912    if ( $user = wp_get_current_user() ) { // look for cookie
     913        if ( isset($_COOKIE['wordpress_editor_' . $user->ID]) && in_array($_COOKIE['wordpress_editor_' . $user->ID], array('tinymce', 'html', 'test') ) )
     914            $r = $_COOKIE['wordpress_editor_' . $user->ID];
     915    }
     916    return apply_filters( 'wp_default_editor', $r ); // filter
     917}
     918
    910919function the_editor($content, $id = 'content', $prev_id = 'title') {
    911920    $rows = get_option('default_post_edit_rows');
     
    916925
    917926    if ( user_can_richedit() ) :
    918         add_filter('the_editor_content', 'wp_richedit_pre');
     927        $wp_default_editor = wp_default_editor();
     928        $active = " class='active'";
     929        $inactive = " onclick='switchEditors(\"$id\");'";
     930
     931        if ( 'tinymce' == $wp_default_editor )
     932            add_filter('the_editor_content', 'wp_richedit_pre');
    919933
    920934        //  The following line moves the border so that the active button "attaches" to the toolbar. Only IE needs it.
     
    926940    <div id='editor-toolbar' style='display:none;'>
    927941        <div class='zerosize'><input accesskey='e' type='button' onclick='switchEditors("<?php echo $id; ?>")' /></div>
    928         <a id='edButtonHTML' class='' onclick='switchEditors("<?php echo $id; ?>")'><?php _e('HTML'); ?></a>
    929         <a id='edButtonPreview' class='active'><?php _e('Visual'); ?></a>
    930         <div id="media-buttons">
    931         <?php _e('Add media:'); ?>
    932         <?php do_action( 'media_buttons'); ?>
    933         </div>
     942        <a id='edButtonHTML'<?php echo 'html' == $wp_default_editor ? $active : $inactive; ?>><?php _e('HTML'); ?></a>
     943            <a id='edButtonPreview'<?php echo 'tinymce' == $wp_default_editor ? $active : $inactive; ?>><?php _e('Visual'); ?></a>
     944
     945            <div id="media-buttons">
     946            <?php _e('Add media:'); ?>
     947            <?php do_action( 'media_buttons'); ?>
     948            </div>
    934949    </div>
     950
    935951    <script type="text/javascript">
    936952    // <![CDATA[
     
    940956    </script>
    941957
    942     <?php endif; ?>
     958    <?php endif; // user_can_richedit() ?>
     959
    943960    <div id="quicktags">
    944961    <?php wp_print_scripts( 'quicktags' ); ?>
    945962    <script type="text/javascript">edToolbar()</script>
    946963    </div>
     964
     965    <?php if ( 'html' != $wp_default_editor ) : ?>
    947966    <script type="text/javascript">
    948967    // <![CDATA[
     
    951970    // ]]>
    952971    </script>
    953     <?php
    954 
    955     $the_editor = apply_filters('the_editor', "<div><textarea class='mceEditor' $rows cols='40' name='$id' tabindex='2' id='$id'>%s</textarea></div>\n");
     972    <?php endif; // 'html' != $wp_default_editor
     973
     974    $the_editor = apply_filters('the_editor', "<div><textarea class='' $rows cols='40' name='$id' tabindex='2' id='$id'>%s</textarea></div>\n");
    956975    $the_editor_content = apply_filters('the_editor_content', $content);
    957976
Note: See TracChangeset for help on using the changeset viewer.