Definition:
function comments_popup_link( $zero = false, $one = false, $more = false, $css_class = '', $none = false ) {}
Displays the link to the comments popup window for the current post ID.
Is not meant to be displayed on single posts and pages. Should be used on the lists of posts
Parameters
- string $zero: The string to display when no comments
- string $one: The string to display when only one comment is available
- string $more: The string to display when there are more than one comment
- string $css_class: The CSS class to use for comments
- string $none: The string to display when comments have been turned off
Return values
returns:Returns null on single posts and pages.
Defined filters
- comments_popup_link_attributes
apply_filters( 'comments_popup_link_attributes', '' )
Source code
function comments_popup_link( $zero = false, $one = false, $more = false, $css_class = '', $none = false ) { global $wpcommentspopupfile, $wpcommentsjavascript; $id = get_the_ID(); if ( false === $zero ) $zero = __( 'No Comments' ); if ( false === $one ) $one = __( '1 Comment' ); if ( false === $more ) $more = __( '% Comments' ); if ( false === $none ) $none = __( 'Comments Off' ); $number = get_comments_number( $id ); if ( 0 == $number && !comments_open() && !pings_open() ) { echo '<span' . ((!empty($css_class)) ? ' class="' . esc_attr( $css_class ) . '"' : '') . '>' . $none . '</span>'; return; } if ( post_password_required() ) { echo __('Enter your password to view comments.'); return; } echo '<a href="'; if ( $wpcommentsjavascript ) { if ( empty( $wpcommentspopupfile ) ) $home = home_url(); else $home = get_option('siteurl'); echo $home . '/' . $wpcommentspopupfile . '?comments_popup=' . $id; echo '" onclick="wpopen(this.href); return false"'; } else { // if comments_popup_script() is not in the template, display simple comment link if ( 0 == $number ) echo get_permalink() . '#respond'; else comments_link(); echo '"'; } if ( !empty( $css_class ) ) { echo ' class="'.$css_class.'" '; } $title = the_title_attribute( array('echo' => 0 ) ); echo apply_filters( 'comments_popup_link_attributes', '' ); echo ' title="' . esc_attr( sprintf( __('Comment on %s'), $title ) ) . '">'; comments_number( $zero, $one, $more ); echo '</a>'; }
651
No comments yet... Be the first to leave a reply!