Skip to content

Instantly share code, notes, and snippets.

@proweb
Last active December 14, 2025 15:16
Show Gist options
  • Select an option

  • Save proweb/6f3ca2f27b0ba0afae5b8d28b3217003 to your computer and use it in GitHub Desktop.

Select an option

Save proweb/6f3ca2f27b0ba0afae5b8d28b3217003 to your computer and use it in GitHub Desktop.
Guenberg blocks for WordPress
<?php
// Allow only needed blocks in post types
function wpdocs_allowed_post_type_blocks( $allowed_block_types, $editor_context ) {
if ( 'sponsors' === $editor_context->post->post_type ) {
return array(
'core/paragraph',
);
}
if ( 'news' === $editor_context->post->post_type ) {
return array(
'core/paragraph',
'core/list',
'core/image',
'core/buttons',
'core/quote',
);
}
if ( 'faqs' === $editor_context->post->post_type ) {
return array(
'core/paragraph',
'core/list',
'core/image',
'core/buttons',
);
}
return $allowed_block_types;
}
add_filter( 'allowed_block_types_all', 'wpdocs_allowed_post_type_blocks', 10, 2 );
<?php
$block_types = WP_Block_Type_Registry::get_instance()->get_all_registered();

Работа с паттернами

Скопировать код паттерна из Gutenberg

Экранировать JSON через https://www.jsonescaper.com/

Открыть Playground базовый Blueprint

вставить в ENV['content']

Получить список цветов в консоли.

wp.data.select('core/block-editor').getSettings().colors;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment