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

CPT/templates: Inserter horizontal line still shows up #29211

Closed
jasmussen opened this issue Feb 22, 2021 · 2 comments
Closed

CPT/templates: Inserter horizontal line still shows up #29211

jasmussen opened this issue Feb 22, 2021 · 2 comments
Labels
[Feature] Templates API Related to API powering block template functionality in the Site Editor [Type] Bug An existing feature does not function as intended

Comments

@jasmussen
Copy link
Contributor

Description

If you create a custom post type with a locked template ($post_type_object->template_lock), the sibling inserter is not supposed to show up. But the blue horizontal line still does.

Step-by-step reproduction instructions

Create a custom post type with a template. Here's something you can drop in your functions.php to test it:

// Create a custom post type.
function myplugin_custom_post_type() {
	register_post_type( 'podcast',
		array(
			'labels' => array(
				'name' => __( 'Podcasts' ),
				'singular_name' => __( 'Podcast' )
			),
			'public' => true,
			'has_archive' => true,
			'rewrite' => array('slug' => 'podcast'),
			'show_in_rest' => true,
			'supports' => [
				'title', 'editor', 'custom-fields', // Custom fields must be supported for meta handling to function.
			],
		)
	);
}
add_action( 'init', 'myplugin_custom_post_type' );

// Assign a post template to our custom post type
function myplugin_register_template() {
	$post_type_object = get_post_type_object( 'podcast' );
	$post_type_object->template = array(
		array( 'core/heading', array( 'level' => 3, 'content' => 'Description', ) ),
		array( 'core/paragraph', array( 'placeholder' => 'Add description', ) ),
		array( 'core/heading', array( 'level' => 3, 'content' => 'Heading', ) ),
		array( 'core/paragraph', array( 'placeholder' => 'Add show notes', ) ),
	);

	// Lock the template from being rearranged or items deleted.
	$post_type_object->template_lock = 'all'; // Can be "all" or "insert", the latter allows moving blocks around.
}
add_action( 'init', 'myplugin_register_template' );

Be sure that $post_type_object->template_lock = 'all'; is present, and set to "all" or "insert".

Expected behaviour

The blue line should not show up.

Screenshots or screen recording (optional)

locked

@jasmussen jasmussen added [Type] Bug An existing feature does not function as intended [Feature] Templates API Related to API powering block template functionality in the Site Editor labels Feb 22, 2021
@Mamaduka
Copy link
Member

Mamaduka commented Jul 1, 2021

I think this got fixed via #32576.

@jasmussen
Copy link
Contributor Author

Confirmed! I'm not seeing any hover lines:

Screenshot 2021-08-04 at 15 26 35

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Templates API Related to API powering block template functionality in the Site Editor [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

2 participants