Skip to content

Commit

Permalink
Reverted a change that would stop the 'Disable On' functionality from…
Browse files Browse the repository at this point in the history
… working correctly
  • Loading branch information
aprea committed May 29, 2014
1 parent cfe8af0 commit 4bedcbe
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
11 changes: 5 additions & 6 deletions class/advanced-excerpt.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,6 @@ function __construct( $plugin_file_path ) {
}

function hook_content_filters() {
// Excerpt filtering should always occur on the 'get_the_excerpt' hook, regardless of page type
if ( 1 == $this->options['the_excerpt'] ) {
remove_all_filters( 'get_the_excerpt' );
add_filter( 'get_the_excerpt', array( $this, 'filter' ) );
}

/*
* Allow developers to skip running the advanced excerpt filters on certain page types.
* They can do so by using the "Disable On" checkboxes on the options page or
Expand All @@ -94,6 +88,11 @@ function hook_content_filters() {
$page_type_matches = array_intersect( $page_types, $skip_page_types );
if ( !empty( $page_types ) && !empty( $page_type_matches ) ) return;

if ( 1 == $this->options['the_excerpt'] ) {
remove_all_filters( 'get_the_excerpt' );
add_filter( 'get_the_excerpt', array( $this, 'filter' ) );
}

if ( 1 == $this->options['the_content'] ) {
add_filter( 'the_content', array( $this, 'filter' ) );
}
Expand Down
6 changes: 6 additions & 0 deletions functions/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ function the_advanced_excerpt( $args = '', $get = false ) {
// Set temporary options
$advanced_excerpt->options = wp_parse_args( $args, $advanced_excerpt->options );

// Ensure our filter is hooked, regardless of the page type
if ( ! has_filter( 'get_the_excerpt', array( $advanced_excerpt, 'filter' ) ) ) {
remove_all_filters( 'get_the_excerpt' );
add_filter( 'get_the_excerpt', array( $advanced_excerpt, 'filter' ) );
}

if ( $get ) {
return get_the_excerpt();
} else {
Expand Down

0 comments on commit 4bedcbe

Please sign in to comment.