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

git-svn-id: http://svn.automattic.com/wordpress/trunk@4417 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
markjaquith 2006-10-24 03:57:19 +00:00
parent b228b5eda2
commit 0fd28b6d83
4 changed files with 21 additions and 15 deletions

View File

@ -287,12 +287,10 @@ function edit_comment() {
// Get an existing post and format it for editing.
function get_post_to_edit($id) {
global $richedit;
$richedit = ( 'true' == get_user_option('rich_editing') ) ? true : false;
$post = get_post($id);
$post->post_content = format_to_edit($post->post_content, $richedit);
$post->post_content = format_to_edit($post->post_content, user_can_richedit());
$post->post_content = apply_filters('content_edit_pre', $post->post_content);
$post->post_excerpt = format_to_edit($post->post_excerpt);
@ -350,12 +348,9 @@ function get_default_post_to_edit() {
}
function get_comment_to_edit($id) {
global $richedit;
$richedit = ( 'true' == get_user_option('rich_editing') ) ? true : false;
$comment = get_comment($id);
$comment->comment_content = format_to_edit($comment->comment_content, $richedit);
$comment->comment_content = format_to_edit($comment->comment_content, user_can_richedit());
$comment->comment_content = apply_filters('comment_edit_pre', $comment->comment_content);
$comment->comment_author = format_to_edit($comment->comment_author);

View File

@ -17,9 +17,11 @@ if ( is_wp_error( $errors ) ) {
exit;
}
if ( !isset( $_POST['rich_editing'] ) )
$_POST['rich_editing'] = 'false';
update_user_option( $current_user->id, 'rich_editing', $_POST['rich_editing'], true );
if ( rich_edit_exists() ) {
if ( !isset( $_POST['rich_editing'] ) )
$_POST['rich_editing'] = 'false';
update_user_option( $current_user->id, 'rich_editing', $_POST['rich_editing'], true );
}
do_action('personal_options_update');

View File

@ -30,8 +30,10 @@ $bookmarklet_height= 440;
<h3><?php _e('Personal Options'); ?></h3>
<?php if ( rich_edit_exists() ) : // don't bother showing the option if the editor has been removed ?>
<p><label for="rich_editing"><input name="rich_editing" type="checkbox" id="rich_editing" value="true" <?php checked('true', get_user_option('rich_editing')); ?> />
<?php _e('Use the visual editor when writing') ?></label></p>
<?php endif; ?>
<?php do_action('profile_personal_options'); ?>

View File

@ -750,13 +750,20 @@ function noindex() {
echo "<meta name='robots' content='noindex,nofollow' />\n";
}
function rich_edit_exists() {
global $wp_rich_edit_exists;
if ( !isset($wp_rich_edit_exists) )
$wp_rich_edit_exists = file_exists(ABSPATH . WPINC . '/js/tinymce/tiny_mce.js');
return $wp_rich_edit_exists;
}
function user_can_richedit() {
$can = true;
global $wp_rich_edit;
if ( !isset($wp_rich_edit) )
$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;
if ( 'true' != get_user_option('rich_editing') || preg_match('!opera[ /][2-8]|konqueror|safari!i', $_SERVER['HTTP_USER_AGENT']) )
$can = false;
return apply_filters('user_can_richedit', $can);
return apply_filters('user_can_richedit', $wp_rich_edit);
}
function the_editor($content, $id = 'content', $prev_id = 'title') {