Skip to content

Commit

Permalink
Related Posts: only enable on all singular views in block themes (#39784
Browse files Browse the repository at this point in the history
)

Fixes #39783

This is a follow-up to #39730. Instead of enabling related posts in all singular views for every theme, keep relying on the `jetpack_relatedposts_filter_enabled_for_request` filter to enable theme in classic themes. Block themes will get them for every singular view by default, but classic themes will continue to only get them only for posts.
  • Loading branch information
jeherve authored Oct 16, 2024
1 parent 5ff2353 commit e87ae9f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: other

Related Posts: refine how related posts are made available on singular views in block themes.
Original file line number Diff line number Diff line change
Expand Up @@ -1883,12 +1883,20 @@ protected function log_click( $post_id, $to_post_id, $link_position ) { // phpcs
/**
* Determines if the current post is able to use related posts.
*
* @since 14.0 Checks for singular instead of single to allow usage on non-posts CPTs.
* @since 14.0 Checks for singular instead of single to allow usage on non-posts CPTs in block themes.
* @uses self::get_options, is_admin, is_singular, apply_filters
* @return bool
*/
protected function enabled_for_request() {
$enabled = is_singular()
/*
* On block themes, allow usage on any singular view (post, page, CPT).
* On classic themes, only allow usage on single posts by default.
*/
$enabled_on_singular_views = wp_is_block_theme()
? is_singular()
: is_single();

$enabled = $enabled_on_singular_views
&& ! is_attachment()
&& ! is_admin()
&& ! is_embed()
Expand Down

0 comments on commit e87ae9f

Please sign in to comment.