Skip to content
This repository was archived by the owner on Dec 11, 2023. It is now read-only.

Commit b6245c5

Browse files
committed
More documentation on several files
1 parent 6212d30 commit b6245c5

File tree

5 files changed

+11
-3
lines changed

5 files changed

+11
-3
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ Note that if you plan to extend the block editor, the files should be placed in
115115

116116
* `packages/blocks` is where custom block definitions reside. You will find a `demo` block that serves as an example of custom block that you can delete or modify. Remember to import your blocks in the file `packages/blocks/index.js` so that they are built properly.
117117
* `assets/src/js/admin` is for all admin-specific functionality. You will find an example of editor plugin in `plugin.js` that extends the block editor. You can delete it or modify such plugin.
118+
* `wp-beb.php` contains the function `enqueue_block_editor_assets` where you should enqueue the new files you create in `assets/src/js` and `assets/src/css` that compile into `assets/dist/js` and `assets/dist/css`, respectively.
118119

119120
# Credits
120121

assets/src/js/admin/plugin-component.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,22 @@ const {
1010
} = wp.components;
1111

1212
function addDemoBlock() {
13+
1314
const demoBlock = createBlock( 'wp-beb/demo', {
1415
greeting: 'Hey there!',
1516
className: 'is-style-awesome',
1617
} );
1718
dispatch( 'core/editor' ).insertBlock( demoBlock );
19+
1820
}//end addDemoBlock()
1921

2022
const PluginComponent = () => (
2123

24+
// Every component must have only one parent element.
25+
// In this case, the parent element is a Fragment.
2226
<Fragment>
2327
<PluginSidebarMoreMenuItem target="sidebar-name">
24-
My Sidebar
28+
{ _x( 'My Sidebar', 'text', 'wp-beb' ) }
2529
</PluginSidebarMoreMenuItem>
2630
<PluginSidebar name="sidebar-name" title="My Sidebar">
2731

assets/src/js/admin/plugin.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import ElementIcon from '../../images/icon.svg';
55

66
const { registerPlugin } = wp.plugins;
77

8+
// More info:
9+
// https://wordpress.org/gutenberg/handbook/designers-developers/developers/packages/packages-plugins/
810
registerPlugin( 'plugin-name', {
911
icon: <ElementIcon />,
1012
render: PluginComponent,

packages/blocks/demo/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ export const settings = {
2424
title: BLOCK_TITLE,
2525
description: BLOCK_DESCRIPTION,
2626

27-
// icon: <ElementIcon />, // Use a SVG for the icon.
28-
icon: 'heart', // Use a Dashicon for the icon.
27+
// icon: <ElementIcon />, // Use a SVG for the icon instead.
28+
icon: 'heart', // Use a Dashicon for the icon instead of a SVG.
2929

3030
category: 'demo',
3131
keywords: [

wp-beb.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ public function init_hooks() {
7272
// Add Demo category.
7373
add_filter( 'block_categories', [ $this, 'block_categories' ], 9 );
7474

75+
// Enqueue scripts and styles.
7576
add_action( 'enqueue_block_editor_assets', [ $this, 'enqueue_block_editor_assets' ], 9 );
7677

7778
}//end if

0 commit comments

Comments
 (0)