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

Using register_block_type_from_metadata requires extra filter #1

Open
coderaaron opened this issue Nov 16, 2021 · 0 comments
Open

Using register_block_type_from_metadata requires extra filter #1

coderaaron opened this issue Nov 16, 2021 · 0 comments

Comments

@coderaaron
Copy link

Thank you so much for this! I've been trying to build something similar on my own but not having much success.

If you use register_block_type_from_metadata to register a block it does property mappings and will discard any value passed in for ssr (see line 230 in wp-includes/blocks.php).

To get around this I added this filter.

add_filter(
	'block_type_metadata_settings',
	function( $settings, $metadata ) {
		if ( isset( $metadata['ssr'] ) && $metadata['ssr'] == true ) {
			$settings['ssr'] = true;
		}
		return $settings;
	},
	10,
	2
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant