-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #107 from gziolo/update/scaffold-block
Block: Improve in file documentation to make it easier to edit content
- Loading branch information
Showing
7 changed files
with
163 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
/** | ||
* The following styles get applied inside the editor only. | ||
* | ||
* Replace them with your own styles or remove the file completely. | ||
*/ | ||
|
||
.wp-block-{{namespace}}-{{slug}} { | ||
/* Replace with your styles. */ | ||
background-color: #000; | ||
color: #fff; | ||
border: 1px dotted #f00; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,54 @@ | ||
<?php | ||
/** | ||
* Functions to register client-side assets (scripts and stylesheets) for the Gutenberg block. | ||
* | ||
* @package {{namespace}} | ||
*/ | ||
|
||
/** | ||
* Enqueues block assets to apply inside the editor only. | ||
*/ | ||
function {{machine_name}}_enqueue_block_editor_assets() { | ||
$dir = dirname( __FILE__ ); | ||
$block_js = '{{slug}}/block.js'; | ||
wp_enqueue_script( | ||
'{{slug}}-block-editor', | ||
plugins_url( $block_js, __FILE__ ), | ||
array( | ||
'wp-blocks', | ||
'wp-i18n', | ||
'wp-element', | ||
), | ||
filemtime( "$dir/$block_js" ) | ||
); | ||
$editor_css = '{{slug}}/editor.css'; | ||
wp_enqueue_script( '{{slug}}-block', plugins_url( $block_js, __FILE__ ), array( | ||
'wp-blocks', | ||
'wp-i18n', | ||
'wp-element', | ||
), filemtime( "$dir/$block_js" ) ); | ||
wp_enqueue_style( '{{slug}}-block', plugins_url( $editor_css, __FILE__ ), array( | ||
'wp-blocks', | ||
), filemtime( "$dir/$editor_css" ) ); | ||
wp_enqueue_style( | ||
'{{slug}}-block-editor', | ||
plugins_url( $editor_css, __FILE__ ), | ||
array( | ||
'wp-blocks', | ||
), | ||
filemtime( "$dir/$editor_css" ) | ||
); | ||
} | ||
add_action( 'enqueue_block_editor_assets', '{{machine_name}}_enqueue_block_editor_assets' ); | ||
|
||
/** | ||
* Enqueues block assets to apply both on the front of your site and in the editor. | ||
*/ | ||
function {{machine_name}}_enqueue_block_assets() { | ||
$dir = dirname( __FILE__ ); | ||
$style_css = '{{slug}}/style.css'; | ||
wp_enqueue_style( | ||
'{{slug}}-block', | ||
plugins_url( $style_css, __FILE__ ), | ||
array( | ||
'wp-blocks', | ||
), | ||
filemtime( "$dir/$style_css" ) | ||
); | ||
} | ||
add_action( 'enqueue_block_assets', '{{machine_name}}_enqueue_block_assets' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/** | ||
* The following styles get applied both on the front of your site and in the editor. | ||
* | ||
* Replace them with your own styles or remove the file completely. | ||
*/ | ||
|
||
.wp-block-{{namespace}}-{{slug}} { | ||
background-color: #000; | ||
color: #fff; | ||
padding: 2px; | ||
} |