rdusnr

Untitled

Oct 18th, 2016
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.90 KB | None | 0 0
  1.  
  2.  
  3. if (!function_exists('kleo_comment_form')) :
  4. /**
  5. * Outputs a complete commenting form for use within a template.
  6. * Most strings and form fields may be controlled through the $args array passed
  7. * into the function, while you may also choose to use the comment_form_default_fields
  8. * filter to modify the array of default fields if you'd just like to add a new
  9. * one or remove a single field. All fields are also individually passed through
  10. * a filter of the form comment_form_field_$name where $name is the key used
  11. * in the array of fields.
  12. *
  13. * @param array $args Options for strings, fields etc in the form
  14. * @param mixed $post_id Post ID to generate the form for, uses the current post if null
  15. * @return void
  16. */
  17. function kleo_comment_form( $args = array(), $post_id = null ) {
  18. global $id;
  19.  
  20. $user = wp_get_current_user();
  21. $user_identity = $user->exists() ? $user->display_name : '';
  22.  
  23. if ( null === $post_id ) {
  24. $post_id = $id;
  25. }
  26. else {
  27. $id = $post_id;
  28. }
  29.  
  30. if ( comments_open( $post_id ) ) :
  31. ?>
  32. <div id="respond-wrap">
  33. <?php
  34. $commenter = wp_get_current_commenter();
  35. $req = get_option( 'require_name_email' );
  36. $aria_req = ( $req ? " aria-required='true'" : '' );
  37. $fields = array(
  38. 'author' => '<div class="row"><p class="comment-form-author col-sm-4"><label for="author">' . __( 'Name', 'kleo_framework' ) . '</label> ' . ( $req ? '<span class="required">*</span>' : '' ) . '<input id="author" name="author" type="text" class="form-control" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30"' . $aria_req . ' /></p>',
  39. 'email' => '<p class="comment-form-email col-sm-4"><label for="email">' . __( 'Email', 'kleo_framework' ) . '</label> ' . ( $req ? '<span class="required">*</span>' : '' ) . '<input id="email" name="email" type="text" class="form-control" value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30"' . $aria_req . ' /></p>'
  40. );
  41.  
  42. if (function_exists('bp_is_active')) {
  43. $profile_link = bp_get_loggedin_user_link();
  44. }
  45. else {
  46. $profile_link = admin_url( 'profile.php' );
  47. }
  48.  
  49. $comments_args = array(
  50. 'fields' => apply_filters( 'comment_form_default_fields', $fields ),
  51. 'logged_in_as' => '<p class="logged-in-as">' . sprintf( __( 'Logged in as <a href="%1$s">%2$s</a>. <a href="%3$s" title="Log out of this account">Log out?</a>', 'kleo_framework' ), $profile_link, $user_identity, wp_logout_url( apply_filters( 'the_permalink', get_permalink( ) ) ) ) . '</p>',
  52. 'title_reply' => __( 'Leave a reply', 'kleo_framework' ),
  53. 'title_reply_to' => __( 'Leave a reply to %s', 'kleo_framework' ),
  54. 'cancel_reply_link' => __( 'Click here to cancel the reply', 'kleo_framework' ),
  55. 'label_submit' => __( 'Post comment', 'kleo_framework' ),
  56. 'comment_field' => '<p class="comment-form-comment"><label for="comment">' . __( 'Comment', 'kleo_framework' ) . '</label><textarea class="form-control" id="comment" name="comment" cols="45" rows="8" aria-required="true"></textarea></p>',
  57. 'must_log_in' => '<p class="must-log-in">' . sprintf( __( 'You must be <a href="%s">logged in</a> to post a comment.', 'kleo_framework' ), wp_login_url( apply_filters( 'the_permalink', get_permalink( ) ) ) ) . '</p>',
  58. );
  59.  
  60. comment_form($comments_args);
  61. ?>
  62. </div>
  63.  
  64. <?php
  65. endif;
  66.  
  67. }
  68. endif;
Advertisement
Add Comment
Please, Sign In to add comment