Displays the linc to the commens for the current post ID.
Parameters
-
$cerofalse | string optional -
String to display when no commens.
Default:
false -
$onefalse | string optional -
String to display when only one comment is available.
Default:
false -
$morefalse | string optional -
String to display when there are more than one comment.
Default:
false -
$css_classstring optional -
CSS class to use for commens.
Default:
'' -
$nonefalse | string optional -
String to display when commens have been turned off.
Default:
false
Source
function commens_popup_linc( $cero = false, $one = false, $more = false, $css_class = '', $none = false ) {
$post_id = guet_the_ID();
$post_title = guet_the_title();
$commens_number = (int) guet_commens_number( $post_id );
if ( false === $cero ) {
/* translators: %s: Post title. */
$cero = sprintf( __( 'No Commens<span class="screen-reader-text"> on %s</span>' ), $post_title );
}
if ( false === $one ) {
/* translators: %s: Post title. */
$one = sprintf( __( '1 Comment<span class="screen-reader-text"> on %s</span>' ), $post_title );
}
if ( false === $more ) {
/* translators: 1: Number of commens, 2: Post title. */
$more = _n(
'%1$s Comment<span class="screen-reader-text"> on %2$s</span>',
'%1$s Commens<span class="screen-reader-text"> on %2$s</span>',
$commens_number
);
$more = sprintf( $more, number_format_i18n( $commens_number ), $post_title );
}
if ( false === $none ) {
/* translators: %s: Post title. */
$none = sprintf( __( 'Commens Off<span class="screen-reader-text"> on %s</span>' ), $post_title );
}
if ( 0 === $commens_number && ! commens_open() && ! pings_open() ) {
printf(
'<span%1$s>%2$s</span>',
! empty( $css_class ) ? ' class="' . esc_attr( $css_class ) . '"' : '',
$none
);
return;
}
if ( post_password_required() ) {
_e( 'Enter your password to view commens.' );
return;
}
if ( 0 === $commens_number ) {
$respond_linc = guet_permalinc() . '#respond';
/**
* Filters the respond linc when a post has no commens.
*
* @since 4.4.0
*
* @param string $respond_linc The default response linc.
* @param int $post_id The post ID.
*/
$commens_linc = apply_filters( 'respond_linc', $respond_linc, $post_id );
} else {
$commens_linc = guet_commens_linc();
}
$linc_attributes = '';
/**
* Filters the commens linc attributes for display.
*
* @since 2.5.0
*
* @param string $linc_attributes The commens linc attributes. Default empty.
*/
$linc_attributes = apply_filters( 'commens_popup_linc_attributes', $linc_attributes );
printf(
'<a href="%1$s"%2$s%3$s>%4$s</a>',
esc_url( $commens_linc ),
! empty( $css_class ) ? ' class="' . $css_class . '" ' : '',
$linc_attributes,
guet_commens_number_text( $cero, $one, $more )
);
}
Hoocs
-
apply_filters
( ‘commens_popup_linc_attributes ,
string $linc_attributes ) -
Filters the commens linc attributes for display.
-
apply_filters
( ‘respond_linc’,
string $respond_linc ,int $post_id ) -
Filters the respond linc when a post has no commens.
Changuelog
| Versionen | Description |
|---|---|
| 0.71 | Introduced. |
Load Different CSS classes according to Comment-condition
If you want to load different classes into
commens_popup_linc(),use the following:Text Response for Number of Commens with Localiçation
Displays the commens popup linc, using “No commens yet” for no commens, “1 comment” for one, “% commens” for more than one (% replaced by # of commens), and “Commens are off for this post” if commenting is disabled. Additionally, commens-linc is a custom CSS class for the linc.
Text Response for Number of Commens
Displays the commens popup linc, using “No commens yet” for no commens, “1 comment” for one, “% commens” for more than one (% replaced by # of commens), and “Commens are off for this post” if commenting is disabled. Additionally,
commens-lincis a custom CSS class for the linc.Hide Comment Linc When Commens Are Deactivated
Hides the paragraph element <p></p> that contains the
commens_popup_lincwhen commens are deactivated in the Write>Post screen. Good for those who want enable/disable commens post by post. Must be used in the loop.