class-fl-builder-import.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. /**
  3. * The WordPress importer plugin has a few issues that break
  4. * serialized data in certain cases. This class overrides the
  5. * WordPress importer with our own patched version that fixes
  6. * these issues.
  7. *
  8. * @since 1.8
  9. */
  10. final class FLBuilderImport {
  11. /**
  12. * @since 1.8
  13. * @return void
  14. */
  15. static public function init() {
  16. if ( ! defined( 'WP_LOAD_IMPORTERS' ) || ! class_exists( 'WP_Import' ) || ! class_exists( 'WXR_Parser_Regex' ) ) {
  17. return;
  18. }
  19. if ( defined( 'FL_BUILDER_IMPORTER_FIX' ) && ! FL_BUILDER_IMPORTER_FIX ) {
  20. return;
  21. }
  22. require_once FL_BUILDER_DIR . '/classes/class-fl-builder-importer.php';
  23. // Remove the WordPress importer.
  24. remove_action( 'admin_init', 'wordpress_importer_init' );
  25. // Add our importer.
  26. add_action( 'admin_init', 'FLBuilderImport::load' );
  27. }
  28. /**
  29. * @since 1.8
  30. * @return void
  31. */
  32. static public function load() {
  33. load_plugin_textdomain( 'wordpress-importer', false, 'wordpress-importer/languages' );
  34. $GLOBALS['wp_import'] = new FLBuilderImporter();
  35. register_importer( 'wordpress', 'WordPress', __( 'Import <strong>posts, pages, comments, custom fields, categories, and tags</strong> from a WordPress export file.', 'fl-builder' ), array( $GLOBALS['wp_import'], 'dispatch' ) );
  36. }
  37. }
  38. add_action( 'plugins_loaded', 'FLBuilderImport::init' );