Skip to content

WP-CLI

Snippets are folders on disk, so the terminal suits them. wp sleek byte manages snippets without the workspace, for a deploy script, a CI pipeline or a coding agent. The CLI reference lists every command with its arguments and options, and wp help sleek byte prints the same on a site.

A snippet’s id is its folder path inside its source, such as my-snippet; file paths are relative to the source, such as my-snippet/index.php.

Snippets

Shell
wp sleek byte snippet list --format=json
wp sleek byte snippet get my-snippet --files --format=json
wp sleek byte snippet create my-snippet --title="My Snippet" --hook=wp_head
wp sleek byte snippet disable my-snippet
wp sleek byte snippet enable my-snippet
wp sleek byte snippet delete my-snippet --yes

wp sleek byte snippet list shows each snippet’s context, hook, source and whether it would run right now, judged by its enabled, environments and schedule; conditions are not evaluated. wp sleek byte snippet get with --files and --format=json includes every file’s content. wp sleek byte snippet create writes a snippet.json and an index.php holding only <?php into the first source, and refuses hooks that have already fired when snippets load. wp sleek byte snippet disable is the fastest way to switch off a broken snippet on a live site.

Files and checks

Shell
wp sleek byte file update my-snippet/index.php --from-file=index.php
cat style.css | wp sleek byte file update my-snippet/style.css --stdin
wp sleek byte file delete my-snippet/legacy.php --yes
wp sleek byte test --snippet=my-snippet

wp sleek byte file update writes the file as given, creating its folders, and does not check it. wp sleek byte test runs the check the workspace runs before saving: it parses the PHP for syntax errors and refuses shell execution functions and variable function calls, without running the code. With --snippet it checks the snippet’s index.php only. It exits with an error when the check fails, so it can gate a deploy.

Errors and export

Shell
wp sleek byte errors list my-snippet
wp sleek byte errors clear my-snippet
wp sleek byte export my-snippet --zip --dest=/tmp

wp sleek byte errors list prints a snippet’s runtime error log, and clearing it lets a snippet stopped by repeated fatal errors run again. wp sleek byte export builds a standalone plugin from a snippet and prints its path; without --dest it writes into uploads/sleek-byte-exports.

Stay in the Loop!  

Be the first to hear about new updates, special offers, and helpful tips, delivered straight to your inbox.

We respect your inbox (and your privacy). Read our privacy policy.