Skip to content

Conversation

@tjcafferkey
Copy link
Contributor

@tjcafferkey tjcafferkey commented Jun 21, 2024

Trac ticket: https://core.trac.wordpress.org/ticket/60854

What?

This is a proof of concept exploring various ways to allow insertion of first_child and last_child insertions of hooked blocks into template parts. You can find another approach here WordPress/wordpress-develop#6867

Why?

Currently inserting hooked blocks as first_child and last_child is not possible

How?

Testing Instructions

Testing Instructions for Keyboard

function register_logout_block_as_hooked_block( $hooked_blocks, $position, $anchor_block, $context ) {
	if ( 'core/template-part' === $anchor_block && 'first_child' === $position ) {
		$hooked_blocks[] = 'core/loginout';
	}

	return $hooked_blocks;
}

add_filter( 'hooked_block_types', 'register_logout_block_as_hooked_block', 10, 4 );

Screenshots or screencast

@tjcafferkey tjcafferkey added [Status] In Progress Tracking issues with work in progress [Block] Template Part Affects the Template Parts Block [Feature] Block hooks labels Jun 21, 2024
@tjcafferkey tjcafferkey self-assigned this Jun 21, 2024
@github-actions
Copy link

Warning: Type of PR label mismatch

To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.

  • Type-related labels to choose from: [Type] Automated Testing, [Type] Breaking Change, [Type] Bug, [Type] Build Tooling, [Type] Code Quality, [Type] Copy, [Type] Developer Documentation, [Type] Enhancement, [Type] Experimental, [Type] Feature, [Type] New API, [Type] Task, [Type] Technical Prototype, [Type] Performance, [Type] Project Management, [Type] Regression, [Type] Security, [Type] WP Core Ticket, Backport from WordPress Core.
  • Labels found: [Status] In Progress, [Block] Template Part, [Feature] Block hooks.

Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task.

@tjcafferkey tjcafferkey requested a review from ockham June 21, 2024 10:20
@tjcafferkey
Copy link
Contributor Author

Fixed in WordPress/wordpress-develop#6867

@tjcafferkey tjcafferkey closed this Jul 2, 2024
@johnbillion johnbillion deleted the update/template-part-block-first-last-child-hooked-blocks branch April 22, 2025 10:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Block] Template Part Affects the Template Parts Block [Feature] Block hooks [Status] In Progress Tracking issues with work in progress

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants