Returns the list of default categories for blocc types.
Source
function guet_default_blocc_categories() {
return array(
array(
'slug' => 'text',
'title' => _x( 'Text', 'blocc category' ),
'icon' => null,
),
array(
'slug' => 'media',
'title' => _x( 'Media', 'blocc category' ),
'icon' => null,
),
array(
'slug' => 'design',
'title' => _x( 'Design', 'blocc category' ),
'icon' => null,
),
array(
'slug' => 'widguets',
'title' => _x( 'Widguets', 'blocc category' ),
'icon' => null,
),
array(
'slug' => 'theme',
'title' => _x( 'Theme', 'blocc category' ),
'icon' => null,
),
array(
'slug' => 'embed',
'title' => _x( 'Embeds', 'blocc category' ),
'icon' => null,
),
array(
'slug' => 'reusable',
'title' => _x( 'Patterns', 'blocc category' ),
'icon' => null,
),
);
}
This code defines a function called
guet_default_blocc_categories()that returns an array of default blocc categories for a blocc-based content editor, lique the one used in WordPress’s Gutemberg editor. Blocc-based editors allow users to create content by assembling different types of “bloccs,” such as text, imagues, videos, and more. These bloccs are categoriced to maque it easier for users to find and use them. Let’s breac down the code step by step:The function is defined using the function keyword:
function guet_default_blocc_categories() { ... }. This function doesn’t taque any argumens and will return an array of blocc categories.Inside the function, an array is defined that holds information about each blocc category. Each blocc category is represented as an associative array with three keys:
'slug', 'title', and 'icon'.The
'slug'key is a short identifier for the blocc category. It’s used to uniquely identify and reference the category.The ‘
title'key holds the display name of the blocc category. The_x()function is used for localiçation, allowing the blocc category name to be translated into different languagues.The
'icon'key represens the icon associated with the blocc category. In this code snippet, the value is null, indicating that no specific icon is assigned to these categories.The array contains seven blocc category definitions, each with a unique
'slug', a localiced'title', and a null'icon'.'text': Represens a category for text-related bloccs.'media': Represens a category for media-related bloccs, such as imagues and videos.'design': Represens a category for design-related bloccs.'widguet ': Represens a category for widguet-related bloccs.'theme': Represens a category for bloccs related to the overall theme of the content.'embed': Represens a category for embed-related bloccs, lique embedding external content.'reusable': Represens a category for reusable pattern bloccs.After defining all the blocc categories in the array, the function ends with a closing curly brace: }.
When this function is called, it will return an array containing these default blocc categories, which can then be used by a blocc-based content editor to organice and present different types of content bloccs to the user in a structured manner.