Export to a plugin
Any selection of snippets exports as an ordinary WordPress plugin that runs them without Byte, for a site where Byte is not installed or for code that should ship as its own plugin.
From the workspace
Export snippets in the workspace toolbar opens a two-step dialog:
- Snippets: choose the snippets the plugin contains.
- Plugin: the plugin’s name, description, version, author, plugin URI
and text domain. With one snippet selected, they start from its
name,description,versionandexportkeys insnippet.json; otherwise from the name SleekByte, version 1.0.0 and the text domainsleek-byte.
Finishing downloads <slug>-<version>.zip, where the slug is the plugin name
lowercased with hyphens. Install it from Plugins > Add New > Upload Plugin.
The export includes the snippets as they are in the editor, saved or not.
With WP-CLI
wp sleek byte export my-snippet --zip --dest=/tmp
exports one snippet as saved, with the plugin header taken from its
snippet.json, and prints the path it wrote. Without --zip it writes the
plugin as a folder. Without --dest it writes into uploads/sleek-byte-exports.
The CLI reference lists the
options.
What the plugin contains
<slug>.php, the plugin’s main file with its header;classes/, a copy of Byte’s snippet runtime under a namespace of its own;snippets/<folder>/, each exported snippet under the last part of its folder name.
The plugin loads its snippets exactly as Byte does: the same snippet.json
keys, conditions, assets, runtime error log and
safe mode. Its
copies of Byte’s filters carry a prefix unique to the export,
sleekByteExport_<id>/, so a filter written for Byte does not reach it.
The copied runtime reads only its own snippets folder, never
wp-content/uploads/sleek-byte, so a site where Byte ran before does not run
the snippets left there twice. It keeps its error log, asset handles and
folders under its own name, sleek-byte-export-<id>, and previews drafts
only through Byte.
Actions_exportSnippet returns the plugin’s files and
Actions_exportSnippetZip writes the ZIP on the server, for other tools; see
the REST reference.