1
|
|
|
<?php |
|
|
|
|
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* The plugin bootstrap file |
5
|
|
|
* |
6
|
|
|
* This file is read by WordPress to generate the plugin information in the plugin |
7
|
|
|
* admin area. This file also includes all of the dependencies used by the plugin, |
8
|
|
|
* registers the activation and deactivation functions, and defines a function |
9
|
|
|
* that starts the plugin. |
10
|
|
|
* |
11
|
|
|
* @link http://www.thinkovi.com |
12
|
|
|
* @since 1.0.0 |
13
|
|
|
* @package Xcloner |
14
|
|
|
* |
15
|
|
|
* @wordpress-plugin |
16
|
|
|
* Plugin Name: XCloner - Site Backup and Restore |
17
|
|
|
* Plugin URI: http://www.xcloner.com |
18
|
|
|
* Description: XCloner is a tool that will help you manage your website backups, generate/restore/move so your website will be always secured! With XCloner you will be able to clone your site to any other location with just a few clicks, as well as transfer the backup archives to remote FTP, SFTP, DropBox, Amazon S3, Google Drive, WebDAV, BackBlaze, Azure accounts. |
19
|
|
|
* Version: 4.0.2 |
20
|
|
|
* Author: Liuta Ovidiu |
21
|
|
|
* Author URI: http://www.thinkovi.com |
22
|
|
|
* License: GPL-2.0+ |
23
|
|
|
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt |
24
|
|
|
* Text Domain: xcloner-backup-and-restore |
25
|
|
|
* Domain Path: /languages |
26
|
|
|
*/ |
27
|
|
|
|
28
|
|
|
// If this file is called directly, abort. |
29
|
|
|
if ( ! defined( 'WPINC' ) ) { |
30
|
|
|
die; |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
//i will not load the plugin outside admin or cron |
34
|
|
|
if(!is_admin() and !defined('DOING_CRON')) |
|
|
|
|
35
|
|
|
return; |
36
|
|
|
|
37
|
|
|
define("DS", DIRECTORY_SEPARATOR); |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* The code that runs during plugin activation. |
41
|
|
|
* This action is documented in includes/class-xcloner-activator.php |
42
|
|
|
*/ |
43
|
|
|
function activate_xcloner() |
44
|
|
|
{ |
45
|
|
|
require_once plugin_dir_path( __FILE__ ) . 'includes/class-xcloner-activator.php'; |
46
|
|
|
Xcloner_Activator::activate(); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* The code that runs during plugin deactivation. |
51
|
|
|
* This action is documented in includes/class-xcloner-deactivator.php |
52
|
|
|
*/ |
53
|
|
|
function deactivate_xcloner() |
54
|
|
|
{ |
55
|
|
|
require_once plugin_dir_path( __FILE__ ) . 'includes/class-xcloner-deactivator.php'; |
56
|
|
|
Xcloner_Deactivator::deactivate(); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
register_activation_hook( __FILE__, 'activate_xcloner' ); |
60
|
|
|
register_deactivation_hook( __FILE__, 'deactivate_xcloner' ); |
61
|
|
|
|
62
|
|
|
require_once plugin_dir_path( __FILE__ ) . 'includes/class-xcloner-activator.php'; |
63
|
|
|
|
64
|
|
|
if(version_compare(phpversion(), Xcloner_Activator::xcloner_minimum_version, '<')) |
65
|
|
|
{ |
66
|
|
|
?> |
67
|
|
|
<div class="error notice"> |
68
|
|
|
<p><?php echo sprintf(__("XCloner requires minimum PHP version %s in order to run correctly. We have detected your version as %s. Plugin is now deactivated."),Xcloner_Activator::xcloner_minimum_version, phpversion())?></p> |
69
|
|
|
</div> |
70
|
|
|
<?php |
71
|
|
|
require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
72
|
|
|
deactivate_plugins( plugin_basename( __FILE__ ) ); |
73
|
|
|
return; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
$db_installed_ver = get_option( "xcloner_db_version" ); |
77
|
|
|
$xcloner_db_version = Xcloner_Activator::xcloner_db_version; |
78
|
|
|
|
79
|
|
|
if($db_installed_ver != $xcloner_db_version) |
80
|
|
|
{ |
81
|
|
|
Xcloner_Activator::activate(); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* The core plugin class that is used to define internationalization, |
87
|
|
|
* admin-specific hooks, and public-facing site hooks. |
88
|
|
|
*/ |
89
|
|
|
|
90
|
|
|
function xcloner_stop_heartbeat() { |
91
|
|
|
wp_deregister_script('heartbeat'); |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
if(isset($_GET['page']) and stristr($_GET['page'] , "xcloner_")) |
|
|
|
|
95
|
|
|
{ |
96
|
|
|
add_action( 'init', 'xcloner_stop_heartbeat', 1 ); |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* Begins execution of the plugin. |
101
|
|
|
* |
102
|
|
|
* Since everything within the plugin is registered via hooks, |
103
|
|
|
* then kicking off the plugin from this point in the file does |
104
|
|
|
* not affect the page life cycle. |
105
|
|
|
* |
106
|
|
|
* @since 1.0.0 |
107
|
|
|
*/ |
108
|
|
|
function run_xcloner() |
109
|
|
|
{ |
110
|
|
|
$plugin = new Xcloner(); |
111
|
|
|
$plugin->check_dependencies(); |
112
|
|
|
$plugin->init(); |
113
|
|
|
$plugin->run(); |
114
|
|
|
|
115
|
|
|
return $plugin; |
116
|
|
|
|
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
require_once(plugin_dir_path( __FILE__ ) . '/vendor/autoload.php'); |
120
|
|
|
require plugin_dir_path( __FILE__ ) . 'includes/class-xcloner.php'; |
121
|
|
|
|
122
|
|
|
try{ |
123
|
|
|
|
124
|
|
|
$xcloner_plugin = run_xcloner(); |
125
|
|
|
|
126
|
|
|
}catch(Exception $e){ |
127
|
|
|
|
128
|
|
|
echo $e->getMessage(); |
129
|
|
|
|
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
|
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.