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

Extensibility: Pass the post object to `allowed_block_types` filter #6208

Merged
merged 1 commit into from Apr 17, 2018

Conversation

3 participants
@gziolo
Member

gziolo commented Apr 16, 2018

Description

Closes #2685.

This PR open an access to the current post to the allowed_block_types filter to make it possible to provide a different set of allowed block types per post type or based on other properties.

How has this been tested?

Manually added the following filter:

function my_test_allowed_block_types( $allowed_block_types, $post ) {
	if ( $post->post_type === 'post' ) {
		return $allowed_block_types;
	}
	return [ 'core/paragraph' ];
}
	
add_filter( 'allowed_block_types', 'my_test_allowed_block_types', 10, 2 );

Types of changes

Improvement.

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.

@gziolo gziolo self-assigned this Apr 16, 2018

@gziolo gziolo added this to To do in Extensibility via automation Apr 16, 2018

@gziolo gziolo moved this from To do to In progress in Extensibility Apr 16, 2018

@gziolo

This comment has been minimized.

Member

gziolo commented Apr 16, 2018

@zgordon - can you give it a try?

@gziolo gziolo requested a review from WordPress/gutenberg-core Apr 16, 2018

@zgordon

This comment has been minimized.

zgordon commented Apr 16, 2018

@gziolo do I just pill down latest Master to try this?

@gziolo

This comment has been minimized.

Member

gziolo commented Apr 16, 2018

Rather this branch: update/extensibility-allowed-block-types.

@@ -937,8 +937,9 @@ function gutenberg_editor_scripts_and_styles( $hook ) {
*
* @param bool|array $allowed_block_types Array of block type slugs, or
* boolean to enable/disable all.
* @param object The post resource data.

This comment has been minimized.

@noisysocks

noisysocks Apr 17, 2018

Member

This @param comment is missing the name of the argument.

(It's weird that the linter didn't yell about this.)

This comment has been minimized.

@gziolo

gziolo Apr 17, 2018

Member

It's not a function, so it's tricky for both human and computer. I updated :)

@noisysocks

👍 nice. This looks good to me once that @param is fixed up.

@zgordon

This comment has been minimized.

zgordon commented Apr 17, 2018

Sweet! @gziolo can confirm it's working for me as expected :)

@gziolo gziolo merged commit 1ba33b2 into master Apr 17, 2018

2 checks passed

codecov/project 43.94% remains the same compared to 9966a96
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

Extensibility automation moved this from In progress to Done Apr 17, 2018

@gziolo gziolo deleted the update/extensibility-allowed-block-types branch Apr 17, 2018

@westonruter westonruter referenced this pull request Apr 18, 2018

Open

Implement AMP Stories #968

11 of 25 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment