-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Patterns: add
delete_posts
to the wp_block (patterns) capabilities (#…
…53405) * Adding `delete_posts` to the wp_block (patterns) capabilities * - Adding a bit of defensive code just in case `$args['capabilities']` type isn't what we expect. * - Conditions were in the wrong order. We want to check for the existence of `$args['capabilities']` before typing checking. If the first expression fails we skip the second, otherwise there'll be a PHP error.
- Loading branch information
Showing
2 changed files
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
/** | ||
* Temporary compatibility shims for block APIs present in Gutenberg. | ||
* | ||
* @package gutenberg | ||
*/ | ||
|
||
/** | ||
* Adds delete_posts capabilities to the wp_block post type. | ||
* | ||
* @param array $args Register post type args. | ||
* | ||
* @return array Register post type args. | ||
*/ | ||
function gutenberg_add_custom_capabilities_to_wp_block( $args ) { | ||
if ( is_array( $args ) ) { | ||
if ( ! isset( $args['capabilities'] ) || is_array( $args['capabilities'] ) ) { | ||
$args['capabilities']['delete_posts'] = 'delete_posts'; | ||
} | ||
} | ||
return $args; | ||
} | ||
add_filter( 'register_wp_block_post_type_args', 'gutenberg_add_custom_capabilities_to_wp_block', 10, 1 ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters