'comment_parent', 'id' => 'comment_ID', ); /** * Whether the comment approval notification opt-in form or message needs to be * output automatically. * * @since 5.7.0 * * @var bool */ protected $needs_comment_approval_notification_output = true; /** * Starts the list before the elements are added. * * @since 2.7.0 * * @see Walker::start_lvl() * @global int $comment_depth * * @param string $output Used to append additional content (passed by reference). * @param int $depth Optional. Depth of the current comment. Default 0. * @param array $args Optional. Uses 'style' argument for type of HTML list. Default empty array. */ public function start_lvl( &$output, $depth = 0, $args = array() ) { $GLOBALS['comment_depth'] = $depth + 1; switch ( $args['style'] ) { case 'div': break; case 'ol': $output .= '
    ' . "\n"; break; case 'ul': default: $output .= '
\n"; break; case 'ul': default: $output .= "\n"; break; } } /** * Traverses elements to create list from elements. * * This function is designed to enhance Walker::display_element() to * display children of higher nesting levels than selected inline on * the highest depth level displayed. This prevents them being orphaned * at the end of the comment list. * * Example: max_depth = 2, with 5 levels of nested content. * 1 * 1.1 * 1.1.1 * 1.1.1.1 * 1.1.1.1.1 * 1.1.2 * 1.1.2.1 * 2 * 2.2 * * @since 2.7.0 * * @see Walker::display_element() * @see wp_list_comments() * * @param WP_Comment $element Comment data object. * @param array $children_elements List of elements to continue traversing. Passed by reference. * @param int $max_depth Max depth to traverse. * @param int $depth Depth of the current element. * @param array $args An array of arguments. * @param string $output Used to append additional content. Passed by reference. */ public function display_element( $element, &$children_elements, $max_depth, $depth, $args, &$output ) { if ( ! $element ) { return; } $id_field = $this->db_fields['id']; $id = $element->$id_field; parent::display_element( $element, $children_elements, $max_depth, $depth, $args, $output ); /* * If at the max depth, and the current element still has children, loop over those * and display them at this level. This is to prevent them being orphaned to the end * of the list. */ if ( $max_depth <= $depth + 1 && isset( $children_elements[ $id ] ) ) { foreach ( $children_elements[ $id ] as $child ) { $this->display_element( $child, $children_elements, $max_depth, $depth, $args, $output ); } unset( $children_elements[ $id ] ); } } /** * Starts the element output. * * @since 2.7.0 * * @see Walker::start_el() * @see wp_list_comments() * @global int $comment_depth * @global WP_Comment $comment Global comment object. * * @param string $output Used to append additional content. Passed by reference. * @param WP_Comment $comment Comment data object. * @param int $depth Optional. Depth of the current comment in reference to parents. Default 0. * @param array $args Optional. An array of arguments. Default empty array. * @param int $id Optional. ID of the current comment. Default 0 (unused). */ public function start_el( &$output, $comment, $depth = 0, $args = array(), $id = 0 ) { $depth++; $GLOBALS['comment_depth'] = $depth; $GLOBALS['comment'] = $comment; if ( ! empty( $args['callback'] ) ) { ob_start(); call_user_func( $args['callback'], $comment, $args, $depth ); $output .= ob_get_clean(); return; } if ( 'comment' === $comment->comment_type ) { add_filter( 'comment_text', array( $this, 'filter_comment_text' ), 40, 2 ); } if ( ( 'pingback' === $comment->comment_type || 'trackback' === $comment->comment_type ) && $args['short_ping'] ) { ob_start(); $this->ping( $comment, $depth, $args ); $output .= ob_get_clean(); } elseif ( 'html5' === $args['format'] ) { ob_start(); $this->html5_comment( $comment, $depth, $args ); $output .= ob_get_clean(); } else { ob_start(); $this->comment( $comment, $depth, $args ); $output .= ob_get_clean(); } if ( 'comment' === $comment->comment_type ) { remove_filter( 'comment_text', array( $this, 'filter_comment_text' ), 40, 2 ); } } /** * Ends the element output, if needed. * * @since 2.7.0 * * @see Walker::end_el() * @see wp_list_comments() * * @param string $output Used to append additional content. Passed by reference. * @param WP_Comment $comment The current comment object. Default current comment. * @param int $depth Optional. Depth of the current comment. Default 0. * @param array $args Optional. An array of arguments. Default empty array. */ public function end_el( &$output, $comment, $depth = 0, $args = array() ) { if ( ! empty( $args['end-callback'] ) ) { ob_start(); call_user_func( $args['end-callback'], $comment, $args, $depth ); $output .= ob_get_clean(); return; } if ( 'div' === $args['style'] ) { $output .= "\n"; } else { $output .= "\n"; } } /** * Outputs a pingback comment. * * @since 3.6.0 * * @see wp_list_comments() * * @param WP_Comment $comment The comment object. * @param int $depth Depth of the current comment. * @param array $args An array of arguments. */ protected function ping( $comment, $depth, $args ) { $tag = ( 'div' === $args['style'] ) ? 'div' : 'li'; ?> < id="comment-" >
', '' ); ?>
comment_approved && ! $show_pending_links ) { $comment_text = wp_kses( $comment_text, array() ); } /* * Checks if we need to output the comment approval notification opt-in form. */ if ( $this->needs_comment_approval_notification_output ) { $comment_text = $this->comment_approval_notification_form( $comment ) . "\n" . $comment_text; } $this->needs_comment_approval_notification_output = true; return $comment_text; } /** * Outputs the awaiting moderation text. * * @since 5.7.0 * * @param WP_Comment $comment Comment to display. */ protected function awaiting_moderation_text( $comment ) { if ( '0' !== $comment->comment_approved ) { return; } $commenter = wp_get_current_commenter(); if ( $commenter['comment_author_email'] ) { $moderation_note = __( 'Your comment is awaiting moderation.' ); } else { $moderation_note = __( 'Your comment is awaiting moderation. This is a preview, your comment will be visible after it has been approved.' ); } printf( '%s', esc_html( $moderation_note ) ); } /** * Gets the comment approval notification opt-in form or message for a pending comment. * * @since 5.7.0 * * @param WP_Comment $comment Comment to display. * @return string HTML output. */ protected function comment_approval_notification_form( $comment ) { $comment_approval_output = ''; if ( '0' === $comment->comment_approved && has_action( 'comment_unapproved_to_approved', 'wp_new_comment_notify_comment_author' ) ) { if ( get_comment_meta( $comment->comment_ID, '_wp_comment_author_notification_optin', true ) ) { $comment_approval_output = sprintf( '

%s

', esc_html__( 'You will receive an email when your comment is approved.' ) ); } else { $comment_approval_output = sprintf( '

', esc_url( site_url( '/wp-comments-post.php' ) ), esc_html__( 'I want to be notified by email when my comment is approved.' ), absint( $comment->comment_ID ), wp_hash( $comment->comment_date_gmt ), esc_html_x( 'Save', 'comment approval notification form' ) ); } } // Disable the backcompat output. $this->needs_comment_approval_notification_output = false; // Return the approval notification opt-in form. return $comment_approval_output; } /** * Outputs a single comment. * * @since 3.6.0 * * @see wp_list_comments() * * @param WP_Comment $comment Comment to display. * @param int $depth Depth of the current comment. * @param array $args An array of arguments. */ protected function comment( $comment, $depth, $args ) { if ( 'div' === $args['style'] ) { $tag = 'div'; $add_below = 'comment'; } else { $tag = 'li'; $add_below = 'div-comment'; } $commenter = wp_get_current_commenter(); $show_pending_links = isset( $commenter['comment_author'] ) && $commenter['comment_author']; ?> < has_children ? 'parent' : '', $comment ); ?> id="comment-">
comment_approved && ! $show_pending_links ) { $comment_author = get_comment_author( $comment ); } printf( /* translators: %s: Comment author link. */ __( '%s says:' ), sprintf( '%s', $comment_author ) ); ?>
awaiting_moderation_text( $comment ); // Output the comment approval notification opt-in form if needed. echo $this->comment_approval_notification_form( $comment ); ?>
%s', esc_url( get_comment_link( $comment, $args ) ), sprintf( /* translators: 1: Comment date, 2: Comment time. */ __( '%1$s at %2$s' ), get_comment_date( '', $comment ), get_comment_time() ) ); edit_comment_link( __( '(Edit)' ), '   ', '' ); ?>
$add_below, 'depth' => $depth, 'max_depth' => $args['max_depth'], ) ) ); ?> $add_below, 'depth' => $depth, 'max_depth' => $args['max_depth'], 'before' => '
', 'after' => '
', ) ) ); ?>
< id="comment-" has_children ? 'parent' : '', $comment ); ?>>
comment_approved || $show_pending_links ) { comment_reply_link( array_merge( $args, array( 'add_below' => 'div-comment', 'depth' => $depth, 'max_depth' => $args['max_depth'], 'before' => '
', 'after' => '
', ) ) ); } ?>