A WordPress CLI Script designed to provide a report of all Gutenberg Blocks on your site in CSV format ( or in the terminal ). Easy to use, multi-site compatible with options for post type and post status. Also, with the ability to customize the fields output.
Showing a simple table output excluding details
Showing the resulting CSV of a full export
Add this repository to your composer.json
{
"repositories": [
{
"type": "vcs",
"url": "https://github.com/JayWood/wordpress-block-report"
}
]
}
Or if you're fancy:
composer config repositories.wp-block-report vcs https://github.com/JayWood/wordpress-block-report
Require the package
composer require jaywood/wordpress-block-report
If you happen to use the sweet Composer Installers library, this CLI script is marked as a
wp-cli-package
for ease of use later.
- Download or clone the repository to
wp-content/mu-plugins/wordpress-block-report/
( Name is up to you ) - Create a new file in
wp-content/mu-plugins
call it whatever you want, I useinit.php
- Require the file like so:
<?php
if ( defined( 'WP_CLI' ) && WP_CLI ) {
require_once 'wordpress-block-report/block-report.php';
}
Now since your init.php
file is in wp-content/mu-plugins
it will always load.
Synopsis:
wp jwcli block report [--post-type=<post_type>] [--fields=<fields>] [--post-status=<post-status>] [--csv]
Multisite flags like --url are supported.
Supports any post type slug that's registered at run-time. Comma separated lists are supported as well.
Default: post,page
Example:
$> wp jwcli block report --post-type=article,publication
Supports any post status slug that's registered at run-time. Comma separated lists are supported as well.
Default: any
Example:
$> wp jwcli block report --post-status=publish,in-review
Supports specific fields to return within the report.
Default: post_id,name,attributes,innerHtml,innerContent,innerBlocks
Example:
$> wp jwcli block report --fields=post_id,name,innerBlocks
Prints out the CSV data to the terminal instead of displaying a table.
Example:
$> wp jwcli block report --csv
To output to a file is quite easy with the proper terminal. Below is how you would do this with a unix terminal.
$> wp jwcli block report --csv > out.csv
( A wp-cli plugin by Jay Wood )