Skip to content

Hooks

SleekByte fires these hooks for site code. Each is documented by the @api docblock on the apply_filters or do_action call that fires it; a hook without one is internal and may change without notice.

sleekByte/activated

Action, fired in product/includes/classes/Lifecycle.php.

Fires when Byte is activated, after its sync tables and schema version are in place.

sleekByte/deactivated

Action, fired in product/includes/classes/Lifecycle.php.

Fires when Byte is deactivated, after the hourly preview cleanup is unscheduled. Snippets and their files stay in place.

sleekByte/init

Action, fired in product/includes/classes/Plugin.php.

Fires once Byte’s backend has booted, after its WP-CLI commands, snippet runtime and REST routes are registered.

Parameter Type Description
$plugin \SleekByte\Plugin The Byte backend, also returned by sleekByte().

sleekByte/snippets/defaults/context

Filter, fired in product/includes/classes/Loader/SnippetRuntime.php.

Filters the context of every snippet whose snippet.json sets no context: frontend, admin, block-editor, or a list of them. WP-CLI’s snippet listing reports the same default.

Parameter Type Description
$defaultContext string|array<int, string> The default context, frontend.

Returns string|array<int, string> The context or contexts such a snippet loads in.

sleekByte/snippets/defaults/hook

Filter, fired in product/includes/classes/Loader/SnippetRuntime.php.

Filters the default hook. A PHP file without a hook of its own or of its snippet runs on it, and the CSS, SCSS and JavaScript files of snippets without conditions are registered on it for enqueueing, so a hook that does not fire on a request, such as the front-end-only wp in wp-admin, stops those files there. Snippets register during after_setup_theme, so a hook that has already fired never runs a file.

Parameter Type Description
$defaultHook string The default hook, init.

Returns string The hook name.

sleekByte/snippets/defaults/php/hook

Filter, fired in product/includes/classes/Loader/SnippetRuntime.php.

Filters the hook each snippet PHP file runs on. It receives the hook already resolved for the file, so what it returns also replaces a hook the file or its snippet sets.

Parameter Type Description
$hook string The file’s hook, else its snippet’s, else the default hook.

Returns string The hook the file runs on.

sleekByte/snippets/git

Filter, fired in product/includes/classes/Rest/Actions.php.

Turns on per-snippet Git history. While it returns false, Actions_gitCheck answers enabled: false, Actions_gitRead and Actions_gitWrite answer 409, and saving records no history.

Parameter Type Description
$enabled bool Whether Git history is on, false by default.

Returns bool True to record a commit for every snippet a save touches.

sleekByte/snippets/paths

Filter, fired in product/includes/classes/Loader/SnippetFinder.php.

Filters the folders Byte reads snippets from. Every folder that holds a snippet.json, at any depth, is a snippet. A source whose path does not exist is skipped, and Byte creates only its default folder. WP-CLI writes new files into the first source in the returned list, the workspace into the one with the lowest sort.

Parameter Type Description
$sources array<int, array{name: string, path: string, sort?: int}> The sources: a display name unique across sources, an absolute path, and a sort order for the file tree (lower first). The default is one source, Snippets, at uploads/sleek-byte with sort 100.

Returns array<int, array{name: string, path: string, sort?: int}> The sources Byte reads.

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.