Definition:
function wp_trim_excerpt($text = '') {}
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

February 12, 2011 


wp_trash_post_comments
Definition:
function wp_trash_post_comments($post = null) {}
Parameters
Return values
returns:False on failure
Defined actions
do_action('trash_post_comments', $post_id);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