WP Manifestindependent plugin directory
manifest / developer / gn-wp-cli

GN - WP-CLI Commands

Custom WP-CLI commands for WordPress content auditing

★ 0stars

Install

Download source zip No release zip yet

This is the repository archive. It installs, but the folder name will carry the branch suffix and updates will not flow.

Install straight from GitHub with WP-CLI:

wp plugin install https://github.com/gregoirenoyelle/gn-wp-cli/archive/refs/heads/main.zip
No built-in updater. New versions won't appear under Dashboard → Updates. Install new releases yourself, or let Git Updater track the repository.

Custom WP-CLI commands for auditing WordPress content.

wp gn blocks find

Finds every post using a given Gutenberg block, recursing into nested innerBlocks — a block sitting inside a core/group or core/columns wrapper is still counted, unlike a has_block() check or a raw string match on post_content, both of which only see the top-level block comment.

wp gn blocks find core/embed
wp gn blocks find core/embed --post_type=page --post_status=publish --format=csv
NAME

  wp gn blocks find

DESCRIPTION

  Finds every post using a given block, recursing into innerBlocks.

SYNOPSIS

  wp gn blocks find <block-name> [--post_type=<post_type>]
  [--post_status=<post_status>] [--format=<format>]

OPTIONS

  <block-name>
    Fully-qualified block name to search for, e.g. core/embed.

  [--post_type=<post_type>]
    Restrict the search to one or more post types (comma-separated).
    default: post,page

  [--post_status=<post_status>]
    Restrict the search to a post status.
    default: publish

  [--format=<format>]
    Output format: table, csv, json, or count.
    default: table

Real-world run, on a live client site: 115 posts found using core/embed, 382 total occurrences — a manual audit had estimated ~6 affected pages before this command existed.

Installation

Not published as a WordPress.org plugin or a Packagist package — this is a personal CLI tool, installed by cloning and either activating it as a plugin or loading it via WP-CLI's require: config:

git clone git@github.com:gregoirenoyelle/gn-wp-cli.git
cd gn-wp-cli
composer install --no-dev

Then either:

  • Activate as a plugin on any WordPress site (wp plugin activate gn-wp-cli), or

  • Load globally via require:, so the command works from any site's folder with no per-site activation — add to ~/.wp-cli/config.yml:

    require:
      - /path/to/gn-wp-cli/gn-wp-cli.php

The command is a no-op outside a WP-CLI context either way — gn-wp-cli.php guards itself with defined( 'WP_CLI' ) && WP_CLI, so activating it on a live site doesn't add any frontend/admin behavior.

Development

composer install
composer test    # PHPUnit + Brain Monkey — no WordPress install or database required

Tests mock WordPress/WP-CLI (WP_Query, WP_CLI, parse_blocks(), etc.) rather than requiring a real WordPress install — the full suite runs in under 50ms.

Architecture

  • PSR-4 autoload (GN\WpCli\ → src/) via Composer.
  • Class-based command registration — WP_CLI::add_command( 'gn blocks', BlocksCommand::class ); each public method on the class becomes a subcommand.
  • Paginated WP_Query, not posts_per_page => -1 — scans in batches of 50 with a progress bar, so it stays usable against large content sets.

License

GPL-2.0-or-later — see LICENSE.