WordPress.org

Make WordPress Core

Ticket #4614: importerplugin.php

File importerplugin.php, 726 bytes (added by Nazgul, 8 years ago)

Sample importer plugin

Line 
1<?php
2/*
3Plugin Name: Example Importer Plugin
4Version: 0.1
5Plugin URI: http://nazgul.nu/blog/
6Description: Bundle an importer in a plugin.
7Author: Nazgul
8Author URI: http://nazgul.nu/
9*/
10
11require_once(ABSPATH . 'wp-admin/includes/import.php');
12
13register_importer('importerplugin', __('Importer Plugin'), __('Import ...'), 'importerplugin_dispatch');
14add_filter('importer_path', 'importerplugin_import_path');
15
16function importerplugin_dispatch() {
17        // Write your importer code here
18}
19
20function importerplugin_import_path($text) {
21        if(stripos($text, ABSPATH . "wp-admin/import/importerplugin.php") !== false)
22                $text = str_replace('wp-admin/import', 'wp-content/plugins', $text);
23       
24        return $text;
25}
26
27?>