Make WordPress Core

Ticket #3272: tinymce_graceful.diff

File tinymce_graceful.diff, 3.6 KB (added by markjaquith, 18 years ago)

Patch for trunk. Makes removal of TinyMCE more graceful.

  • wp-includes/general-template.php

     
    750750                echo "<meta name='robots' content='noindex,nofollow' />\n";
    751751}
    752752
     753function rich_edit_exists() {
     754        global $wp_rich_edit_exists;
     755        if ( !isset($wp_rich_edit_exists) )
     756                $wp_rich_edit_exists = file_exists(ABSPATH . WPINC . '/js/tinymce/tiny_mce.js');
     757        return $wp_rich_edit_exists;
     758}
     759
    753760function user_can_richedit() {
    754         $can = true;
     761        global $wp_rich_edit;
     762       
     763        if ( !isset($wp_rich_edit) )
     764                $wp_rich_edit = ( 'true' == get_user_option('rich_editing') && !preg_match('!opera[ /][2-8]|konqueror|safari!i', $_SERVER['HTTP_USER_AGENT']) && rich_edit_exists() ) ? true : false;
    755765
    756         if ( 'true' != get_user_option('rich_editing') || preg_match('!opera[ /][2-8]|konqueror|safari!i', $_SERVER['HTTP_USER_AGENT']) )
    757                 $can = false;
    758 
    759         return apply_filters('user_can_richedit', $can);
     766        return apply_filters('user_can_richedit', $wp_rich_edit);
    760767}
    761768
    762769function the_editor($content, $id = 'content', $prev_id = 'title') {
  • wp-admin/profile-update.php

     
    1717        exit;
    1818}
    1919
    20 if ( !isset( $_POST['rich_editing'] ) )
    21         $_POST['rich_editing'] = 'false';
    22 update_user_option( $current_user->id, 'rich_editing', $_POST['rich_editing'], true );
     20if ( rich_edit_exists() ) {
     21        if ( !isset( $_POST['rich_editing'] ) )
     22                $_POST['rich_editing'] = 'false';
     23        update_user_option( $current_user->id, 'rich_editing', $_POST['rich_editing'], true );
     24}
    2325
    2426do_action('personal_options_update');
    2527
  • wp-admin/admin-functions.php

     
    287287
    288288// Get an existing post and format it for editing.
    289289function get_post_to_edit($id) {
    290         global $richedit;
    291         $richedit = ( 'true' == get_user_option('rich_editing') ) ? true : false;
    292290
    293291        $post = get_post($id);
    294292
    295         $post->post_content = format_to_edit($post->post_content, $richedit);
     293        $post->post_content = format_to_edit($post->post_content, user_can_richedit());
    296294        $post->post_content = apply_filters('content_edit_pre', $post->post_content);
    297295
    298296        $post->post_excerpt = format_to_edit($post->post_excerpt);
     
    350348}
    351349
    352350function get_comment_to_edit($id) {
    353         global $richedit;
    354         $richedit = ( 'true' == get_user_option('rich_editing') ) ? true : false;
    355 
    356351        $comment = get_comment($id);
    357352
    358         $comment->comment_content = format_to_edit($comment->comment_content, $richedit);
     353        $comment->comment_content = format_to_edit($comment->comment_content, user_can_richedit());
    359354        $comment->comment_content = apply_filters('comment_edit_pre', $comment->comment_content);
    360355
    361356        $comment->comment_author = format_to_edit($comment->comment_author);
  • wp-admin/profile.php

     
    3030
    3131<h3><?php _e('Personal Options'); ?></h3>
    3232
     33<?php if ( rich_edit_exists() ) : // don't bother showing the option if the editor has been removed ?>
    3334<p><label for="rich_editing"><input name="rich_editing" type="checkbox" id="rich_editing" value="true" <?php checked('true', get_user_option('rich_editing')); ?> />
    3435<?php _e('Use the visual editor when writing') ?></label></p>
     36<?php endif; ?>
    3537
    3638<?php do_action('profile_personal_options'); ?>
    3739