Пример #1
0
 public function post_restore()
 {
     if (isset($_POST['job_id']) && isset($_POST['backup_uniqid']) && isset($_POST['_wpnonce']) && isset($_POST['method'])) {
         $nonce = filter_input(INPUT_POST, '_wpnonce', FILTER_SANITIZE_STRING);
         if (!wp_verify_nonce($nonce, 'my-wp-backup-restore-backup')) {
             wp_die(esc_html__('Nope! Security check failed!', 'my-wp-backup'));
         }
         $id = absint($_POST['job_id']);
         $uniqid = sanitize_key($_POST['backup_uniqid']);
         $method = filter_input(INPUT_POST, 'method', FILTER_SANITIZE_STRING);
         $backup = self::get($id, $uniqid);
         if (!isset($backup['duration'])) {
             add_settings_error('', '', __('Invalid backup id/uniqid.', 'my-wp-backup'));
             set_transient('settings_errors', get_settings_errors());
             wp_safe_redirect($this->admin->get_page_url('backup', array('settings-updated' => 1)));
         }
         if (!$backup->has_archives()) {
             // No local copy and no remote copy === DEAD END.
             if (empty($backup['destinations'])) {
                 add_settings_error('', '', __('Backup files missing.', 'my-wp-backup'));
                 set_transient('settings_errors', get_settings_errors());
                 wp_safe_redirect($this->admin->get_page_url('backup', array('settings-updated' => 1)));
             }
             if (!isset($backup['destinations'][$method])) {
                 add_settings_error('', '', sprintf(__('No backup files from %s.', 'my-wp-backup'), Job::$destinations[$method]));
                 set_transient('settings_errors', get_settings_errors());
                 wp_safe_redirect($this->admin->get_page_url('backup', array('settings-updated' => 1)));
             }
         }
         wp_schedule_single_event(time(), 'wp_backup_restore_backup', array(array($id, $uniqid, $method)));
         wp_safe_redirect($this->admin->get_page_url('backup', array('uniqid' => $uniqid, 'action' => 'viewprogress', 'id' => $id)));
     }
 }
Пример #2
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']);
         }
     }
 }
Пример #3
0
 public function post_create()
 {
     if (!check_admin_referer('MyWPBackup_job') || !isset($_POST['my-wp-backup-jobs'])) {
         wp_die(esc_html__('Nope! Security check failed!', 'my-wp-backup'));
     }
     $job = $this->validate($_POST['my-wp-backup-jobs']);
     // Input var okay. Sanitization okay.
     $jobs = get_site_option('my-wp-backup-jobs', array());
     $jobs['job-' . $job['id']] = $job;
     update_site_option('my-wp-backup-jobs', $jobs);
     $action = isset($_POST['my-wp-backup-jobs']['action']) && 'new' === $_POST['my-wp-backup-jobs']['action'] ? 'created' : 'updated';
     // Input var okay.
     // Clear schedules if the job was changed from scheduled to manual.
     if ('updated' === $action && 'manual' === $job['schedule_type']) {
         wp_clear_scheduled_hook('wp_backup_run_scheduled_job', array(array($job['id'])));
     }
     add_settings_error('', '', sprintf(__('Job "%s" %s.', 'my-wp-backup'), $job['job_name'], $action), 'updated');
     set_transient('settings_errors', get_settings_errors());
     wp_safe_redirect(Admin::get_page_url('jobs', array('settings-updated' => 1, 'tour' => isset($_POST['tour']) && 'yes' === $_POST['tour'] ? 'yes' : null)));
 }
Пример #4
0
</strong></li>
			    </ul>
			    <label for="restore-method"><?php 
        esc_html_e('Select where to restore the backup from:', 'my-wp-backup');
        ?>
</label><br><br>
			    <select name="method" id="restore-method">
				    <?php 
        wpb_select_options($backup->available_destinations());
        ?>
			    </select><br><br>
			    <?php 
        submit_button('Start', null, 'submit', false);
        ?>
			    <a class="button button-cancel" href="<?php 
        echo esc_attr(Admin::get_page_url('backup'));
        ?>
"><?php 
        esc_html_e('Cancel', 'my-wp-backup');
        ?>
</a>
		    </form>

	    <?php 
    } elseif ('viewprogress' === $action) {
        ?>

		    <label for="show-verbose"><input type="checkbox" value="yes" id="show-verbose"><?php 
        esc_html_e('Verbose Output', 'my-wp-backup');
        ?>
</label>
Пример #5
0
 function column_date($item)
 {
     $actions = array('log' => sprintf('<a href="%s">Review Log</a>', Admin::get_page_url('backup', array('uniqid' => $item['uniqid'], 'action' => 'log', 'id' => $item['job']['id']))), 'list' => sprintf('<a href="%s">List Files</a>', Admin::get_page_url('backup', array('uniqid' => $item['uniqid'], 'action' => 'list', 'id' => $item['job']['id']))), 'delete' => sprintf('<a href="%s">Delete</a>', Admin::get_page_url('backup', array('uniqid' => $item['uniqid'], 'action' => 'delete', 'id' => $item['job']['id']))), 'restore' => sprintf('<a href="%s">Restore</a>', Admin::get_page_url('backup', array('uniqid' => $item['uniqid'], 'action' => 'restore', 'id' => $item['job']['id']))));
     return sprintf('%1$s ago %2$s', human_time_diff($item['timestamp'], time()), $this->row_actions($actions));
 }
Пример #6
0
</p>
			<ul class="ul-disc">
				<li><strong><?php 
    echo esc_html($job['job_name']);
    ?>
</strong></li>
			</ul>
			<p><?php 
    esc_html_e('Are you sure you want to do this?', 'my-wp-backup');
    ?>
</p>
			<?php 
    submit_button('Yes, Delete this job', 'delete', 'submit', false);
    ?>
			<a class="button button-cancel" href="<?php 
    echo esc_attr(\MyWPBackup\Admin\Admin::get_page_url('jobs'));
    ?>
"><?php 
    esc_html_e('No, Return me to job list', 'my-wp-backup');
    ?>
</a>
		</form>


    <?php 
} elseif (isset($_GET['action']) && in_array($_GET['action'], array('new', 'edit'))) {
    // input var okay, sanitization okay
    ?>
		<?php 
    $action = sanitize_text_field($_GET['action']);
    // input var okay
Пример #7
0
 public function column_name($item)
 {
     $delete_link = Admin::get_page_url('jobs', array('action' => 'delete', 'id' => $item['id']));
     $run_link = Admin::get_page_url('jobs', array('action' => 'run', 'id' => $item['id'], 'tour' => isset($_GET['tour']) && 'yes' === $_GET['tour'] ? 'yes' : null));
     $view_link = Admin::get_page_url('jobs', array('action' => 'view', 'id' => $item['id'], 'uniqid' => $this->running['uniqid']));
     $actions = array('edit' => sprintf('<a href="%s">Edit</a>', Admin::get_page_url('jobs', array('action' => 'edit', 'id' => $item['id']))), 'delete' => sprintf('<a href="%s">Delete</a>', $delete_link));
     if (false !== $this->running && $this->running['id'] === $item['id']) {
         $actions['view'] = sprintf('<a href="%s">View Progress</a>', $view_link);
     } elseif (false === $this->running && 'manual' === $item['schedule_type']) {
         $actions['run'] = sprintf('<a href="%s">Run Now</a>', $run_link);
     }
     return sprintf('%1$s %2$s', $item['job_name'], $this->row_actions($actions));
 }
Пример #8
0
}
?>
	</div>

	<div class="row">

        <div class="col col-md-4">
            <div class="postbox">
                <h3 class="hndle"><span><?php 
esc_html_e('Getting Started', 'my-wp-backup');
?>
</span></h3>
                <div class="inside">
                    <p><?php 
esc_html_e('New to WP Backup?', 'my-wp-backup');
?>
 <br><br><a class="button" href="<?php 
echo esc_attr(\MyWPBackup\Admin\Admin::get_page_url('jobs', array('tour' => 'yes')));
?>
"><?php 
esc_html_e('Take Tour', 'my-wp-backup');
?>
</a></p>
                </div>
            </div>
        </div>

	</div>

</div>