-
Notifications
You must be signed in to change notification settings - Fork 35
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 #45 from wptrainingteam/feature/migrate-07-slotfil…
…ls-esnext Migrate 07-slotfills-esnext
- Loading branch information
Showing
14 changed files
with
251 additions
and
0 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
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 |
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,8 @@ | ||
{ | ||
"extends": [ "plugin:@wordpress/eslint-plugin/recommended" ], | ||
"settings": { | ||
"jest": { | ||
"version": 26 | ||
} | ||
} | ||
} |
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,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 |
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,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. |
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 @@ | ||
<?php return array('dependencies' => array('react', 'wp-components', 'wp-core-data', 'wp-data', 'wp-edit-post', 'wp-i18n', 'wp-plugins'), 'version' => '4ed241ca8d761ffab796'); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,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" | ||
} | ||
} |
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,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', | ||
) | ||
); | ||
} | ||
); |
Oops, something went wrong.