%PDF- %PDF-
| Direktori : /home/gachan/www/wp-content/themes/jekas/inc/ |
| Current File : /home/gachan/www/wp-content/themes/jekas/inc/jekas_comments.php |
<?php
function jekas_comment_element($comment, $args, $depth){
$GLOBALS['comment'] = $comment;
$author_id = $comment->user_id;
$image = '';
if(function_exists('rwmb_user_meta')){
$img = rwmb_user_meta('user_picture',array('type' => 'image'),$author_id);
if(is_array($img))
$image = reset($img);
}
$author_image = !empty($image) ? $image['full_url'] : get_template_directory_uri().'/img/user.jpg';
?>
<div class="row">
<div class="comment">
<div class="col-md-3">
<img src="<?php print esc_url($author_image)?>" alt="" class="img-circle">
</div>
<div class="col-md-9 text_left">
<div class="title_comment">
<h5><?php print get_comment_author()?> -</h5>
<span><?php print get_comment_date('l, d F Y g:i') ?> </span>
<span><a href="<?php print esc_url( get_comment_link( $comment->comment_ID ) ); ?>"><?php esc_html_e('Comment Link','jekas')?></a> </span>
</div>
<?php comment_text()?>
</div>
</div>
</div>
<?php
}
function jekas_comment_form( $args = array(), $post_id = null ) {
if ( null === $post_id )
$post_id = get_the_ID();
$commenter = wp_get_current_commenter();
$user = wp_get_current_user();
$user_identity = $user->exists() ? $user->display_name : '';
$args = wp_parse_args( $args );
if ( ! isset( $args['format'] ) )
$args['format'] = current_theme_supports( 'html5', 'comment-form' ) ? 'html5' : 'xhtml';
$req = get_option( 'require_name_email' );
$aria_req = ( $req ? " aria-required='true'" : '' );
$html_req = ( $req ? " required='required'" : '' );
$html5 = 'html5' === $args['format'];
$fields = array(
'author' => '<div class="col-md-6">'.
'<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" placeholder = "'.esc_html__('Name','jekas').'" '. $aria_req . $html_req . ' /></div>',
'email' => '<div class="col-md-6">'.
'<input id="email" name="email" ' . ( $html5 ? 'type="email"' : 'type="text"' ) . ' value="' . esc_attr( $commenter['comment_author_email'] ) . '" aria-describedby="email-notes" placeholder = "'.esc_html__('Email','jekas').'" '. $aria_req . $html_req . ' /></div>',
'url' => '<div class = "col-md-12"><p>' .
'<input id="url" name="url" ' . ( $html5 ? 'type="url"' : 'type="text"' ) . ' value="' . esc_attr( $commenter['comment_author_url'] ) . '" placeholder="'.esc_html__('Website','jekas').'" /></p>',
);
$required_text = sprintf( ' ' . esc_html__('Required fields are marked %s','jekas'), '<span class="required">*</span>' );
/**
* Filter the default comment form fields.
*
* @since 3.0.0
*
* @param array $fields The default comment fields.
*/
$fields = apply_filters( 'comment_form_default_fields', $fields );
$defaults = array(
'fields' => $fields,
'comment_field' => '<div class = "col-md-12"><textarea id="comment" name="comment" cols="45" rows="8" aria-describedby="form-allowed-tags" required="required" placeholder="'._x('Your Message ','jekas','jekas').'"></textarea></div>',
/** This filter is documented in wp-includes/link-template.php */
'must_log_in' => '<div class = "col-md-12"><p class="must-log-in">' . sprintf(__( 'You must be <a href="%s">logged in</a> to post a comment.','jekas' ), wp_login_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) ) . '</p></div>',
/** This filter is documented in wp-includes/link-template.php */
'logged_in_as' => '<div class = ""><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>','jekas' ), get_edit_user_link(), $user_identity, wp_logout_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) ) . '</p></div>',
'comment_notes_before' => '<div class = ""><p class="comment-notes"><span id="email-notes">' .__( 'Your email address will not be published.','jekas' ) . '</span>'. ( $req ? $required_text : '' ) . '</p></div>',
'comment_notes_after' => '<div class = "col-md-12"><p class="form-allowed-tags" id="form-allowed-tags">' . sprintf( esc_html__( 'You may use these <abbr title="HyperText Markup Language">HTML</abbr> tags and attributes: %s','jekas' ), ' <code>' . allowed_tags() . '</code>' ) . '</p></div>',
'id_form' => 'commentform',
'id_submit' => 'submit',
'class_submit' => 'button',
'name_submit' => 'submit',
'title_reply' => esc_html__( 'Leave a Reply','jekas' ),
'title_reply_to' => esc_html__( 'Leave a Reply to %s','jekas' ),
'cancel_reply_link' => esc_html__( 'Cancel reply' , 'jekas'),
'label_submit' => esc_html__( 'Send Comment','jekas' ),
'submit_button' => '<input name="%1$s" type="submit" id="%2$s" class="%3$s" value="%4$s" />',
'submit_field' => '<p class="col-md-12 form-submit">%1$s %2$s</p>',
'format' => 'xhtml',
);
/**
* Filter the comment form default arguments.
*
* Use 'comment_form_default_fields' to filter the comment fields.
*
* @since 3.0.0
*
* @param array $defaults The default comment form arguments.
*/
$args = wp_parse_args( $args, apply_filters( 'comment_form_defaults', $defaults ) );
// Ensure that the filtered args contain all required default values.
$args = array_merge( $defaults, $args );
if ( comments_open( $post_id ) ) : ?>
<?php
/**
* Fires before the comment form.
*
* @since 3.0.0
*/
do_action( 'comment_form_before' );
?>
<h2 id="reply-title" ><?php comment_form_title( $args['title_reply'], $args['title_reply_to'] ); ?> <small><?php cancel_comment_reply_link( $args['cancel_reply_link'] ); ?></small></h2>
<?php if ( get_option( 'comment_registration' ) && !is_user_logged_in() ) : ?>
<?php echo $args['must_log_in']; ?>
<?php
/**
* Fires after the HTML-formatted 'must log in after' message in the comment form.
*
* @since 3.0.0
*/
do_action( 'comment_form_must_log_in_after' );
?>
<?php else : ?>
<form action="<?php echo esc_url(site_url( '/wp-comments-post.php' )); ?>" method="post" id="<?php echo esc_attr( $args['id_form'] ); ?>" class="form_comment padding_top_mini" <?php echo $html5 ? ' novalidate' : ''; ?>>
<?php
/**
* Fires at the top of the comment form, inside the form tag.
*
* @since 3.0.0
*/
do_action( 'comment_form_top' );
?>
<?php if ( is_user_logged_in() ) : ?>
<?php
/**
* Filter the 'logged in' message for the comment form for display.
*
* @since 3.0.0
*
* @param string $args_logged_in The logged-in-as HTML-formatted message.
* @param array $commenter An array containing the comment author's
* username, email, and URL.
* @param string $user_identity If the commenter is a registered user,
* the display name, blank otherwise.
*/
echo apply_filters( 'comment_form_logged_in', $args['logged_in_as'], $commenter, $user_identity );
?>
<?php
/**
* Fires after the is_user_logged_in() check in the comment form.
*
* @since 3.0.0
*
* @param array $commenter An array containing the comment author's
* username, email, and URL.
* @param string $user_identity If the commenter is a registered user,
* the display name, blank otherwise.
*/
do_action( 'comment_form_logged_in_after', $commenter, $user_identity );
?>
<?php else : ?>
<?php echo $args['comment_notes_before']; ?>
<?php
/**
* Fires before the comment fields in the comment form.
*
* @since 3.0.0
*/
do_action( 'comment_form_before_fields' );
print '<div class="row">';
foreach ( (array) $args['fields'] as $name => $field ) {
/**
* Filter a comment form field for display.
*
* The dynamic portion of the filter hook, `$name`, refers to the name
* of the comment form field. Such as 'author', 'email', or 'url'.
*
* @since 3.0.0
*
* @param string $field The HTML-formatted output of the comment form field.
*/
echo apply_filters( "comment_form_field_{$name}", $field ) . "\n";
}
/**
* Fires after the comment fields in the comment form.
*
* @since 3.0.0
*/
print '</div>';
do_action( 'comment_form_after_fields' );
?>
<?php endif; ?>
<?php
/**
* Filter the content of the comment textarea field for display.
*
* @since 3.0.0
*
* @param string $args_comment_field The content of the comment textarea field.
*/
echo apply_filters( 'comment_form_field_comment', $args['comment_field'] );
?>
<?php echo $args['comment_notes_after']; ?>
<?php
$submit_button = sprintf(
$args['submit_button'],
esc_attr( $args['name_submit'] ),
esc_attr( $args['id_submit'] ),
esc_attr( $args['class_submit'] ),
esc_attr( $args['label_submit'] )
);
/**
* Filter the submit button for the comment form to display.
*
* @since 4.2.0
*
* @param string $submit_button HTML markup for the submit button.
* @param array $args Arguments passed to `comment_form()`.
*/
$submit_button = apply_filters( 'comment_form_submit_button', $submit_button, $args );
$submit_field = sprintf(
$args['submit_field'],
$submit_button,
get_comment_id_fields( $post_id )
);
/**
* Filter the submit field for the comment form to display.
*
* The submit field includes the submit button, hidden fields for the
* comment form, and any wrapper markup.
*
* @since 4.2.0
*
* @param string $submit_field HTML markup for the submit field.
* @param array $args Arguments passed to comment_form().
*/
echo apply_filters( 'comment_form_submit_field', $submit_field, $args );
/**
* Fires at the bottom of the comment form, inside the closing </form> tag.
*
* @since 1.5.0
*
* @param int $post_id The post ID.
*/
do_action( 'comment_form', $post_id );
?>
</form>
<?php endif; ?>
<?php
/**
* Fires after the comment form.
*
* @since 3.0.0
*/
do_action( 'comment_form_after' );
else :
/**
* Fires after the comment form if comments are closed.
*
* @since 3.0.0
*/
do_action( 'comment_form_comments_closed' );
endif;
}