register(); return $iwp; } function iwp_is_pro_disabled() { return defined('IWP_PRO_VERSION') && version_compare(IWP_PRO_VERSION, IWP_CORE_MIN_PRO_VERSION, '<'); } /** * When updating ImportWP errors can arrise if the pro version has a different codebase * * Disable PRO functionality and alert user to reason. * * @return void */ function iwp_has_required_version_of_pro() { if (iwp_is_pro_disabled()) { remove_action('plugins_loaded', 'iwp_pro_loaded'); // Display compatability message $message = 'Import WP v' . IWP_VERSION . ' requires Import WP PRO v' . IWP_CORE_MIN_PRO_VERSION . ' or greater, Download the lastest version of Import WP Pro or Rollback Import WP to a compatable version.'; add_action('admin_notices', function () use ($message) { global $pagenow; if (!in_array($pagenow, ['plugins.php', 'update-core.php', 'index.php'])) { return; } echo '

' . $message . '

'; }); // display error message after plugin row $upgrade_mesasge = function () use ($message) { ?> 'error', 'message' => strip_tags($message)]; return $notices; }); } } add_action('plugins_loaded', 'iwp_has_required_version_of_pro', 0); function iwp_loaded() { if (function_exists('import_wp_pro') && !iwp_is_pro_disabled()) { return; } if (function_exists('import_wp')) { import_wp(); } } add_action('plugins_loaded', 'iwp_loaded'); /** * Register IWP Addon * * @param string $name * @param string $id * @param callable(AddonInterface) $callback * * @return ImportWP\Common\Addon\AddonInterface */ function iwp_register_importer_addon($name, $id, $callback) { return new ImportWP\Common\Addon\AddonBase($name, $id, $callback); }