comments_popup_script

Definition:
function comments_popup_script($width=400, $height=400, $file='') {}

Displays the JS popup script to show a comment.
If the $file parameter is empty, then the home page is assumed. The defaults for the window are 400px by 400px.

Parameters

  • int $width: Optional. The width of the popup window
  • int $height: Optional. The height of the popup window
  • string $file: Optional. Sets the location of the popup window

Source code

function comments_popup_script($width=400, $height=400, $file='') {

	global $wpcommentspopupfile, $wpcommentsjavascript;



	if (empty ($file)) {

		$wpcommentspopupfile = '';  // Use the index.

	} else {

		$wpcommentspopupfile = $file;

	}



	$wpcommentsjavascript = 1;

	$javascript = "<script type='text/javascript'>\nfunction wpopen (macagna) {\n    window.open(macagna, '_blank', 'width=$width,height=$height,scrollbars=yes,status=yes');\n}\n</script>\n";

	echo $javascript;

}

653

comments_popup_link

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

comments_open

Definition:
function comments_open( $post_id=NULL ) {}

Whether the current post is open for comments.

Parameters

  • int $post_id: An optional post ID to check instead of the current post.

Return values

returns:True if the comments are open

Defined filters

  • comments_open
    apply_filters( 'comments_open', $open, $post_id )

Source code

function comments_open( $post_id=NULL ) {



	$_post = get_post($post_id);



	$open = ( 'open' == $_post->comment_status );

	return apply_filters( 'comments_open', $open, $post_id );

}

649

comments_number

Definition:
function comments_number( $zero = false, $one = false, $more = false, $deprecated = '' ) {}

Display the language string for the number of comments the current post has.

Parameters

  • string $zero: Text for no comments
  • string $one: Text for one comment
  • string $more: Text for more than one comment
  • string $deprecated: Not used.

Defined filters

  • comments_number
    apply_filters('comments_number', $output, $number)

Source code

function comments_number( $zero = false, $one = false, $more = false, $deprecated = '' ) {

	if ( !empty( $deprecated ) )

		_deprecated_argument( __FUNCTION__, '1.3' );



	$number = get_comments_number();



	if ( $number > 1 )

		$output = str_replace('%', number_format_i18n($number), ( false === $more ) ? __('% Comments') : $more);

	elseif ( $number == 0 )

		$output = ( false === $zero ) ? __('No Comments') : $zero;

	else // must be one

		$output = ( false === $one ) ? __('1 Comment') : $one;



	echo apply_filters('comments_number', $output, $number);

}

647

comments_link_feed

Definition:
function comments_link_feed() {}

Outputs the link to the comments for the current post in an xml safe way

Source code

function comments_link_feed() {

	echo esc_url( get_comments_link() );

}

645