WordPress.org

Forums

[resolved] [closed] [NSFW] Visual vs Text Editor does not work properly. (21 posts)

  1. ctltvoz
    Member
    Posted 1 year ago #

    As mentioned in title.

    Demo: http://truyengay.mobi/hoan-doi-co-dau-truyen-gay-boy-hay/

    Visual Editor works well in post area but not work in comment field. Really appreciate if anyone can help.

    Best regards.

  2. esmi
    Forum Moderator
    Posted 1 year ago #

    Have you tried:

    - deactivating all plugins to see if this resolves the problem. If this works, re-activate the plugins one by one until you find the problematic plugin(s).

    - switching to the default theme to rule out any theme-specific problems.

    - resetting the plugins folder by FTP or PhpMyAdmin. Sometimes, an apparently inactive plugin can still cause problems.

    - re-uploading all files & folders - except the wp-content folder and wp-config.php & root .htaccess files - from a fresh download of WordPress. Make sure that you delete the old copies of files & folder before uploading the new ones.

  3. ctltvoz
    Member
    Posted 1 year ago #

  4. esmi
    Forum Moderator
    Posted 1 year ago #

    Please try the steps I posted above.

  5. ctltvoz
    Member
    Posted 1 year ago #

    I tried all but does not work.

  6. ctltvoz
    Member
    Posted 1 year ago #

    how can I disable Visual vs Text Editor for the comment?

  7. esmi
    Forum Moderator
    Posted 1 year ago #

    Can we see the first site using the default Twenty Fourteen theme with all plugins deactivated?

  8. esmi
    Forum Moderator
    Posted 1 year ago #

    how can I disable Visual vs Text Editor for the comment?

    Sorry? There is "visual editor" for comments in WordPress by default.

  9. ctltvoz
    Member
    Posted 1 year ago #

    please wait a moment.

  10. ctltvoz
    Member
    Posted 1 year ago #

    I changed it default theme - See it here; http://truyengay.mobi/truyen-gay-boy-u-day-lam-gi-nhau/

    I would like to have the comment without Visual Editor like the default Twenty Fourteen theme.

  11. esmi
    Forum Moderator
    Posted 1 year ago #

    Right now, I am not seeing an special editor for comments. So either this comments editor was part of your theme or was added by a plugin. Without activating any plugins, re-activate your old theme.

  12. ctltvoz
    Member
    Posted 1 year ago #

    I think it is a part of my theme. Is there anyway I can disable my theme comment?

  13. esmi
    Forum Moderator
    Posted 1 year ago #

    What theme were you using? Where did you download it from?

  14. ctltvoz
    Member
    Posted 1 year ago #

    This is my comment template.

    <?php
    if (!empty($_SERVER['SCRIPT_FILENAME']) && 'comments.php' == basename($_SERVER['SCRIPT_FILENAME']))
    die ('Please do not load this page directly. Thanks!'); ?>
    	<span class="title">Bình luận (<?php comments_number(__('0'), __('1'), __('%'));?>)</span>
    <?php if ( have_comments() ) : ?>
    	<?php wp_list_comments('type=comment&avatar_size=60&callback=bbit_comment'); ?>
    	<span class="left"><?php previous_comments_link(); ?></span>
    	<span class="right"><?php next_comments_link(); ?></span>
    	<br>
    <?php else : ?>
    
    <?php endif; ?>
    
    <?php if ( comments_open() ) : ?>
    
    <div class="pad" id="respond">
    	<p class="cancel-comment-reply"><?php cancel_comment_reply_link(); ?></p>
    	<?php if ( get_option('comment_registration') && !is_user_logged_in() ) : ?>
    	<p>Vui lòng <a href="<?php echo wp_login_url( get_permalink() ); ?>">đăng nhập</a> để bình luận.</p>
    	<?php else : ?>
    
    	<form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post">
    	<?php if ( is_user_logged_in() ) : ?>
    		<em>Chào <a href="<?php echo get_option('siteurl'); ?>/wp-admin/profile.php"><?php echo $user_identity; ?></a>!</em><br>
    	    <?php wp_editor( '', 'comment', array(
            'media_buttons' => false,
            'textarea_rows' => '3',
            'tinymce' => array(
            'plugins' => 'inlinepopups, wordpress, wplink, wpdialogs',
            'theme_advanced_buttons1' => 'bold, italic, underline, strikethrough, forecolor, separator, bullist, numlist, separator, link, unlink, image','theme_advanced_buttons2' => ''),
    		'quicktags' => array('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close')
            )); ?>
    		<button type="submit">Gửi</button>
    		<?php comment_id_fields(); ?>
    		<?php do_action('comment_form', $post->ID); ?>
    
    	<?php else : ?>
    		<input placeholder="Tên bạn" type="text" name="author" id="author" value="<?php echo esc_attr($comment_author); ?>" /><br>
    		<input placeholder="Email" type="text" name="email" id="email" value="<?php echo esc_attr($comment_author_email); ?>" /><br>
    	    <?php wp_editor( '', 'comment', array(
            'media_buttons' => false,
            'textarea_rows' => '3',
            'tinymce' => array(
            'plugins' => 'inlinepopups, wordpress, wplink, wpdialogs',
            'theme_advanced_buttons1' => 'bold, italic, underline, strikethrough, forecolor, separator, bullist, numlist, separator, link, unlink, image','theme_advanced_buttons2' => ''),
    		'quicktags' => array('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close')
            )); ?>
    		<button type="submit">Gửi</button>
    		<?php comment_id_fields(); ?>
    		<?php do_action('comment_form', $post->ID); ?>
    	<?php endif; ?>
    	</form>
    	<?php endif;?>
    </div>
    
    <?php endif; ?>
  15. ctltvoz
    Member
    Posted 1 year ago #

    What theme were you using? Where did you download it from?

    The theme is not on a store. Someone wrote this theme to optimize for wapsite, I bought from them. I asked them for help but they say WordPress 3.9.1 have problem with Visual Editor; they asked me to wait for the new fix. :(

  16. ctltvoz
    Member
    Posted 1 year ago #

    Here is my functions file.

    <?php
    //Cho phep editor
    function bbp_enable_visual_editor( $args = array() ) {
        $args['tinymce'] = true;
        return $args;
    }
    add_filter( 'bbp_after_get_the_content_parse_args', 'bbp_enable_visual_editor' );
    /* ------------------------- Add Theme Options, Include Modun ---------------------- */
    include_once('admin/index.php');
    include_once('includes/index.php');
    
    /* -------------------------------Add Theme Support -------------------------------- */
    add_theme_support('post-thumbnails', array('post'));
    add_theme_support('post-formats', array('image', 'video', 'audio'));
    add_image_size('image', 55, 55, true);
    
    register_nav_menu('menu', __('Danh mục'));
    
    register_sidebar(array(
    	'name' => 'Header',
    	'before_widget' => '',
    	'after_widget' => '',
    	'before_title' => '<span class="title">',
    	'after_title' => '</span>',
    ));
    
    register_sidebar(array(
    	'name' => 'Home',
    	'before_widget' => '',
    	'after_widget' => '',
    	'before_title' => '<span class="title">',
    	'after_title' => '</span>',
    ));
    
    register_sidebar(array(
    	'name' => 'Footer',
    	'before_widget' => '',
    	'after_widget' => '',
    	'before_title' => '<span class="title">',
    	'after_title' => '</span>',
    ));	
    
    function TrimStringIfToLong($s) {
        $maxLength = 60;
    
        if (strlen($s) > $maxLength) {
            echo substr($s, 0, $maxLength - 5) . ' ...';
        } else {
            echo $s;
        }
    }
    /* ------------------------------- Get First Image -------------------------------- */
    function first_image() {
      global $post, $posts;
      $first_img = '';
      ob_start();
      ob_end_clean();
      $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
      $first_img = $matches [1] [0];
      return $first_img;
    }
    
    /* ----------------------------------- Post View ---------------------------------- */
    function get_bbit_views($postID){
        $count_key = 'post_views_count';
        $count = get_post_meta($postID, $count_key, true);
        if($count==''){
            delete_post_meta($postID, $count_key);
            add_post_meta($postID, $count_key, '0');
            return "0";
        }
        return $count;
    }
    
    function bbit_views($postID) {
        $count_key = 'post_views_count';
        $count = get_post_meta($postID, $count_key, true);
        if($count==''){
            $count = 0;
            delete_post_meta($postID, $count_key);
            add_post_meta($postID, $count_key, '0');
        }else{
            $count++;
            update_post_meta($postID, $count_key, $count);
        }
    }
    
    /* ------------------------------------ Pagenavi ----------------------------------- */
    function bbit_pagination($pages = '', $range = 2)
    {
        $showitems = ($range * 2)+1;  
    
        global $paged;
        if(empty($paged)) $paged = 1;
    
        if($pages == '')
        {
            global $wp_query;
            $pages = $wp_query->max_num_pages;
            if(!$pages)
    		{
    		$pages = 1;
    		}
        }
    
        if(1 != $pages)
        {
            echo "<div class='pad pagenavi'>";
            if($paged > 2 && $paged > $range+1 && $showitems < $pages) echo "<a href='".get_pagenum_link(1)."'> <<</a>";
            if($paged > 1 && $showitems < $pages) echo "<a href='".get_pagenum_link($paged - 1)."'> <</a>";
    
            for ($i=1; $i <= $pages; $i++)
            {
                if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems ))
                {
                echo ($paged == $i)? "<span class='NowPage'>".$i."</span>":"<a href='".get_pagenum_link($i)."' class='NextPage' >".$i."</a>";
                }
            }
    
            if ($paged < $pages && $showitems < $pages) echo "<a href='".get_pagenum_link($paged + 1)."'>> </a>";
            if ($paged < $pages-1 &&  $paged+$range-1 < $pages && $showitems < $pages) echo "<a href='".get_pagenum_link($pages)."'>>> </a>";
            echo "</div>\n";
        }
    }
    
    /* ---------------------------------- Limited Text --------------------------------- */
    function bbit_string_limit($string, $word_limit)
    {
        $words = explode(' ', $string, ($word_limit + 1));
        if(count($words) > $word_limit) {
            array_pop($words);
        }
        return implode(' ', $words);
    }
    
    /* ------------------------------------ Time Ago ----------------------------------- */
    function bbit_time_ago() {
    
    	global $post;
    
    	$date = get_post_time('G', true, $post);
    
    	$chunks = array(
    		array( 60 * 60 * 24 * 365 , __( 'năm'), __( 'năm') ),
    		array( 60 * 60 * 24 * 30 , __( 'tháng'), __( 'tháng') ),
    		array( 60 * 60 * 24 * 7, __( 'tuần'), __( 'tuần') ),
    		array( 60 * 60 * 24 , __( 'ngày'), __( 'ngày') ),
    		array( 60 * 60 , __( 'giờ'), __( 'giờ') ),
    		array( 60 , __( 'phút'), __( 'phút') ),
    		array( 1, __( 'giây'), __( 'giây') )
    	);
    
    	if ( !is_numeric( $date ) ) {
    		$time_chunks = explode( ':', str_replace( ' ', ':', $date ) );
    		$date_chunks = explode( '-', str_replace( ' ', '-', $date ) );
    		$date = gmmktime( (int)$time_chunks[1], (int)$time_chunks[2], (int)$time_chunks[3], (int)$date_chunks[1], (int)$date_chunks[2], (int)$date_chunks[0] );
    	}
    
    	$current_time = current_time( 'mysql', $gmt = 0 );
    	$newer_date = strtotime( $current_time );
    
    	$since = $newer_date - $date;
    
    	if ( 0 > $since )
    		return __( 'sometime');
    
    	for ( $i = 0, $j = count($chunks); $i < $j; $i++) {
    		$seconds = $chunks[$i][0];
    
    		if ( ( $count = floor($since / $seconds) ) != 0 )
    			break;
    	}
    
    	$output = ( 1 == $count ) ? '1 '. $chunks[$i][1] : $count . ' ' . $chunks[$i][2];
    
    	if ( !(int)trim($output) ){
    		$output = '0 ' . __( 'giây');
    	}
    
    	$output .= __(' trước');
    
    	return $output;
    }
    add_filter('the_time', 'bbit_time_ago');
    
    /* -------------------------- Auto Remove Empty Meta Value ------------------------- */
    add_action('save_post','bbit_auto_remove_meta');
    function bbit_auto_remove_meta($post_id) { 
    
        if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) return;
        if (!current_user_can('edit_post', $post_id)) return;
        $custom_fields = get_post_custom($post_id);
        if(!$custom_fields) return;
    
        foreach($custom_fields as $key=>$custom_field):
    
            $values = array_filter($custom_field);
    
            if(empty($values)):
                delete_post_meta($post_id,$key);
            endif;
    
        endforeach;
        return;
    }
    
    /* ------------------------------- Modun Not Outlink ------------------------------- */
    class bbit_outlink {
    	public function __construct() {
    	add_action( 'wp', array( $this, 'call_wp' ) );
    	}
    
    	function call_wp() {
    		if ( ! is_admin() && ! is_feed() ) {
    		$priority = 1000000000;
    		add_filter( 'the_title', array( $this, 'call_filter_content' ), $priority );
    		add_filter( 'the_content', array( $this, 'call_filter_content' ), $priority );
    		add_filter( 'get_the_excerpt', array( $this, 'call_filter_content' ), $priority );
    		}
    		do_action('wpel_ready', array($this, 'call_filter_content'), $this);
    	}
    
    	function call_filter_content( $content ) {
    		return $this->filter( $content );
    	}
    
    	function is_external( $href, $rel ) {
    		for ( $x = 0, $count = count($this->ignored); $x < $count; $x++ ) {
    			if ( strrpos( $href, $this->ignored[ $x ] ) !== FALSE )
    				return FALSE;
    		}
    
    		return ( isset( $href ) AND ( strpos( $rel, 'external' ) !== FALSE
    			OR  ( strpos( $href, strtolower( get_bloginfo( 'wpurl' ) ) ) === FALSE )
    			AND ( substr( $href, 0, 7 ) == 'http://'
    			OR substr( $href, 0, 8 ) == 'https://'
    			OR substr( $href, 0, 6 ) == 'ftp://' ) ) );
    	}
    
    	function filter( $content ) {
    		$content = preg_replace_callback( '/<a[^A-Za-z](.*?)>(.*?)<\/a[\s+]*>/is', array( $this, 'call_parse_link' ), $content );
    		return $content;
    	}
    
    	function call_parse_link( $matches ) {
    		$attrs = $matches[ 1 ];
    		$attrs = stripslashes( $attrs );
    		$attrs = shortcode_parse_atts( $attrs );
    
    		$rel = ( isset( $attrs[ 'rel' ] ) ) ? strtolower( $attrs[ 'rel' ] ) : '';
    		$href = $attrs[ 'href' ];
    		$href = strtolower( $href );
    		$href = trim( $href );
    		if ( ! $this->is_external( $href, $rel ) )
    			return $matches[ 0 ];
    			$this->add_attr_value( $attrs, 'rel', 'nofollow' );
    
    		$link = '<a ';
    
    		foreach ( $attrs AS $key => $value )
    		$link .= $key .'="'. $value .'" ';
    		$link = substr( $link, 0, -1 );
    		$link .= '>'. $matches[ 2 ] .'</a>';
    		$link = apply_filters('wpel_external_link', $link, $matches[ 0 ], $matches[ 2 ], $attrs);
    		return $link;
    	}
    
    	function add_attr_value( &$attrs, $attr_name, $value, $default = NULL ) {
    		if ( key_exists( $attr_name, $attrs ) )
    			$old_value = $attrs[ $attr_name ];
    
    		if ( empty( $old_value ) )
    			$old_value = '';
    
    		$split = split( ' ', strtolower( $old_value ) );
    
    		if ( in_array( $value, $split ) ) {
    			$value = $old_value;
    		} else {
    			$value = ( empty( $old_value ) )
    								? $value
    								: $old_value .' '. $value;
    		}
    
    		if ( empty( $value ) AND $default === NULL ) {
    			unset( $attrs[ $attr_name ] );
    		} else {
    			$attrs[ $attr_name ] = $value;
    		}
    		return $value;
    	}
    }
    $bbit_outlink = new bbit_outlink();
    
    /* -------------------------------- Comment Option --------------------------------- */
    function bbit_comment($comment, $args, $depth) {
    	$GLOBALS['comment'] = $comment; ?>
    <article id="comment-<?php comment_ID() ?>">
    	<span class="icon_comment"><strong><?php echo get_comment_author_link() ?></strong></span>
    	<small><?php printf(__('%1$s lúc %2$s'), get_comment_date(),  get_comment_time()) ?></small>
    	<?php if ($comment->comment_approved == '0') : ?><em>Bình luận chờ duyệt!</em><br><?php endif; ?>
    	<?php comment_text() ?>
    </article>
    <?php }
  17. esmi
    Forum Moderator
    Posted 1 year ago #

    As it's a custom theme, it's difficult for us to know what effect any code changes are likely to have as we have no real idea who the theme was pout together. You could try removing:

    <?php wp_editor( '', 'comment', array(
            'media_buttons' => false,
            'textarea_rows' => '3',
            'tinymce' => array(
            'plugins' => 'inlinepopups, wordpress, wplink, wpdialogs',
            'theme_advanced_buttons1' => 'bold, italic, underline, strikethrough, forecolor, separator, bullist, numlist, separator, link, unlink, image','theme_advanced_buttons2' => ''),
    		'quicktags' => array('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close')
            )); ?>

    from the above file but do make a backup copy first as I don't know if the change will cause any problems.

  18. ctltvoz
    Member
    Posted 1 year ago #

    I removed that code and added <?php comment_form(); ?> to it. I think it is Ok now.

  19. ctltvoz
    Member
    Posted 1 year ago #

    Hi! I found a new way to make it work. I put // into the following:

    <?php wp_editor( '', 'comment', array(
            'media_buttons' => false,
            'textarea_rows' => '3',
            //'tinymce' => array(
            //'plugins' => 'inlinepopups, wordpress, wplink, wpdialogs',
            //'theme_advanced_buttons1' => 'bold, italic, underline, strikethrough, forecolor, separator, bullist, numlist, separator, link, unlink, image','theme_advanced_buttons2' => ''),
    		//'quicktags' => array('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close')
            )); ?>

    I think these lines conflict with wordpress comment function.

  20. ipoojasharma
    Member
    Posted 11 months ago #

    Hi

    my website is http://www.khaanabanana.com

    In the posts and pages area there is generally 2 options which is Visual Editor & Text editor.
    But on my website there is only one visual option available. can u plz tell me how to sort this thing.
    I deleted my earlier theme but i think there is a problem in the coding part as nothing changed when i deleted the option.
    It was still showing visual option only.

    [ redacted, support is only offered in the forums and not email, phone, Skype or IM ]

  21. @ipoojasharma If you need assistance then please start your own topic.

    https://wordpress.org/support/forum/how-to-and-troubleshooting#postform

    This topic is already marked resolved.

Topic Closed

This topic has been closed to new replies.

About this Topic