Skip to main content

WP-CLI Commands

Yoko Core provides custom WP-CLI commands under the yoko namespace.

Run commands using:

wp yoko <command> [options]

rel_tax

What It Does

Repairs relational taxonomy assignments for a configured CPT.

Options

  • cleanup (or repair) positional command
  • --cpt=<cpt_slug> required target post type

Examples

wp yoko rel_tax cleanup --cpt=resource
wp yoko rel_tax repair --cpt=resource

gfpdf rerender

What It Does

Re-renders Gravity PDF output for a specific Gravity Forms entry.

Behavior:

  • Loads the entry and its form.
  • Re-renders all active PDFs configured on that form by default.
  • Supports targeting one PDF setting via --pdf_id.

Options

  • <entry_id> required positional argument
  • --pdf_id=<pdf_id> optional Gravity PDF setting ID (pid)

Examples

wp yoko gfpdf rerender 1234
wp yoko gfpdf rerender 1234 --pdf_id=69de636897366

Notes

  • Requires both Gravity Forms and Gravity PDF to be active.
  • Prints generated file paths for each re-rendered PDF.
  • Legacy alias wp yoko gravity_pdf_rerender is still supported with a deprecation warning.

What It Does

Scans content for local PDF links already in Media Library and attaches unattached PDFs to the linking post.

Behavior:

  • Supports direct .pdf URLs and PDF attachment permalinks.
  • Only attaches when post_parent is 0.
  • Skips files already attached to another post.
  • Dry run by default; pass --apply to write changes.

Options

  • --post_type=<post_type[,post_type]>
  • --post_status=<status[,status]>
  • --post_id=<id[,id]>
  • --limit=<number>
  • --offset=<number>
  • --batch_size=<number>
  • --apply
  • --dry-run
  • --verbose

Examples

wp yoko attach_pdf_links --dry-run
wp yoko attach_pdf_links --post_type=page --post_status=publish --verbose
wp yoko attach_pdf_links --post_id=3512 --apply

create_missing_pdf_attachments

What It Does

Scans local .pdf URLs and creates missing attachment records when files exist in uploads but are not registered in Media Library.

Behavior:

  • Creates attachment post records.
  • Sets attachment guid to the resolved uploads URL.
  • Dry run by default; pass --apply to write changes.

Options

  • --post_type=<post_type[,post_type]>
  • --post_status=<status[,status]>
  • --post_id=<id[,id]>
  • --limit=<number>
  • --offset=<number>
  • --batch_size=<number>
  • --apply
  • --dry-run
  • --verbose

Examples

wp yoko create_missing_pdf_attachments --dry-run
wp yoko create_missing_pdf_attachments --post_type=page --post_status=publish --verbose
wp yoko create_missing_pdf_attachments --post_id=3512 --apply

What It Does

Replaces direct local .pdf URLs with attachment permalinks.

Options

  • --post_type=<post_type[,post_type]>
  • --post_status=<status[,status]>
  • --post_id=<id[,id]>
  • --limit=<number>
  • --offset=<number>
  • --batch_size=<number>
  • --apply
  • --dry-run
  • --verbose

Examples

wp yoko replace_pdf_urls_with_attachment_permalinks --dry-run
wp yoko replace_pdf_urls_with_attachment_permalinks --post_id=3512 --verbose
wp yoko replace_pdf_urls_with_attachment_permalinks --post_id=3512 --apply

What It Does

Inverse of the previous command. Replaces PDF attachment permalinks with direct .pdf file URLs.

Options

  • --post_type=<post_type[,post_type]>
  • --post_status=<status[,status]>
  • --post_id=<id[,id]>
  • --limit=<number>
  • --offset=<number>
  • --batch_size=<number>
  • --apply
  • --dry-run
  • --verbose

Examples

wp yoko replace_pdf_attachment_permalinks_with_urls --dry-run
wp yoko replace_pdf_attachment_permalinks_with_urls --post_id=3512 --verbose
wp yoko replace_pdf_attachment_permalinks_with_urls --post_id=3512 --apply

pdf_protection

What It Does

Manages protected file storage for gated PDFs — the support-side equivalent of the "Protect the PDF file" checkbox in the PDF Viewer Options metabox.

protect moves the PDF and its generated preview images out of the public uploads directory into a directory outside the web root, so the direct file URL stops working and the document is served only through the gated streaming endpoint. unprotect moves everything back. status reports the viewer, gating, protection, and teaser state of every PDF in the media library.

Options

  • protect | unprotect | status positional command
  • --id=<attachment_id> required for protect and unprotect; optional for status (omit to report on all PDFs)

Examples

wp yoko pdf_protection status
wp yoko pdf_protection status --id=123
wp yoko pdf_protection protect --id=123
wp yoko pdf_protection unprotect --id=123

Notes

  • Protection requires the PDF viewer to be enabled for the document — with the viewer off there is no gated way to serve the file. If the viewer is switched off while a file is protected, the attachment permalink falls back to the gated stream endpoint so the document never becomes unreachable.
  • status is the fastest way to confirm protected files survived a migration or staging clone: a row showing protected: yes whose file is missing on disk means the protected directory did not come across with the environment.

user_post_counts

What It Does

Reports how many posts each user authored, broken out by post type — the same numbers as the User Content Column on Users → All Users, for sites where the admin is too slow to page through, or for answering "is this account safe to delete?" without loading the UI.

Read-only; it never writes.

Options

  • [<user>] optional positional argument limiting the report to one user, by ID, login, or email address. This is positional rather than --user= because WP-CLI reserves --user globally for choosing the account a command runs as.
  • [--hide-empty] omit users who have not authored any content
  • [--format=<format>] table (default), json, csv, or yaml

Examples

wp yoko user_post_counts
wp yoko user_post_counts admin
wp yoko user_post_counts --hide-empty --format=json

soft_gate_tokens

What It Does

Lists the Soft Gate magic-link tokens that have been issued — support's answer to "did this person's access link ever get created?".

The raw token is never stored, only its SHA-256 hash, so this reports when a link was issued and when it expires, never the link itself. Timestamps are UTC.

Read-only; it never writes.

Options

  • [--email=<email>] only show tokens issued to this address
  • [--limit=<limit>] how many rows to show, newest first (default 20)
  • [--format=<format>] table (default), json, csv, or yaml

Examples

wp yoko soft_gate_tokens
wp yoko soft_gate_tokens --email=someone@example.com
wp yoko soft_gate_tokens --limit=100 --format=csv

soft_gate_purge

What It Does

Deletes expired Soft Gate tokens — the same operation the daily yoko_soft_gate_purge_tokens cron event performs, runnable on demand. Useful on a site where cron is not firing, or to confirm the cleanup works before trusting it to cron.

Only rows whose expiry has already passed are removed; live tokens are untouched.

Examples

wp yoko soft_gate_purge

soft_gate_revoke

What It Does

Invalidates every Soft Gate access link issued to an email address, so a visitor who has not yet clicked one can no longer use it.

Anyone who has already clicked a link holds an access cookie set in their own browser. No server-side action can withdraw that — it lapses on its own schedule.

Options

  • --email=<email> required; the address whose links should be revoked
  • [--yes] skip the confirmation prompt

Examples

wp yoko soft_gate_revoke --email=someone@example.com
wp yoko soft_gate_revoke --email=someone@example.com --yes

What It Does

Finds Stretched Links that will not do anything.

A stretched link fails quietly by design — with no container ancestor it simply stays an ordinary link, which is the right behavior for visitors and the wrong one for support, because "the card isn't clickable" looks exactly like "nobody set it up". This reports three misconfigurations across the whole site:

  • dormant-link — a link is set to stretch but no ancestor is a designated container
  • empty-container — a container is designated but holds no stretched link
  • competing-links — a container holds more than one stretched link, so only the last one rendered is clickable

Read-only; it never writes.

Options

  • --post_type=<post_type> limit the scan to one post type (default: every post type with content)
  • --format=<format> table (default), csv, json, yaml, or count

Examples

wp yoko stretched-links audit
wp yoko stretched-links audit --post_type=page --format=json

Notes

  • Only post content is scanned. Blocks living in FSE templates and template parts are not covered, so a card built into a template needs checking in the editor.
  • An empty report means every stretched link and container on the site is paired correctly.

panel_order

What It Does

Inspects or clears the block editor sidebar panel order.

The order is normally set in the editor (⋮ Options → Reorder sidebar panels). This command is the support hatch: it shows what a site has stored, and puts a site back to WordPress defaults without anyone opening the editor.

Options

  • list show the stored order, one row per panel
  • reset delete the stored order
  • --post_type=<post_type> limit to one post type (default: every post type with a stored order)
  • --yes skip the confirmation prompt on reset

Examples

wp yoko panel_order list
wp yoko panel_order list --post_type=page
wp yoko panel_order reset --post_type=page
wp yoko panel_order reset --yes

Notes

  • panel_key values are derived in the browser, not in PHP — see how panels are identified.
  • Resetting a post type removes its entry entirely; WordPress's own panel order returns on the next editor load.

taxonomy_panel

What It Does

Inspects or changes which taxonomies share the consolidated taxonomy panel, per post type.

The choice is normally made in the block editor, by an admin looking at the sidebar. This command is the headless equivalent — for a broken site, a scripted rollout, or confirming what the editor is actually reading.

The stored list is also the panel's order, so add appends and order sets the whole sequence at once.

Options

  • list show what is consolidated, one row per taxonomy, in panel order
  • add append a taxonomy to the panel on one post type
  • remove take it out again
  • order set the whole panel order at once
  • reset clear one post type, or every post type when none is named
  • --post_type=<post_type> the post type whose sidebar is being configured; required for add, remove and order, narrows list and reset
  • --taxonomy=<taxonomy> the taxonomy to add or remove; required for those
  • --taxonomies=<slug,slug,…> comma-separated slugs in panel order; required for order, and it replaces the list — a slug left out is removed
  • --yes skip the confirmation prompt on reset

Examples

wp yoko taxonomy_panel list
wp yoko taxonomy_panel list --post_type=pet
wp yoko taxonomy_panel add --post_type=pet --taxonomy=pet-type
wp yoko taxonomy_panel remove --post_type=pet --taxonomy=pet-type
wp yoko taxonomy_panel order --post_type=pet --taxonomies=pet-type,altered,pet-age
wp yoko taxonomy_panel reset --post_type=pet --yes

Notes

  • The same taxonomy can be consolidated on one post type and not another; that is the point of keying it by post type.
  • add and remove refuse a taxonomy the block editor cannot edit on that post type, and list the ones it can.
  • A taxonomy without show_in_rest is never offered; the block editor cannot edit it, so consolidating it would hide it.
  • The stored list is the panel's order: add appends, and order replaces the sequence. A panel that has never been ordered by hand follows the order the taxonomies are attached to the post type.

theme_icons

What It Does

Lists the SVG files in the active theme's icon folder, showing which became theme icons and why the rest did not.

WordPress keeps only <svg>, <path> and <polygon> in a registered icon and deletes the rest silently. Yoko Core rewrites what it can and refuses what it cannot, rather than registering an icon that renders as an empty square. This is where the refusals are, on the command line — the same list is on the Site Health screen.

Options

  • list (default) one row per file: the icon name, whether it registered, the file, and the reason if it did not
  • flush throw the cached manifest away, so the folder is read again on the next request
  • --format=<format> table (default), csv, json or yaml

Examples

wp yoko theme_icons
wp yoko theme_icons --format=json
wp yoko theme_icons flush

Notes

  • The folder is cached against the files' own names, sizes and modification times, so an edited icon is picked up on the next request. flush is for the cases that cannot see — a filter that now returns something different, or a file rewritten to the same size within the same second.
  • registered (stroked) means the icon is an outline, and its stroke is restored by a generated stylesheet rather than by the file. It renders on the front end and in the editor, and as nothing in a context that loads no styles.
  • Icons come from icon/ and icons/, in the child theme before the parent.
  • The command errors on WordPress older than 7.1, which is where the icon registry arrived.

Beaver Builder Support

When Beaver Builder is active, replacement commands process both:

  • post_content
  • _fl_builder_data

Details:

  • URLs found only in Beaver Builder module settings are included as candidates.
  • _fl_builder_data updates are done via WordPress meta APIs to preserve serialized integrity.
  • Verbose output includes explicit lines when a candidate URL is found in Beaver Builder builder data.
  • Summary output includes separate counts for _fl_builder_data rewrites.

Suggested Workflow

  1. Run with --dry-run --verbose.
  2. Review candidate replacements.
  3. Re-run with --apply.
  4. Re-run dry run to confirm no remaining replacements.

Troubleshooting

Unknown --post_id parameter

Update to the latest plugin code and clear opcode cache if enabled.

No candidates found, but page has Beaver Builder PDF buttons

Check:

  1. Beaver Builder is active.
  2. The page has _fl_builder_data.
  3. URLs are local to the same host.
  4. You are running with --verbose.

Local WP database connection issues

Confirm wp-config.php supports the local wrapper host override:

define( 'DB_HOST', getenv( 'WP_LOCAL_DB_HOST' ) ?: 'localhost' );