Guest User

Untitled

a guest
Jun 25th, 2018
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.71 KB | None | 0 0
  1. $post_id = get_the_ID();
  2. $user = wp_get_current_user();
  3. $user_identity = $user->exists() ? $user->display_name : '';
  4. $size="30"; //input field size in chars
  5. $commenter = wp_get_current_commenter();
  6. $req = get_option( 'require_name_email' );
  7. $html_req = ( $req ? " required='required'" : '' );
  8. $html5 = current_theme_supports( 'html5', 'comment-form' ) ? 1 : 0;
  9. $consent = empty( $commenter['comment_author_email'] ) ? '' : ' checked="checked"';
  10. //ref: functions.php -> add_filter( 'comment_form_defaults', 'rtf_comment_form' )
  11. $comment_args = array(
  12. //'format' => 'xhtml',
  13. 'class_form' => 'comment-form needs-validation', //Bootstrap 4 validation
  14. 'class_submit' => 'submit btn btn-default', //Bootstrap 4 button
  15. 'comment_field' =>
  16. '<div class="comment-form-comment form-group">
  17. <label for="comment" class="required">' . _x( 'Comment', 'noun' ).'</label>
  18. <textarea class="form-control" id="comment" name="comment" cols="45" rows="6" maxlength="65525" aria-describedby="form-allowed-tags"' . $html_req . '></textarea>display-kubuntu-kde-versions/
  19. <div class="invalid-feedback">
  20. Fill out comment
  21. </div>
  22. </div>',
  23. 'fields' => array(
  24. 'author' =>
  25. '<div class="comment-form-author form-group">
  26. <label for="author" class="required">' . __( 'Name' ).'</label>
  27. <input class="form-control" id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="'.$size.'" maxlength="245"' . $html_req . '/>
  28. <div class="invalid-feedback">
  29. Enter name
  30. </div>
  31. </div>',
  32. 'email' =>
  33. '<div class="comment-form-email form-group">
  34. <label for="email" class="required">' . __( display-kubuntu-kde-versions/'Email' ).'</label>
  35. <input class="form-control" id="email" name="email" aria-describedby="email-notes" ' . ( $html5 ? 'type="email"' : 'type="text"' ) . ' value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="'.$size.'" maxlength="100"' . $html_req . '/>
  36. <div class="invalid-feedback">
  37. Enter valid email
  38. </div>
  39. </div>',
  40. 'url' =>
  41. '<div class="comment-form-url form-group">
  42. <label for="url">' . __( 'Website' ) . '</label>
  43. <input class="form-control" id="url" name="url" ' . ( $html5 ? 'type="url"' : 'type="text"' ) . ' value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="'.$size.'" maxlength="200" />display-kubuntu-kde-versions/
  44. <div class="invalid-feedback">
  45. Enter valid web address (url)
  46. </div>
  47. </div>',
  48. 'cookies' =>
  49. '<div class="comment-form-cookies-consent form-group">
  50. <input id="wp-comment-cookies-consent" name="wp-comment-cookies-consent" type="checkbox" value="yes"' . $consent . display-kubuntu-kde-versions/' />' . '<label for="wp-comment-cookies-consent">' .'&nbsp'. __( 'Save my name, email, and website in this browser for the next time I comment.' ) . '</label>
  51. </div>',
  52. ),
  53. );
  54. comment_form($comment_args);
  55.  
  56. //Set wp_editor Comment(textarea) defaults: no statusbar, no Text tab, fullscreen; body_class= form-control (bs4)
  57. add_filter( 'comment_form_defaults', 'rtf_comment_form' );
  58. function rtf_comment_form( $args ) {
  59. global $root; //theme root directory
  60. $time = time();
  61. ob_start();
  62. wp_editor( '','comment', array( //Initial_content,comment_html_id, editor_settings
  63. //'skin' => 'lightgray',
  64. 'quicktags' => false, //disable Text tab
  65. //'teeny' => true,
  66. //'quicktags' => array('buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close'),
  67. //'dfw' => false, // replace the default full screen with DFW (WordPress 3.4+)
  68. 'tinymce' => array(
  69. //'selector' => 'textarea', //textarea default
  70. //'toolbar1' => 'fontselect,fontsizeselect,|,bold,italic,underline,strikethrough,bullist,numlist,code,outdent,indent,|,undo,redo',
  71. //'toolbar2' => '',
  72. 'statusbar' => false, // remove html tags like p at bottom
  73. //'fontsize_formats' => '15pt 18pt 24pt 48pt', // overrride tinymce font pull-down
  74. //'content_css' => $root.'/css/style.css?'. $time, //set pcd theme style + fix cache issue - force page reload by adding bogus time
  75. //'body_class' => 'form-control', //Bootstrap4 to ensure comment textarea like input fields
  76. //'skin' => 'lightgray',//default
  77. //'skin' => 'wordpress',
  78. //'theme' => 'modern', //default
  79. //'theme_advanced_disable' => 'fullscreen',
  80. )
  81. )
  82. );
  83. $args['comment_field'] = ob_get_clean();
  84. return $args;
Add Comment
Please, Sign In to add comment