Version Description
- Fix: The
the_advanced_excerpt()
function was not working on singular page types (pages / posts)
Download this release
Release Info
Developer | aprea |
Plugin | Advanced Excerpt |
Version | 4.2.2 |
Comparing to | |
See all releases |
Code changes from version 4.2.1 to 4.2.2
- advanced-excerpt.php +2 -2
- class/advanced-excerpt.php +15 -8
- functions/functions.php +10 -1
- readme.txt +4 -1
advanced-excerpt.php
CHANGED
@@ -3,12 +3,12 @@
|
|
3 |
Plugin Name: Advanced Excerpt
|
4 |
Plugin URI: http://wordpress.org/plugins/advanced-excerpt/
|
5 |
Description: Control the appearance of WordPress post excerpts
|
6 |
-
Version: 4.2.
|
7 |
Author: Delicious Brains
|
8 |
Author URI: http://deliciousbrains.com/
|
9 |
*/
|
10 |
|
11 |
-
$GLOBALS['advanced_excerpt_version'] = '4.2.
|
12 |
|
13 |
function advanced_excerpt_load_textdomain() {
|
14 |
load_plugin_textdomain( 'advanced-excerpt', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
|
3 |
Plugin Name: Advanced Excerpt
|
4 |
Plugin URI: http://wordpress.org/plugins/advanced-excerpt/
|
5 |
Description: Control the appearance of WordPress post excerpts
|
6 |
+
Version: 4.2.2
|
7 |
Author: Delicious Brains
|
8 |
Author URI: http://deliciousbrains.com/
|
9 |
*/
|
10 |
|
11 |
+
$GLOBALS['advanced_excerpt_version'] = '4.2.2';
|
12 |
|
13 |
function advanced_excerpt_load_textdomain() {
|
14 |
load_plugin_textdomain( 'advanced-excerpt', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
|
class/advanced-excerpt.php
CHANGED
@@ -79,8 +79,8 @@ class Advanced_Excerpt {
|
|
79 |
* The filter, when implemented, takes precedence over the options page selection.
|
80 |
*
|
81 |
* WordPress default themes (and others) do not use the_excerpt() or get_the_excerpt()
|
82 |
-
* instead
|
83 |
-
* To ensure we're not changing the content of posts / pages we
|
84 |
*/
|
85 |
$page_types = $this->get_current_page_types();
|
86 |
$skip_page_types = array_unique( array_merge( array( 'singular' ), $this->options['exclude_pages'] ) );
|
@@ -88,12 +88,12 @@ class Advanced_Excerpt {
|
|
88 |
$page_type_matches = array_intersect( $page_types, $skip_page_types );
|
89 |
if ( !empty( $page_types ) && !empty( $page_type_matches ) ) return;
|
90 |
|
91 |
-
if( 1 == $this->options['the_excerpt'] ) {
|
92 |
remove_all_filters( 'get_the_excerpt' );
|
93 |
add_filter( 'get_the_excerpt', array( $this, 'filter' ) );
|
94 |
}
|
95 |
|
96 |
-
if( 1 == $this->options['the_content'] ) {
|
97 |
add_filter( 'the_content', array( $this, 'filter' ) );
|
98 |
}
|
99 |
}
|
@@ -218,12 +218,19 @@ class Advanced_Excerpt {
|
|
218 |
if ( 1 == $no_shortcode ) {
|
219 |
$text = strip_shortcodes( $text );
|
220 |
}
|
221 |
-
|
222 |
-
|
|
|
|
|
|
|
|
|
223 |
}
|
|
|
224 |
$text = apply_filters( 'the_content', $text );
|
225 |
-
|
226 |
-
|
|
|
|
|
227 |
}
|
228 |
|
229 |
if ( $the_content_no_break && false !== strpos( $text, '<!--more-->' ) ) {
|
79 |
* The filter, when implemented, takes precedence over the options page selection.
|
80 |
*
|
81 |
* WordPress default themes (and others) do not use the_excerpt() or get_the_excerpt()
|
82 |
+
* and instead use the_content(). As such, we also need to hook into the_content().
|
83 |
+
* To ensure we're not changing the content of single posts / pages we automatically exclude 'singular' page types.
|
84 |
*/
|
85 |
$page_types = $this->get_current_page_types();
|
86 |
$skip_page_types = array_unique( array_merge( array( 'singular' ), $this->options['exclude_pages'] ) );
|
88 |
$page_type_matches = array_intersect( $page_types, $skip_page_types );
|
89 |
if ( !empty( $page_types ) && !empty( $page_type_matches ) ) return;
|
90 |
|
91 |
+
if ( 1 == $this->options['the_excerpt'] ) {
|
92 |
remove_all_filters( 'get_the_excerpt' );
|
93 |
add_filter( 'get_the_excerpt', array( $this, 'filter' ) );
|
94 |
}
|
95 |
|
96 |
+
if ( 1 == $this->options['the_content'] ) {
|
97 |
add_filter( 'the_content', array( $this, 'filter' ) );
|
98 |
}
|
99 |
}
|
218 |
if ( 1 == $no_shortcode ) {
|
219 |
$text = strip_shortcodes( $text );
|
220 |
}
|
221 |
+
|
222 |
+
// prevent recursion on 'the_content' hook
|
223 |
+
$content_has_filter = false;
|
224 |
+
if ( has_filter( 'the_content', array( $this, 'filter' ) ) ) {
|
225 |
+
remove_filter( 'the_content', array( $this, 'filter' ) );
|
226 |
+
$content_has_filter = true;
|
227 |
}
|
228 |
+
|
229 |
$text = apply_filters( 'the_content', $text );
|
230 |
+
|
231 |
+
// add our filter back in
|
232 |
+
if ( $content_has_filter ) {
|
233 |
+
add_filter( 'the_content', array( $this, 'filter' ) );
|
234 |
}
|
235 |
|
236 |
if ( $the_content_no_break && false !== strpos( $text, '<!--more-->' ) ) {
|
functions/functions.php
CHANGED
@@ -59,11 +59,20 @@ function the_advanced_excerpt( $args = '', $get = false ) {
|
|
59 |
}
|
60 |
|
61 |
// Set temporary options
|
62 |
-
$advanced_excerpt->options = wp_parse_args( $args, $advanced_excerpt->
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
|
64 |
if ( $get ) {
|
65 |
return get_the_excerpt();
|
66 |
} else {
|
67 |
the_excerpt();
|
68 |
}
|
|
|
|
|
|
|
69 |
}
|
59 |
}
|
60 |
|
61 |
// Set temporary options
|
62 |
+
$advanced_excerpt->options = wp_parse_args( $args, $advanced_excerpt->options );
|
63 |
+
|
64 |
+
// Ensure our filter is hooked, regardless of the page type
|
65 |
+
if ( ! has_filter( 'get_the_excerpt', array( $advanced_excerpt, 'filter' ) ) ) {
|
66 |
+
remove_all_filters( 'get_the_excerpt' );
|
67 |
+
add_filter( 'get_the_excerpt', array( $advanced_excerpt, 'filter' ) );
|
68 |
+
}
|
69 |
|
70 |
if ( $get ) {
|
71 |
return get_the_excerpt();
|
72 |
} else {
|
73 |
the_excerpt();
|
74 |
}
|
75 |
+
|
76 |
+
// Reset the options back to their original state
|
77 |
+
$advanced_excerpt->load_options();
|
78 |
}
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
|
|
4 |
Tags: excerpt, post, content, formatting
|
5 |
Requires at least: 3.2
|
6 |
Tested up to: 3.9
|
7 |
-
Stable tag: 4.2.
|
8 |
License: GPLv3
|
9 |
|
10 |
Control the appearance of WordPress post excerpts
|
@@ -96,6 +96,9 @@ However, you can [start The Loop manually](http://codex.wordpress.org/The_Loop#M
|
|
96 |
|
97 |
== Changelog ==
|
98 |
|
|
|
|
|
|
|
99 |
= 4.2.1 =
|
100 |
* Fix: Undefined index errors when using the `the_advanced_excerpt()` function
|
101 |
* Fix: Not excluding tags when using the `exclude_tags` argument in the `the_advanced_excerpt()` function
|
4 |
Tags: excerpt, post, content, formatting
|
5 |
Requires at least: 3.2
|
6 |
Tested up to: 3.9
|
7 |
+
Stable tag: 4.2.2
|
8 |
License: GPLv3
|
9 |
|
10 |
Control the appearance of WordPress post excerpts
|
96 |
|
97 |
== Changelog ==
|
98 |
|
99 |
+
= 4.2.2 =
|
100 |
+
* Fix: The `the_advanced_excerpt()` function was not working on singular page types (pages / posts)
|
101 |
+
|
102 |
= 4.2.1 =
|
103 |
* Fix: Undefined index errors when using the `the_advanced_excerpt()` function
|
104 |
* Fix: Not excluding tags when using the `exclude_tags` argument in the `the_advanced_excerpt()` function
|