Skip to content

WP-CLI commands

SleekByte registers these WP-CLI commands. Each is documented by the WP-CLI docblock where it is declared; wp help <command> prints the same text on a site.

wp sleek byte

Validates and exports SleekByte snippets.

wp sleek byte errors

Reads and clears the per-snippet error logs.

wp sleek byte errors clear

Clears the error log of a snippet.

Shell
wp sleek byte errors clear <id>
Argument Description
<id> The snippet id.

Examples

Shell
wp sleek byte errors clear my-snippet

wp sleek byte errors list

Prints the logged errors for a snippet.

Shell
wp sleek byte errors list <id>
Argument Description
<id> The snippet id.

Examples

Shell
wp sleek byte errors list my-snippet

wp sleek byte export

Exports a snippet as a standalone plugin and prints the output path.

Shell
wp sleek byte export <id> [--zip] [--name=<name>] [--slug=<slug>] [--dest=<dir>]
Argument Description
<id> The snippet id.
[--zip] Write a zip archive instead of a plugin folder.
[--name=<name>] The plugin name. Defaults to the snippet title.
[--slug=<slug>] The plugin slug. Defaults to the sanitized name.
[--dest=<dir>] The directory to write into. Defaults to uploads/sleek-byte-exports.

Examples

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

wp sleek byte file

Manages individual files inside the snippets directory.

wp sleek byte file delete

Deletes files or folders from the snippets directory.

Shell
wp sleek byte file delete <path>... [--yes]
Argument Description
<path>... One or more paths relative to the snippets directory.
[--yes] Skip the confirmation prompt.

Examples

Shell
wp sleek byte file delete my-snippet/legacy.php --yes

wp sleek byte file update

Writes a file, creating parent folders as needed.

Shell
wp sleek byte file update <path> [--content=<content>] [--from-file=<file>] [--stdin]
Argument Description
<path> The file path relative to the snippets directory, like my-snippet/index.php.
[--content=<content>] The file content.
[--from-file=<file>] Read the content from a local file. Pass – to read from STDIN.
[--stdin] Read the content from STDIN.

Examples

Shell
wp sleek byte file update my-snippet/index.php --from-file=index.php
cat index.php | wp sleek byte file update my-snippet/index.php --stdin

wp sleek byte snippet

Manages the code snippets stored on disk.

wp sleek byte snippet create

Creates a snippet folder with a snippet.json and an index.php stub.

Shell
wp sleek byte snippet create <id> [--title=<title>] [--context=<context>] [--hook=<hook>] [--disabled]
Argument Description
<id> The snippet id, used as its folder name.
[--title=<title>] A display name. Defaults to the id.
[--context=<context>] Comma separated execution contexts out of frontend, admin and block-editor. Defaults to the plugin default (frontend).
[--hook=<hook>] The action hook the PHP file runs on. Default init. Hooks that run before snippets load (muplugins_loaded, plugins_loaded, setup_theme, after_setup_theme) are refused.
[--disabled] Create the snippet in a disabled state.

Examples

Shell
wp sleek byte snippet create my-snippet --title="My Snippet" --hook=wp_head

wp sleek byte snippet delete

Deletes a snippet folder and everything in it.

Shell
wp sleek byte snippet delete <id> [--yes]
Argument Description
<id> The snippet id.
[--yes] Skip the confirmation prompt.

Examples

Shell
wp sleek byte snippet delete my-snippet --yes

wp sleek byte snippet disable

Disables a snippet without deleting it.

Shell
wp sleek byte snippet disable <id>
Argument Description
<id> The snippet id.

Examples

Shell
wp sleek byte snippet disable my-snippet

wp sleek byte snippet enable

Enables a snippet.

Shell
wp sleek byte snippet enable <id>
Argument Description
<id> The snippet id.

Examples

Shell
wp sleek byte snippet enable my-snippet

wp sleek byte snippet get

Shows one snippet and its configuration.

Shell
wp sleek byte snippet get <id> [--files] [--format=<format>]
Argument Description
<id> The snippet id, its folder name inside the snippets directory.
[--files] Include the content of every file in the snippet.
[--format=<format>] Output format. Supports table and json. File contents are only part of the json output; the table output lists the file paths.

Examples

Shell
wp sleek byte snippet get my-snippet --files --format=json

wp sleek byte snippet list

Lists every snippet with its execution state.

Shell
wp sleek byte snippet list [--format=<format>]
Argument Description
[--format=<format>] Output format. Supports table and json.

Examples

Shell
wp sleek byte snippet list --format=json

wp sleek byte test

Validates PHP code the same way the app does before saving.

Exits non-zero when the code is rejected or fails, so it can gate scripted deploys.

Shell
wp sleek byte test [--file=<path>] [--snippet=<id>] [--stdin]
Argument Description
[--file=<path>] Test a file inside the snippets directory, like my-snippet/index.php.
[--snippet=<id>] Test the index.php of a snippet.
[--stdin] Test PHP code read from STDIN.

Examples

Shell
wp sleek byte test --snippet=my-snippet
cat index.php | wp sleek byte test --stdin

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.