From 8e95857406249e777301b17c8cdde447626ce5c5 Mon Sep 17 00:00:00 2001 From: arthur Date: Fri, 23 Aug 2024 19:07:36 +0900 Subject: [PATCH] Fix Jetpack OG --- .../src/features/blog-privacy/blog-privacy.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/projects/packages/jetpack-mu-wpcom/src/features/blog-privacy/blog-privacy.php b/projects/packages/jetpack-mu-wpcom/src/features/blog-privacy/blog-privacy.php index ec103137116c5..f7d15dc613161 100644 --- a/projects/packages/jetpack-mu-wpcom/src/features/blog-privacy/blog-privacy.php +++ b/projects/packages/jetpack-mu-wpcom/src/features/blog-privacy/blog-privacy.php @@ -70,14 +70,19 @@ function remove_og_tags() { return; } - /** This filter is documented in class.jetpack.php */ - $jetpack_enable_open_graph = apply_filters( 'jetpack_enable_open_graph', false ); // Disable Jetpack Open Graph Tags. - if ( $jetpack_enable_open_graph && function_exists( 'jetpack_og_tags' ) ) { + if ( function_exists( 'jetpack_og_tags' ) ) { // @phan-suppress-next-line PhanUndeclaredFunctionInCallable remove_action( 'wp_head', 'jetpack_og_tags' ); } + // Avoid calling check_open_graph as it registers the jetpack_og_tags function when running wp_head action. + if ( class_exists( '\Jetpack', false ) ) { + // @phan-suppress-next-line PhanUndeclaredFunction, PhanUndeclaredClassReference + $jetpack = \Jetpack::init(); + remove_action( 'wp_head', array( $jetpack, 'check_open_graph' ), 1 ); + } + // Disable Yoast SEO. See https://developer.yoast.com/customization/yoast-seo/disabling-yoast-seo/. if ( function_exists( 'YoastSEO' ) && class_exists( 'Yoast\WP\SEO\Integrations\Front_End_Integration', false ) ) { // @phan-suppress-next-line PhanUndeclaredFunction, PhanUndeclaredClassReference @@ -86,4 +91,4 @@ function remove_og_tags() { } } -add_action( 'init', __NAMESPACE__ . '\remove_og_tags' ); +add_action( 'wp_head', __NAMESPACE__ . '\remove_og_tags', 0 );