{"id":179,"date":"2024-10-04T11:41:39","date_gmt":"2024-10-04T15:41:39","guid":{"rendered":"http:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/?page_id=179"},"modified":"2025-02-20T13:50:49","modified_gmt":"2025-02-20T18:50:49","slug":"icons-naming-categories","status":"publish","type":"page","link":"https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/handbook\/wp-core\/icons-naming-categories\/","title":{"rendered":"Block Icons, Naming, &#038; Categories"},"content":{"rendered":"\n<h2>Naming<\/h2>\n\n\n\n<p>The Name of a block is the primary namespace and identifier for a given block. Though it might be tempting to include the plugin name as part of the block name, this should be avoided since a Collection can be used to denote that grouping. Ideally the name of a BU block should be limited to its most basic descriptor, and additional identifiers should only be thrown in if the use of collections and the BU Red icon styling are not enough to differentiate it from an existing block. For example a BU Button block is named just &#8220;Button&#8221; same as core WP Button block, but the BU version has a red icon to differentiate it.<\/p>\n\n\n\n<h2>Categories<\/h2>\n\n\n\n<p>A Category is the name space to which a given block is grouped to. The block will appear under that category in the Inserter Menu. <em>A block can only be registered to one category.<\/em><\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-medium\"><img loading=\"lazy\" width=\"437\" height=\"636\" src=\"\/gutenberg\/files\/2024\/10\/379856988-b1325de2-4d2b-4a44-bf2d-7bbd2625a8dc-437x636.png\" alt=\"\" class=\"wp-image-242\" srcset=\"https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/files\/2024\/10\/379856988-b1325de2-4d2b-4a44-bf2d-7bbd2625a8dc-437x636.png 437w, https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/files\/2024\/10\/379856988-b1325de2-4d2b-4a44-bf2d-7bbd2625a8dc.png 682w\" sizes=\"(max-width: 437px) 100vw, 437px\" \/><figcaption>Example blocks assigned to custom categories.<\/figcaption><\/figure><\/div>\n\n\n\n<p>Categories are created in <code>php<\/code> and assigned via the&nbsp;&#8220;category&#8221; node in block.json.<\/p>\n\n\n\n<p><a href=\"https:\/\/developer.wordpress.org\/reference\/hooks\/block_categories_all\/\">WordPress Documentation<\/a><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public function custom_block_category( $categories ) {\n\tarray_unshift(\n\t\t$categories,\n\t\tarray(\n\t\t\t'slug'  => 'theme-or-plugin-slug-block-category',\n\t\t\t'title' => 'BU: Theme Starter Block Category (PHP)',\n\t\t)\n\t);\n\n\treturn $categories;\n}\nadd_filter( 'block_categories_all', 'custom_block_category' );<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>{\n\t\"$schema\": \"https:\/\/schemas.wp.org\/trunk\/block.json\",\n\t\"apiVersion\": 3,\n\t\"name\": \"theme-or-plugin-slug-block-collection\/example-block\",\n\t\"version\": \"0.1.0\",\n\t\"title\": \"BU: Theme Starter 1\",\n\t\"category\": \"theme-or-plugin-slug-block-category\"\n}<\/code><\/pre>\n\n\n\n<h2>Collections<\/h2>\n\n\n\n<p>Collections allow specific block types to be grouped together for added visibility in the editor\u2019s Inserter menu, regardless of their categories. <em>A block can only be registered to one collection.<\/em><\/p>\n\n\n\n<p>For instance take two different BU Blocks; the Lead-In block could be registered to the Layout category and the BUniverse block might be registered under the Embeds category. By registering a collection for the BU Blocks namespace, these blocks would appear in the Inserter under their respective categories but also grouped under a BU Blocks collection. So while a block is registered to one Category, it can appear under multiple areas of the Inserter Menu thru the use of Collections.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-medium\"><img loading=\"lazy\" width=\"325\" height=\"636\" src=\"\/gutenberg\/files\/2024\/10\/379857057-b5179b2b-e19b-4d6f-9cdf-bc07d819b256-325x636.png\" alt=\"\" class=\"wp-image-243\" srcset=\"https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/files\/2024\/10\/379857057-b5179b2b-e19b-4d6f-9cdf-bc07d819b256-325x636.png 325w, https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/files\/2024\/10\/379857057-b5179b2b-e19b-4d6f-9cdf-bc07d819b256-524x1024.png 524w, https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/files\/2024\/10\/379857057-b5179b2b-e19b-4d6f-9cdf-bc07d819b256.png 678w\" sizes=\"(max-width: 325px) 100vw, 325px\" \/><figcaption>Example blocks assigned to custom collections.<\/figcaption><\/figure><\/div>\n\n\n\n<p>Collections are created in <code>js<\/code> and assigned via the&nbsp;&#8220;namespace&#8221; node in block.json&nbsp;(must match the first argument of &#8220;registerBlockCollection&#8221;). The collection will have all blocks registered as&nbsp;<code>namespace\/*<\/code>.<\/p>\n\n\n\n<p><a href=\"https:\/\/developer.wordpress.org\/block-editor\/reference-guides\/packages\/packages-blocks\/#registerblockcollection\">WordPress Documentation<\/a><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>registerBlockCollection( 'theme-or-plugin-slug-block-collection', {\n\ttitle: 'BU: Theme Starter Blocks Collection (JS)',\n} );<\/code><\/pre>\n\n\n\n<h2>Block Icon<\/h2>\n\n\n\n<p>To keep BU developed block consistent and recognizable in the block selection panel, we&#8217;ve provided a template for creating their SVG icons.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"659\" src=\"\/gutenberg\/files\/2024\/10\/Screenshot-2024-10-08-at-9.45.52\u202fAM-1024x659.png\" alt=\"\" class=\"wp-image-199\" srcset=\"https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/files\/2024\/10\/Screenshot-2024-10-08-at-9.45.52\u202fAM-1024x659.png 1024w, https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/files\/2024\/10\/Screenshot-2024-10-08-at-9.45.52\u202fAM-636x409.png 636w, https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/files\/2024\/10\/Screenshot-2024-10-08-at-9.45.52\u202fAM-768x494.png 768w, https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/files\/2024\/10\/Screenshot-2024-10-08-at-9.45.52\u202fAM.png 1266w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<div class=\"wp-block-buttons\">\n<div class=\"wp-block-button\"><a class=\"wp-block-button__link has-background has-very-light-gray-background-color\" href=\"\/gutenberg\/files\/2024\/10\/svg-bu-icons_EXAMPLE-TEMPLATE.ai\">Download Template<\/a><\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Naming The Name of a block is the primary namespace and identifier for a given block. Though it might be tempting to include the plugin name as part of the block name, this should be avoided since a Collection can be used to denote that grouping. Ideally the name of a BU block should be [&hellip;]<\/p>\n","protected":false},"author":3670,"featured_media":0,"parent":575,"menu_order":6,"comment_status":"closed","ping_status":"closed","template":"","meta":[],"status-is-a-reserved-term":[],"assignee":[],"_links":{"self":[{"href":"https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/wp-json\/wp\/v2\/pages\/179"}],"collection":[{"href":"https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/wp-json\/wp\/v2\/users\/3670"}],"replies":[{"embeddable":true,"href":"https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/wp-json\/wp\/v2\/comments?post=179"}],"version-history":[{"count":11,"href":"https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/wp-json\/wp\/v2\/pages\/179\/revisions"}],"predecessor-version":[{"id":251,"href":"https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/wp-json\/wp\/v2\/pages\/179\/revisions\/251"}],"up":[{"embeddable":true,"href":"https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/wp-json\/wp\/v2\/pages\/575"}],"wp:attachment":[{"href":"https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/wp-json\/wp\/v2\/media?parent=179"}],"wp:term":[{"taxonomy":"status-is-a-reserved-term","embeddable":true,"href":"https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/wp-json\/wp\/v2\/status-is-a-reserved-term?post=179"},{"taxonomy":"assignee","embeddable":true,"href":"https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/wp-json\/wp\/v2\/assignee?post=179"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}