Skip to content

Commit 6a130e9

Browse files
committed
Bug fix for how post excerpts are generated. Tested with WordPress 5.2.3.
1 parent a97dd3f commit 6a130e9

File tree

2 files changed

+19
-13
lines changed

2 files changed

+19
-13
lines changed

RandomPostOnRefresh.php

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
* Description: Show a random post on every page load.
66
* Plugin URI: http://wpscholar.com/wordpress-plugins/random-post-on-refresh/
77
* Author: Micah Wood
8-
* Author URI: http://wpscholar.com
9-
* Version: 1.1
8+
* Author URI: https://wpscholar.com
9+
* Version: 1.1.1
1010
* Text Domain: random-post-on-refresh
1111
* License: GPL3
1212
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
13-
* Copyright 2018 by Micah Wood - All rights reserved.
13+
* Copyright 2018-2019 by Micah Wood - All rights reserved.
1414
*/
1515

1616
if ( ! class_exists( 'RandomPostOnRefresh' ) ) {
@@ -80,10 +80,10 @@ function ( $group ) {
8080
);
8181

8282
$can_show = [ 'title', 'image', 'excerpt', 'content' ];
83-
$show = array_merge( ...$groups );
83+
$show = array_merge( ...$groups );
8484

85-
$show_title = in_array( 'title', $show, true );
86-
$show_image = in_array( 'image', $show, true );
85+
$show_title = in_array( 'title', $show, true );
86+
$show_image = in_array( 'image', $show, true );
8787
$show_excerpt = in_array( 'excerpt', $show, true );
8888
$show_content = in_array( 'content', $show, true );
8989

@@ -99,7 +99,7 @@ function ( $group ) {
9999
if ( ! empty( $atts['taxonomy'] ) && ! taxonomy_exists( $atts['taxonomy'] ) ) {
100100
return self::error(
101101
sprintf(
102-
// Translators: %1$s is replaced with taxonomy shortcode argument and %2$s is replaced with a comma-separated list of available taxonomies.
102+
// Translators: %1$s is replaced with taxonomy shortcode argument and %2$s is replaced with a comma-separated list of available taxonomies.
103103
__( 'Sorry, taxonomy "%1$s" is invalid. Valid options are: %2$s. Please check your shortcode implementation.', 'random-post-on-refresh' ),
104104
$atts['taxonomy'],
105105
implode( ', ', get_taxonomies() )
@@ -130,7 +130,7 @@ function ( $group ) {
130130
if ( ! post_type_exists( $post_type ) ) {
131131
return self::error(
132132
sprintf(
133-
// Translators: %1$s is replaced with post_type shortcode argument and %2$s is replaced with a comma-separated list of available post types.
133+
// Translators: %1$s is replaced with post_type shortcode argument and %2$s is replaced with a comma-separated list of available post types.
134134
__( 'Sorry, post type "%1$s" is invalid. Valid options are: %2$s. Please check your shortcode implementation.', 'random-post-on-refresh' ),
135135
$post_type,
136136
implode( ', ', get_post_types( [ 'public' => true ] ) )
@@ -287,9 +287,7 @@ public static function list_to_array( $list, $delimiter = ',' ) {
287287
* @return string
288288
*/
289289
public static function get_the_excerpt( WP_Post $post ) {
290-
$excerpt = empty( $post->post_excerpt ) ? $post->post_content : $post->post_excerpt;
291-
292-
return (string) apply_filters( 'the_excerpt', apply_filters( 'get_the_excerpt', wp_kses_post( $excerpt ) ) );
290+
return (string) apply_filters( 'the_excerpt', apply_filters( 'get_the_excerpt', $post->post_excerpt, $post ) );
293291
}
294292

295293
/**

readme.txt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ Contributors: woodent, wpscholar, Imzodigital
33
Donate link: https://www.paypal.me/wpscholar
44
Tags: random post, post rotation, different post
55
Requires at least: 4.5
6-
Tested up to: 5.0
7-
Stable tag: 1.1
6+
Tested up to: 5.2.3
7+
Stable tag: 1.1.1
88
License: GPLv3
99
License URI: http://www.gnu.org/licenses/gpl-3.0.html
1010

@@ -77,6 +77,10 @@ Keep in mind that any of these attributes can be combined as needed. Example: `
7777

7878
== Changelog ==
7979

80+
= 1.1.1 =
81+
82+
* Fixed bug where post excerpts were being generated incorrectly.
83+
8084
= 1.1 =
8185

8286
* Ensure code meets coding standards.
@@ -94,3 +98,7 @@ Keep in mind that any of these attributes can be combined as needed. Example: `
9498

9599
* The latest update pulls from a larger selection of matching posts before selecting a random post. Works with WordPress 5.0.
96100

101+
= 1.1.1 =
102+
103+
* Bug fix for how post excerpts are generated. Tested with WordPress 5.2.3.
104+

0 commit comments

Comments
 (0)