Skip to content

Commit

Permalink
Merge pull request #45 from wptrainingteam/feature/migrate-07-slotfil…
Browse files Browse the repository at this point in the history
…ls-esnext

Migrate 07-slotfills-esnext
  • Loading branch information
ryanwelcher authored Nov 7, 2023
2 parents 74c0b00 + 521d33f commit e1537a4
Show file tree
Hide file tree
Showing 14 changed files with 251 additions and 0 deletions.
1 change: 1 addition & 0 deletions .wp-env.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"./plugins/basic-esnext-a2ab62",
"./plugins/inner-blocks-dcd824",
"./plugins/block-supports-6aa4dd",
"./plugins/slotfill-2fb190",
"./plugins/dynamic-block-b0bce7",
"./plugins/meta-block-bb1e55",
"https://downloads.wordpress.org/plugin/gutenberg.zip"
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Welcome to the `block-development-examples` repo on GitHub. Here you can find a
| [📁](https://github.com/wptrainingteam/block-development-examples/tree/trunk/plugins/dynamic-block-b0bce7) | Dynamic Block | <small><code><a href="https://github.com/wptrainingteam/block-development-examples/wiki/03-Tags#dynamic-rendering">DYNAMIC RENDERING</a></code></small> | `b0bce7` | [📦](https://raw.githubusercontent.com/wptrainingteam/block-development-examples/deploy/zips/dynamic-block-b0bce7.zip "Install the plugin using this zip and activate it. Then use the ID of the block (b0bce7) to find it and add it to a post to see it in action") | [![](https://raw.githubusercontent.com/wptrainingteam/block-development-examples/trunk/assets/icon-wp.svg)](https://playground.wordpress.net/#%7B%22landingPage%22:%22/wp-admin/plugins.php%22,%22steps%22:%5B%7B%22step%22:%22login%22,%22username%22:%22admin%22,%22password%22:%22password%22%7D,%7B%22step%22:%22mkdir%22,%22path%22:%22/downloads%22%7D,%7B%22step%22:%22writeFile%22,%22path%22:%22/downloads/plugin.zip%22,%22data%22:%7B%22resource%22:%22url%22,%22url%22:%22https://raw.githubusercontent.com/wptrainingteam/block-development-examples/deploy/zips/dynamic-block-b0bce7.zip%22,%22caption%22:%22Downloading%20plugin...%22%7D%7D,%7B%22step%22:%22installPlugin%22,%22pluginZipFile%22:%7B%22resource%22:%22vfs%22,%22path%22:%22/downloads/plugin.zip%22%7D%7D%5D%7D "Use the ID of the block (b0bce7) to find it and add it to a post to see it in action") |
| [📁](https://github.com/wptrainingteam/block-development-examples/tree/trunk/plugins/meta-block-bb1e55) | Meta Block | <small><code><a href="https://github.com/wptrainingteam/block-development-examples/wiki/03-Tags#meta">META</a></code></small> | `bb1e55` | [📦](https://raw.githubusercontent.com/wptrainingteam/block-development-examples/deploy/zips/meta-block-bb1e55.zip "Install the plugin using this zip and activate it. Then use the ID of the block (bb1e55) to find it and add it to a post to see it in action") | [![](https://raw.githubusercontent.com/wptrainingteam/block-development-examples/trunk/assets/icon-wp.svg)](https://playground.wordpress.net/#%7B%22landingPage%22:%22/wp-admin/plugins.php%22,%22steps%22:%5B%7B%22step%22:%22login%22,%22username%22:%22admin%22,%22password%22:%22password%22%7D,%7B%22step%22:%22mkdir%22,%22path%22:%22/downloads%22%7D,%7B%22step%22:%22writeFile%22,%22path%22:%22/downloads/plugin.zip%22,%22data%22:%7B%22resource%22:%22url%22,%22url%22:%22https://raw.githubusercontent.com/wptrainingteam/block-development-examples/deploy/zips/meta-block-bb1e55.zip%22,%22caption%22:%22Downloading%20plugin...%22%7D%7D,%7B%22step%22:%22installPlugin%22,%22pluginZipFile%22:%7B%22resource%22:%22vfs%22,%22path%22:%22/downloads/plugin.zip%22%7D%7D%5D%7D "Use the ID of the block (bb1e55) to find it and add it to a post to see it in action") |
| [📁](https://github.com/wptrainingteam/block-development-examples/tree/trunk/plugins/inner-blocks-dcd824) | Inner Blocks | <small><code><a href="https://github.com/wptrainingteam/block-development-examples/wiki/03-Tags#">undefined</a></code></small> | `dcd824` | [📦](https://raw.githubusercontent.com/wptrainingteam/block-development-examples/deploy/zips/inner-blocks-dcd824.zip "Install the plugin using this zip and activate it. Then use the ID of the block (dcd824) to find it and add it to a post to see it in action") | [![](https://raw.githubusercontent.com/wptrainingteam/block-development-examples/trunk/assets/icon-wp.svg)](https://playground.wordpress.net/#%7B%22landingPage%22:%22/wp-admin/plugins.php%22,%22steps%22:%5B%7B%22step%22:%22login%22,%22username%22:%22admin%22,%22password%22:%22password%22%7D,%7B%22step%22:%22mkdir%22,%22path%22:%22/downloads%22%7D,%7B%22step%22:%22writeFile%22,%22path%22:%22/downloads/plugin.zip%22,%22data%22:%7B%22resource%22:%22url%22,%22url%22:%22https://raw.githubusercontent.com/wptrainingteam/block-development-examples/deploy/zips/inner-blocks-dcd824.zip%22,%22caption%22:%22Downloading%20plugin...%22%7D%7D,%7B%22step%22:%22installPlugin%22,%22pluginZipFile%22:%7B%22resource%22:%22vfs%22,%22path%22:%22/downloads/plugin.zip%22%7D%7D%5D%7D "Use the ID of the block (dcd824) to find it and add it to a post to see it in action") |
| [📁](https://github.com/wptrainingteam/block-development-examples/tree/trunk/plugins/slotfill-2fb190) | SlotFill | <small><code><a href="https://github.com/wptrainingteam/block-development-examples/wiki/03-Tags#no-block">NO BLOCK</a></code></small> | `2fb190` | [📦](https://raw.githubusercontent.com/wptrainingteam/block-development-examples/deploy/zips/slotfill-2fb190.zip "") | [![](https://raw.githubusercontent.com/wptrainingteam/block-development-examples/trunk/assets/icon-wp.svg)](https://playground.wordpress.net/#%7B%22landingPage%22:%22/wp-admin/plugins.php%22,%22steps%22:%5B%7B%22step%22:%22login%22,%22username%22:%22admin%22,%22password%22:%22password%22%7D,%7B%22step%22:%22mkdir%22,%22path%22:%22/downloads%22%7D,%7B%22step%22:%22writeFile%22,%22path%22:%22/downloads/plugin.zip%22,%22data%22:%7B%22resource%22:%22url%22,%22url%22:%22https://raw.githubusercontent.com/wptrainingteam/block-development-examples/deploy/zips/slotfill-2fb190.zip%22,%22caption%22:%22Downloading%20plugin...%22%7D%7D,%7B%22step%22:%22installPlugin%22,%22pluginZipFile%22:%7B%22resource%22:%22vfs%22,%22path%22:%22/downloads/plugin.zip%22%7D%7D%5D%7D "") |
<!-- @TABLE EXAMPLES END -->

## More info
Expand Down
5 changes: 5 additions & 0 deletions data/examples.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,10 @@
"slug": "inner-blocks-dcd824",
"description": "Inner Blocks",
"tags": [ "" ]
},
{
"slug": "slotfill-2fb190",
"description": "SlotFill",
"tags": [ "no-block" ]
}
]
18 changes: 18 additions & 0 deletions plugins/slotfill-2fb190/.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
8 changes: 8 additions & 0 deletions plugins/slotfill-2fb190/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": [ "plugin:@wordpress/eslint-plugin/recommended" ],
"settings": {
"jest": {
"version": 26
}
}
}
30 changes: 30 additions & 0 deletions plugins/slotfill-2fb190/.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
37 changes: 37 additions & 0 deletions plugins/slotfill-2fb190/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
### Block Development Examples - Slotfill 2fb190

<!-- Please, do not remove these @TABLE EXAMPLES BEGIN and @TABLE EXAMPLES END comments or modify the table inside. This table is automatically generated from the data at data/examples.json and data/tags.json -->
<!-- @TABLE EXAMPLES BEGIN -->
| Folder | <span style="display: inline-block; width:250px">Short description</span> | Tags | ID ([❓](https://github.com/wptrainingteam/block-development-examples/wiki/04-Why-an-ID-for-every-example%3F "Why an ID for every example?")) | Download .zip | Live Demo |
| ----------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [📁](https://github.com/wptrainingteam/block-development-examples/tree/trunk/plugins/slotfill-2fb190) | SlotFill | <small><code><a href="https://github.com/wptrainingteam/block-development-examples/wiki/03-Tags#no-block">NO BLOCK</a></code></small> | `2fb190` | [📦](https://raw.githubusercontent.com/wptrainingteam/block-development-examples/deploy/zips/slotfill-2fb190.zip "") | [![](https://raw.githubusercontent.com/wptrainingteam/block-development-examples/trunk/assets/icon-wp.svg)](https://playground.wordpress.net/#%7B%22landingPage%22:%22/wp-admin/plugins.php%22,%22steps%22:%5B%7B%22step%22:%22login%22,%22username%22:%22admin%22,%22password%22:%22password%22%7D,%7B%22step%22:%22mkdir%22,%22path%22:%22/downloads%22%7D,%7B%22step%22:%22writeFile%22,%22path%22:%22/downloads/plugin.zip%22,%22data%22:%7B%22resource%22:%22url%22,%22url%22:%22https://raw.githubusercontent.com/wptrainingteam/block-development-examples/deploy/zips/slotfill-2fb190.zip%22,%22caption%22:%22Downloading%20plugin...%22%7D%7D,%7B%22step%22:%22installPlugin%22,%22pluginZipFile%22:%7B%22resource%22:%22vfs%22,%22path%22:%22/downloads/plugin.zip%22%7D%7D%5D%7D "") |
<!-- @TABLE EXAMPLES END -->

## Start Guide

#### 1. Install dependencies

Check the [Repo Commands > Dependencies](../../DEVELOPMENT.md#dependencies) instructions for this repo

#### 2. Generate the build

Once the dependencies are installed (a `node_modules` folder should have been created), we should [launch the build process](../../DEVELOPMENT.md#build-process) to get the final version of the block that can be used from WordPress.

#### 3. Use it in a WordPress

Check the [WordPress Local Development Environment](../../DEVELOPMENT.md#wordpress-local-development-environment) instructions for this repo.

<details>
<summary><em>If you have a local WordPress installation already running, you can clone the repo inside the <code>plugins</code> folder of that installation and check the example there</em></summary>
<br>
<p>If you do that, you'll need to do the following</p>
<ul>
<li>Remove any <code>node_modules</code> folder inside this folder</li>
<li>Run <code>npm install</code> to install the dependencies</li>
<li>Run <code>npm build</code> to generate the "build" version of the blocks</li>
<li>Activate the plugin in your own WordPress installation</li>
<ul>
</details>
<br>

At this point you should be able to insert the custom blocks into any post (after activating the plugin) of your WordPress installation, and see how it behaves in the frontend when published.
1 change: 1 addition & 0 deletions plugins/slotfill-2fb190/build/slotfill-2fb190.asset.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?php return array('dependencies' => array('react', 'wp-components', 'wp-core-data', 'wp-data', 'wp-edit-post', 'wp-i18n', 'wp-plugins'), 'version' => '4ed241ca8d761ffab796');
1 change: 1 addition & 0 deletions plugins/slotfill-2fb190/build/slotfill-2fb190.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions plugins/slotfill-2fb190/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "@block-development-examples/slotfill-2fb190",
"version": "0.1.0",
"author": "The WordPress Contributors",
"license": "GPL-2.0-or-later",
"scripts": {
"build": "wp-scripts build",
"start": "wp-scripts start",
"plugin-zip": "wp-scripts plugin-zip"
},
"files": [
"*"
],
"devDependencies": {
"@wordpress/scripts": "^26.15.0"
}
}
46 changes: 46 additions & 0 deletions plugins/slotfill-2fb190/slotfill-2fb190.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php
/**
* Plugin Name: WP Block Development Examples - Slotfill 2fb190
* Requires at least: 6.1
* Requires PHP: 7.0
* Version: 0.1.0
* Author: The WordPress Contributors
* License: GPL-2.0-or-later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: block-development-examples
*
* @package block-development-examples
*/
add_action(
'enqueue_block_editor_assets',
function () {
$slotfill_2fb190_file = plugin_dir_path( __FILE__ ) . '/build/slotfill-2fb190.asset.php';

if ( file_exists( $slotfill_2fb190_file ) ) {
$assets = include $slotfill_2fb190_file;
wp_enqueue_script(
'slotfill-2fb190',
plugin_dir_url( __FILE__ ) . '/build/slotfill-2fb190.js',
$assets['dependencies'],
$assets['version'],
true
);
}
}
);

add_action(
'init',
function () {
// Register the post meta field the meta box will save to.
register_post_meta(
'post',
'example_meta_field',
array(
'show_in_rest' => true,
'single' => true,
'type' => 'string',
)
);
}
);
Loading

0 comments on commit e1537a4

Please sign in to comment.