wp_get_current_commenter

Definition:
function wp_get_current_commenter() {}

Get current commenter’s name, email, and URL.
Expects cookies content to already be sanitized. User of this function might wish to recheck the returned array for validity.

Return values

returns:Comment author, email, url respectively.

Defined filters

  • wp_get_current_commenter
    apply_filters('wp_get_current_commenter', compact('comment_author', 'comment_author_email', 'comment_author_url')

Source code

function wp_get_current_commenter() {

	// Cookies should already be sanitized.



	$comment_author = '';

	if ( isset($_COOKIE['comment_author_'.COOKIEHASH]) )

		$comment_author = $_COOKIE['comment_author_'.COOKIEHASH];



	$comment_author_email = '';

	if ( isset($_COOKIE['comment_author_email_'.COOKIEHASH]) )

		$comment_author_email = $_COOKIE['comment_author_email_'.COOKIEHASH];



	$comment_author_url = '';

	if ( isset($_COOKIE['comment_author_url_'.COOKIEHASH]) )

		$comment_author_url = $_COOKIE['comment_author_url_'.COOKIEHASH];



	return apply_filters('wp_get_current_commenter', compact('comment_author', 'comment_author_email', 'comment_author_url'));

}

3699

wp_get_comment_status

Definition:
function wp_get_comment_status($comment_id) {}

The status of a comment by ID.

Parameters

  • int $comment_id: Comment ID

Return values

returns:Status might be ‘trash’, ‘approved’, ‘unapproved’, ‘spam’. False on failure.

Source code

function wp_get_comment_status($comment_id) {

	$comment = get_comment($comment_id);

	if ( !$comment )

		return false;



	$approved = $comment->comment_approved;



	if ( $approved == NULL )

		return false;

	elseif ( $approved == '1' )

		return 'approved';

	elseif ( $approved == '0' )

		return 'unapproved';

	elseif ( $approved == 'spam' )

		return 'spam';

	elseif ( $approved == 'trash' )

		return 'trash';

	else

		return false;

}

3695

wp_get_attachment_url

Definition:
function wp_get_attachment_url( $post_id = 0 ) {}

Retrieve the URL for an attachment.

Parameters

  • int $post_id: Attachment ID.

Defined filters

  • wp_get_attachment_url
    apply_filters( 'wp_get_attachment_url', $url, $post->ID )

Source code

function wp_get_attachment_url( $post_id = 0 ) {

	$post_id = (int) $post_id;

	if ( !$post =& get_post( $post_id ) )

		return false;



	if ( 'attachment' != $post->post_type )

		return false;



	$url = '';

	if ( $file = get_post_meta( $post->ID, '_wp_attached_file', true) ) { //Get attached file

		if ( ($uploads = wp_upload_dir()) && false === $uploads['error'] ) { //Get upload directory

			if ( 0 === strpos($file, $uploads['basedir']) ) //Check that the upload base exists in the file location

				$url = str_replace($uploads['basedir'], $uploads['baseurl'], $file); //replace file location with url location

			elseif ( false !== strpos($file, 'wp-content/uploads') )

				$url = $uploads['baseurl'] . substr( $file, strpos($file, 'wp-content/uploads') + 18 );

			else

				$url = $uploads['baseurl'] . "/$file"; //Its a newly uploaded file, therefor $file is relative to the basedir.

		}

	}



	if ( empty($url) ) //If any of the above options failed, Fallback on the GUID as used pre-2.7, not recommended to rely upon this.

		$url = get_the_guid( $post->ID );



	$url = apply_filters( 'wp_get_attachment_url', $url, $post->ID );



	if ( empty( $url ) )

		return false;



	return $url;

}

3693

wp_get_attachment_thumb_url

Definition:
function wp_get_attachment_thumb_url( $post_id = 0 ) {}

Retrieve URL for an attachment thumbnail.

Parameters

  • int $post_id: Attachment ID

Return values

returns:False on failure. Thumbnail URL on success.

Defined filters

  • wp_get_attachment_thumb_url
    apply_filters( 'wp_get_attachment_thumb_url', $url, $post->ID )

Source code

function wp_get_attachment_thumb_url( $post_id = 0 ) {

	$post_id = (int) $post_id;

	if ( !$post =& get_post( $post_id ) )

		return false;

	if ( !$url = wp_get_attachment_url( $post->ID ) )

		return false;



	$sized = image_downsize( $post_id, 'thumbnail' );

	if ( $sized )

		return $sized[0];



	if ( !$thumb = wp_get_attachment_thumb_file( $post->ID ) )

		return false;



	$url = str_replace(basename($url), basename($thumb), $url);



	return apply_filters( 'wp_get_attachment_thumb_url', $url, $post->ID );

}

3691