Make WordPress Core

Changeset 4417


Ignore:
Timestamp:
10/24/2006 03:57:19 AM (18 years ago)
Author:
markjaquith
Message:

Don't assume that TinyMCE exists, and degrade gracefully if it doesn't. fixes #3272

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/admin-functions.php

    r4413 r4417  
    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
     
    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
  • trunk/wp-admin/profile-update.php

    r3985 r4417  
    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');
  • trunk/wp-admin/profile.php

    r4349 r4417  
    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'); ?>
  • trunk/wp-includes/general-template.php

    r4371 r4417  
    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;
    755 
    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);
     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;
     765
     766    return apply_filters('user_can_richedit', $wp_rich_edit);
    760767}
    761768
Note: See TracChangeset for help on using the changeset viewer.