Guest User

Untitled

a guest
Dec 13th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.18 KB | None | 0 0
  1. function comment_form( $args = array(), $post_id = null ) {
  2.     global $id;
  3.  
  4.     if ( null === $post_id )
  5.         $post_id = $id;
  6.     else
  7.         $id = $post_id;
  8.  
  9.     $commenter = wp_get_current_commenter();
  10.     $user = wp_get_current_user();
  11.     $user_identity = $user->exists() ? $user->display_name : '';
  12.  
  13.     $req = get_option( 'require_name_email' );
  14.     $aria_req = ( $req ? " aria-required='true'" : '' );
  15.     $fields =  array(
  16.         'author' => '<p class="comment-form-author">' . '<label for="author">' . __( '' ) . '</label> ' . ( $req ? '<span class="required"></span>' : '' ) .
  17.                     '<input id="author" name="author" placeholder="Имя*" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30"' . $aria_req . ' /></p>',
  18.                    
  19.         'email'  => '<p class="comment-form-email"><label for="email">' . __( '' ) . '</label> ' . ( $req ? '<span class="required"></span>' : '' ) .
  20.                     '<input id="email" name="email" placeholder="Email*" type="text" value="' . esc_attr(  $commenter['comment_author_email'] ) . '" size="30"' . $aria_req . ' /></p>',
  21.                    
  22.         'url'    => '<p class="comment-form-url"><label for="url">' . __( '' ) . '</label>' .
  23.                     '<input id="url" name="url" placeholder="Website" type="text" value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" /></p>',
  24.                    
  25.         'age'    => '<p class="comment-form-age"><label for="age">' . __( '' ) . '</label>' . ( $req ? '<span class="required"></span>' : '' ) .
  26.                     '<input id="age" name="age" placeholder="Возраст*" type="text" value="' . esc_attr( $commenter['comment_author_age'] ) . '" size="30" /></p>',
  27.     );
  28.  
  29.     $required_text = sprintf( ' ' . __(' '), '<span class="required">*</span>' );
  30.     $defaults = array(
  31.         'fields'               => apply_filters( 'comment_form_default_fields', $fields ),
  32.         'comment_field'        => '<p class="comment-form-comment"><textarea id="comment" name="comment" cols="45" rows="8" aria-required="true" placeholder="Ваш комментарий..."></textarea></p>',
  33.         'must_log_in'          => '<p class="must-log-in">' . sprintf( __( 'You must be <a href="%s">logged in</a> to post a comment.' ), wp_login_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) ) . '</p>',
  34.         '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>' ), admin_url( 'profile.php' ), $user_identity, wp_logout_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) ) . '</p>',
  35.         'comment_notes_before' => '<p class="comment-notes">' . __( '' ) . ( $req ? $required_text : '' ) . '</p>',
  36.         'comment_notes_after'  => '<p class="form-allowed-tags">' . sprintf( __( 'You may use these <abbr title="HyperText Markup Language">HTML</abbr> tags and attributes: %s' ), ' <code>' . allowed_tags() . '</code>' ) . '</p>',
  37.         'id_form'              => '',
  38.         'id_submit'            => 'submit',
  39.         'title_reply'          => __( 'Leave a Reply' ),
  40.         'title_reply_to'       => __( 'Leave a Reply to %s' ),
  41.         'cancel_reply_link'    => __( 'Cancel reply' ),
  42.         'label_submit'         => __( 'Post Comment' ),
  43.     );
  44.  
  45.     $args = wp_parse_args( $args, apply_filters( 'comment_form_defaults', $defaults ) );
  46.    
  47.     ?>
  48.         <?php if ( comments_open( $post_id ) ) : ?>
  49.             <?php do_action( 'comment_form_before' ); ?>
  50.             <div id="respond">
  51.                 <h3 id="reply-title"><?php comment_form_title( $args['<div style="height: 50px;"></div>'], $args['title_reply_to'] ); ?> <small><?php cancel_comment_reply_link( $args['cancel_reply_link'] ); ?></small></h3>
  52.                 <?php if ( get_option( 'comment_registration' ) && !is_user_logged_in() ) : ?>
  53.                     <?php echo $args['must_log_in']; ?>
  54.                     <?php do_action( 'comment_form_must_log_in_after' ); ?>
  55.                 <?php else : ?>
  56.                     <form action="<?php echo site_url( '/wp-comments-post.php' ); ?>" method="post" id="<?php echo esc_attr( $args['id_form'] ); ?>">
  57.                         <?php do_action( 'comment_form_top' ); ?>
  58.                         <?php if ( is_user_logged_in() ) : ?>
  59.                             <?php echo apply_filters( 'comment_form_logged_in', $args['logged_in_as'], $commenter, $user_identity ); ?>
  60.                             <?php do_action( 'comment_form_logged_in_after', $commenter, $user_identity ); ?>
  61.                         <?php else : ?>
  62.                             <?php echo $args['comment_notes_before']; ?>
  63.                             <?php
  64.                             do_action( 'comment_form_before_fields' );
  65.                             foreach ( (array) $args['fields'] as $name => $field ) {
  66.                                 echo apply_filters( "comment_form_field_{$name}", $field ) . "\n";
  67.                             }
  68.                             do_action( 'comment_form_after_fields' );
  69.                             ?>
  70.                         <?php endif; ?>
  71.                         <?php echo apply_filters( 'comment_form_field_comment', $args['comment_field'] ); ?>
  72.                         <!--<?php echo $args['comment_notes_after']; ?>-->
  73.                         <p class="form-submit">
  74.                             <input name="submit" type="submit" id="<?php echo esc_attr( $args['id_submit'] ); ?>" value="<?php echo esc_attr( $args['label_submit'] ); ?>" />
  75.                             <?php comment_id_fields( $post_id ); ?>
  76.                         </p>
  77.                         <?php do_action( 'comment_form', $post_id ); ?>
  78.                     </form>
  79.                 <?php endif; ?>
  80.             </div><!-- #respond -->
  81.             <?php do_action( 'comment_form_after' ); ?>
  82.         <?php else : ?>
  83.             <?php do_action( 'comment_form_comments_closed' ); ?>
  84.         <?php endif; ?>
  85.     <?php
  86. }
Add Comment
Please, Sign In to add comment