wp_trim_excerpt

Definition:
function wp_trim_excerpt($text = '') {}

Generates an excerpt from the content, if needed.
The excerpt word amount will be 55 words and if the amount is greater than that, then the string ‘ […]’ will be appended to the excerpt. If the string is less than 55 words, then the content will be returned as is.

Parameters

  • string $text: Optional. The excerpt. If set to empty, an excerpt is generated.

Return values

returns:The excerpt.

Defined filters

  • the_content
    apply_filters('the_content', $text)
  • excerpt_length
    apply_filters('excerpt_length', 55)
  • excerpt_more
    apply_filters('excerpt_more', ' ' . '[...]')
  • wp_trim_excerpt
    apply_filters('wp_trim_excerpt', $text, $raw_excerpt)

Source code

function wp_trim_excerpt($text = '') {

	$raw_excerpt = $text;

	if ( '' == $text ) {

		$text = get_the_content('');



		$text = strip_shortcodes( $text );



		$text = apply_filters('the_content', $text);

		$text = str_replace(']]>', ']]>', $text);

		$excerpt_length = apply_filters('excerpt_length', 55);

		$excerpt_more = apply_filters('excerpt_more', ' ' . '[...]');

		$text = wp_trim_words( $text, $excerpt_length, $excerpt_more );

	}

	return apply_filters('wp_trim_excerpt', $text, $raw_excerpt);

}

4189

wp_trash_post_comments

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

Moves comments for a post to the trash

Parameters

  • int $post: Post ID or object.

Return values

returns:False on failure

Defined actions

  • trash_post_comments
    do_action('trash_post_comments', $post_id);
  • trashed_post_comments
    do_action('trashed_post_comments', $post_id, $statuses);

Source code

function wp_trash_post_comments($post = null) {

	global $wpdb;



	$post = get_post($post);

	if ( empty($post) )

		return;



	$post_id = $post->ID;



	do_action('trash_post_comments', $post_id);



	$comments = $wpdb->get_results( $wpdb->prepare("SELECT comment_ID, comment_approved FROM $wpdb->comments WHERE comment_post_ID = %d", $post_id) );

	if ( empty($comments) )

		return;



	// Cache current status for each comment

	$statuses = array();

	foreach ( $comments as $comment )

		$statuses[$comment->comment_ID] = $comment->comment_approved;

	add_post_meta($post_id, '_wp_trash_meta_comments_status', $statuses);



	// Set status for all comments to post-trashed

	$result = $wpdb->update($wpdb->comments, array('comment_approved' => 'post-trashed'), array('comment_post_ID' => $post_id));



	clean_comment_cache( array_keys($statuses) );



	do_action('trashed_post_comments', $post_id, $statuses);



	return $result;

}

4187

wp_trash_post

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

Moves a post or page to the Trash
If trash is disabled, the post or page is permanently deleted.

Parameters

  • int $post_id: Post ID.

Return values

returns:False on failure

Defined actions

  • wp_trash_post
    do_action('wp_trash_post', $post_id);
  • trashed_post
    do_action('trashed_post', $post_id);

Source code

function wp_trash_post($post_id = 0) {

	if ( !EMPTY_TRASH_DAYS )

		return wp_delete_post($post_id, true);



	if ( !$post = wp_get_single_post($post_id, ARRAY_A) )

		return $post;



	if ( $post['post_status'] == 'trash' )

		return false;



	do_action('wp_trash_post', $post_id);



	add_post_meta($post_id,'_wp_trash_meta_status', $post['post_status']);

	add_post_meta($post_id,'_wp_trash_meta_time', time());



	$post['post_status'] = 'trash';

	wp_insert_post($post);



	wp_trash_post_comments($post_id);



	do_action('trashed_post', $post_id);



	return $post;

}

4185

wp_trash_comment

Definition:
function wp_trash_comment($comment_id) {}

Moves a comment to the Trash
If trash is disabled, comment is permanently deleted.

Parameters

  • int $comment_id: Comment ID.

Return values

returns:False on failure

Defined actions

  • trash_comment
    do_action('trash_comment', $comment_id);
  • trashed_comment
    do_action('trashed_comment', $comment_id);

Source code

function wp_trash_comment($comment_id) {

	if ( !EMPTY_TRASH_DAYS )

		return wp_delete_comment($comment_id, true);



	if ( !$comment = get_comment($comment_id) )

		return false;



	do_action('trash_comment', $comment_id);



	if ( wp_set_comment_status($comment_id, 'trash') ) {

		add_comment_meta($comment_id, '_wp_trash_meta_status', $comment->comment_approved);

		add_comment_meta($comment_id, '_wp_trash_meta_time', time() );

		do_action('trashed_comment', $comment_id);

		return true;

	}



	return false;

}

4183

wp_transition_post_status

Definition:
function wp_transition_post_status($new_status, $old_status, $post) {}

Transition the post status of a post.
Calls hooks to transition post status.

Parameters

  • string $new_status: Transition to this post status.
  • string $old_status: Previous post status.
  • object $post: Post data.

Defined actions

  • transition_post_status
    do_action('transition_post_status', $new_status, $old_status, $post);
  • {$old_status}_to_{$new_status}
    do_action("{$old_status}_to_{$new_status}", $post);

Source code

function wp_transition_post_status($new_status, $old_status, $post) {

	do_action('transition_post_status', $new_status, $old_status, $post);

	do_action("{$old_status}_to_{$new_status}", $post);

4181