From bf52578c2493c4ac0ff9fc897a590181a216af01 Mon Sep 17 00:00:00 2001 From: Brandon Kraft Date: Fri, 11 Oct 2024 16:43:46 -0500 Subject: [PATCH] Related Posts: check for any single post without regard for post type. (#39730) --- projects/plugins/jetpack/changelog/add-rp-support-on-pages | 4 ++++ .../modules/related-posts/jetpack-related-posts.php | 7 ++++--- 2 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 projects/plugins/jetpack/changelog/add-rp-support-on-pages diff --git a/projects/plugins/jetpack/changelog/add-rp-support-on-pages b/projects/plugins/jetpack/changelog/add-rp-support-on-pages new file mode 100644 index 0000000000000..563217652fa5c --- /dev/null +++ b/projects/plugins/jetpack/changelog/add-rp-support-on-pages @@ -0,0 +1,4 @@ +Significance: minor +Type: compat + +Related Posts: allow Related Posts on non-post CPTs where the block is already able to be used. diff --git a/projects/plugins/jetpack/modules/related-posts/jetpack-related-posts.php b/projects/plugins/jetpack/modules/related-posts/jetpack-related-posts.php index 7d607baf53d3a..827bffdd56822 100644 --- a/projects/plugins/jetpack/modules/related-posts/jetpack-related-posts.php +++ b/projects/plugins/jetpack/modules/related-posts/jetpack-related-posts.php @@ -1883,18 +1883,19 @@ protected function log_click( $post_id, $to_post_id, $link_position ) { // phpcs /** * Determines if the current post is able to use related posts. * - * @uses self::get_options, is_admin, is_single, apply_filters + * @since $$next-version$$ Checks for singular instead of single to allow usage on non-posts CPTs. + * @uses self::get_options, is_admin, is_singular, apply_filters * @return bool */ protected function enabled_for_request() { - $enabled = is_single() + $enabled = is_singular() && ! is_attachment() && ! is_admin() && ! is_embed() && ( ! $this->allow_feature_toggle() || $this->get_option( 'enabled' ) ); /** - * Filter the Enabled value to allow related posts to be shown on pages as well. + * Filter the Enabled value to allow related posts to be selectively enabled/disabled. * * @module related-posts *