A Precoded Clip is the ideal deliverable for hand-over of site customizations to clients. If the destination site has WP Clips installed, developers can use this simple guide to precode a Clip, then either upload themselves or email the zip file to the client.
Developer’s Guide to Precoding a Clip
- Click here to download the Precoded Clip template and unzip the file, or download/install the WP Clips v3 Clips Publisher to automatically generate Clips via ‘WP Clips Manager’.
-
Rename the Clip folder as per the template, using an appropriate Clip Slug prefixed with ‘clip-‘ and ending with the version number (e.g. ‘clip-my-great-precoded-clip.1.0.0’).
Note: Use dashes and not underscores. Dots should only be used to separate the version numbers and extension.
-
Open the Clip’s clip-functions.php file and comment in data headers. A list of fields are shown below. Minimum requirements include the Clip Name: and Version: headers.
/** * Clip Name: My Great Precoded Clip * Clip URI: http://wpclips.net/my-great-precoded-clip * Description: This clip adds some awesome custom code to this theme. * Version: 1.0 * Author: WP Clips * Author URI: https://wpclips.net * Required Theme: theme-folder-name * Required Plugins: plugin-folder-name, another-plugin-folder-name * Safe: true * Network: true * Editable: true */
Clip Name: (required) Name of the Clip.
Clip URI: Home page of the Clip, which should be a unique URL, preferably on your own website.
Description: Short description for the Clip (no more than 140 characters).
Version: (required) Current version number of the Clip, such as 1.0 or 1.0.1.
Author: Name of the Clip’s author. Multiple authors may be listed (comma-separated).
Author URI: Author’s website or profile on another website.
Required Theme: Folder name (slug) of a theme dependency (parent or child).
Required Plugins: Folder names of all plugin dependencies (comma-separated).
Safe: (bool) Whether a precoded Clip is protected from deletion via WP Clips Manager. Set to ‘true’, or omit completely if not applicable.
Network: (bool) Whether the Clip can only be network-activated. Set to ‘true’, or omit completely if not applicable.
Editable: (bool) Whether the Clip can be edited via ‘WP Plugins Editor’ when the Clips editor is installed. Set to ‘true’, or omit completely if not applicable.Theme and plugin requirements dictate whether the Clip should or should not be engaged in the presence of a declared theme or plugin(s). If a named theme or plugin is not active, the Clip will automatically ‘unclip’ to prevent site errors.
-
Add all necessary file and folder resources to your Clip‘s directory, while adding enqueues, includes and additional PHP code to your clip-functions.php file.
File paths point to a Clips directory in the contents folder wp-content/clips/
For single site installs, the path to an active precoded Clip is wp-content/clips/precoded/
For multisite installs, the path injects a blog (site) directory wp-content/clips/site-{blog_id}/precoded/ or network wp-content/clips/network/precoded/
Include the text-domain ‘wp-clips’ for translatable strings and they will be included in updates to the plugin’s POT translation file languages/wp-clips.pot
- Open the Clip‘s README file template and replace the square-bracket items [ ] with your variable names in the first step. Ensure you include all requirements and dependencies, setup and usage instructions, and any additional notes.
- Once your Precoded Clip is completed and thoroughly tested, compress the file into a zip format and clear its resource forks.
And that’s it! You’ve now created a Precoded Clip for easy-install with WP Clips.
Additional Rules
Add ‘uninstall’ for external files
If your Precoded Clip installs files outside of its own directory or adds meta to the database, you should create an uninstall.php ‘clean-up’ file in the Clip‘s root folder. The file will automatically be executed immediately before deletion of the Precoded Clip.
Global variables and constants
Global variables cannot be declared in a Precoded Clip. However, constants are permitted and must begin with the Clip Slug.