'; printf( // WPCS: XSS OK. esc_html( _nx( 'Comment (%1$s)', 'Comments (%1$s)', $comments_number, 'comments title', 'razzi' ) ), number_format_i18n( $comments_number ) ); echo ''; } /** * No comment * * @since 1.0.0 * * @return void */ public function comment_fields() { if ( ! comments_open() ) { echo '

' . esc_html__( 'Comments are closed.', 'razzi' ) . '

'; } else { $comment_field = '

'; comment_form( array( 'format' => 'xhtml', 'comment_field' => $comment_field, ) ); } } /** * Loop content * * @since 1.0.0 * * @return void */ public function comment_content() { echo '
    '; wp_list_comments( array( 'avatar_size' => 70, 'short_ping' => true, 'style' => 'ol', 'callback' => array( $this, 'razzi_comment' ) ) ); echo '
'; } /** * Custom fields comment form * * @since 1.0 * * @return array $fields */ public function comment_form_fields() { global $commenter, $aria_req; $comment_author = isset($commenter['comment_author']) ? $commenter['comment_author'] : ''; $comment_author_email = isset($commenter['comment_author_email']) ? $commenter['comment_author_email'] : ''; $comment_author_url = isset($commenter['comment_author_url']) ? $commenter['comment_author_url'] : ''; $fields = array( 'author' => '

' . '

', 'email' => '

' . '

', 'url' => '

' . '

' ); return $fields; } /** * Comment callback function * * @since 1.0.0 * * @param object $comment * @param array $args * @param int $depth * * @return string */ public function razzi_comment( $comment, $args, $depth ) { $GLOBALS['comment'] = $comment; extract( $args, EXTR_SKIP ); $avatar = ''; if ( $args['avatar_size'] != 0 ) { $avatar = get_avatar( $comment, $args['avatar_size'] ); } $classes = get_comment_class( empty( $args['has_children'] ) ? '' : 'parent' ); $classes = $classes ? implode( ' ', $classes ) : $classes; $comments = array( 'comment_parent' => 0, 'comment_ID' => get_comment_ID(), 'comment_class' => $classes, 'comment_avatar' => $avatar, 'comment_author_link' => get_comment_author_link(), 'comment_link' => get_comment_link( get_comment_ID() ), 'comment_date' => get_comment_date(), 'comment_time' => get_comment_time(), 'comment_approved' => $comment->comment_approved, 'comment_text' => get_comment_text(), 'comment_reply' => get_comment_reply_link( array_merge( $args, array( 'add_below' => 'comment', 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ) ); $comment = $this->comment_template( $comments ); echo ! empty( $comment ) ? $comment : ''; } /** * Comment Template function * * @since 1.0.0 * * @param object $comment * * @return string */ public function comment_template( $comments ) { $output = array(); $output[] = sprintf( '
  • ', esc_attr( $comments['comment_ID'] ), esc_attr( $comments['comment_class'] ) ); $output[] = sprintf( '
    ', $comments['comment_ID'] ); $output [] = ! empty( $comments['comment_avatar'] ) ? sprintf( '
    ' . '
    %s
    ' . '
    ', $comments['comment_avatar'] ) : ''; $output[] = '
    '; if ( $comments['comment_approved'] == '0' ) { $output[] = sprintf( '%s', esc_html__( 'Your comment is awaiting moderation.', 'razzi' ) ); } else { $output[] = $comments['comment_text']; } $output[] = '
    '; $output[] = $comments['comment_reply']; if ( current_user_can( 'edit_comment', $comments['comment_ID'] ) ) { $output[] = sprintf( '%s', esc_url( admin_url( 'comment.php?action=editcomment&c=' ) . $comments['comment_ID'] ), esc_html__( 'Edit', 'razzi' ) ); } $output[] = '
    '; return implode( ' ', $output ); } }