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

Plugin: Deprecate gutenberg_can_edit_* functions #13470

Merged
merged 1 commit into from
Feb 14, 2019

Conversation

aduth
Copy link
Member

@aduth aduth commented Jan 24, 2019

Related: #11015

This pull request seeks to deprecate the gutenberg_can_edit_post_type and gutenberg_can_edit_post functions in favor of the core-equivalent use_block_editor_for_post_type and use_block_editor_for_post functions.

See:

Testing instructions:

Verify that one can edit a Gutenberg post if and only if the post type and user are capable of editing (e.g. show_in_rest, supports editor, etc). The logic is not identical in core, and this will continue to be aligned until eventually Gutenberg merely extends the edit-form-blocks.php interface.

The core implementations also use the meta-box-loader query parameter for meta boxes, which is not the same as what's used in Gutenberg. However, this is already slated for removal as of #13449.

@aduth aduth added the Gutenberg Plugin Issues or PRs related to Gutenberg Plugin management related efforts label Jan 24, 2019
@aduth aduth force-pushed the deprecate/gutenberg-can-edit branch 3 times, most recently from 0b65b9c to 35db60e Compare January 29, 2019 17:07
@aduth aduth force-pushed the deprecate/gutenberg-can-edit branch from 35db60e to c84e4e2 Compare February 4, 2019 19:15
@gziolo gziolo added this to the 5.1 (Gutenberg) milestone Feb 7, 2019
@aduth aduth force-pushed the deprecate/gutenberg-can-edit branch from c84e4e2 to 8e33fd6 Compare February 8, 2019 21:01
@aduth aduth requested a review from notnownikki as a code owner February 8, 2019 21:01
Copy link
Member

@jorgefilipecosta jorgefilipecosta left a comment

Choose a reason for hiding this comment

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

LGTM 👍
I verified that for this CPT:

function create_product_type() {
    register_post_type( 'acme_product',
        array(
	    'label'  => 'Product',
            'labels' => array(
                'name' => __( 'Products' ),
                'singular_name' => __( 'Product' )
            ),
            'public' => true,
            'show_in_rest' => true,
            'supports' => array( 'title' ),
        )
    );
}
add_action( 'init', 'create_product_type' );

The editor is not loaded, and classic editor opens with just the title field (as before).

If we replace title with editor the editor loads without the option to choose the title.

If we remove the supports array the editor loads normally if we set show_in_rest to false the classic editor starts being used instead.

I also did some grepping and I verified that there are no usages of the deprecated functions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Gutenberg Plugin Issues or PRs related to Gutenberg Plugin management related efforts
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants