get_block_categories() WP 5.0.0
Returns all the block categories that will be shown in the block editor.
Хуки из функции
Возвращает
Массив[]. Array of block categories.
Использование
get_block_categories( $post );
- $post(WP_Post) (обязательный)
- Post object.
Список изменений
С версии 5.0.0 | Введена. |
Код get_block_categories() get block categories WP 5.6.2
function get_block_categories( $post ) {
$default_categories = array(
array(
'slug' => 'text',
'title' => _x( 'Text', 'block category' ),
'icon' => null,
),
array(
'slug' => 'media',
'title' => _x( 'Media', 'block category' ),
'icon' => null,
),
array(
'slug' => 'design',
'title' => _x( 'Design', 'block category' ),
'icon' => null,
),
array(
'slug' => 'widgets',
'title' => _x( 'Widgets', 'block category' ),
'icon' => null,
),
array(
'slug' => 'embed',
'title' => _x( 'Embeds', 'block category' ),
'icon' => null,
),
array(
'slug' => 'reusable',
'title' => _x( 'Reusable Blocks', 'block category' ),
'icon' => null,
),
);
/**
* Filters the default array of block categories.
*
* @since 5.0.0
*
* @param array[] $default_categories Array of block categories.
* @param WP_Post $post Post being loaded.
*/
return apply_filters( 'block_categories', $default_categories, $post );
}