Skip to content

Commit

Permalink
Patterns: add delete_posts to the wp_block (patterns) capabilities (#…
Browse files Browse the repository at this point in the history
…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
ramonjd authored Aug 10, 2023
1 parent 0ff8477 commit 530deb6
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
23 changes: 23 additions & 0 deletions lib/compat/wordpress-6.4/blocks.php
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 );
3 changes: 3 additions & 0 deletions lib/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ function gutenberg_is_experiment_enabled( $name ) {
require __DIR__ . '/compat/wordpress-6.3/block-editor-settings.php';
require_once __DIR__ . '/compat/wordpress-6.3/kses.php';

// WordPress 6.4 compat.
require __DIR__ . '/compat/wordpress-6.4/blocks.php';

// Experimental features.
require __DIR__ . '/experimental/block-editor-settings-mobile.php';
require __DIR__ . '/experimental/blocks.php';
Expand Down

0 comments on commit 530deb6

Please sign in to comment.