Contributors: toddmilliken
Tags: gutenberg, blocks
Requires at least: 4.9.8
Tested up to: 5.4
Stable tag: trunk
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
BU Blocks is a WordPress plugin that registers additional blocks for the new WordPress editor.
BU Blocks provides content editors with additional blocks for the new WordPress editor. These blocks were built for various sites within the BU WordPress ecosystem and have been tested and designed to be re-used for any project.
To make testing changes to this plugin easier, you may wish to test your sandbox against an existing website. This is possible to do using wp-cli and the bu-webdiff library, which allows you to pull a list of URLs to test, and then test the differences locally in npm. This is just like you do during a WordPress upgrade.
For example, let's say I cloned the BU Blocks demo site to my sandbox. Here, I am grabbing a list of all the pages that are on that demo site in my sandbox.
wp post list --post_type=page --url=https://id-ashley.cms-devl.bu.edu/bu-blocks/ --fields=url --format=csv
From here, you could copy and paste the URLs into a text file and use the npm instructions to run visual regression testing locally.
You'll need to ssh into your sandbox to do this, just like if you were looking for PHP error logs.
/wp-content/plugins/
directory.This plugin was built using a few open source plugin boilerplate examples:
src/
directory where block development occurs.dist/
directory where the npm scripts distribute the
final build files that get enqueued into the Editor and front-end.wp scaffold plugin
command --
The official WordPress plugin boilerplate.
readme.txt
file that is required
for the official WordPress plugin repository to the more traditional README.md
markdown format that Github can parse..distignore
, .gitignore
, .editorconfig
configuration files..travis.yml
, phpunit.xml.dist
, and initial tests/
directory for continuous
integration setup and PHPUnit testing.phpcs.xml.dist
to define the WordPress Coding Standards this project follows./src/init.php
where define_admin_hooks()
exists for consolidating all
admin-specific hooks.docker-compose.yml
and the bin/wpdc.sh
scripts for running the PHPUnit
tests locally in an isolated docker container.src/init.php
to help development focus on
the creation of blocks rather than adding includes and requires for each block-specific
PHP file that needs to be created.This project was bootstrapped with Create Guten Block.
Below you will find some information on how to run scripts.
You can find the most recent version of this guide here.
npm start
npm run build
dist
folder.npm run eject
create-guten-block
.eject
and you have to maintain everything yourself.eject
a project because by ejecting you lose the connection with create-guten-block
and from there onwards you have to update and maintain all the dependencies on your own.Running tests locally in docker requires docker and docker-compose to be installed in your machine.
You can download it here https://www.docker.com/community-edition#/download.
Note: docker-compose comes with Docker for Mac and Docker for Windows. On linux you need to install docker-compose separately.
cd /path/to/plugin
bash bin/wpdc.sh up
bash bin/wpdc.sh test
bash bin/wpdc.sh down
up
Starts docker containers and sets up WordPress testing environment so that we can use the test command. Usage
bash bin/wpdc.sh up [php-version] [wp-version]
It takes 2 optional arguments:
[php-version]
The php version we want to test. Normally a 2 digit version like 5.6
, 7.0
, 7.1
. It defaults to latest (which at the moment resolves to 7.1
but can change in the future).
[wp-version]
The WordPress version we want to test. It can be a 1, 2 or 3 digit version like: 4
, 4.9
, 4.7.3
. It defaults to latest.
Examples
bash bin/wpdc.sh up
bash bin/wpdc.sh up latest
bash bin/wpdc.sh up latest latest
bash bin/wpdc.sh up 7.0
bash bin/wpdc.sh up 7.0 latest
bash bin/wpdc.sh up latest 4.6
bash bin/wpdc.sh up 7.1-apache 4.7
bash bin/wpdc.sh up latest 4.8
bash bin/wpdc.sh up 5.6 4.3
down
Stops and removes everything created with the up command. Usage
bash bin/wpdc.sh down
It takes no arguments.
test
Runs the phpunit tests inside the docker container. Usage
bash bin/wpdc.sh test
It takes no arguments.