Skip to content

Commit

Permalink
Fix Jetpack OG
Browse files Browse the repository at this point in the history
  • Loading branch information
arthur791004 committed Aug 26, 2024
1 parent 6eef0bd commit 8e95857
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -86,4 +91,4 @@ function remove_og_tags() {
}
}

add_action( 'init', __NAMESPACE__ . '\remove_og_tags' );
add_action( 'wp_head', __NAMESPACE__ . '\remove_og_tags', 0 );

0 comments on commit 8e95857

Please sign in to comment.