post_reply_link

Definition:
function post_reply_link($args = array() {}

Displays the HTML content for reply to post link.

Parameters

  • array $args: Optional. Override default options.
  • int|object $post: Optional. Post that the comment is going to be displayed on.

Return values

returns:Link to show comment form, if successful. False, if comments are closed.

Source code

function post_reply_link($args = array(), $post = null) {

	echo get_post_reply_link($args, $post);

}

2579

post_preview

Definition:
function post_preview() {}

Save draft or manually autosave for showing preview.

Return values

returns:URL to redirect to show the preview

Source code

function post_preview() {



	$post_ID = (int) $_POST['post_ID'];

	$status = get_post_status( $post_ID );

	if ( 'auto-draft' == $status )

		wp_die( __('Preview not available. Please save as a draft first.') );



	if ( isset($_POST['catslist']) )

		$_POST['post_category'] = explode(",", $_POST['catslist']);



	if ( isset($_POST['tags_input']) )

		$_POST['tags_input'] = explode(",", $_POST['tags_input']);



	if ( $_POST['post_type'] == 'page' || empty($_POST['post_category']) )

		unset($_POST['post_category']);



	$_POST['ID'] = $post_ID;

	$post = get_post($post_ID);



	if ( 'page' == $post->post_type ) {

		if ( !current_user_can('edit_page', $post_ID) )

			wp_die(__('You are not allowed to edit this page.'));

	} else {

		if ( !current_user_can('edit_post', $post_ID) )

			wp_die(__('You are not allowed to edit this post.'));

	}



	if ( 'draft' == $post->post_status ) {

		$id = edit_post();

	} else { // Non drafts are not overwritten.  The autosave is stored in a special post revision.

		$id = wp_create_post_autosave( $post->ID );

		if ( ! is_wp_error($id) )

			$id = $post->ID;

	}



	if ( is_wp_error($id) )

		wp_die( $id->get_error_message() );



	if ( $_POST['post_status'] == 'draft'  ) {

		$url = add_query_arg( 'preview', 'true', get_permalink($id) );

	} else {

		$nonce = wp_create_nonce('post_preview_' . $id);

		$url = add_query_arg( array( 'preview' => 'true', 'preview_id' => $id, 'preview_nonce' => $nonce ), get_permalink($id) );

	}



	return $url;

}

2577

post_permalink

Definition:
function post_permalink( $post_id = 0, $deprecated = '' ) {}

Retrieve permalink from post ID.

Parameters

  • int $post_id: Optional. Post ID.
  • mixed $deprecated: Not used.

Source code

function post_permalink( $post_id = 0, $deprecated = '' ) {

	if ( !empty( $deprecated ) )

		_deprecated_argument( __FUNCTION__, '1.3' );



	return get_permalink($post_id);

}

2575

post_password_required

Definition:
function post_password_required( $post = null ) {}

Whether post requires password and correct password has been provided.

Parameters

  • int|object $post: An optional post. Global $post used if not provided.

Return values

returns:false if a password is not required or the correct password cookie is present, true otherwise.

Source code

function post_password_required( $post = null ) {

	$post = get_post($post);



	if ( empty($post->post_password) )

		return false;



	if ( !isset($_COOKIE['wp-postpass_' . COOKIEHASH]) )

		return true;



	if ( stripslashes( $_COOKIE['wp-postpass_' . COOKIEHASH] ) != $post->post_password )

		return true;



	return false;

}

2573

post_exists

Definition:
function post_exists($title, $content = '', $date = '') {}

Determine if a post exists based on title, content, and date

Parameters

  • string $title: Post title
  • string $content: Optional post content
  • string $date: Optional post date

Return values

returns:Post ID if post exists, 0 otherwise.

Source code

function post_exists($title, $content = '', $date = '') {

	global $wpdb;



	$post_title = stripslashes( sanitize_post_field( 'post_title', $title, 0, 'db' ) );

	$post_content = stripslashes( sanitize_post_field( 'post_content', $content, 0, 'db' ) );

	$post_date = stripslashes( sanitize_post_field( 'post_date', $date, 0, 'db' ) );



	$query = "SELECT ID FROM $wpdb->posts WHERE 1=1";

	$args = array();



	if ( !empty ( $date ) ) {

		$query .= ' AND post_date = %s';

		$args[] = $post_date;

	}



	if ( !empty ( $title ) ) {

		$query .= ' AND post_title = %s';

		$args[] = $post_title;

	}



	if ( !empty ( $content ) ) {

		$query .= 'AND post_content = %s';

		$args[] = $post_content;

	}



	if ( !empty ( $args ) )

		return $wpdb->get_var( $wpdb->prepare($query, $args) );



	return 0;

}

2571