Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#1010: [Gutenberg] Fix issues with rendering native blocks #1022

Merged
merged 5 commits into from
Mar 19, 2018

Conversation

miina
Copy link
Contributor

@miina miina commented Mar 15, 2018

Fixes the issue for Categories with dropdown found within #845.

Wraps select with form tags and adds on:change to select.

Fixes #1010 .

@miina miina changed the title [WIP] #1010: [Gutenberg] Fix issues with rendering native blocks #1010: [Gutenberg] Fix issues with rendering native blocks Mar 16, 2018
'AMP_Tumblr_Embed_Handler' => array(),
'AMP_Gallery_Embed_Handler' => array(),
'WPCOM_AMP_Polldaddy_Embed' => array(),
'AMP_Gutenberg_Categories_Handler' => array(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since “Gutenberg“ project name will not be carried over when merged into core, we should just call it AMP_Categories_Block_Handler.

*/
public function register_embed() {
if ( function_exists( 'gutenberg_init' ) ) {
add_action( 'the_post', array( $this, 'override_category_block_render_callback' ) );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this needs to wait for the_post action. I think it can just do $this-> override_category_block_render_callback()

* Override the output of Gutenberg core/category block.
*/
public function override_category_block_render_callback() {
if ( is_amp_endpoint() ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that register_embed will have only been called if it is an AMP endpoint to begin with. So this override_category_block_render_callback method can actually be eliminated in favor of moving the logic to register_embed directly, minus the is_amp_endpoint check.

*
* @since 1.0
*/
class AMP_Gutenberg_Categories_Handler extends AMP_Base_Embed_Handler {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As noted above, the “Gutenberg” name is going to be dropped with the core merge so we can change it to just AMP_Categories_Block_Handler. But given that there is only one block that needs to be overridden, maybe it would be better to just call it AMP_Core_Block_Handler. This then can include the logic for the categories block and we can add support for any other core blocks that need special handling instead of creating a separate class for each, which I think is somewhat overkill.

/**
* Unregister embed.
*/
public function unregister_embed() {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should undo what is done in register_embed. The original render_callback for the core/categories block should be saved and then restored here.

@westonruter westonruter modified the milestones: v0.7, v1.0 Mar 19, 2018
@westonruter westonruter merged commit a9ae03b into develop Mar 19, 2018
@westonruter westonruter deleted the add/1010-gutenberg_core_blocks_support branch March 19, 2018 18:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants