Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Basic block. #148

Merged
merged 1 commit into from
Sep 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions 01-basic/block.asset.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?php return array('dependencies' => array('wp-blocks', 'wp-element', 'wp-i18n', 'wp-polyfill'), 'version' => 'a35cc1c098b69994c9c6d6dc1416bb90');
9 changes: 9 additions & 0 deletions 01-basic/block.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"title": "Example: Basic",
"name":"gutenberg-examples/example-01-basic",
"category":"layout",
"icon": "universal-access-alt",
"textDomain": "gutenberg-examples",
"example":{},
"editorScript": "file:./block.js"
}
32 changes: 12 additions & 20 deletions 01-basic/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,26 +33,18 @@ function gutenberg_examples_01_register_block() {
// Gutenberg is not active.
return;
}

wp_register_script(
'gutenberg-examples-01',
plugins_url( 'block.js', __FILE__ ),
array( 'wp-blocks', 'wp-i18n', 'wp-element' ),
filemtime( plugin_dir_path( __FILE__ ) . 'block.js' )
);

register_block_type( 'gutenberg-examples/example-01-basic', array(
'editor_script' => 'gutenberg-examples-01',
) );

if ( function_exists( 'wp_set_script_translations' ) ) {
/**
* May be extended to wp_set_script_translations( 'my-handle', 'my-domain',
* plugin_dir_path( MY_PLUGIN ) . 'languages' ) ). For details see
* https://make.wordpress.org/core/2018/11/09/new-javascript-i18n-support-in-wordpress/
*/
wp_set_script_translations( 'gutenberg-examples-01', 'gutenberg-examples' );
}

// __DIR__ is the current directory where block.json file is stored.
register_block_type( __DIR__ );

if ( function_exists( 'wp_set_script_translations' ) ) {
/**
* May be extended to wp_set_script_translations( 'my-handle', 'my-domain',
* plugin_dir_path( MY_PLUGIN ) . 'languages' ) ). For details see
* https://make.wordpress.org/core/2018/11/09/new-javascript-i18n-support-in-wordpress/
*/
wp_set_script_translations( 'gutenberg-examples-01', 'gutenberg-examples' );
}

}
add_action( 'init', 'gutenberg_examples_01_register_block' );