File tree Expand file tree Collapse file tree
packages/cgb-scripts/template/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66 */
77
88// Import CSS.
9- import './style.scss' ;
109import './editor.scss' ;
10+ import './style.scss' ;
1111
1212const { __ } = wp . i18n ; // Import __() from wp.i18n
1313const { registerBlockType } = wp . blocks ; // Import registerBlockType() from wp.blocks
@@ -43,8 +43,11 @@ registerBlockType( 'cgb/block-<% blockName %>', {
4343 * The "edit" property must be a valid function.
4444 *
4545 * @link https://wordpress.org/gutenberg/handbook/block-api/block-edit-save/
46+ *
47+ * @param {Object } props Props.
48+ * @returns {Mixed } JSX Component.
4649 */
47- edit : function ( props ) {
50+ edit : ( props ) => {
4851 // Creates a <p class='wp-block-cgb-block-<% blockName %>'></p>.
4952 return (
5053 < div className = { props . className } >
@@ -71,10 +74,13 @@ registerBlockType( 'cgb/block-<% blockName %>', {
7174 * The "save" property must be specified and must be a valid function.
7275 *
7376 * @link https://wordpress.org/gutenberg/handbook/block-api/block-edit-save/
77+ *
78+ * @param {Object } props Props.
79+ * @returns {Mixed } JSX Frontend HTML.
7480 */
75- save : function ( props ) {
81+ save : ( props ) => {
7682 return (
77- < div >
83+ < div className = { props . className } >
7884 < p > β Hello from the frontend.</ p >
7985 < p >
8086 CGB BLOCK: < code > < % blockName % > </ code > is a new Gutenberg block.
Original file line number Diff line number Diff line change @@ -53,14 +53,14 @@ function <% blockNamePHPLower %>_cgb_block_assets() { // phpcs:ignore
5353 null // filemtime( plugin_dir_path( __DIR__ ) . 'dist/blocks.editor.build.css' ) // Version: File modification time.
5454 );
5555
56- // Localised globals. Use dynamic PHP stuff in JavaScript via `cgbGlobal object.
56+ // Localized globals. Use dynamic PHP stuff in JavaScript via `cgbGlobal` object.
5757 wp_localize_script (
5858 '<% blockNamePHPLower %>-cgb-block-js ' ,
5959 'cgbGlobal ' , // Array containing dynamic data for a JS Global.
6060 [
6161 'pluginDirPath ' => plugin_dir_path ( __DIR__ ),
6262 'pluginDirUrl ' => plugin_dir_url ( __DIR__ ),
63- // Add more data here that you want to access from cgbGlobal object.
63+ // Add more data here that you want to access from ` cgbGlobal` object.
6464 ]
6565 );
6666
You canβt perform that action at this time.
0 commit comments