register_importer( string $id, string $name, string $description, callable $callback ): void|WP_Error

Registers importer for WordPress.

Parameters

$idstringrequired
Importer tag. Used to uniquely identify importer.
$namestringrequired
Importer name and title.
$descriptionstringrequired
Importer description.
$callbackcallablerequired
Callback to run.

Return

void|WP_Error Void on success. WP_Error when $callback is WP_Error.

Source

function register_importer( $id, $name, $description, $callback ) {
	global $wp_importers;
	if ( is_wp_error( $callback ) ) {
		return $callback;
	}
	$wp_importers[ $id ] = array( $name, $description, $callback );
}

Changelog

VersionDescription
2.0.0Introduced.

User Contributed Notes

  1. Skip to note 2 content

    This function needs to be called inside the admin_init (or init) action, otherwise it will sometimes cause a Fatal Error.

    add_action( 'admin_init', function () {
    	register_importer( 
    		'wpdocs-import-the-things',
    		'WPDocs Import the Things',
    		'Lets you import those things',
    		'wpdocs_the_things_importer'
    	);
    } );
    
    function wpdocs_the_things_importer() {
    	// echo the content of the page for when this importer is called. 
    	// Just like any other admin page
    }

You must log in before being able to contribute a note or feedback.