Skip to content

Commit

Permalink
feat: Added block polyfill
Browse files Browse the repository at this point in the history
  • Loading branch information
seebeen committed Jan 24, 2024
1 parent 4ac7ac9 commit 376c0f7
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
},
"files": [
"src/oblak-polyfill-array.php",
"src/oblak-polyfill-block.php",
"src/oblak-polyfill-conditionals.php",
"src/oblak-polyfill-filter.php",
"src/oblak-polyfill-terms.php",
Expand Down
26 changes: 26 additions & 0 deletions src/oblak-polyfill-block.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php
/**
* Block polyfills
*
* ! This file intentionally left without namespace
*
* @package WP Polyfills
*/

if ( ! function_exists( 'deregister_all_blocks' ) ) :
/**
* Deregisters all registered blocks.
*/
function deregister_all_blocks() {
if ( did_action( 'init' ) || 'init' !== current_action() ) {
_doing_it_wrong( __FUNCTION__, 'You need to call this function on init', '1.0.0' );
return;
}

array_walk(
array_keys( WP_Block_Type_Registry::get_instance()->get_all_registered() ),
static fn( $b ) => WP_Block_Type_Registry::get_instance()->unregister( $b )
);
}

endif;

0 comments on commit 376c0f7

Please sign in to comment.