Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #1052360

    As you did here on the board – is it possible to have for comments an editor like this here or f.e. tinyMCE ?
    there are some links on google – but all of them do not work in combination with our theme.
    Especially on responding to nested comments does not work at all.

    #1052365

    Just in that moment i found a suitable solution for me – this comes to functions.php of child-theme:

    add_filter('avia_form_tag_output','avia_form_tag_output',10,1);
    function avia_form_tag_output($output){
        $args=array(
          'orderby'    => 'count',
          'order'    => 'DESC',
          'hide_empty' => false,
         );
        $tag_terms=get_terms('avia-question_tag', $args ) ;
        $output='<select name="question-tag" id="question-tag" class="postform">';
        $output.='<option value="">Select question Tags</option>';
        foreach($tag_terms as $tag_term)
          $output.='<option value="'.$tag_term->name.'">'.$tag_term->name.'</option>';
        $output.='</select>';
      return $output;
    }
    
    add_filter( 'comment_form_field_comment', 'comment_editor' );
    
    function comment_editor() {
      global $post;
    
      ob_start();
    
      wp_editor( '', 'comment', array(
        'textarea_rows' => 15,
        'teeny' => true,
        'quicktags' => false,
        'media_buttons' => false
      ) );
    
      $editor = ob_get_contents();
    
      ob_end_clean();
    
      //make sure comment media is attached to parent post
      $editor = str_replace( 'post_id=0', 'post_id='.get_the_ID(), $editor );
    
      return $editor;
    }
    
    // wp_editor doesn't work when clicking reply. Here is the fix.
    add_action( 'wp_enqueue_scripts', '__THEME_PREFIX__scripts' );
    function __THEME_PREFIX__scripts() {
        wp_enqueue_script('jquery');
    }
    add_filter( 'comment_reply_link', '__THEME_PREFIX__comment_reply_link' );
    function __THEME_PREFIX__comment_reply_link($link) {
        return str_replace( 'onclick=', 'data-onclick=', $link );
    }
    add_action( 'wp_head', '__THEME_PREFIX__wp_head' );
    function __THEME_PREFIX__wp_head() {
    ?>
    <script type="text/javascript">
      jQuery(function($){
        $('.comment-reply-link').click(function(e){
          e.preventDefault();
          var args = $(this).data('onclick');
          args = args.replace(/.*\(|\)/gi, '').replace(/\"|\s+/g, '');
          args = args.split(',');
          tinymce.EditorManager.execCommand('mceRemoveEditor', true, 'comment');
          addComment.moveForm.apply( addComment, args );
          tinymce.EditorManager.execCommand('mceAddEditor', true, 'comment');
        });
      });
    </script>
    <?php 
    }
    #1052367

    Looks this way:
    (Purchase code hidden if logged out) -15-15-33.jpg” alt=”” />

    #1052490

    by the way you can decide which buttons of tinyMCE are active for that case:
    you only have to edit the tinyMCE details in the code above like:

    wp_editor( '', 'comment', array(
        'textarea_rows' => 15,
        'teeny' => true,
        'quicktags' => false,
        'media_buttons' => false,
        'tinymce' => array(
        'toolbar1' => 'formatselect | bold italic strikethrough | alignleft aligncenter alignright alignjustify  | numlist bullist outdent indent ',
        'toolbar2'=>false
      ),
      ) );

    with this options it will look like this:
    (Purchase code hidden if logged out) -19-46-26.jpg” alt=”” />

    see here f.e. how to style: https://www.tiny.cloud/docs/demo/full-featured/

    #1053116

    Hi,

    Thanks for sharing the tip!

    Best regards,
    Basilis

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.