ID ); } if( ! anchorage_are_comments_approved() ) { return false; } $href = esc_url( get_comments_link( $post_id ) ); $comments_count = wp_count_comments( $post_id ); $comments_approved = absint( $comments_count -> approved ); if( empty( $comments_approved ) ) { $label = __( 'Comment', 'anchorage' ); } else { $label = sprintf( _n( '1 Comment', '%s Comments', $comments_approved, 'anchorage' ), $comments_approved ); } $label = esc_html( $label ); $link = "$label"; return $link; } } /** * Determine if there are approved comments for a post. * * @param int $post_id The ID of the post we're checking * @return boolean True if there are approved comments, otherwise false * * @since anchorage 1.0 */ if( ! function_exists('anchorage_are_comments_approved' ) ) { function anchorage_are_comments_approved( $post_id = '' ) { // Determine which post we're grabbing from. $post_id = absint( $post_id ); if( empty( $post_id ) ) { global $post; $post_id = absint( $post -> ID ); } // Are there comments approved for this post? $comments_count = wp_count_comments( $post_id ); $comments_approved = absint( $comments_count -> approved ); if( empty ( $comments_approved ) ) { return false; } return true; } } /** * Outputs the comments form for a post. * * @param $post_id The ID of the post we're grabbing from * * @since anchorage 1.0 */ if ( ! function_exists( 'anchorage_the_comment_form' ) ) { function anchorage_the_comment_form( $post_id = '' ) { // determine which post we're grabbing from $post_id = absint( $post_id ); if( empty( $post_id ) ) { global $post; $post_id = absint( $post -> ID ); } $leave_a_comment = esc_html__( 'Leave a Comment', 'anchorage' ); $br = anchorage_get_hard_rule(); // There does not seem to be a way to return instead of echo. comment_form( array( 'title_reply' => "$leave_a_comment $br", 'comment_notes_before' => '', 'comment_notes_after' => '', 'cancel_reply_link' => '', ), $post_id ); } } /** * Returns the comments pagination for a post * * @param int $post_id The id of the post we're grabbing from * @return string The comments pagination for a post * * @since anchorage 1.0 */ if( ! function_exists( 'anchorage_get_comments_pagination' ) ) { function anchorage_get_comments_pagination( $post_id = '' ) { // Determine which post we're grabbing from. $post_id = absint( $post_id ); if( empty( $post_id ) ) { global $post; $post_id = absint( $post -> ID ); } // Does this blog break comments into pages? $page_comments = get_option( 'page_comments' ); if( empty ( $page_comments ) ) { return false; } // How many comments per page? $comments_per_page = get_option( 'comments_per_page' ); // Get the comment count for this post $comments_count = wp_count_comments( $post_id ); $comments_approved = absint( $comments_count -> approved ); // Are there more comments than can fit on one page? If so, show pagination. if( $comments_approved <= $comments_per_page ) { return false; } // The link for older comments. $next = ''; if ( get_next_comments_link() ) { $older_comments = esc_html__( 'Older Comments', 'anchorage' ); $arrow = anchorage_get_arrow( 'right', array(), false ); $next_text = "$older_comments$arrow"; $next_link = get_next_comments_link( $next_text ); $next = " "; } // The link for newer comments. $prev=''; if ( get_previous_comments_link() ) { $newer_comments = esc_html__( 'Newer Comments', 'anchorage' ); $arrow = anchorage_get_arrow( 'left', array(), false ); $prev_text = "$arrow$newer_comments"; $prev_link = get_previous_comments_link( $prev_text ); $prev = " "; } // Wrap the comments pagination. $out = " "; return $out; } } /** * Returns the comments title for a post * * @param int $post_id The id of the post we're grabbing from * @return string The comments title for a post * * @since anchorage 1.0 */ if( ! function_exists( 'anchorage_get_comments_title' ) ) { function anchorage_get_comments_title( $post_id = '' ) { // determine which post we're grabbing from $post_id = absint( $post_id ); if( empty( $post_id ) ) { global $post; $post_id = absint( $post -> ID ); } $post_title = get_the_title( $post_id ); // create a title for the comments section depending on how many comments there are $out = sprintf( _nx( 'One comment on “%2$s”', '%1$s comments on “%2$s”', get_comments_number( $post_id ), 'comments title', 'anchorage' ), number_format_i18n( get_comments_number( $post_id ) ), "$post_title" ); // wrap the comments title $out = "
$awaiting
"; // If the comment is approved, grab the comment. } else { $header = anchorage_get_comment_header( $comment, $args, $depth ); $body = anchorage_get_comment_body( $comment, $args, $depth ); $break = anchorage_get_hard_rule( array( 'break-minor' ) ); $footer = anchorage_get_comment_footer( $comment, $args, $depth ); $out = $header . $body . $break . $footer; } if( empty( $post_id ) ) { $post_id = get_the_ID(); } $post_id = absint( $post_id ); // Apply a class to the comment depending on is/not a parent of other comments. $maybe_parent = 'not-parent'; if( ! empty( $args['has_children'] ) ) { $maybe_parent = 'parent'; } $comment_class = comment_class( $maybe_parent, $comment_id, $post_id, false ); /** * This is left unclosed because wp_list_comments automatically closes it after any child comments. */ $out = "