Skip to content

Add a Custom Migration Source with nxt/import_sources

Table of Contents

The import screen offers the sources Nexter ships with. nxt/import_sources lets you add your own, so a bespoke or in-house field system can be imported the same way.

What It Does

The filter receives the array of registered sources. Adding an entry puts it on the import screen alongside the built-in ones.

Before You Start

  • Nexter Extension 4.9.0 or later.
  • A source whose data you can read in PHP.
  • An understanding of the shape Nexter expects — read the built-in adapters before writing your own.

Register a Source

  1. Add a filter on nxt/import_sources.
The Import Data button, which lists the sources this filter extends
  1. Append your source to the array and return it.
  1. Implement the reading and mapping your source needs.
  1. Test on a copy of a real site, then verify the values against the source before trusting it.

When to Use It

  • Importing from an in-house or bespoke field system.
  • Adding a source Nexter does not ship an adapter for.
  • Building a one-off migration path for a single client site.

Display the Value

Adding a source to the list:

<?php
add_filter( 'nxt/import_sources', function ( $sources ) {
    $sources[] = array(
        'slug'  => 'my_legacy_fields',
        'label' => 'Our Legacy Fields',
    );
    return $sources;
} );

Limitations

  • Registering a source only puts it on the screen. The reading and mapping is yours to implement — the filter does not give you that for free.
  • The built-in adapters are the reference for the expected shape. Read them before writing one.
  • A migration that reports success is not evidence the data arrived. Verify values on real posts, every time.

Troubleshooting

My source appears but the scan finds nothing

Registering the source is only the first half. The scan needs your implementation to report what it found.

Should I write an adapter or a one-off script?

For a single site, a one-off script is usually simpler and easier to verify. An adapter earns its keep when you will run the same migration repeatedly.

Related Docs

Share your Thoughts

Still in Doubt? Let’s Assist You

Have Feedback or Questions?

Join our WordPress Community on Facebook!