Ejemplo n.º 1
0
 /**
  * Create and/or upgrade the plugin's database tables.
  *
  * @return bool
  */
 public static function upgrade_database()
 {
     global $wpdb, $blclog;
     $conf = blc_get_configuration();
     $current = $conf->options['current_db_version'];
     if ($current != 0 && $current < 4) {
         //The 4th DB version makes a lot of backwards-incompatible changes to the main
         //BLC tables, so instead of upgrading we just throw them away and recreate.
         if (!blcDatabaseUpgrader::drop_tables()) {
             return false;
         }
         $current = 0;
     }
     //Create/update the plugin's tables
     if (!blcDatabaseUpgrader::make_schema_current()) {
         return false;
     }
     if ($current != 0) {
         if ($current < 5) {
             blcDatabaseUpgrader::upgrade_095();
         }
     }
     $conf->options['current_db_version'] = BLC_DATABASE_VERSION;
     $conf->save_options();
     $blclog->info('Database successfully upgraded.');
     return true;
 }
Ejemplo n.º 2
0
 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');
         }
     }
 }
Ejemplo n.º 3
0
$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...');