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

Projects
None yet
2 participants
@miina
Copy link
Collaborator

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 added some commits Mar 15, 2018

@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(),

This comment has been minimized.

Copy link
@westonruter

westonruter Mar 17, 2018

Member

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' ) );

This comment has been minimized.

Copy link
@westonruter

westonruter Mar 17, 2018

Member

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() ) {

This comment has been minimized.

Copy link
@westonruter

westonruter Mar 17, 2018

Member

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 {

This comment has been minimized.

Copy link
@westonruter

westonruter Mar 17, 2018

Member

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() {}

This comment has been minimized.

Copy link
@westonruter

westonruter Mar 17, 2018

Member

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

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details

@westonruter westonruter deleted the add/1010-gutenberg_core_blocks_support branch Mar 19, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.