Skip to content

Commit

Permalink
chore(plugin multi-dynamic-example): Experimental plugin to explore h…
Browse files Browse the repository at this point in the history
…ow to build a single plugin that supports multiple dynamic blocks
  • Loading branch information
victorkane committed Apr 6, 2023
1 parent 54e9e5a commit b40e9d1
Show file tree
Hide file tree
Showing 20 changed files with 28,453 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,4 @@ build/
# !wp-content/plugins/metadata-block
# !wp-content/plugins/post-meta-testimonial
!wp-content/plugins/awf-cpt-proto
!wp-content/plugins/multi-dynamic-example
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ Sooooo, let's get this prototype on the road with code-based cpt registration, w
>
> Also [Discussions](https://github.com/awebfactory/awf-cpt-proto/discussions) are open!
## Multi-dyanamic example

- Experiment to scaffold a simple plugin `Multi-dynamic example` with multiple dynamic blocks (`multi-dynamic-example`) which supports multiple (dynamic) blocks
- Based on [WordPress functions reference docs for register_block_type(), comment: How to write a plugin with multiple blocks](https://developer.wordpress.org/reference/functions/register_block_type/#comment-5954) which seems to me to be the most simple and straightforward, allowing for individual directories for each block in the `build` directory.
- See commit 2023-04-06

## References and shout outs (in chronological order of usage for this project)

- [Learn WordPress Courses](https://learn.wordpress.org/courses/)
Expand Down
18 changes: 18 additions & 0 deletions wp-content/plugins/multi-dynamic-example/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# This file is for unifying the coding style for different editors and IDEs
# editorconfig.org

# WordPress Coding Standards
# https://make.wordpress.org/core/handbook/coding-standards/

root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = tab

[*.{yml,yaml}]
indent_style = space
indent_size = 2
30 changes: 30 additions & 0 deletions wp-content/plugins/multi-dynamic-example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Coverage directory used by tools like istanbul
coverage

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Output of `npm pack`
*.tgz

# Output of `wp-scripts plugin-zip`
*.zip

# dotenv environment variables file
.env
28 changes: 28 additions & 0 deletions wp-content/plugins/multi-dynamic-example/multi-dynamic-example.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php
/**
* Plugin Name: Multi-dyanamic example
* Description: Multiple dynamic blocks
* Requires at least: 6.1
* Requires PHP: 7.0
* Version: 0.1.0
* Author: victorkane
* License: GPL-2.0-or-later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: multi-dynamic-example
* Domain Path: awebfactory
*
* @package awebfactory
*/

/**
* Registers the block using the metadata loaded from the `block.json` file.
* Behind the scenes, it registers also all assets so they can be enqueued
* through the block editor in the corresponding context.
*
* @see https://developer.wordpress.org/reference/functions/register_block_type/
*/
function awebfactory_multi_dynamic_example_block_init() {
register_block_type( __DIR__ . '/build/block-1' );
register_block_type( __DIR__ . '/build/block-2' );
}
add_action( 'init', 'awebfactory_multi_dynamic_example_block_init' );
Loading

0 comments on commit b40e9d1

Please sign in to comment.