GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Branch dev (47ca59)
by Liuta
03:25
created

Xcloner::get_version()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 2
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * XCloner - Backup and Restore backup plugin for Wordpress
4
 *
5
 * class-xcloner.php
6
 * @author Liuta Ovidiu <[email protected]>
7
 *
8
 *        This program is free software; you can redistribute it and/or modify
9
 *        it under the terms of the GNU General Public License as published by
10
 *        the Free Software Foundation; either version 2 of the License, or
11
 *        (at your option) any later version.
12
 *
13
 *        This program is distributed in the hope that it will be useful,
14
 *        but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 *        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 *        GNU General Public License for more details.
17
 *
18
 *        You should have received a copy of the GNU General Public License
19
 *        along with this program; if not, write to the Free Software
20
 *        Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
21
 *        MA 02110-1301, USA.
22
 *
23
 * @link https://github.com/ovidiul/XCloner-Wordpress
24
 *
25
 * @modified 7/31/18 3:29 PM
26
 *
27
 */
28
29
/**
30
 * The core plugin class.
31
 *
32
 * This is used to define internationalization, admin-specific hooks, and
33
 * public-facing site hooks.
34
 *
35
 * Also maintains the unique identifier of this plugin as well as the current
36
 * version of the plugin.
37
 *
38
 * @since      1.0.0
39
 * @package    Xcloner
40
 * @subpackage Xcloner/includes
41
 * @author     Liuta Ovidiu <[email protected]>
42
 * @link       http://www.thinkovi.com
43
 */
44
class Xcloner {
45
46
	/**
47
	 * The loader that's responsible for maintaining and registering all hooks that power
48
	 * the plugin.
49
	 *
50
	 * @since    1.0.0
51
	 * @access   protected
52
	 * @var      Xcloner_Loader    $loader    Maintains and registers all hooks for the plugin.
53
	 */
54
	protected $loader;
55
56
	/**
57
	 * The unique identifier of this plugin.
58
	 *
59
	 * @since    1.0.0
60
	 * @access   protected
61
	 * @var      string    $plugin_name    The string used to uniquely identify this plugin.
62
	 */
63
	protected $plugin_name;
64
65
	protected $plugin_admin;
66
67
	/**
68
	 * The current version of the plugin.
69
	 *
70
	 * @since    1.0.0
71
	 * @access   protected
72
	 * @var      string    $version    The current version of the plugin.
73
	 */
74
	protected $version;
75
76
	private $xcloner_settings;
77
	private $xcloner_logger;
78
	private $xcloner_sanitization;
79
	private $xcloner_requirements;
80
	private $xcloner_filesystem;
81
	private $archive_system;
82
	private $xcloner_database;
83
	private $xcloner_scheduler;
84
	private $xcloner_remote_storage;
85
	private $xcloner_file_transfer;
86
	private $xcloner_encryption;
87
88
	/**
89
	 * Define the core functionality of the plugin.
90
	 *
91
	 * Set the plugin name and the plugin version that can be used throughout the plugin.
92
	 * Load the dependencies, define the locale, and set the hooks for the admin area and
93
	 * the public-facing side of the site.
94
	 *
95
	 * @since    1.0.0
96
	 */
97
	public function init()
98
	{
99
		register_shutdown_function(array($this, 'exception_handler'));
100
101
		$this->plugin_name = 'xcloner';
102
		$this->version = '4.0.4';
103
104
		$this->load_dependencies();
105
		$this->set_locale();
106
		$this->define_admin_hooks();
107
		$this->define_public_hooks();
108
109
		$this->define_admin_menu();
110
		$this->define_plugin_settings();
111
112
		$this->define_ajax_hooks();
113
		$this->define_cron_hooks();
114
115
	}
116
117
    /**
118
     * Retrieve the version number of the plugin.
119
     *
120
     * @since     1.0.0
121
     * @return    string    The version number of the plugin.
122
     */
123
    /*public function get_version() {
124
        return $this->version;
125
    }
126
127
    public function get_xcloner_settings()
128
	{
129
		return $this->xcloner_settings;
130
	}
131
132
	public function get_xcloner_filesystem()
133
	{
134
		return $this->xcloner_filesystem;
135
	}
136
137
	public function get_xcloner_logger()
138
	{
139
		return $this->xcloner_logger;
140
	}
141
142
	public function get_xcloner_sanitization()
143
	{
144
		return $this->xcloner_sanitization;
145
	}
146
147
	public function get_xcloner_requirements()
148
	{
149
		return $this->xcloner_requirements;
150
	}
151
152
	public function get_archive_system()
153
	{
154
		return $this->archive_system;
155
	}
156
157
	public function get_xcloner_database()
158
	{
159
		return $this->xcloner_database;
160
	}
161
162
	public function get_xcloner_scheduler()
163
	{
164
		return $this->xcloner_scheduler;
165
	}
166
167
	public function get_xcloner_remote_storage()
168
	{
169
		return $this->xcloner_remote_storage;
170
	}
171
172
	public function get_xcloner_file_transfer()
173
	{
174
		return $this->xcloner_file_transfer;
175
	}
176
177
	public function get_xcloner_encryption()
178
	{
179
		return $this->xcloner_encryption;
180
	}*/
181
182
    public function __call($property, $args) {
183
184
        $property = str_replace("get_", "", $property);
185
186
        if(property_exists($this, $property)){
187
            return $this->$property;
188
        }
189
    }
190
191
	public function check_dependencies() {
192
193
		$backup_storage_path = realpath(__DIR__.DS."..".DS."..".DS."..").DS."backups".DS;
194
195
		define("XCLONER_STORAGE_PATH", realpath($backup_storage_path));
196
197
		if (!is_dir($backup_storage_path))
198
		{
199
			if (!@mkdir($backup_storage_path))
200
			{
201
				$status = "error";
202
				$message = sprintf(__("Unable to create the Backup Storage Location Folder %s . Please fix this before starting the backup process."), $backup_storage_path);
203
				$this->trigger_message($message, $status, $backup_storage_path);
204
				return;
205
			}
206
		}
207
		if (!is_writable($backup_storage_path))
208
		{
209
			$status = "error";
210
			$message = sprintf(__("Unable to write to the Backup Storage Location Folder %s . Please fix this before starting the backup process."), $backup_storage_path);
211
			$this->trigger_message($message, $status, $backup_storage_path);
212
213
			return;
214
		}
215
216
	}
217
218
	public function trigger_message($message, $status = "error", $message_param1 = "", $message_param2 = "", $message_param3 = "")
219
	{
220
			$message = sprintf(__($message), $message_param1, $message_param2, $message_param3);
221
			add_action('xcloner_admin_notices', array($this, "trigger_message_notice"), 10, 2);
222
			do_action('xcloner_admin_notices', $message, $status);
223
	}
224
225
	public function trigger_message_notice($message, $status = "success")
226
	{
227
		?>
228
		<div class="notice notice-<?php echo $status?> is-dismissible">
229
	        <p><?php _e($message, 'xcloner-backup-and-restore'); ?></p>
230
	    </div>
231
		<?php
232
	}
233
234
	/**
235
	 * Load the required dependencies for this plugin.
236
	 *
237
	 * Include the following files that make up the plugin:
238
	 *
239
	 * - Xcloner_Loader. Orchestrates the hooks of the plugin.
240
	 * - Xcloner_i18n. Defines internationalization functionality.
241
	 * - Xcloner_Admin. Defines all hooks for the admin area.
242
	 * - Xcloner_Public. Defines all hooks for the public side of the site.
243
	 *
244
	 * Create an instance of the loader which will be used to register the hooks
245
	 * with WordPress.
246
	 *
247
	 * @since    1.0.0
248
	 * @access   private
249
	 */
250
	private function load_dependencies() {
251
252
		/**
253
		 * The class responsible for orchestrating the actions and filters of the
254
		 * core plugin.
255
		 */
256
		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-xcloner-loader.php';
257
258
		/**
259
		 * The class responsible for defining internationalization functionality
260
		 * of the plugin.
261
		 */
262
		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-xcloner-i18n.php';
263
264
		/**
265
		 * The class responsible for defining all actions that occur in the admin area.
266
		 */
267
		require_once plugin_dir_path(dirname(__FILE__)).'admin/class-xcloner-admin.php';
268
269
		/**
270
		 * The class responsible for debugging XCloner.
271
		 */
272
		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-xcloner-logger.php';
273
274
		/**
275
		 * The class responsible for defining the admin settings area.
276
		 */
277
		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-xcloner-settings.php';
278
279
		/**
280
		 * The class responsible for defining the Remote Storage settings area.
281
		 */
282
		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-xcloner-remote-storage.php';
283
284
		/**
285
		 * The class responsible for implementing the database backup methods.
286
		 */
287
		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-xcloner-database.php';
288
289
		/**
290
		 * The class responsible for sanitization of users input.
291
		 */
292
		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-xcloner-sanitization.php';
293
294
		/**
295
		 * The class responsible for XCloner system requirements validation.
296
		 */
297
		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-xcloner-requirements.php';
298
299
		/**
300
		 * The class responsible for XCloner backup archive creation.
301
		 */
302
		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-xcloner-archive.php';
303
304
		/**
305
		 * The class responsible for XCloner API requests.
306
		 */
307
		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-xcloner-api.php';
308
309
		/**
310
		 * The class responsible for the XCloner File System methods.
311
		 */
312
		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-xcloner-file-system.php';
313
314
		/**
315
		 * The class responsible for the XCloner File Transfer methods.
316
		 */
317
		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-xcloner-file-transfer.php';
318
319
		/**
320
		 * The class responsible for the XCloner Scheduler methods.
321
		 */
322
		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-xcloner-scheduler.php';
323
324
		/**
325
		 * The class responsible for the XCloner Encryption methods.
326
		 */
327
		require_once plugin_dir_path(dirname(__FILE__)).'includes/class-xcloner-encryption.php';
328
329
		/**
330
		 * The class responsible for defining all actions that occur in the public-facing
331
		 * side of the site.
332
		 */
333
		require_once plugin_dir_path(dirname(__FILE__)).'public/class-xcloner-public.php';
334
335
		$this->loader = new Xcloner_Loader($this);
336
337
	}
338
339
	/**
340
	 * Define the locale for this plugin for internationalization.
341
	 *
342
	 * Uses the Xcloner_i18n class in order to set the domain and to register the hook
343
	 * with WordPress.
344
	 *
345
	 * @since    1.0.0
346
	 * @access   private
347
	 */
348
	private function set_locale() {
349
350
		$plugin_i18n = new Xcloner_i18n();
351
352
		$this->loader->add_action('plugins_loaded', $plugin_i18n, 'load_plugin_textdomain');
353
354
		//wp_localize_script( 'ajax-script', 'my_ajax_object',
355
		//   array( 'ajax_url' => admin_url( 'admin-ajax.php' ) ) );
356
357
	}
358
359
	/**
360
	 * Register all of the hooks related to the admin area functionality
361
	 * of the plugin.
362
	 *
363
	 * @since    1.0.0
364
	 * @access   private
365
	 */
366
	private function define_admin_hooks() {
367
368
		$plugin_admin = new Xcloner_Admin($this);
369
		$this->plugin_admin = $plugin_admin;
370
371
		$this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_styles');
372
		$this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts');
373
374
		add_action('backup_archive_finished', array($this, 'do_action_after_backup_finished'), 10, 2);
375
	}
376
377
	/**
378
	 * Register the Admin Sidebar menu
379
	 *
380
	 * @access    private
381
	 *
382
	 */
383
	private function define_admin_menu() {
384
385
		add_action('admin_menu', array($this->loader, 'xcloner_backup_add_admin_menu'));
386
387
	}
388
389
	private function define_plugin_settings() {
390
		/**
391
		 * register wporg_settings_init to the admin_init action hook
392
		 */
393
394
		$this->xcloner_settings = new XCloner_Settings($this);
395
396
		if (defined('DOING_CRON') || isset($_POST['hash'])) {
397
398
			if (defined('DOING_CRON') || $_POST['hash'] == "generate_hash") {
399
				$this->xcloner_settings->generate_new_hash();
400
			} else {
401
				$this->xcloner_settings->set_hash($_POST['hash']);
402
			}
403
		}
404
405
		if (defined('DOING_CRON') || !isset($_POST['hash']))
406
		{
407
			add_action('shutdown', function() {
408
				$this->xcloner_filesystem = new Xcloner_File_System($this);
409
				$this->xcloner_filesystem->remove_tmp_filesystem();
410
			});
411
		}
412
413
		$this->xcloner_sanitization 	= new Xcloner_Sanitization();
414
		$this->xcloner_requirements 	= new Xcloner_Requirements($this);
415
416
		add_action('admin_init', array($this->xcloner_settings, 'settings_init'));
417
418
		//adding links to the Manage Plugins Wordpress page for XCloner
419
		add_filter('plugin_action_links', array($this, 'add_plugin_action_links'), 10, 2);
420
421
422
423
	}
424
425
	/*
426
	 * @method get_xcloner_logger()
427
	 * @method get_xcloner_settings()
428
	 * type = core|plugin|theme|translation
429
	 */
430
	public function pre_auto_update($type, $item, $context)
431
	{
432
		if (!$type)
433
		{
434
			return false;
435
		}
436
437
		$exclude_files = array();
438
		$regex = "";
439
		$data = "";
440
441
		$this->get_xcloner_logger()->info(sprintf("Doing automatic backup before %s upgrade, pre_auto_update hook.", $type));
1 ignored issue
show
Bug introduced by
The method get_xcloner_logger() does not exist on Xcloner. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

441
		$this->/** @scrutinizer ignore-call */ 
442
         get_xcloner_logger()->info(sprintf("Doing automatic backup before %s upgrade, pre_auto_update hook.", $type));
Loading history...
442
443
		$content_dir = str_replace(ABSPATH, "", WP_CONTENT_DIR);
444
		$plugins_dir 	= str_replace(ABSPATH, "", WP_PLUGIN_DIR);
445
		$langs_dir 		= $content_dir.DS."languages";
446
		$themes_dir 		= $content_dir.DS."themes";
447
448
		switch ($type) {
449
			case 'core':
450
				$exclude_files = array(
451
									"^(?!(wp-admin|wp-includes|(?!.*\/.*.php)))(.*)$",
452
								);
453
				break;
454
			case 'plugin':
455
456
				$dir_array = explode(DS, $plugins_dir);
457
458
				foreach ($dir_array as $dir)
459
				{
460
					$data .= "\/".$dir;
461
					$regex .= $data."$|";
462
				}
463
464
				$regex .= "\/".implode("\/", $dir_array);
465
466
				$exclude_files = array(
467
									"^(?!(".$regex."))(.*)$",
468
								);
469
				break;
470
			case 'theme':
471
472
				$dir_array = explode(DS, $themes_dir);
473
474
				foreach ($dir_array as $dir)
475
				{
476
					$data .= "\/".$dir;
477
					$regex .= $data."$|";
478
				}
479
480
				$regex .= "\/".implode("\/", $dir_array);
481
482
				$exclude_files = array(
483
									"^(?!(".$regex."))(.*)$",
484
								);
485
				break;
486
			case 'translation':
487
488
				$dir_array = explode(DS, $langs_dir);
489
490
				foreach ($dir_array as $dir)
491
				{
492
					$data .= "\/".$dir;
493
					$regex .= $data."$|";
494
				}
495
496
				$regex .= "\/".implode("\/", $dir_array);
497
498
				$exclude_files = array(
499
									"^(?!(".$regex."))(.*)$",
500
								);
501
				break;
502
		}
503
504
		$schedule = array();
505
506
		$schedule['id'] = 0;
507
		$schedule['name'] = "pre_auto_update";
508
		$schedule['recurrence'] = "single";
509
		$schedule['excluded_files'] = json_encode($exclude_files);
510
		$schedule['table_params'] = json_encode(array("#" => array($this->get_xcloner_settings()->get_db_database())));
1 ignored issue
show
Bug introduced by
The method get_xcloner_settings() does not exist on Xcloner. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

510
		$schedule['table_params'] = json_encode(array("#" => array($this->/** @scrutinizer ignore-call */ get_xcloner_settings()->get_db_database())));
Loading history...
511
512
		$schedule['backup_params'] = new stdClass();
513
		$schedule['backup_params']->email_notification = get_option('admin_email');
514
		$schedule['backup_params']->backup_name = "backup_pre_auto_update_".$type."_[domain]-[time]-sql";
515
516
		try {
517
			$this->xcloner_scheduler->xcloner_scheduler_callback(0, $schedule);
518
		}catch (Exception $e) {
519
			$this->get_xcloner_logger()->error($e->getMessage());
520
		}
521
522
	}
523
524
	/**
525
	 * Register all of the hooks related to the public-facing functionality
526
	 * of the plugin.
527
	 *
528
	 * @since    1.0.0
529
	 * @access   private
530
	 */
531
	private function define_public_hooks() {
532
533
		$plugin_public = new Xcloner_Public($this);
534
535
		$this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_styles');
536
		$this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_scripts');
537
538
	}
539
540
	public function exception_handler() {
541
542
		$logger = new XCloner_Logger($this, "php_system");
543
		$error = error_get_last();
544
545
		if ($error['type'] and $logger)
546
		{
547
			$logger->info($this->friendly_error_type($error['type']).": ".var_export($error, true));
548
		}
549
550
	}
551
552
	public function friendly_error_type($type) {
553
		static $levels = null;
554
		if ($levels === null) {
555
			$levels = [];
556
			foreach (get_defined_constants() as $key=>$value) {
557
				if (strpos($key, 'E_') !== 0) {continue; }
558
					$levels[$value] = $key; //substr($key,2);
559
			}
560
		}
561
		return (isset($levels[$type]) ? $levels[$type] : "Error #{$type}");
562
	}
563
564
    /**
565
     * @method get_xcloner_scheduler()
566
     * @throws Exception
567
     */
568
	private function define_ajax_hooks()
569
	{
570
		//adding the pre-update hook
571
572
		if (is_admin() || defined('DOING_CRON'))
573
		{
574
			$this->xcloner_logger = new XCloner_Logger($this, "xcloner_api");
575
			$this->xcloner_filesystem = new Xcloner_File_System($this);
576
577
			//$this->xcloner_filesystem->set_diff_timestamp_start (strtotime("-15 days"));
578
579
			$this->archive_system = new Xcloner_Archive($this);
580
			$this->xcloner_database = new Xcloner_Database($this);
581
			$this->xcloner_scheduler = new Xcloner_Scheduler($this);
582
			$this->xcloner_remote_storage = new Xcloner_Remote_Storage($this);
583
			$this->xcloner_file_transfer 	= new Xcloner_File_Transfer($this);
584
			$this->xcloner_encryption    	= new Xcloner_Encryption($this);
585
586
			$xcloner_api = new Xcloner_Api($this);
587
588
			add_action('wp_ajax_get_database_tables_action', array($xcloner_api, 'get_database_tables_action'));
589
			add_action('wp_ajax_get_file_system_action', array($xcloner_api, 'get_file_system_action'));
590
			add_action('wp_ajax_scan_filesystem', array($xcloner_api, 'scan_filesystem'));
591
			add_action('wp_ajax_backup_database', array($xcloner_api, 'backup_database'));
592
			add_action('wp_ajax_backup_files', array($xcloner_api, 'backup_files'));
593
			add_action('wp_ajax_save_schedule', array($xcloner_api, 'save_schedule'));
594
			add_action('wp_ajax_get_schedule_by_id', array($xcloner_api, 'get_schedule_by_id'));
595
			add_action('wp_ajax_get_scheduler_list', array($xcloner_api, 'get_scheduler_list'));
596
			add_action('wp_ajax_delete_schedule_by_id', array($xcloner_api, 'delete_schedule_by_id'));
597
			add_action('wp_ajax_delete_backup_by_name', array($xcloner_api, 'delete_backup_by_name'));
598
			add_action('wp_ajax_download_backup_by_name', array($xcloner_api, 'download_backup_by_name'));
599
			add_action('wp_ajax_remote_storage_save_status', array($xcloner_api, 'remote_storage_save_status'));
600
			add_action('wp_ajax_upload_backup_to_remote', array($xcloner_api, 'upload_backup_to_remote'));
601
			add_action('wp_ajax_list_backup_files', array($xcloner_api, 'list_backup_files'));
602
			add_action('wp_ajax_restore_upload_backup', array($xcloner_api, 'restore_upload_backup'));
603
			add_action('wp_ajax_download_restore_script', array($xcloner_api, 'download_restore_script'));
604
			add_action('wp_ajax_copy_backup_remote_to_local', array($xcloner_api, 'copy_backup_remote_to_local'));
605
			add_action('wp_ajax_restore_backup', array($xcloner_api, 'restore_backup'));
606
			add_action('wp_ajax_backup_encryption', array($xcloner_api, 'backup_encryption'));
607
			add_action('wp_ajax_backup_decryption', array($xcloner_api, 'backup_decryption'));
608
			add_action('wp_ajax_get_manage_backups_list', array($xcloner_api, 'get_manage_backups_list'));
609
			add_action('admin_notices', array($this, 'xcloner_error_admin_notices'));
610
611
		}
612
613
		//Do a pre-update backup of targeted files
614
		if ($this->get_xcloner_settings()->get_xcloner_option('xcloner_enable_pre_update_backup'))
615
		{
616
			add_action("pre_auto_update", array($this, "pre_auto_update"), 1, 3);
617
		}
618
	}
619
620
	public function add_plugin_action_links($links, $file) {
621
		if ($file == plugin_basename(dirname(dirname(__FILE__)).'/xcloner.php'))
622
		{
623
			$links[] = '<a href="admin.php?page=xcloner_settings_page">'.__('Settings', 'xcloner-backup-and-restore').'</a>';
624
			$links[] = '<a href="admin.php?page=xcloner_generate_backups_page">'.__('Generate Backup', 'xcloner-backup-and-restore').'</a>';
625
		}
626
627
		return $links;
628
	}
629
630
	public function xcloner_error_admin_notices() {
631
			settings_errors('xcloner_error_message');
632
		}
633
634
	public function define_cron_hooks()
635
	{
636
		//registering new schedule intervals
637
		add_filter('cron_schedules', array($this, 'add_new_intervals'));
638
639
640
		$xcloner_scheduler = $this->get_xcloner_scheduler();
1 ignored issue
show
Bug introduced by
The method get_xcloner_scheduler() does not exist on Xcloner. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

640
		/** @scrutinizer ignore-call */ 
641
  $xcloner_scheduler = $this->get_xcloner_scheduler();
Loading history...
641
		$xcloner_scheduler->update_wp_cron_hooks();
642
643
	}
644
645
	/**
646
	 * @param $schedules
647
	 * @return mixed
648
	 */
649
	public function add_new_intervals($schedules)
650
	{
651
		//weekly scheduler interval
652
		$schedules['weekly'] = array(
653
			'interval' => 604800,
654
			'display' => __('Once Weekly', 'xcloner-backup-and-restore')
655
		);
656
657
		//monthly scheduler interval
658
		$schedules['monthly'] = array(
659
			'interval' => 2635200,
660
			'display' => __('Once Monthly', 'xcloner-backup-and-restore')
661
		);
662
663
		//monthly scheduler interval
664
		$schedules['twicedaily'] = array(
665
			'interval' => 43200,
666
			'display' => __('Twice Daily', 'xcloner-backup-and-restore')
667
		);
668
669
		return $schedules;
670
	}
671
672
673
	/**
674
	 * Run the loader to execute all of the hooks with WordPress.
675
	 *
676
	 * @since    1.0.0
677
	 */
678
	public function run() {
679
		$this->loader->run();
680
	}
681
682
	/**
683
	 * The name of the plugin used to uniquely identify it within the context of
684
	 * WordPress and to define internationalization functionality.
685
	 *
686
	 * @since     1.0.0
687
	 * @return    string    The name of the plugin.
688
	 */
689
	public function get_plugin_name() {
690
		return $this->plugin_name;
691
	}
692
693
	/**
694
	 * The reference to the class that orchestrates the hooks with the plugin.
695
	 *
696
	 * @since     1.0.0
697
	 * @return    Xcloner_Loader    Orchestrates the hooks of the plugin.
698
	 */
699
	public function get_loader() {
700
		return $this->loader;
701
	}
702
703
	public function xcloner_display()
704
	{
705
		// check user capabilities
706
		if (!current_user_can('manage_options')) {
707
			return;
708
		}
709
710
		$page = sanitize_key($_GET['page']);
711
712
		if ($page)
713
		{
714
			$this->display($page);
715
		}
716
717
	}
718
719
	public function display($page)
720
	{
721
		$plugin_admin = new Xcloner_Admin($this);
722
		$this->plugin_admin = $plugin_admin;
723
724
		call_user_func_array(array($this->plugin_admin, $page), array());
725
	}
726
}
727