← All articles

Workflow

How to Migrate from WPCode to File-Based Snippets (Without Downtime)

A step-by-step migration from WPCode to a file-based snippet plugin: inventory every snippet, map types and auto-insert locations, find shortcodes in content, and cut over one snippet at a time.

6 min read Mark Ashton

  • wpcode
  • workflow
  • comparisons
  • wordpress
Abstract cover artwork for How to Migrate from WPCode to File-Based Snippets (Without Downtime)

WPCode is where many WordPress sites start with custom code, and it does that job well. Teams usually start looking elsewhere for one of three reasons: they want snippets stored as files instead of database rows, they want the code in Git, or they have outgrown a single-site library.

Whatever you are moving to, the migration itself is the risky part. Two plugins running the same hook causes double output or "Cannot redeclare" fatals; missing one snippet causes a quiet bug nobody notices for a week. This guide is a migration plan that avoids both.

Before you start

  • Do this on staging first. Clone production, run the whole migration there, and write down anything surprising.
  • Take a full backup of files and database.
  • Pick a quiet window for the production cutover.
  • Install the new plugin but do not activate any snippets yet. Examples below use general terms; they apply equally to FluentSnippets, SnipVault, or another file-based tool.

Step 1: Export a backup from WPCode

In WPCode, go to Code Snippets → Tools → Export, select all snippets, and export. You get a JSON file with each snippet's code and settings.

Keep it even if your new plugin cannot import it directly. It is the reference you will check against, and your rollback plan if something goes wrong.

Step 2: Build an inventory

Open Code Snippets and list every snippet, active or not, with:

  • Title and what it actually does
  • Code type: PHP, JavaScript, CSS, HTML, Text, or Universal
  • Insert method: Auto Insert (and its location) or Shortcode
  • Conditions or scheduling, if any
  • Priority, if it is not the default
  • Status: active or inactive

A spreadsheet is fine for this — it is temporary.

Do not forget Header & Footer. Scripts added under Code Snippets → Header & Footer are stored separately from the snippet list. They are easy to miss and are often the tracking codes marketing cares about most.

Step 3: Decide what not to migrate

A migration is the cheapest moment you will ever get to clean up:

  • Inactive for months? Archive it in your export and do not recreate it.
  • Duplicated by a plugin or core feature? Many CSS tweaks and small PHP fixes are now built in. WordPress 7.1 removed the need for a lot of CSS snippets.
  • Two snippets on the same hook doing related things? Merge them, or split a snippet that does two unrelated jobs.
  • Tracking scripts for tools you no longer use? Delete them.

It is common to end up with a third fewer snippets than you started with.

Step 4: Map types

Most types map directly. The exceptions need attention:

  • PHP → PHP. Remove any leading <?php if the new plugin adds it.
  • JavaScript → JavaScript. WPCode adds the <script> wrapper for you, so the code should already be bare JavaScript. If a snippet relied on WPCode's handling of <script> tags, read WPCode HTML vs JavaScript snippets first.
  • CSS → CSS.
  • HTML → HTML, or the equivalent "content" type.
  • Text → usually HTML, or a reusable block if it is really content.
  • Universal → split it. A Universal snippet can mix PHP and HTML; recreate it as a PHP snippet that outputs markup, or as separate PHP and HTML snippets.

Step 5: Map auto-insert locations to hooks

WPCode's auto-insert locations are friendly names for WordPress hooks. In a file-based plugin you choose the equivalent hook or location yourself:

  • Run Everywhere (PHP) → loads early, on both front end and admin. Most file-based plugins load PHP snippets at a similar point by default.
  • Frontend Only → the same, with a front-end-only condition, or wrap the code in if ( ! is_admin() ).
  • Admin Only → an admin-only condition, or if ( is_admin() ).
  • Site Wide Header → wp_head
  • Site Wide Body → wp_body_open (only if your theme calls it)
  • Site Wide Footer → wp_footer
  • Insert Before / After Post → a the_content filter, or the new plugin's content location

For a location with no direct equivalent, the snippet can hook itself:

<?php
add_filter( 'the_content', function ( $content ) {
	if ( ! is_singular( 'post' ) || ! in_the_loop() || ! is_main_query() ) {
		return $content;
	}

	return $content . '<aside class="acme-newsletter">…</aside>';
} );

Priority: if a WPCode snippet had a custom priority, set the same value in the new plugin or as the third argument of add_action / add_filter. Order matters when two snippets touch the same thing.

Step 6: Recreate conditions

Rebuild any WPCode conditional logic with your new plugin's conditions rather than burying it in PHP — visible conditions are easier to review. See conditional loading for WordPress snippets for patterns that hold up.

Step 7: Find every shortcode in your content

Shortcode snippets are the part people miss. WPCode shortcodes look like [wpcode id="123"], and they can be in posts, pages, widgets, and page-builder data. Snippets can also be placed with WPCode's block or Elementor widget.

With WP-CLI, search the whole database:

wp db search '[wpcode' --all-tables
wp db search 'wp:wpcode' --all-tables

The first finds shortcodes; the second catches WPCode blocks in the block editor. Page-builder data is often serialized, so also check any Elementor pages that used WPCode's widget. Without WP-CLI, a search-and-replace plugin in "dry run" mode does the same job.

For each hit, recreate the snippet with your new plugin's shortcode or content location and update the content. If there are many, keep the old shortcode working during the transition with a small bridge:

<?php
// Temporary: map old WPCode IDs to new shortcodes until content is updated.
add_shortcode( 'wpcode', function ( $atts ) {
	$map = array(
		'123' => '[acme_pricing_table]',
		'456' => '[acme_newsletter_form]',
	);
	$id = isset( $atts['id'] ) ? (string) $atts['id'] : '';

	return isset( $map[ $id ] ) ? do_shortcode( $map[ $id ] ) : '';
} );

Only activate the bridge after WPCode is deactivated, since both would register the same shortcode.

Step 8: Cut over one snippet at a time

Never have the old and new copies active together. For each snippet, in order of risk (lowest first):

  1. Create it in the new plugin, inactive
  2. Deactivate the WPCode copy
  3. Activate the new copy
  4. Check the pages it affects and the error log
  5. Mark it done in your inventory

Leave checkout, login, and payment-related snippets until last, and test each with a real transaction on staging.

Step 9: Verify, then remove WPCode

Once every snippet is migrated:

  • Compare the page source of key pages before and after. Tracking scripts should appear exactly once.
  • Check the error log for a day.
  • Search the database for [wpcode again — it should find nothing, or only content you have bridged.
  • Deactivate WPCode, wait a few days, then delete it.

Keep the JSON export from Step 1 in your records.

Step 10: Put the new library under version control

The biggest benefit of file-based snippets is that they can live in Git. If you are moving to SnipVault, connect GitHub sync and push the freshly cleaned library as your first commit; every change after that has a history, a diff, and a rollback. If you manage several sites, the multi-site guide covers sharing the library across them.

Migration checklist

  • Staging clone and full backup
  • WPCode JSON export saved
  • Inventory, including Header & Footer scripts
  • Dead snippets dropped
  • Types and locations mapped, priorities preserved
  • Conditions rebuilt
  • Shortcodes and blocks found and replaced or bridged
  • Cut over one snippet at a time
  • Page source and error log verified
  • WPCode deactivated, then removed
  • New library in Git

Comparing tools before you commit? SnipVault vs WPCode covers storage, workflow, and pricing side by side.

Next

Ready to upgrade your snippet workflow?

GitHub sync, the Snippet Engineer, and security auditing — in one WordPress plugin.