Skip to content

Commit

Permalink
[N/A] Add Support to unregister block variations
Browse files Browse the repository at this point in the history
  • Loading branch information
bd-viget committed Jan 6, 2025
1 parent 027a8e7 commit f4f46f0
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 2 deletions.
35 changes: 35 additions & 0 deletions wp-content/plugins/viget-blocks-toolkit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,38 @@ add_filter(
}
);
```

### `vgtbt_unregister_block_styles` (Filter)

Unregister block styles from core blocks.

```php
add_filter(
'vgtbt_unregister_block_styles',
function ( array $styles ): array {
$styles[] = [
'core/separator',
'dots',
];

return $styles;
}
);

```
### `vgtbt_unregister_block_variations` (Filter)

Unregister block variations from core blocks.

```php
add_filter(
'vgtbt_unregister_block_variations',
function ( array $variations ): array {
$variations[] = [
'core/social-link',
'bluesky',
];
return $variations;
}
);
```
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-dom-ready', 'wp-edit-post', 'wp-edit-site', 'wp-element', 'wp-hooks', 'wp-i18n'), 'version' => '51ec98a728af948bc821');
<?php return array('dependencies' => array('react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-dom-ready', 'wp-edit-post', 'wp-edit-site', 'wp-element', 'wp-hooks', 'wp-i18n'), 'version' => '0b0af76a6c769d3fad35');
2 changes: 1 addition & 1 deletion wp-content/plugins/viget-blocks-toolkit/build/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ public static function init(): void {
// Allow for core block style de-registration.
self::unregister_block_styles();

// Allow for core block variation de-registration.
self::unregister_block_variations();

// Register block patterns within block folders
self::register_block_patterns();

Expand Down Expand Up @@ -572,4 +575,27 @@ function () {
20
);
}

/**
* Allow for core block variation de-registration.
*
* @return void
*/
private static function unregister_block_variations(): void {
add_action(
'enqueue_block_assets',
function () {
$unregister_variations = apply_filters( 'vgtbt_unregister_block_variations', [] );

wp_localize_script(
'vgtbt-editor-scripts',
'vgtbtVariations',
[
'unregister' => $unregister_variations,
]
);
},
20
);
}
}
Loading

0 comments on commit f4f46f0

Please sign in to comment.