From 4861b8c10203ab7fea941e7bb495fa94a5db5f37 Mon Sep 17 00:00:00 2001 From: Tony Arcangelini Date: Tue, 24 Feb 2026 22:17:41 +0100 Subject: [PATCH 1/6] Only filter excerpts for newsletter emails --- .../jetpack/changelog/fix-subscription-block-excerpt-text | 4 ++++ .../extensions/blocks/subscriptions/subscriptions.php | 5 +++++ 2 files changed, 9 insertions(+) create mode 100644 projects/plugins/jetpack/changelog/fix-subscription-block-excerpt-text diff --git a/projects/plugins/jetpack/changelog/fix-subscription-block-excerpt-text b/projects/plugins/jetpack/changelog/fix-subscription-block-excerpt-text new file mode 100644 index 00000000000..74afeb28b9d --- /dev/null +++ b/projects/plugins/jetpack/changelog/fix-subscription-block-excerpt-text @@ -0,0 +1,4 @@ +Significance: patch +Type: bugfix + +Subscriptions: Only filter excerpts for newsletter emails, not on the front end. diff --git a/projects/plugins/jetpack/extensions/blocks/subscriptions/subscriptions.php b/projects/plugins/jetpack/extensions/blocks/subscriptions/subscriptions.php index 43d98c75146..86b99b21e16 100644 --- a/projects/plugins/jetpack/extensions/blocks/subscriptions/subscriptions.php +++ b/projects/plugins/jetpack/extensions/blocks/subscriptions/subscriptions.php @@ -991,6 +991,11 @@ function render_email( $block_content, array $parsed_block, $rendering_context ) * @return mixed */ function jetpack_filter_excerpt_for_newsletter( $excerpt, $post = null ) { + // Only modify excerpts when rendering a newsletter email. + if ( ! defined( 'IS_HTML_EMAIL' ) && ! defined( 'IS_WC_EMAIL' ) ) { + return $excerpt; + } + // The blogmagazine theme is overriding WP core `get_the_excerpt` filter and only passing the excerpt // TODO: Until this is fixed, return the excerpt without gating. See https://github.com/Automattic/jetpack/pull/28102#issuecomment-1369161116 if ( $post instanceof \WP_Post && has_block( 'jetpack/subscriptions', $post ) ) { From 0783f445a3860770efbf0afdf14d41380ba1d89e Mon Sep 17 00:00:00 2001 From: Tony Arcangelini Date: Wed, 25 Feb 2026 10:48:56 +0100 Subject: [PATCH 2/6] Lets do this differently --- .../blocks/subscriptions/subscriptions.php | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/projects/plugins/jetpack/extensions/blocks/subscriptions/subscriptions.php b/projects/plugins/jetpack/extensions/blocks/subscriptions/subscriptions.php index 86b99b21e16..3f7dbc5d80a 100644 --- a/projects/plugins/jetpack/extensions/blocks/subscriptions/subscriptions.php +++ b/projects/plugins/jetpack/extensions/blocks/subscriptions/subscriptions.php @@ -991,22 +991,24 @@ function render_email( $block_content, array $parsed_block, $rendering_context ) * @return mixed */ function jetpack_filter_excerpt_for_newsletter( $excerpt, $post = null ) { - // Only modify excerpts when rendering a newsletter email. - if ( ! defined( 'IS_HTML_EMAIL' ) && ! defined( 'IS_WC_EMAIL' ) ) { + // Only gate paid posts where the viewer cannot access the content. + if ( ! is_paid_post() ) { return $excerpt; } - // The blogmagazine theme is overriding WP core `get_the_excerpt` filter and only passing the excerpt - // TODO: Until this is fixed, return the excerpt without gating. See https://github.com/Automattic/jetpack/pull/28102#issuecomment-1369161116 - if ( $post instanceof \WP_Post && has_block( 'jetpack/subscriptions', $post ) ) { - $excerpt .= '

'; - $excerpt .= sprintf( - // translators: %s is the permalink url to the current post. - __( "

View post to subscribe to the site's newsletter.

", 'jetpack' ), - get_post_permalink() - ); + require_once JETPACK__PLUGIN_DIR . 'modules/memberships/class-jetpack-memberships.php'; + + $post_id = null; + if ( $post instanceof \WP_Post ) { + $post_id = $post->ID; } + if ( Jetpack_Memberships::user_can_view_post( $post_id ) ) { + return $excerpt; + } + + $excerpt .= get_paywall_blocks(); + return $excerpt; } From e0d4dd06c8d937ae82990e45c54e4238160ce0e0 Mon Sep 17 00:00:00 2001 From: Tony Arcangelini Date: Wed, 25 Feb 2026 11:03:12 +0100 Subject: [PATCH 3/6] Update changelog entry --- .../jetpack/changelog/fix-subscription-block-excerpt-text | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/plugins/jetpack/changelog/fix-subscription-block-excerpt-text b/projects/plugins/jetpack/changelog/fix-subscription-block-excerpt-text index 74afeb28b9d..4e459cad5e8 100644 --- a/projects/plugins/jetpack/changelog/fix-subscription-block-excerpt-text +++ b/projects/plugins/jetpack/changelog/fix-subscription-block-excerpt-text @@ -1,4 +1,4 @@ Significance: patch Type: bugfix -Subscriptions: Only filter excerpts for newsletter emails, not on the front end. +Subscriptions: Append paywall gate to excerpt on paid posts where the viewer cannot access the content. From 5d4017fa2aca6cf12f2357eac5c6a6a55dc6693a Mon Sep 17 00:00:00 2001 From: Tony Arcangelini Date: Wed, 25 Feb 2026 12:02:52 +0100 Subject: [PATCH 4/6] Remove jetpack_filter_excerpt_for_newsletter filter completly --- .../blocks/subscriptions/subscriptions.php | 33 ------------------- 1 file changed, 33 deletions(-) diff --git a/projects/plugins/jetpack/extensions/blocks/subscriptions/subscriptions.php b/projects/plugins/jetpack/extensions/blocks/subscriptions/subscriptions.php index 3f7dbc5d80a..b192857da7f 100644 --- a/projects/plugins/jetpack/extensions/blocks/subscriptions/subscriptions.php +++ b/projects/plugins/jetpack/extensions/blocks/subscriptions/subscriptions.php @@ -153,9 +153,6 @@ function ( $allowed_meta ) { // Hide existing comments add_filter( 'get_comment', __NAMESPACE__ . '\maybe_gate_existing_comments' ); - // Gate the excerpt for a post - add_filter( 'get_the_excerpt', __NAMESPACE__ . '\jetpack_filter_excerpt_for_newsletter', 10, 2 ); - // Add a 'Newsletter' column to the Edit posts page // We only display the "Newsletter" column if we have configured the paid newsletter plan if ( defined( 'WP_ADMIN' ) && WP_ADMIN && Jetpack_Memberships::has_configured_plans_jetpack_recurring_payments( 'newsletter' ) ) { @@ -982,36 +979,6 @@ function render_email( $block_content, array $parsed_block, $rendering_context ) ); } -/** - * Filter excerpts looking for subscription data. - * - * @param string $excerpt The extrapolated excerpt string. - * @param \WP_Post $post The current post being processed (in `get_the_excerpt`). - * - * @return mixed - */ -function jetpack_filter_excerpt_for_newsletter( $excerpt, $post = null ) { - // Only gate paid posts where the viewer cannot access the content. - if ( ! is_paid_post() ) { - return $excerpt; - } - - require_once JETPACK__PLUGIN_DIR . 'modules/memberships/class-jetpack-memberships.php'; - - $post_id = null; - if ( $post instanceof \WP_Post ) { - $post_id = $post->ID; - } - - if ( Jetpack_Memberships::user_can_view_post( $post_id ) ) { - return $excerpt; - } - - $excerpt .= get_paywall_blocks(); - - return $excerpt; -} - /** * Gate access to posts * From f1c319d3e9fc173ae79c3bc44600e533a02dc76f Mon Sep 17 00:00:00 2001 From: Tony Arcangelini Date: Wed, 25 Feb 2026 12:03:58 +0100 Subject: [PATCH 5/6] Update changelog --- .../jetpack/changelog/fix-subscription-block-excerpt-text | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/plugins/jetpack/changelog/fix-subscription-block-excerpt-text b/projects/plugins/jetpack/changelog/fix-subscription-block-excerpt-text index 4e459cad5e8..d2cbc811394 100644 --- a/projects/plugins/jetpack/changelog/fix-subscription-block-excerpt-text +++ b/projects/plugins/jetpack/changelog/fix-subscription-block-excerpt-text @@ -1,4 +1,4 @@ Significance: patch Type: bugfix -Subscriptions: Append paywall gate to excerpt on paid posts where the viewer cannot access the content. +Subscriptions: Remove jetpack_filter_excerpt_for_newsletter method from the excerpt filter. From 57662061e2f264def2e6c30272bea0ec884869bc Mon Sep 17 00:00:00 2001 From: Tony Arcangelini <33258733+arcangelini@users.noreply.github.com> Date: Wed, 25 Feb 2026 12:24:33 +0100 Subject: [PATCH 6/6] Update changelog copy Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .../jetpack/changelog/fix-subscription-block-excerpt-text | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/plugins/jetpack/changelog/fix-subscription-block-excerpt-text b/projects/plugins/jetpack/changelog/fix-subscription-block-excerpt-text index d2cbc811394..f389622bcd8 100644 --- a/projects/plugins/jetpack/changelog/fix-subscription-block-excerpt-text +++ b/projects/plugins/jetpack/changelog/fix-subscription-block-excerpt-text @@ -1,4 +1,4 @@ Significance: patch Type: bugfix -Subscriptions: Remove jetpack_filter_excerpt_for_newsletter method from the excerpt filter. +Subscriptions: Stop appending the “View post … subscribe” message to post excerpts in subscription emails.