/** * Set needed filters and actions and load */ private function __construct() { // Nothing else matters if we're not on the main site if (!is_main_site()) { return; } //auto loader spl_autoload_register(array($this, 'autoloader')); //start upgrade if needed if (get_site_option('backwpup_version') != self::get_plugin_data('Version')) { BackWPup_Install::activate(); } //load pro features if (class_exists('BackWPup_Pro')) { BackWPup_Pro::get_instance(); } //WP-Cron if (defined('DOING_CRON') && DOING_CRON) { if (!empty($_GET['backwpup_run']) && class_exists('BackWPup_Job')) { //early disable caches BackWPup_Job::disable_caches(); //add action for running jobs in wp-cron.php add_action('wp_loaded', array('BackWPup_Cron', 'cron_active'), PHP_INT_MAX); } else { //add cron actions add_action('backwpup_cron', array('BackWPup_Cron', 'run')); add_action('backwpup_check_cleanup', array('BackWPup_Cron', 'check_cleanup')); } //if in cron the rest is not needed return; } //deactivation hook register_deactivation_hook(__FILE__, array('BackWPup_Install', 'deactivate')); //Admin bar if (get_site_option('backwpup_cfg_showadminbar', FALSE)) { add_action('init', array('BackWPup_Adminbar', 'get_instance')); } //only in backend if (is_admin() && class_exists('BackWPup_Admin')) { BackWPup_Admin::get_instance(); } //work with wp-cli if (defined('WP_CLI') && WP_CLI && method_exists('WP_CLI', 'add_command')) { WP_CLI::add_command('backwpup', 'BackWPup_WP_CLI'); } }
/** * Set needed filters and actions and load */ private function __construct() { // Nothing else matters if we're not on the main site if (!is_main_site()) { return; } //auto loader spl_autoload_register(array($this, 'autoloader')); //Options new BackWPup_Option(); //start upgrade if needed if (get_site_option('backwpup_version') != self::get_plugin_data('Version')) { BackWPup_Install::activate(); } //load pro features if (class_exists('BackWPup_Pro')) { BackWPup_Pro::get_instance(); } //WP-Cron if (defined('DOING_CRON') && DOING_CRON) { //early disable caches if (!empty($_GET['backwpup_run']) && class_exists('BackWPup_Job')) { BackWPup_Job::disable_caches(); } // add normal cron actions add_action('backwpup_cron', array('BackWPup_Cron', 'run')); add_action('backwpup_check_cleanup', array('BackWPup_Cron', 'check_cleanup')); // add action for doing thinks if cron active // must done in int before wp-cron control add_action('init', array('BackWPup_Cron', 'cron_active'), 1); // if in cron the rest must not needed return; } //deactivation hook register_deactivation_hook(__FILE__, array('BackWPup_Install', 'deactivate')); //Things that must do in plugin init add_action('init', array($this, 'plugin_init')); //only in backend if (is_admin() && class_exists('BackWPup_Admin')) { BackWPup_Admin::get_instance(); } //work with wp-cli if (defined('WP_CLI') && WP_CLI && class_exists('WP_CLI') && class_exists('BackWPup_WP_CLI')) { WP_CLI::addCommand('backwpup', 'BackWPup_WP_CLI'); } }