Plugin Directory

Changeset 929323


Ignore:
Timestamp:
06/10/2014 03:32:24 AM (12 years ago)
Author:
aprea
Message:

4.2.3 release

Location:
advanced-excerpt
Files:
22 added
4 edited

Legend:

Unmodified
Added
Removed
  • advanced-excerpt/trunk/advanced-excerpt.php

    r925433 r929323  
    44Plugin URI: http://wordpress.org/plugins/advanced-excerpt/
    55Description: Control the appearance of WordPress post excerpts
    6 Version: 4.2.2
     6Version: 4.2.3
    77Author: Delicious Brains
    88Author URI: http://deliciousbrains.com/
    99*/
    1010
    11 $GLOBALS['advanced_excerpt_version'] = '4.2.2';
     11$GLOBALS['advanced_excerpt_version'] = '4.2.3';
    1212
    1313function advanced_excerpt_load_textdomain() {
  • advanced-excerpt/trunk/class/advanced-excerpt.php

    r925433 r929323  
    2727    public $options_basic_tags; // Basic HTML tags (determines which tags are in the checklist by default)
    2828    public $options_all_tags; // Almost all HTML tags (extra options)
     29    public $filter_type; // Determines wether we're filtering the_content or the_excerpt at any given time
    2930
    3031    function __construct( $plugin_file_path ) {
     
    9192        if ( 1 == $this->options['the_excerpt'] ) {
    9293            remove_all_filters( 'get_the_excerpt' );
    93             add_filter( 'get_the_excerpt', array( $this, 'filter' ) );
     94            remove_all_filters( 'the_excerpt' );
     95            add_filter( 'get_the_excerpt', array( $this, 'filter_excerpt' ) );
    9496        }
    9597
    9698        if ( 1 == $this->options['the_content'] ) {
    97             add_filter( 'the_content', array( $this, 'filter' ) );
     99            add_filter( 'the_content', array( $this, 'filter_content' ) );
    98100        }
    99101    }
     
    204206    }
    205207
    206     function filter( $text ) {
     208    function filter_content( $content ) {
     209        $this->filter_type = 'content';
     210        return $this->filter( $content );
     211    }
     212
     213    function filter_excerpt( $content ) {
     214        $this->filter_type = 'excerpt';
     215        return $this->filter( $content );
     216    }
     217
     218    function filter( $content ) {
     219        extract( wp_parse_args( $this->options, $this->default_options ), EXTR_SKIP );
     220
     221        if ( true === apply_filters( 'advanced_excerpt_skip_excerpt_filtering', false ) ) {
     222            return $content;
     223        }
     224
    207225        global $post;
    208         extract( wp_parse_args( $this->options, $this->default_options ), EXTR_SKIP );
    209         $original_excerpt = $text;
     226        if ( $the_content_no_break && false !== strpos( $post->post_content, '<!--more-->' ) && 'content' == $this->filter_type ) {
     227            return $content;
     228        }
    210229
    211230        // Avoid custom excerpts
    212         if ( !empty( $text ) && !$no_custom ) {
    213             return $text;
    214         }
    215 
    216         // Get the full content and filter it
    217         $text = $post->post_content;
    218         if ( 1 == $no_shortcode ) {
    219             $text = strip_shortcodes( $text );
     231        if ( !empty( $content ) && !$no_custom ) {
     232            return $content;
    220233        }
    221234
    222235        // prevent recursion on 'the_content' hook
    223236        $content_has_filter = false;
    224         if ( has_filter( 'the_content', array( $this, 'filter' ) ) ) {
    225             remove_filter( 'the_content', array( $this, 'filter' ) );
     237        if ( has_filter( 'the_content', array( $this, 'filter_content' ) ) ) {
     238            remove_filter( 'the_content', array( $this, 'filter_content' ) );
    226239            $content_has_filter = true;
    227240        }
    228241
     242        $text = get_the_content( '' );
    229243        $text = apply_filters( 'the_content', $text );
    230244
    231245        // add our filter back in
    232246        if ( $content_has_filter ) {
    233             add_filter( 'the_content', array( $this, 'filter' ) );
    234         }
    235 
    236         if ( $the_content_no_break && false !== strpos( $text, '<!--more-->' ) ) {
    237             return $original_excerpt;
     247            add_filter( 'the_content', array( $this, 'filter_content' ) );
    238248        }
    239249
     
    242252        $text = str_replace( ']]>', ']]&gt;', $text );
    243253
    244         $original_post_content = $text;
    245 
    246         // Determine allowed tags
    247254        if ( empty( $allowed_tags ) ) {
    248             $allowed_tags = $this->options_all_tags;
    249         }
    250 
     255            $allowed_tags = array();
     256        }
     257
     258        // the $exclude_tags args takes precedence over the $allowed_tags args (only if they're both defined)
    251259        if ( ! empty( $exclude_tags ) ) {
    252             $allowed_tags = array_diff( $allowed_tags, $exclude_tags );
     260            $allowed_tags = array_diff( $this->options_all_tags, $exclude_tags );
    253261        }
    254262
     
    260268                $tag_string = '';
    261269            }
     270
    262271            $text = strip_tags( $text, $tag_string );
    263272        }
     273
     274        $text_before_trimming = $text;
    264275
    265276        // Create the excerpt
     
    267278
    268279        // Add the ellipsis or link
    269         if ( !apply_filters( 'advanced_excerpt_disable_add_more', false, $original_post_content, $this->options ) ) {
     280        if ( !apply_filters( 'advanced_excerpt_disable_add_more', false, $text_before_trimming, $this->options ) ) {
    270281            $text = $this->text_add_more( $text, $ellipsis, ( $add_link ) ? $read_more : false );
    271282        }
  • advanced-excerpt/trunk/functions/functions.php

    r925433 r929323  
    6363
    6464    // Ensure our filter is hooked, regardless of the page type
    65     if ( ! has_filter( 'get_the_excerpt', array( $advanced_excerpt, 'filter' ) ) ) {
     65    if ( ! has_filter( 'get_the_excerpt', array( $advanced_excerpt, 'filter_excerpt' ) ) ) {
    6666        remove_all_filters( 'get_the_excerpt' );
    67         add_filter( 'get_the_excerpt', array( $advanced_excerpt, 'filter' ) );
     67        remove_all_filters( 'the_excerpt' );
     68        add_filter( 'get_the_excerpt', array( $advanced_excerpt, 'filter_excerpt' ) );
    6869    }
    6970
  • advanced-excerpt/trunk/readme.txt

    r925433 r929323  
    55Requires at least: 3.2
    66Tested up to: 3.9
    7 Stable tag: 4.2.2
     7Stable tag: 4.2.3
    88License: GPLv3
    99
     
    9797== Changelog ==
    9898
     99= 4.2.3 =
     100* Fix: The "Remove all tags except the following" wasn't excluding tags as expected
     101* Fix: Call `remove_all_filter()` on the `the_excerpt` hook to improve excerpt rendering
     102* Fix: Only honor the "Only filter `the_content()` when there's no break (<!--more-->) tag in the post content" setting when hooking into `the_content` filter
     103* Improvement: Improve backwards compatibility by reverting back to using `get_the_content()` for the base excerpt text
     104* Improvement: Added the `advanced_excerpt_skip_excerpt_filtering` filter allowing users to skip excerpt filtering on a per excerpt basis
     105
    99106= 4.2.2 =
    100107* Fix: The `the_advanced_excerpt()` function was not working on singular page types (pages / posts)
Note: See TracChangeset for help on using the changeset viewer.