Exemplo n.º 1
0
 protected function __construct()
 {
     if (false !== get_transient('_my-wp-backup-activated')) {
         delete_transient('_my-wp-backup-activated');
         wp_redirect(Admin::get_page_url(''));
     }
     self::$info = get_file_data(__FILE__, array('name' => 'Plugin Name', 'pluginUri' => 'Plugin URI', 'supportUri' => 'Support URI', 'version' => 'Version', 'description' => 'Description', 'author' => 'Author', 'authorUri' => 'Author URI', 'textDomain' => 'Text Domain', 'domainPath' => 'Domain Path', 'slug' => 'Slug', 'license' => 'License', 'licenseUri' => 'License URI'));
     Admin::get_instance();
     $options = get_site_option('my-wp-backup-options', Admin::$options);
     self::$info['baseDir'] = plugin_dir_path(__FILE__);
     self::$info['baseDirUrl'] = plugin_dir_url(__FILE__);
     self::$info['backup_dir'] = trailingslashit(ABSPATH) . trailingslashit(ltrim($options['backup_dir'], '/'));
     self::$info['root_dir'] = trailingslashit(ABSPATH);
     if (defined('WP_CLI') && WP_CLI) {
         \WP_CLI::add_command('job', new Cli\Job());
         \WP_CLI::add_command('backup', new Cli\Backup());
     }
     add_action('wp_backup_run_job', array(Job::get_instance(), 'cron_run'));
     add_action('wp_backup_restore_backup', array(Backup::get_instance(), 'cron_run'));
     $version = get_site_option(self::KEY_VERSION);
     if (!$version || self::$info['version'] !== $version) {
         if ($this->update_options()) {
             update_site_option(self::KEY_VERSION, self::$info['version']);
         }
     }
 }
Exemplo n.º 2
0
 protected function __construct()
 {
     self::$form_defaults = array('job_name' => '', 'filename' => 'my-wp-backup_%c', 'password' => '', 'volsize' => 0, 'compression' => 'zip', 'schedule_type' => 'manual', 'cron_type' => 'simple', 'backup_files' => '1', 'backup_uploads' => '1', 'exclude_files' => '1', 'file_filters' => array('**/.git', '**/.DS_Store', '**/*.log', '**/*.tmp'), 'export_db' => '1', 'exclude_tables' => '0', 'table_filters' => array(), 'differential' => '0', 'delete_local' => '0', 'destination' => array(), 'destination_options' => array('ftp' => array('host' => '', 'username' => '', 'password' => '', 'port' => 21, 'folder' => '', 'ssl' => '0'), 'dropbox' => array('token' => '', 'folder' => '/My Wp Backup/'), 'googledrive' => array('token' => '', 'token_json' => '', 'folder' => '/My Wp Backup/')), 'rep_destination' => array('none'), 'reporter_options' => array('mail' => array('from' => get_bloginfo('admin_email'), 'name' => get_bloginfo('name'), 'address' => '', 'title' => __('Hi, your site backup is complete!', 'my-wp-backup'), 'message' => __('Job {{name}} finished in {{duration}}', 'my-wp-backup'), 'attach' => '0', 'method' => 'default', 'smtp_server' => '', 'smtp_port' => '', 'smtp_protocol' => 'none', 'smtp_username' => '', 'smtp_password' => '')));
     self::$compression_methods = array('zip' => 'Zip', 'tar' => 'Tar', 'gz' => 'Tar (gz)', 'bz2' => 'Tar (bz2)');
     self::$destinations = array('ftp' => __('FTP', 'my-wp-backup'), 'dropbox' => __('Dropbox', 'my-wp-backup'), 'googledrive' => __('Google Drive', 'my-wp-backup'));
     self::$reporters = array('none' => __('None', 'my-wp-backup'), 'mail' => __('E-Mail', 'my-wp-backup'));
     self::$email_methods = array('default' => __('Default', 'my-wp-backup'), 'smtp' => __('SMTP', 'my-wp-backup'));
     $this->admin = Admin::get_instance();
     add_action('admin_init', array($this, 'admin_init'));
     add_action('admin_post_MyWPBackup_run_job', array($this, 'post_run_job'));
 }
Exemplo n.º 3
0
 public static function run()
 {
     Admin::get_instance();
     if (!get_site_option('my-wp-backup-jobs', false)) {
         update_site_option('my-wp-backup-jobs', array());
     }
     if (!get_site_option('my-wp-backup-options', false)) {
         update_site_option('my-wp-backup-options', Admin::$options);
     }
     if (version_compare(PHP_VERSION, self::MIN_VER, '<')) {
         self::err(sprintf(__('PHP\'s version is too old. You have %s but My WP Backup requires atleast %s.', 'my-wp-backup'), PHP_VERSION, self::MIN_VER));
     }
     $extensions = array('zlib', 'bz2', 'SPL', 'curl', 'mbstring', 'ftp');
     foreach ($extensions as $extension) {
         if (!extension_loaded($extension)) {
             self::err(sprintf(__('Error: Your PHP installation does not have the %s extension which is required for this plugin to function correctly.', 'my-wp-backup'), $extension));
         }
     }
     set_transient('_my-wp-backup-activated', true, 30);
 }
Exemplo n.º 4
0
 protected function __construct()
 {
     $this->admin = Admin::get_instance();
     $this->admin_init();
 }
Exemplo n.º 5
0
esc_attr_e('Import', 'my-wp-backup');
?>
" class="button-primary" name="Submit"></p>
		</form>
	</div>

	<div id="section-export" class="nav-tab-content">
		<table class="form-table">
			<tr>
				<th scope="row"><label for="export"><?php 
esc_html_e('Copy Code', 'my-wp-backup');
?>
</label></th>
				<td>
					<textarea id="export" cols="40" rows="10"><?php 
echo serialize(\MyWPBackup\Admin\Admin::get_instance()->export());
?>
</textarea>
				</td>
			</tr>
			<tr>
				<th scope="row"><label for="export-dl"><?php 
esc_html_e('Download File', 'my-wp-backup');
?>
</label></th>
				<td>
					<a id="export-dl" href="<?php 
echo esc_attr(MyWPBackup\Admin\Admin::get_page_url('settings', array('action' => 'export')));
?>
"><?php 
esc_html_e('Click here to download', 'my-wp-backup');