/** * */ private function __construct() { //Load text domain BackWPup::load_text_domain(); //add admin bar. Works only in init add_action('admin_bar_menu', array($this, 'adminbar'), 100); //admin css add_action('wp_head', array('BackWPup_Admin', 'admin_css')); }
/** * * Set needed filters and actions and load all needed * * @return \BackWPup_Admin */ public function __construct() { //Load text domain BackWPup::load_text_domain(); //Add menu pages add_filter('backwpup_admin_pages', array($this, 'admin_page_jobs'), 2); add_filter('backwpup_admin_pages', array($this, 'admin_page_editjob'), 3); add_filter('backwpup_admin_pages', array($this, 'admin_page_logs'), 4); add_filter('backwpup_admin_pages', array($this, 'admin_page_backups'), 5); add_filter('backwpup_admin_pages', array($this, 'admin_page_settings'), 6); add_filter('backwpup_admin_pages', array($this, 'admin_page_about'), 20); //Add Menu if (is_multisite()) { add_action('network_admin_menu', array($this, 'admin_menu')); } else { add_action('admin_menu', array($this, 'admin_menu')); } //add Plugin links add_filter('plugin_row_meta', array($this, 'plugin_links'), 10, 2); //add more actions add_action('admin_init', array($this, 'admin_init')); add_action('admin_init', array(__CLASS__, 'admin_css')); //Save Form posts general add_action('admin_post_backwpup', array($this, 'save_post_form')); //Save Form posts wizard add_action('admin_post_backwpup_wizard', array('BackWPup_Pro_Page_Wizard', 'save_post_form')); //Admin Footer Text replacement add_filter('admin_footer_text', array($this, 'admin_footer_text'), 100); add_filter('update_footer', array($this, 'update_footer'), 100); //User Profile fields add_action('show_user_profile', array($this, 'user_profile_fields')); add_action('edit_user_profile', array($this, 'user_profile_fields')); add_action('profile_update', array($this, 'save_profile_update')); add_filter('manage_users_columns', array($this, 'manage_users_columns')); add_filter('manage_users_custom_column', array($this, 'manage_users_custom_column'), 10, 3); //Change Backup message on core updates add_filter('gettext', array($this, 'gettext'), 10, 3); new BackWPup_EasyCron(); }
/** * @param $jobid */ public static function start_cli($jobid) { if (php_sapi_name() != 'cli') { return; } //define DOING_CRON to prevent caching if (!defined('DOING_CRON')) { define('DOING_CRON', true); } //load text domain $log_level = get_site_option('backwpup_cfg_loglevel', 'normal_translated'); if (strstr($log_level, 'translated')) { BackWPup::load_text_domain(); } else { add_filter('override_load_textdomain', '__return_true'); $GLOBALS['l10n'] = array(); } $jobid = absint($jobid); //Logs Folder $log_folder = get_site_option('backwpup_cfg_logfolder'); $log_folder = BackWPup_File::get_absolute_path($log_folder); //check job id exists $jobids = BackWPup_Option::get_job_ids(); if (!in_array($jobid, $jobids, true)) { die(__('Wrong BackWPup JobID', 'backwpup')); } //check folders $log_folder_message = BackWPup_File::check_folder($log_folder); if (!empty($log_folder_message)) { die($log_folder_message); } $log_folder_message = BackWPup_File::check_folder(BackWPup::get_plugin_data('TEMP'), true); if (!empty($log_folder_message)) { die($log_folder_message); } //check running job if (file_exists(BackWPup::get_plugin_data('running_file'))) { die(__('A BackWPup job is already running', 'backwpup')); } //start class $backwpup_job_object = new self(); $backwpup_job_object->create('runcli', (int) $jobid); $backwpup_job_object->run(); }
/** * @param int $jobid */ public static function start_wp_cron($jobid = 0) { if (!defined('DOING_CRON') || !DOING_CRON) { return; } //load text domain $log_level = get_site_option('backwpup_cfg_loglevel'); if (strstr($log_level, 'translated')) { BackWPup::load_text_domain(); } if (!empty($jobid)) { //check folders $log_folder = get_site_option('backwpup_cfg_logfolder'); $folder_message_log = BackWPup_File::check_folder(BackWPup_File::get_absolute_path($log_folder)); $folder_message_temp = BackWPup_File::check_folder(BackWPup::get_plugin_data('TEMP'), TRUE); if (!empty($folder_message_log) || !empty($folder_message_temp)) { BackWPup_Admin::message($folder_message_log, TRUE); BackWPup_Admin::message($folder_message_temp, TRUE); return; } } // Should be preventing doubled running job's on http requests $random = rand(1, 9) * 100000; usleep($random); //get running job $backwpup_job_object = self::get_working_data(); //start/restart class if (empty($backwpup_job_object) && !empty($jobid)) { //schedule restart event wp_schedule_single_event(time() + 60, 'backwpup_cron', array('id' => 'restart')); //start job $backwpup_job_object = new self(); $backwpup_job_object->create('cronrun', (int) $jobid); } if (is_object($backwpup_job_object) && $backwpup_job_object instanceof BackWPup_Job) { $backwpup_job_object->run(); } }