function blc_init() { global $blc_module_manager, $blc_config_manager, $ws_link_checker; static $init_done = false; if ($init_done) { return; } $init_done = true; //Ensure the database is up to date if ($blc_config_manager->options['current_db_version'] != BLC_DATABASE_VERSION) { require_once BLC_DIRECTORY . '/includes/admin/db-upgrade.php'; blcDatabaseUpgrader::upgrade_database(); //Also updates the DB ver. in options['current_db_version']. } //Load the base classes and utilities require_once BLC_DIRECTORY . '/includes/links.php'; require_once BLC_DIRECTORY . '/includes/link-query.php'; require_once BLC_DIRECTORY . '/includes/instances.php'; require_once BLC_DIRECTORY . '/includes/utility-class.php'; //Load the module subsystem require_once BLC_DIRECTORY . '/includes/modules.php'; //Load the modules that want to be executed in all contexts $blc_module_manager->load_modules(); if (is_admin() || defined('DOING_CRON')) { //It's an admin-side or Cron request. Load the core. require_once BLC_DIRECTORY . '/core/core.php'; $ws_link_checker = new wsBrokenLinkChecker(BLC_PLUGIN_FILE, $blc_config_manager); } else { //This is user-side request, so we don't need to load the core. //We might need to inject the CSS for removed links, though. if ($blc_config_manager->options['mark_removed_links'] && !empty($blc_config_manager->options['removed_link_css'])) { function blc_print_removed_link_css() { global $blc_config_manager; echo '<style type="text/css">', $blc_config_manager->options['removed_link_css'], '</style>'; } add_action('wp_head', 'blc_print_removed_link_css'); } } }
$moduleManager = blcModuleManager::getInstance(); //If upgrading, activate/deactivate custom field and comment containers based on old ver. settings if (isset($blc_config_manager->options['check_comment_links'])) { if (!$blc_config_manager->options['check_comment_links']) { $moduleManager->deactivate('comment'); } unset($blc_config_manager->options['check_comment_links']); } if (empty($blc_config_manager->options['custom_fields'])) { $moduleManager->deactivate('custom_field'); } //Prepare the database. $blclog->info('Upgrading the database...'); $upgrade_start = microtime(true); require_once BLC_DIRECTORY . '/includes/admin/db-upgrade.php'; blcDatabaseUpgrader::upgrade_database(); $blclog->info(sprintf('--- Total: %.3f seconds', microtime(true) - $upgrade_start)); //Remove invalid DB entries $blclog->info('Cleaning up the database...'); $cleanup_start = microtime(true); blc_cleanup_database(); $blclog->info(sprintf('--- Total: %.3f seconds', microtime(true) - $cleanup_start)); //Notify modules that the plugin has been activated. This will cause container //modules to create and update synch. records for all new/modified posts and other items. $blclog->info('Notifying modules...'); $notification_start = microtime(true); $moduleManager->plugin_activated(); blc_got_unsynched_items(); $blclog->info(sprintf('--- Total: %.3f seconds', microtime(true) - $notification_start)); //Turn off load limiting if it's not available on this server. $blclog->info('Updating server load limit settings...');