Skip to content

Commit

Permalink
fix: when comparing filtered vs post content, compare only 1st paragraph
Browse files Browse the repository at this point in the history
  • Loading branch information
dkoo committed Jul 5, 2023
1 parent 407734c commit ed41f8a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion includes/class-newspack-popups-inserter.php
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,8 @@ private static function is_memberships_restricted( $post_id = null ) {
* @param string $content The content of the post.
*/
public static function insert_popups_in_content( $content = '' ) {
$filtered_content = explode( "\n", $content );
$post_content = explode( "\n", get_post()->post_content );
if (
// Avoid duplicate execution.
true === self::$the_content_has_rendered
Expand All @@ -467,7 +469,7 @@ public static function insert_popups_in_content( $content = '' ) {
// It doesn't make sense with a paywall message and also causes an infinite loop.
|| self::is_memberships_restricted()
// At filter priority 1, $content should be the same as the unfiltered post_content. This guards against inserting in other content such as featured image captions/descriptions.
|| get_post()->post_content !== $content
|| ( ! empty( $filtered_content ) && ! empty( $post_content ) && $filtered_content[0] !== $post_content[0] )
) {
return $content;
}
Expand Down

0 comments on commit ed41f8a

Please sign in to comment.