Ticket #3978: 3978c.diff

File 3978c.diff, 8.4 kB (added by mdawaffe, 8 months ago)

fixes bug when default tab is HTML and you are editing a pre-existing post

  • wp-includes/general-template.php

    old new  
    907907        return apply_filters('user_can_richedit', $wp_rich_edit); 
    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'); 
    912921        if (($rows < 3) || ($rows > 100)) 
     
    915924        $rows = "rows='$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\");'"; 
    919930 
     931                if ( 'tinymce' == $wp_default_editor ) 
     932                        add_filter('the_editor_content', 'wp_richedit_pre'); 
     933 
    920934                //      The following line moves the border so that the active button "attaches" to the toolbar. Only IE needs it. 
    921935        ?> 
    922936        <style type="text/css"> 
     
    925939        </style> 
    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[ 
    937953                if ( typeof tinyMCE != "undefined" && tinyMCE.configs.length > 0 ) 
     
    939955        // ]]> 
    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[ 
    949968                if ( typeof tinyMCE != "undefined" && tinyMCE.configs.length > 0 ) 
    950969                        document.getElementById("quicktags").style.display="none"; 
    951970        // ]]> 
    952971        </script> 
    953         <?php 
     972        <?php endif; // 'html' != $wp_default_editor 
    954973 
    955         $the_editor = apply_filters('the_editor', "<div><textarea class='mceEditor' $rows cols='40' name='$id' tabindex='2' id='$id'>%s</textarea></div>\n"); 
     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 
    958977        printf($the_editor, $the_editor_content); 
  • wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js

    old new  
    523523                        pdr.style.height = 'auto'; 
    524524                        pdr.style.overflow = 'display'; 
    525525                } 
     526                wpSetDefaultEditor( 'html' ); 
    526527        } else { 
    527528                edToggle(P, H); 
    528529                edCloseAllTags(); // :-( 
     
    557558                        pdr.style.height = 'auto'; 
    558559                        pdr.style.overflow = 'display'; 
    559560                } 
     561                wpSetDefaultEditor( 'tinymce' ); 
    560562        } 
    561563} 
    562564 
     
    568570        A.onclick = null; 
    569571} 
    570572 
     573function wpSetDefaultEditor( editor ) { 
     574        try { 
     575                editor = escape( editor.toString() ); 
     576        } catch(err) { 
     577                editor = 'tinymce'; 
     578        } 
     579 
     580        var userID = document.getElementById('user-id'); 
     581        var date = new Date(); 
     582        date.setTime(date.getTime()+(10*365*24*60*60*1000)); 
     583        document.cookie = "wordpress_editor_" + userID.value + "=" + editor + "; expires=" + date.toGMTString(); 
     584} 
     585 
    571586function wpautop(pee) { 
    572587        pee = pee + "\n\n"; 
    573588        pee = pee.replace(new RegExp('<br />\\s*<br />', 'gi'), "\n\n"); 
  • wp-includes/js/tinymce/tiny_mce_config.php

    old new  
    5454        $mce_locale = ( '' == get_locale() ) ? 'en' : strtolower(get_locale()); 
    5555?> 
    5656 
     57wpEditorInit = function() { 
     58        // Activate tinyMCE if it's the user's default editor 
     59        if ( ( 'undefined' == typeof wpTinyMCEConfig ) || 'tinymce' == wpTinyMCEConfig.defaultEditor ) 
     60                tinyMCE.execCommand("mceAddControl", true, 'content'); 
     61}; 
     62 
    5763initArray = { 
    5864        mode : "specific_textareas", 
    5965        editor_selector : "mceEditor", 
     66        oninit : "wpEditorInit", 
    6067        width : "100%", 
    6168        theme : "advanced", 
    6269        theme_advanced_buttons1 : "<?php echo $mce_buttons; ?>", 
  • wp-includes/script-loader.php

    old new  
    3131                $this->add( 'colorpicker', '/wp-includes/js/colorpicker.js', false, '3517' ); 
    3232 
    3333                // Modify this version when tinyMCE plugins are changed 
    34                 $this->add( 'tiny_mce', '/wp-includes/js/tinymce/tiny_mce_gzip.php', false, '20080103' ); 
     34                $this->add( 'tiny_mce', '/wp-includes/js/tinymce/tiny_mce_gzip.php', false, '20080105' ); 
    3535 
    3636                $mce_config = apply_filters('tiny_mce_config_url', '/wp-includes/js/tinymce/tiny_mce_config.php'); 
    37                 $this->add( 'wp_tiny_mce', $mce_config, array('tiny_mce'), '20070528' ); 
     37                $this->add( 'wp_tiny_mce', $mce_config, array('tiny_mce'), '20080105' ); 
     38                $this->localize( 'wp_tiny_mce', 'wpTinyMCEConfig', array( 'defaultEditor' => wp_default_editor() ) ); 
    3839 
    3940                $this->add( 'prototype', '/wp-includes/js/prototype.js', false, '1.6'); 
    4041 
  • wp-admin/wp-admin.css

    old new  
    402402        padding-right: 6px; 
    403403} 
    404404 
    405 #postdivrich #quicktags { 
    406         display: none; 
    407 } 
    408  
    409405#quicktags #ed_toolbar { 
    410406        padding: 0 2px; 
    411407} 
  • wp-admin/edit-page-form.php

    old new  
    3333        echo '<input type="hidden" name="mode" value="bookmarklet" />'; 
    3434} 
    3535?> 
    36 <input type="hidden" name="user_ID" value="<?php echo $user_ID ?>" /> 
     36<input type="hidden" id="user-id" name="user_ID" value="<?php echo $user_ID ?>" /> 
    3737<input type="hidden" id="hiddenaction" name="action" value='<?php echo $form_action ?>' /> 
    3838<input type="hidden" id="originalaction" name="originalaction" value="<?php echo $form_action ?>" /> 
    3939<?php echo $form_extra ?> 
  • wp-admin/edit-form.php

    old new  
    66<?php if (isset($mode) && 'bookmarklet' == $mode) : ?> 
    77<input type="hidden" name="mode" value="bookmarklet" /> 
    88<?php endif; ?> 
    9 <input type="hidden" name="user_ID" value="<?php echo (int) $user_ID ?>" /> 
     9<input type="hidden" id="user-id" name="user_ID" value="<?php echo (int) $user_ID ?>" /> 
    1010<input type="hidden" name="action" value='post' /> 
    1111 
    1212<script type="text/javascript"> 
  • wp-admin/edit-form-advanced.php

    old new  
    5050 
    5151?> 
    5252 
    53 <input type="hidden" name="user_ID" value="<?php echo (int) $user_ID ?>" /> 
     53<input type="hidden" id="user-id" name="user_ID" value="<?php echo (int) $user_ID ?>" /> 
    5454<input type="hidden" id="hiddenaction" name="action" value="<?php echo $form_action ?>" /> 
    5555<input type="hidden" id="originalaction" name="originalaction" value="<?php echo $form_action ?>" /> 
    5656<input type="hidden" name="post_author" value="<?php echo attribute_escape( $post->post_author ); ?>" />