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

General changes to post type registrations and registration of two new invisible patterns #628

Open
1 task done
Tracked by #626
carstingaxion opened this issue Mar 29, 2024 · 7 comments · May be fixed by #888
Open
1 task done
Tracked by #626
Assignees
Labels
blocks enhancement New feature or request
Milestone

Comments

@carstingaxion
Copy link
Collaborator

Is your enhancement related to a problem? Please describe.

Gaining for greater flexibility, I'd like us to encourage the Block Hooks API to add all of the GatherPress blocks into templates.
Following on, with what I wrote at #626

Therefore GatherPress registers two invisible block patterns, that are used as template properties of the main post types.

  1. Within my exploration I changed the template property to the following:
'template'     => array(
    // array( 'gatherpress/venue' ),
    array( 'core/pattern', array( 'slug' => 'gatherpress/venue-details' ) ),
),
  1. The called pattern looks like this and will not be visible to the editor at any point:
\register_block_pattern( 'gatherpress/venue-details',
    array(
  	  'title'         => 'Invisible Venue Details Block Pattern', // no i18n needed
  	  'content'       => '', // this will a be hooked ;)
  	  'inserter'      => false,
  	  'source'        => 'plugin',
    )
);
  1. Now any block - inside and outside of the GatherPress plugin - can easily declare:
add_filter( 'hooked_block_types', __NAMESPACE__ . '\\hook_block_into_pattern', 10, 4 );
function hook_block_into_pattern( $hooked_block_types, $relative_position, $anchor_block_type, $context ) {
	if (
		// Conditionally hook the block into the "gatherpress/venue-details" pattern.
		is_array( $context ) &&
		isset( $context[ 'name' ] ) &&
		'gatherpress/venue-details' === $context[ 'name' ]
	) {
		$hooked_block_types[] = 'gatherpress/rsvp';
	}
	return $hooked_block_types;
}
  1. It just gets a little messy when it comes to block variations, that use the Block Bindings API under the hood.

Designs

No response

Describe alternatives you've considered

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@carstingaxion carstingaxion added the enhancement New feature or request label Mar 29, 2024
@carstingaxion carstingaxion added this to the 0.30.0 milestone Jun 13, 2024
@carstingaxion
Copy link
Collaborator Author

The described changes are already part of carstingaxion#25

@MervinHernandez
Copy link
Collaborator

✅ Viewed 628 - GB Standards compliance - Carsten has it

@carstingaxion
Copy link
Collaborator Author

I wanted to test the new Event Query block within the normal template hierachy, but was not able to create an archive template.
Bildschirmfoto vom 2024-06-16 23-04-43

until I added the following (for testing) to the post type registration:

'has_archive'   => true,

which allowed me to create an archive template.
Bildschirmfoto vom 2024-06-16 23-08-36

@mauteri and @MervinHernandez Please let me know, if it is a decision by pupose or somehow needed for the existing general['pages'] setting, that gatherpress_event should not have a post type archive?

@mauteri
Copy link
Contributor

mauteri commented Jun 16, 2024

@carstingaxion that may have been done because of sorting being done by publish date, but I don't 100% recall.... if it's need for Event Query, then add the has_archive => true

@MervinHernandez
Copy link
Collaborator

@carstingaxion I am also unsure why this was not set to true. I support declaring it as true.

@carstingaxion
Copy link
Collaborator Author

Thank you both @mauteri and @MervinHernandez for your feedback. I appreciate your answers and made the discussed change in carstingaxion@062aceb

Unfortunately I had no time to test, creating an archive template using the block, yet. But will do in 2 weeks, when we are back from family holiday.

The branch with the change powers the GatherPress Block Playground, so feel free to test it yourself if you want.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocks enhancement New feature or request
Projects
Status: In Progress
Development

Successfully merging a pull request may close this issue.

3 participants