Like Block: Add support for Block Hooks API (Draft)#34732
Like Block: Add support for Block Hooks API (Draft)#34732TimBroddin wants to merge 1 commit intotrunkfrom
Conversation
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available. Once your PR is ready for review, check one last time that all required checks appearing at the bottom of this PR are passing or skipped. Jetpack plugin: The Jetpack plugin has different release cadences depending on the platform:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. |
| * | ||
| * @return array The modified array of blocks to be hooked. | ||
| */ | ||
| function hooked_block_types( $hooked_blocks, $relative_position, $anchor_block, $context ) { |
There was a problem hiding this comment.
Do you think we should make this available for both the sharing block and the like block, maybe via a new method in Jetpack_Gutenberg, so we can use the same strategy for both?
There was a problem hiding this comment.
That's certainly a possibility. However, at the moment, I'm still thinking about the logic that should go into should_hook_block().
Do you mean something along these lines?
function init_function() {
if( should_hook_block() ) {
Jetpack_Gutenberg::block_hook_insert_after_post_content( 'jetpack/like' );
}
}
add_action( 'init', 'init_function');
There was a problem hiding this comment.
I was thinking about moving the whole hooked_block_types function to Jetpack_Gutenberg, and in there add both the like button and the sharing buttons blocks to the $hooked_blocks array, if the blocks are available. This way we hook into the hooked_block_types filter from one place only, with the same conditions and the same priority, and we can expand that list of supported Jetpack blocks later on.
|
I'm putting this PR in draft for a bit. I'm going to focus on the other areas first, and will then revisit. |
|
This PR has been marked as stale. This happened because:
If this PR is still useful, please do a [trunk merge or rebase](https://github.com/Automattic/jetpack/blob/trunk/docs/git-workflow.md#keeping-your-branch-up-to-date) and otherwise make sure it's up to date and has clear testing instructions. You may also want to ping possible reviewers in case they've forgotten about it. Please close this PR if you think it's not valid anymore — if you do, please add a brief explanation. If the PR is not updated (or at least commented on) in another month, it will be automatically closed. |
|
This PR has been automatically closed as it has not been updated in some time. If you want to resume work on the PR, feel free to restore the branch and reopen the PR. |

Proposed changes:
should_hook_block()returns true it inserts the Like block inside awp:groupblock, rendering correctlyOther information:
Jetpack product discussion
Does this pull request change what data or activity we track or use?
Testing instructions:
jetpack watchis runningshould_hook_block()return true. (insideextensions/blocks/like/like.php)