Make WordPress Core

Changeset 8054


Ignore:
Timestamp:
06/05/2008 08:11:38 PM (16 years ago)
Author:
ryan
Message:

Strip shortcodes when making excerpts. Props hailin. fixes #7100

Location:
trunk/wp-includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/formatting.php

    r7815 r8054  
    840840    if ( '' == $text ) {
    841841        $text = get_the_content('');
     842       
     843        $text = strip_shortcodes( $text );
     844       
    842845        $text = apply_filters('the_content', $text);
    843846        $text = str_replace(']]>', ']]>', $text);
  • trunk/wp-includes/shortcodes.php

    r7815 r8054  
    135135}
    136136
     137/*
     138 * stip all the shortcodes from a post's content
     139 * returns the content without shortcodes
     140 */
     141function strip_shortcodes( $content ) {
     142   
     143    global $shortcode_tags;
     144
     145    if (empty($shortcode_tags) || !is_array($shortcode_tags))
     146        return $content;
     147
     148    $pattern = get_shortcode_regex();
     149
     150    return preg_replace('/'.$pattern.'/s', '', $content);
     151   
     152}
     153
    137154add_filter('the_content', 'do_shortcode', 11); // AFTER wpautop()
    138155
Note: See TracChangeset for help on using the changeset viewer.