wordpress-importer
Last commit date
parsers
7 months ago
php-toolkit
6 months ago
class-wp-import.php
6 months ago
compat.php
3 years ago
parsers.php
8 months ago
readme.txt
6 months ago
wordpress-importer.php
6 months ago
wordpress-importer.php
79 lines
| 1 | <?php |
| 2 | /* |
| 3 | * @wordpress-plugin |
| 4 | * Plugin Name: WordPress Importer |
| 5 | * Plugin URI: https://wordpress.org/plugins/wordpress-importer/ |
| 6 | * Description: Import posts, pages, comments, custom fields, categories, tags and more from a WordPress export file. |
| 7 | * Author: wordpressdotorg |
| 8 | * Author URI: https://wordpress.org/ |
| 9 | * Version: 0.9.5 |
| 10 | * Requires at least: 5.2 |
| 11 | * Requires PHP: 7.2 |
| 12 | * Text Domain: wordpress-importer |
| 13 | * License: GPLv2 or later |
| 14 | * License URI: https://www.gnu.org/licenses/gpl-2.0.html |
| 15 | */ |
| 16 | |
| 17 | if ( ! defined( 'WP_LOAD_IMPORTERS' ) ) { |
| 18 | return; |
| 19 | } |
| 20 | |
| 21 | /** Display verbose errors */ |
| 22 | if ( ! defined( 'IMPORT_DEBUG' ) ) { |
| 23 | define( 'IMPORT_DEBUG', WP_DEBUG ); |
| 24 | } |
| 25 | |
| 26 | /** WordPress Import Administration API */ |
| 27 | require_once ABSPATH . 'wp-admin/includes/import.php'; |
| 28 | |
| 29 | if ( ! class_exists( 'WP_Importer' ) ) { |
| 30 | $class_wp_importer = ABSPATH . 'wp-admin/includes/class-wp-importer.php'; |
| 31 | if ( file_exists( $class_wp_importer ) ) { |
| 32 | require $class_wp_importer; |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | /** Functions missing in older WordPress versions. */ |
| 37 | require_once __DIR__ . '/compat.php'; |
| 38 | |
| 39 | if ( ! class_exists( 'WordPress\XML\XMLProcessor' ) ) { |
| 40 | require_once __DIR__ . '/php-toolkit/load.php'; |
| 41 | } |
| 42 | |
| 43 | /** WXR_Parser class */ |
| 44 | require_once __DIR__ . '/parsers/class-wxr-parser.php'; |
| 45 | |
| 46 | /** WXR_Parser_SimpleXML class */ |
| 47 | require_once __DIR__ . '/parsers/class-wxr-parser-simplexml.php'; |
| 48 | |
| 49 | /** WXR_Parser_XML class */ |
| 50 | require_once __DIR__ . '/parsers/class-wxr-parser-xml.php'; |
| 51 | |
| 52 | /** |
| 53 | * WXR_Parser_Regex class |
| 54 | * @deprecated 0.9.0 Use WXR_Parser_XML_Processor instead. The WXR_Parser_Regex class |
| 55 | * is no longer used by the importer or maintained with bug fixes. The only |
| 56 | * reason it is still included in the codebase is for backwards compatibility |
| 57 | * with plugins that directly reference it. |
| 58 | */ |
| 59 | require_once __DIR__ . '/parsers/class-wxr-parser-regex.php'; |
| 60 | |
| 61 | /** WXR_Parser_XML_Processor class */ |
| 62 | require_once __DIR__ . '/parsers/class-wxr-parser-xml-processor.php'; |
| 63 | |
| 64 | /** WP_Import class */ |
| 65 | require_once __DIR__ . '/class-wp-import.php'; |
| 66 | |
| 67 | function wordpress_importer_init() { |
| 68 | load_plugin_textdomain( 'wordpress-importer' ); |
| 69 | |
| 70 | /** |
| 71 | * WordPress Importer object for registering the import callback |
| 72 | * @global WP_Import $wp_import |
| 73 | */ |
| 74 | $GLOBALS['wp_import'] = new WP_Import(); |
| 75 | // phpcs:ignore WordPress.WP.CapitalPDangit |
| 76 | register_importer( 'wordpress', 'WordPress', __( 'Import <strong>posts, pages, comments, custom fields, categories, and tags</strong> from a WordPress export file.', 'wordpress-importer' ), array( $GLOBALS['wp_import'], 'dispatch' ) ); |
| 77 | } |
| 78 | add_action( 'admin_init', 'wordpress_importer_init' ); |
| 79 |