WordPress has a full load of Importer Plugins that you can install from the ~/wp-admin/tools/import screen. They will serve as nice reference.
Then there’s Ralf Alberts @Ralf912 Importer skeleton on GitHub/Gist which you can take as reference. Please note that this skeleton uses namespaces and therefore requires PHP 5.3+, or a rewrite.
The main/important parts are the following:
-
Check if the request comes from
admin.php?import=...if ( ! defined( 'WP_LOAD_IMPORTERS' ) ) return; -
Load Importer API (Importer API = Backendpage
admin.php?import=...)require_once ABSPATH . 'wp-admin/includes/import.php'; -
Load the importer base class
if ( ! class_exists( 'WP_Importer' ) ) { $class_wp_importer = ABSPATH . 'wp-admin/includes/class-wp-importer.php'; if ( file_exists( $class_wp_importer ) ) require $class_wp_importer; } -
Register your Custom Importer to WordPress by using
register_importer()– Codex explanationregister_importer( 'custom', 'CustomPress', __('Import <strong>posts</strong> or not.', 'custom-importer'), array( new Custom_Import(), 'dispatch' ) );