Skip to content

Commit 60cc429

Browse files
committed
πŸ‘Œ IMPROVE: Docs & Standards
1 parent 2946d04 commit 60cc429

6 files changed

Lines changed: 62 additions & 74 deletions

File tree

β€Žexamples/01-single-block/src/init.phpβ€Ž

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* Enqueue CSS/JS of all the blocks.
66
*
7-
* @since 1.0.0
7+
* @since 1.0.0
88
* @package CGB
99
*/
1010

@@ -16,8 +16,7 @@
1616
/**
1717
* Enqueue Gutenberg block assets for both frontend + backend.
1818
*
19-
* `wp-editor`: WP editor styles.
20-
*
19+
* @uses {wp-editor} for WP editor styles.
2120
* @since 1.0.0
2221
*/
2322
function single_block_cgb_block_assets() {
@@ -26,21 +25,20 @@ function single_block_cgb_block_assets() {
2625
'single_block-cgb-style-css', // Handle.
2726
plugins_url( 'dist/blocks.style.build.css', dirname( __FILE__ ) ), // Block style CSS.
2827
array( 'wp-editor' ) // Dependency to include the CSS after it.
29-
// filemtime( plugin_dir_path( __DIR__ ) . 'dist/blocks.style.build.css' ) // Version: filemtime β€” Gets file modification time.
28+
// filemtime( plugin_dir_path( __DIR__ ) . 'dist/blocks.style.build.css' ) // Version: File modification time.
3029
);
31-
} // End function single_block_cgb_block_assets().
30+
}
3231

3332
// Hook: Frontend assets.
3433
add_action( 'enqueue_block_assets', 'single_block_cgb_block_assets' );
3534

3635
/**
3736
* Enqueue Gutenberg block assets for backend editor.
3837
*
39-
* `wp-blocks`: includes block type registration and related functions.
40-
* `wp-element`: includes the WordPress Element abstraction for describing the structure of your blocks.
41-
* `wp-i18n`: internationalize the block's text.
42-
* `wp-editor`: WP editor styles.
43-
*
38+
* @uses {wp-blocks} for block type registration & related functions.
39+
* @uses {wp-element} for WP Element abstraction β€” structure of blocks.
40+
* @uses {wp-i18n} to internationalize the block's text.
41+
* @uses {wp-editor} for WP editor styles.
4442
* @since 1.0.0
4543
*/
4644
function single_block_cgb_editor_assets() {
@@ -49,17 +47,17 @@ function single_block_cgb_editor_assets() {
4947
'single_block-cgb-block-js', // Handle.
5048
plugins_url( '/dist/blocks.build.js', dirname( __FILE__ ) ), // Block.build.js: We register the block here. Built with Webpack.
5149
array( 'wp-blocks', 'wp-i18n', 'wp-element', 'wp-editor' ) // Dependencies, defined above.
52-
// filemtime( plugin_dir_path( __DIR__ ) . 'dist/blocks.build.js' ) // Version: filemtime β€” Gets file modification time.
50+
// filemtime( plugin_dir_path( __DIR__ ) . 'dist/blocks.build.js' ) // Version: File modification time.
5351
);
5452

5553
// Styles.
5654
wp_enqueue_style(
5755
'single_block-cgb-block-editor-css', // Handle.
5856
plugins_url( 'dist/blocks.editor.build.css', dirname( __FILE__ ) ), // Block editor CSS.
5957
array( 'wp-edit-blocks' ) // Dependency to include the CSS after it.
60-
// filemtime( plugin_dir_path( __DIR__ ) . 'dist/blocks.editor.build.css' ) // Version: filemtime β€” Gets file modification time.
58+
// filemtime( plugin_dir_path( __DIR__ ) . 'dist/blocks.editor.build.css' ) // Version: File modification time.
6159
);
62-
} // End function single_block_cgb_editor_assets().
60+
}
6361

6462
// Hook: Editor assets.
65-
add_action( 'enqueue_block_editor_assets', 'single_block_cgb_editor_assets' );
63+
add_action( 'enqueue_block_editor_assets', 'single_block_cgb_editor_assets' );

β€Žexamples/02-single-block-ejected/src/init.phpβ€Ž

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* Enqueue CSS/JS of all the blocks.
66
*
7-
* @since 1.0.0
7+
* @since 1.0.0
88
* @package CGB
99
*/
1010

@@ -16,8 +16,7 @@
1616
/**
1717
* Enqueue Gutenberg block assets for both frontend + backend.
1818
*
19-
* `wp-editor`: WP editor styles.
20-
*
19+
* @uses {wp-editor} for WP editor styles.
2120
* @since 1.0.0
2221
*/
2322
function single_block_cgb_block_assets() {
@@ -26,7 +25,7 @@ function single_block_cgb_block_assets() {
2625
'single_block-cgb-style-css', // Handle.
2726
plugins_url( 'dist/blocks.style.build.css', dirname( __FILE__ ) ), // Block style CSS.
2827
array( 'wp-editor' ) // Dependency to include the CSS after it.
29-
// filemtime( plugin_dir_path( __DIR__ ) . 'dist/blocks.style.build.css' ) // Version: filemtime β€” Gets file modification time.
28+
// filemtime( plugin_dir_path( __DIR__ ) . 'dist/blocks.style.build.css' ) // Version: File modification time.
3029
);
3130
} // End function single_block_cgb_block_assets().
3231

@@ -36,11 +35,10 @@ function single_block_cgb_block_assets() {
3635
/**
3736
* Enqueue Gutenberg block assets for backend editor.
3837
*
39-
* `wp-blocks`: includes block type registration and related functions.
40-
* `wp-element`: includes the WordPress Element abstraction for describing the structure of your blocks.
41-
* `wp-i18n`: internationalize the block's text.
42-
* `wp-editor`: WP editor styles.
43-
*
38+
* @uses {wp-blocks} for block type registration & related functions.
39+
* @uses {wp-element} for WP Element abstraction β€” structure of blocks.
40+
* @uses {wp-i18n} to internationalize the block's text.
41+
* @uses {wp-editor} for WP editor styles.
4442
* @since 1.0.0
4543
*/
4644
function single_block_cgb_editor_assets() {
@@ -49,17 +47,17 @@ function single_block_cgb_editor_assets() {
4947
'single_block-cgb-block-js', // Handle.
5048
plugins_url( '/dist/blocks.build.js', dirname( __FILE__ ) ), // Block.build.js: We register the block here. Built with Webpack.
5149
array( 'wp-blocks', 'wp-i18n', 'wp-element', 'wp-editor' ) // Dependencies, defined above.
52-
// filemtime( plugin_dir_path( __DIR__ ) . 'dist/blocks.build.js' ) // Version: filemtime β€” Gets file modification time.
50+
// filemtime( plugin_dir_path( __DIR__ ) . 'dist/blocks.build.js' ) // Version: File modification time.
5351
);
5452

5553
// Styles.
5654
wp_enqueue_style(
5755
'single_block-cgb-block-editor-css', // Handle.
5856
plugins_url( 'dist/blocks.editor.build.css', dirname( __FILE__ ) ), // Block editor CSS.
5957
array( 'wp-edit-blocks' ) // Dependency to include the CSS after it.
60-
// filemtime( plugin_dir_path( __DIR__ ) . 'dist/blocks.editor.build.css' ) // Version: filemtime β€” Gets file modification time.
58+
// filemtime( plugin_dir_path( __DIR__ ) . 'dist/blocks.editor.build.css' ) // Version: File modification time.
6159
);
6260
} // End function single_block_cgb_editor_assets().
6361

6462
// Hook: Editor assets.
65-
add_action( 'enqueue_block_editor_assets', 'single_block_cgb_editor_assets' );
63+
add_action( 'enqueue_block_editor_assets', 'single_block_cgb_editor_assets' );

β€Žexamples/03-multi-block/src/init.phpβ€Ž

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* Enqueue CSS/JS of all the blocks.
66
*
7-
* @since 1.0.0
7+
* @since 1.0.0
88
* @package CGB
99
*/
1010

@@ -16,8 +16,7 @@
1616
/**
1717
* Enqueue Gutenberg block assets for both frontend + backend.
1818
*
19-
* `wp-editor`: WP editor styles.
20-
*
19+
* @uses {wp-editor} for WP editor styles.
2120
* @since 1.0.0
2221
*/
2322
function multi_block_cgb_block_assets() {
@@ -26,7 +25,7 @@ function multi_block_cgb_block_assets() {
2625
'multi_block-cgb-style-css', // Handle.
2726
plugins_url( 'dist/blocks.style.build.css', dirname( __FILE__ ) ), // Block style CSS.
2827
array( 'wp-editor' ) // Dependency to include the CSS after it.
29-
// filemtime( plugin_dir_path( __DIR__ ) . 'dist/blocks.style.build.css' ) // Version: filemtime β€” Gets file modification time.
28+
// filemtime( plugin_dir_path( __DIR__ ) . 'dist/blocks.style.build.css' ) // Version: File modification time.
3029
);
3130
} // End function multi_block_cgb_block_assets().
3231

@@ -36,11 +35,10 @@ function multi_block_cgb_block_assets() {
3635
/**
3736
* Enqueue Gutenberg block assets for backend editor.
3837
*
39-
* `wp-blocks`: includes block type registration and related functions.
40-
* `wp-element`: includes the WordPress Element abstraction for describing the structure of your blocks.
41-
* `wp-i18n`: internationalize the block's text.
42-
* `wp-editor`: WP editor styles.
43-
*
38+
* @uses {wp-blocks} for block type registration & related functions.
39+
* @uses {wp-element} for WP Element abstraction β€” structure of blocks.
40+
* @uses {wp-i18n} to internationalize the block's text.
41+
* @uses {wp-editor} for WP editor styles.
4442
* @since 1.0.0
4543
*/
4644
function multi_block_cgb_editor_assets() {
@@ -49,17 +47,17 @@ function multi_block_cgb_editor_assets() {
4947
'multi_block-cgb-block-js', // Handle.
5048
plugins_url( '/dist/blocks.build.js', dirname( __FILE__ ) ), // Block.build.js: We register the block here. Built with Webpack.
5149
array( 'wp-blocks', 'wp-i18n', 'wp-element', 'wp-editor' ) // Dependencies, defined above.
52-
// filemtime( plugin_dir_path( __DIR__ ) . 'dist/blocks.build.js' ) // Version: filemtime β€” Gets file modification time.
50+
// filemtime( plugin_dir_path( __DIR__ ) . 'dist/blocks.build.js' ) // Version: File modification time.
5351
);
5452

5553
// Styles.
5654
wp_enqueue_style(
5755
'multi_block-cgb-block-editor-css', // Handle.
5856
plugins_url( 'dist/blocks.editor.build.css', dirname( __FILE__ ) ), // Block editor CSS.
5957
array( 'wp-edit-blocks' ) // Dependency to include the CSS after it.
60-
// filemtime( plugin_dir_path( __DIR__ ) . 'dist/blocks.editor.build.css' ) // Version: filemtime β€” Gets file modification time.
58+
// filemtime( plugin_dir_path( __DIR__ ) . 'dist/blocks.editor.build.css' ) // Version: File modification time.
6159
);
6260
} // End function multi_block_cgb_editor_assets().
6361

6462
// Hook: Editor assets.
65-
add_action( 'enqueue_block_editor_assets', 'multi_block_cgb_editor_assets' );
63+
add_action( 'enqueue_block_editor_assets', 'multi_block_cgb_editor_assets' );

β€Žexamples/04-multi-block-ejected/src/init.phpβ€Ž

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* Enqueue CSS/JS of all the blocks.
66
*
7-
* @since 1.0.0
7+
* @since 1.0.0
88
* @package CGB
99
*/
1010

@@ -16,8 +16,7 @@
1616
/**
1717
* Enqueue Gutenberg block assets for both frontend + backend.
1818
*
19-
* `wp-editor`: WP editor styles.
20-
*
19+
* @uses {wp-editor} for WP editor styles.
2120
* @since 1.0.0
2221
*/
2322
function multi_block_cgb_block_assets() {
@@ -26,7 +25,7 @@ function multi_block_cgb_block_assets() {
2625
'multi_block-cgb-style-css', // Handle.
2726
plugins_url( 'dist/blocks.style.build.css', dirname( __FILE__ ) ), // Block style CSS.
2827
array( 'wp-editor' ) // Dependency to include the CSS after it.
29-
// filemtime( plugin_dir_path( __DIR__ ) . 'dist/blocks.style.build.css' ) // Version: filemtime β€” Gets file modification time.
28+
// filemtime( plugin_dir_path( __DIR__ ) . 'dist/blocks.style.build.css' ) // Version: File modification time.
3029
);
3130
} // End function multi_block_cgb_block_assets().
3231

@@ -36,11 +35,10 @@ function multi_block_cgb_block_assets() {
3635
/**
3736
* Enqueue Gutenberg block assets for backend editor.
3837
*
39-
* `wp-blocks`: includes block type registration and related functions.
40-
* `wp-element`: includes the WordPress Element abstraction for describing the structure of your blocks.
41-
* `wp-i18n`: internationalize the block's text.
42-
* `wp-editor`: WP editor styles.
43-
*
38+
* @uses {wp-blocks} for block type registration & related functions.
39+
* @uses {wp-element} for WP Element abstraction β€” structure of blocks.
40+
* @uses {wp-i18n} to internationalize the block's text.
41+
* @uses {wp-editor} for WP editor styles.
4442
* @since 1.0.0
4543
*/
4644
function multi_block_cgb_editor_assets() {
@@ -49,17 +47,17 @@ function multi_block_cgb_editor_assets() {
4947
'multi_block-cgb-block-js', // Handle.
5048
plugins_url( '/dist/blocks.build.js', dirname( __FILE__ ) ), // Block.build.js: We register the block here. Built with Webpack.
5149
array( 'wp-blocks', 'wp-i18n', 'wp-element', 'wp-editor' ) // Dependencies, defined above.
52-
// filemtime( plugin_dir_path( __DIR__ ) . 'dist/blocks.build.js' ) // Version: filemtime β€” Gets file modification time.
50+
// filemtime( plugin_dir_path( __DIR__ ) . 'dist/blocks.build.js' ) // Version: File modification time.
5351
);
5452

5553
// Styles.
5654
wp_enqueue_style(
5755
'multi_block-cgb-block-editor-css', // Handle.
5856
plugins_url( 'dist/blocks.editor.build.css', dirname( __FILE__ ) ), // Block editor CSS.
5957
array( 'wp-edit-blocks' ) // Dependency to include the CSS after it.
60-
// filemtime( plugin_dir_path( __DIR__ ) . 'dist/blocks.editor.build.css' ) // Version: filemtime β€” Gets file modification time.
58+
// filemtime( plugin_dir_path( __DIR__ ) . 'dist/blocks.editor.build.css' ) // Version: File modification time.
6159
);
6260
} // End function multi_block_cgb_editor_assets().
6361

6462
// Hook: Editor assets.
65-
add_action( 'enqueue_block_editor_assets', 'multi_block_cgb_editor_assets' );
63+
add_action( 'enqueue_block_editor_assets', 'multi_block_cgb_editor_assets' );

β€Žexamples/05-a11y-input/src/init.phpβ€Ž

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
/**
1717
* Enqueue Gutenberg block assets for both frontend + backend.
1818
*
19-
* `wp-editor`: WP editor styles.
20-
*
19+
* @uses {wp-editor} for WP editor styles.
2120
* @since 1.0.0
2221
*/
2322
function a11y_input_cgb_block_assets() {
@@ -26,7 +25,7 @@ function a11y_input_cgb_block_assets() {
2625
'a11y_input-cgb-style-css', // Handle.
2726
plugins_url( 'dist/blocks.style.build.css', dirname( __FILE__ ) ), // Block style CSS.
2827
array( 'wp-editor' ) // Dependency to include the CSS after it.
29-
// filemtime( plugin_dir_path( __DIR__ ) . 'dist/blocks.style.build.css' ) // Version: filemtime β€” Gets file modification time.
28+
// filemtime( plugin_dir_path( __DIR__ ) . 'dist/blocks.style.build.css' ) // Version: File modification time.
3029
);
3130
} // End function a11y_input_cgb_block_assets().
3231

@@ -36,11 +35,10 @@ function a11y_input_cgb_block_assets() {
3635
/**
3736
* Enqueue Gutenberg block assets for backend editor.
3837
*
39-
* `wp-blocks`: includes block type registration and related functions.
40-
* `wp-element`: includes the WordPress Element abstraction for describing the structure of your blocks.
41-
* `wp-i18n`: internationalize the block's text.
42-
* `wp-editor`: WP editor styles.
43-
*
38+
* @uses {wp-blocks} for block type registration & related functions.
39+
* @uses {wp-element} for WP Element abstraction β€” structure of blocks.
40+
* @uses {wp-i18n} to internationalize the block's text.
41+
* @uses {wp-editor} for WP editor styles.
4442
* @since 1.0.0
4543
*/
4644
function a11y_input_cgb_editor_assets() {
@@ -49,7 +47,7 @@ function a11y_input_cgb_editor_assets() {
4947
'a11y_input-cgb-block-js', // Handle.
5048
plugins_url( '/dist/blocks.build.js', dirname( __FILE__ ) ), // Block.build.js: We register the block here. Built with Webpack.
5149
array( 'wp-blocks', 'wp-i18n', 'wp-element', 'wp-editor' ), // Dependencies, defined above.
52-
// filemtime( plugin_dir_path( __DIR__ ) . 'dist/blocks.build.js' ), // Version: filemtime β€” Gets file modification time.
50+
// filemtime( plugin_dir_path( __DIR__ ) . 'dist/blocks.build.js' ), // Version: File modification time.
5351
true // Enqueue the script in the footer.
5452
);
5553

@@ -58,7 +56,7 @@ function a11y_input_cgb_editor_assets() {
5856
'a11y_input-cgb-block-editor-css', // Handle.
5957
plugins_url( 'dist/blocks.editor.build.css', dirname( __FILE__ ) ), // Block editor CSS.
6058
array( 'wp-edit-blocks' ) // Dependency to include the CSS after it.
61-
// filemtime( plugin_dir_path( __DIR__ ) . 'dist/blocks.editor.build.css' ) // Version: filemtime β€” Gets file modification time.
59+
// filemtime( plugin_dir_path( __DIR__ ) . 'dist/blocks.editor.build.css' ) // Version: File modification time.
6260
);
6361
} // End function a11y_input_cgb_editor_assets().
6462

β€Žpackages/cgb-scripts/template/src/init.phpβ€Ž

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,40 +16,38 @@
1616
/**
1717
* Enqueue Gutenberg block assets for both frontend + backend.
1818
*
19-
* `wp-editor`: WP editor styles.
20-
*
19+
* @uses {wp-editor} for WP editor styles.
2120
* @since 1.0.0
2221
*/
23-
function <% blockNamePHPLower %>_cgb_block_assets() {
22+
function <% blockNamePHPLower %>_cgb_block_assets() { // phpcs:ignore
2423
// Styles.
2524
wp_enqueue_style(
2625
'<% blockNamePHPLower %>-cgb-style-css', // Handle.
2726
plugins_url( 'dist/blocks.style.build.css', dirname( __FILE__ ) ), // Block style CSS.
2827
array( 'wp-editor' ) // Dependency to include the CSS after it.
29-
// filemtime( plugin_dir_path( __DIR__ ) . 'dist/blocks.style.build.css' ) // Version: filemtime β€” Gets file modification time.
28+
// filemtime( plugin_dir_path( __DIR__ ) . 'dist/blocks.style.build.css' ) // Version: File modification time.
3029
);
31-
} // End function <% blockNamePHPLower %>_cgb_block_assets().
30+
}
3231

3332
// Hook: Frontend assets.
3433
add_action( 'enqueue_block_assets', '<% blockNamePHPLower %>_cgb_block_assets' );
3534

3635
/**
3736
* Enqueue Gutenberg block assets for backend editor.
3837
*
39-
* `wp-blocks`: includes block type registration and related functions.
40-
* `wp-element`: includes the WordPress Element abstraction for describing the structure of your blocks.
41-
* `wp-i18n`: internationalize the block's text.
42-
* `wp-editor`: WP editor styles.
43-
*
38+
* @uses {wp-blocks} for block type registration & related functions.
39+
* @uses {wp-element} for WP Element abstraction β€” structure of blocks.
40+
* @uses {wp-i18n} to internationalize the block's text.
41+
* @uses {wp-editor} for WP editor styles.
4442
* @since 1.0.0
4543
*/
46-
function <% blockNamePHPLower %>_cgb_editor_assets() {
44+
function <% blockNamePHPLower %>_cgb_editor_assets() { // phpcs:ignore
4745
// Scripts.
4846
wp_enqueue_script(
4947
'<% blockNamePHPLower %>-cgb-block-js', // Handle.
5048
plugins_url( '/dist/blocks.build.js', dirname( __FILE__ ) ), // Block.build.js: We register the block here. Built with Webpack.
5149
array( 'wp-blocks', 'wp-i18n', 'wp-element', 'wp-editor' ), // Dependencies, defined above.
52-
// filemtime( plugin_dir_path( __DIR__ ) . 'dist/blocks.build.js' ), // Version: filemtime β€” Gets file modification time.
50+
// filemtime( plugin_dir_path( __DIR__ ) . 'dist/blocks.build.js' ), // Version: File modification time.
5351
true // Enqueue the script in the footer.
5452
);
5553

@@ -58,9 +56,9 @@ function <% blockNamePHPLower %>_cgb_editor_assets() {
5856
'<% blockNamePHPLower %>-cgb-block-editor-css', // Handle.
5957
plugins_url( 'dist/blocks.editor.build.css', dirname( __FILE__ ) ), // Block editor CSS.
6058
array( 'wp-edit-blocks' ) // Dependency to include the CSS after it.
61-
// filemtime( plugin_dir_path( __DIR__ ) . 'dist/blocks.editor.build.css' ) // Version: filemtime β€” Gets file modification time.
59+
// filemtime( plugin_dir_path( __DIR__ ) . 'dist/blocks.editor.build.css' ) // Version: File modification time.
6260
);
63-
} // End function <% blockNamePHPLower %>_cgb_editor_assets().
61+
}
6462

6563
// Hook: Editor assets.
6664
add_action( 'enqueue_block_editor_assets', '<% blockNamePHPLower %>_cgb_editor_assets' );

0 commit comments

Comments
Β (0)