Creating a Snippet in SnipVault

Written By mark@uipress.co

Last updated 12 months ago

Creating a new code snippet in SnipVault is straightforward and gives you powerful control over your custom WordPress code. Here's how to get started:

Access SnipVault

  1. Log in to your WordPress admin dashboard

  2. Navigate to Settings β†’ SnipVault or go directly to /wp-admin/options-general.php?page=snipvault#/

Create a New Snippet

  1. In the SnipVault interface, locate the New icon in the top-left corner of the sidebar (it looks like a document with a plus sign)

  2. Click this icon to create a new snippet

Configure Your Snippet

Once you've created a new snippet, you'll see the snippet editor with these configuration options in the right sidebar:

  • Title: Give your snippet a descriptive name (e.g., "Custom Login Redirect")

  • Autoload: Choose whether your snippet should load automatically (Yes) or only when called (No)

  • Language: Select the appropriate language for your snippet (PHP, CSS, or JavaScript)

  • Version: Assign a version number to track changes (e.g., "1.0.0")

  • Description: Add notes about what the snippet does and why it exists

Write Your Code

  1. In the main editor area, write your code

  2. SnipVault provides syntax highlighting for your selected language

  3. Line numbers are displayed on the left for easy reference

Save Your Snippet

Once you've written your code and configured the settings:

  1. Click the Save button in the top-right corner

  2. Your snippet will be securely stored in the SnipVault file system

  3. If enabled for autoload, it will begin executing immediately

Monitor for Errors

SnipVault automatically checks your code for errors:

  • The "Errors" section at the bottom of the right sidebar will show "No errors found for this snippet" if your code is error-free

  • If issues are detected, they will be displayed with details to help you troubleshoot

Organise with Folders

To keep your snippets organised:

  1. Create folders by clicking the folder icon in the sidebar

  2. Drag and drop snippets into folders for better organisation

Creating snippets with SnipVault ensures your custom code is securely stored, properly versioned, and safely executed across your WordPress site.