Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions projects/plugins/jetpack/changelog/fix-sharing-block-hooks-65
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: other

Sharing Block: only hook block on WordPress 6.5+
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,17 @@ function register_block() {
__DIR__,
array( 'render_callback' => __NAMESPACE__ . '\render_block' )
);

/*
* Automatically add the sharing block to the end of single posts
* only when running WordPress 6.5 or later.
* @todo: remove when WordPress 6.5 is the minimum required version.
*/
global $wp_version;
if ( version_compare( $wp_version, '6.5-beta2', '>=' ) ) {
add_filter( 'hooked_block_types', __NAMESPACE__ . '\add_block_to_single_posts_template', 10, 4 );
add_filter( 'hooked_block_' . PARENT_BLOCK_NAME, __NAMESPACE__ . '\add_default_services_to_block', 10, 5 );
}
}
add_action( 'init', __NAMESPACE__ . '\register_block' );

Expand Down Expand Up @@ -236,7 +247,6 @@ function add_block_to_single_posts_template( $hooked_block_types, $relative_posi

return $hooked_block_types;
}
add_filter( 'hooked_block_types', __NAMESPACE__ . '\add_block_to_single_posts_template', 10, 4 );

/**
* Add default services to the block we add to the post content by default.
Expand Down Expand Up @@ -312,4 +322,3 @@ function add_default_services_to_block( $parsed_hooked_block, $hooked_block_type
),
);
}
add_filter( 'hooked_block_' . PARENT_BLOCK_NAME, __NAMESPACE__ . '\add_default_services_to_block', 10, 5 );