|
@@ -88,15 +88,15 @@ discard block |
|
|
block discarded – undo |
|
88
|
88
|
|
|
89
|
89
|
} |
|
90
|
90
|
|
|
91
|
|
- public function check_dependencies(){ |
|
|
91
|
+ public function check_dependencies() { |
|
92
|
92
|
|
|
93
|
93
|
$backup_storage_path = realpath(__DIR__.DS."..".DS."..".DS."..").DS."backups".DS; |
|
94
|
94
|
|
|
95
|
95
|
define("XCLONER_STORAGE_PATH", realpath($backup_storage_path)); |
|
96
|
96
|
|
|
97
|
|
- if(!is_dir($backup_storage_path)) |
|
|
97
|
+ if (!is_dir($backup_storage_path)) |
|
98
|
98
|
{ |
|
99
|
|
- if(!@mkdir($backup_storage_path)) |
|
|
99
|
+ if (!@mkdir($backup_storage_path)) |
|
100
|
100
|
{ |
|
101
|
101
|
$status = "error"; |
|
102
|
102
|
$message = sprintf(__("Unable to create the Backup Storage Location Folder %s . Please fix this before starting the backup process."), $backup_storage_path); |
|
@@ -104,7 +104,7 @@ discard block |
|
|
block discarded – undo |
|
104
|
104
|
return; |
|
105
|
105
|
} |
|
106
|
106
|
} |
|
107
|
|
- if(!is_writable($backup_storage_path)) |
|
|
107
|
+ if (!is_writable($backup_storage_path)) |
|
108
|
108
|
{ |
|
109
|
109
|
$status = "error"; |
|
110
|
110
|
$message = sprintf(__("Unable to write to the Backup Storage Location Folder %s . Please fix this before starting the backup process."), $backup_storage_path); |
|
@@ -118,15 +118,15 @@ discard block |
|
|
block discarded – undo |
|
118
|
118
|
public function trigger_message($message, $status = "error", $message_param1 = "", $message_param2 = "", $message_param3 = "") |
|
119
|
119
|
{ |
|
120
|
120
|
$message = sprintf(__($message), $message_param1, $message_param2, $message_param3); |
|
121
|
|
- add_action( 'xcloner_admin_notices', array($this,"trigger_message_notice"), 10, 2); |
|
122
|
|
- do_action( 'xcloner_admin_notices', $message, $status); |
|
|
121
|
+ add_action('xcloner_admin_notices', array($this, "trigger_message_notice"), 10, 2); |
|
|
122
|
+ do_action('xcloner_admin_notices', $message, $status); |
|
123
|
123
|
} |
|
124
|
124
|
|
|
125
|
125
|
public function trigger_message_notice($message, $status = "success") |
|
126
|
126
|
{ |
|
127
|
127
|
?> |
|
128
|
128
|
<div class="notice notice-<?php echo $status?> is-dismissible"> |
|
129
|
|
- <p><?php _e( $message, 'xcloner-backup-and-restore' ); ?></p> |
|
|
129
|
+ <p><?php _e($message, 'xcloner-backup-and-restore'); ?></p> |
|
130
|
130
|
</div> |
|
131
|
131
|
<?php |
|
132
|
132
|
} |
|
@@ -153,79 +153,79 @@ discard block |
|
|
block discarded – undo |
|
153
|
153
|
* The class responsible for orchestrating the actions and filters of the |
|
154
|
154
|
* core plugin. |
|
155
|
155
|
*/ |
|
156
|
|
- require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-xcloner-loader.php'; |
|
|
156
|
+ require_once plugin_dir_path(dirname(__FILE__)).'includes/class-xcloner-loader.php'; |
|
157
|
157
|
|
|
158
|
158
|
/** |
|
159
|
159
|
* The class responsible for defining internationalization functionality |
|
160
|
160
|
* of the plugin. |
|
161
|
161
|
*/ |
|
162
|
|
- require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-xcloner-i18n.php'; |
|
|
162
|
+ require_once plugin_dir_path(dirname(__FILE__)).'includes/class-xcloner-i18n.php'; |
|
163
|
163
|
|
|
164
|
164
|
/** |
|
165
|
165
|
* The class responsible for defining all actions that occur in the admin area. |
|
166
|
166
|
*/ |
|
167
|
|
- require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-xcloner-admin.php'; |
|
|
167
|
+ require_once plugin_dir_path(dirname(__FILE__)).'admin/class-xcloner-admin.php'; |
|
168
|
168
|
|
|
169
|
169
|
/** |
|
170
|
170
|
* The class responsible for debugging XCloner. |
|
171
|
171
|
*/ |
|
172
|
|
- require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-xcloner-logger.php'; |
|
|
172
|
+ require_once plugin_dir_path(dirname(__FILE__)).'includes/class-xcloner-logger.php'; |
|
173
|
173
|
|
|
174
|
174
|
/** |
|
175
|
175
|
* The class responsible for defining the admin settings area. |
|
176
|
176
|
*/ |
|
177
|
|
- require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-xcloner-settings.php'; |
|
|
177
|
+ require_once plugin_dir_path(dirname(__FILE__)).'includes/class-xcloner-settings.php'; |
|
178
|
178
|
|
|
179
|
179
|
/** |
|
180
|
180
|
* The class responsible for defining the Remote Storage settings area. |
|
181
|
181
|
*/ |
|
182
|
|
- require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-xcloner-remote-storage.php'; |
|
|
182
|
+ require_once plugin_dir_path(dirname(__FILE__)).'includes/class-xcloner-remote-storage.php'; |
|
183
|
183
|
|
|
184
|
184
|
/** |
|
185
|
185
|
* The class responsible for implementing the database backup methods. |
|
186
|
186
|
*/ |
|
187
|
|
- require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-xcloner-database.php'; |
|
|
187
|
+ require_once plugin_dir_path(dirname(__FILE__)).'includes/class-xcloner-database.php'; |
|
188
|
188
|
|
|
189
|
189
|
/** |
|
190
|
190
|
* The class responsible for sanitization of users input. |
|
191
|
191
|
*/ |
|
192
|
|
- require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-xcloner-sanitization.php'; |
|
|
192
|
+ require_once plugin_dir_path(dirname(__FILE__)).'includes/class-xcloner-sanitization.php'; |
|
193
|
193
|
|
|
194
|
194
|
/** |
|
195
|
195
|
* The class responsible for XCloner system requirements validation. |
|
196
|
196
|
*/ |
|
197
|
|
- require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-xcloner-requirements.php'; |
|
|
197
|
+ require_once plugin_dir_path(dirname(__FILE__)).'includes/class-xcloner-requirements.php'; |
|
198
|
198
|
|
|
199
|
199
|
/** |
|
200
|
200
|
* The class responsible for XCloner backup archive creation. |
|
201
|
201
|
*/ |
|
202
|
|
- require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-xcloner-archive.php'; |
|
|
202
|
+ require_once plugin_dir_path(dirname(__FILE__)).'includes/class-xcloner-archive.php'; |
|
203
|
203
|
|
|
204
|
204
|
/** |
|
205
|
205
|
* The class responsible for XCloner API requests. |
|
206
|
206
|
*/ |
|
207
|
|
- require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-xcloner-api.php'; |
|
|
207
|
+ require_once plugin_dir_path(dirname(__FILE__)).'includes/class-xcloner-api.php'; |
|
208
|
208
|
|
|
209
|
209
|
/** |
|
210
|
210
|
* The class responsible for the XCloner File System methods. |
|
211
|
211
|
*/ |
|
212
|
|
- require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-xcloner-file-system.php'; |
|
|
212
|
+ require_once plugin_dir_path(dirname(__FILE__)).'includes/class-xcloner-file-system.php'; |
|
213
|
213
|
|
|
214
|
214
|
/** |
|
215
|
215
|
* The class responsible for the XCloner File Transfer methods. |
|
216
|
216
|
*/ |
|
217
|
|
- require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-xcloner-file-transfer.php'; |
|
|
217
|
+ require_once plugin_dir_path(dirname(__FILE__)).'includes/class-xcloner-file-transfer.php'; |
|
218
|
218
|
|
|
219
|
219
|
/** |
|
220
|
220
|
* The class responsible for the XCloner Scheduler methods. |
|
221
|
221
|
*/ |
|
222
|
|
- require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-xcloner-scheduler.php'; |
|
|
222
|
+ require_once plugin_dir_path(dirname(__FILE__)).'includes/class-xcloner-scheduler.php'; |
|
223
|
223
|
|
|
224
|
224
|
/** |
|
225
|
225
|
* The class responsible for defining all actions that occur in the public-facing |
|
226
|
226
|
* side of the site. |
|
227
|
227
|
*/ |
|
228
|
|
- require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-xcloner-public.php'; |
|
|
228
|
+ require_once plugin_dir_path(dirname(__FILE__)).'public/class-xcloner-public.php'; |
|
229
|
229
|
|
|
230
|
230
|
$this->loader = new Xcloner_Loader(); |
|
231
|
231
|
|
|
@@ -244,7 +244,7 @@ discard block |
|
|
block discarded – undo |
|
244
|
244
|
|
|
245
|
245
|
$plugin_i18n = new Xcloner_i18n(); |
|
246
|
246
|
|
|
247
|
|
- $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' ); |
|
|
247
|
+ $this->loader->add_action('plugins_loaded', $plugin_i18n, 'load_plugin_textdomain'); |
|
248
|
248
|
|
|
249
|
249
|
//wp_localize_script( 'ajax-script', 'my_ajax_object', |
|
250
|
250
|
// array( 'ajax_url' => admin_url( 'admin-ajax.php' ) ) ); |
|
@@ -260,11 +260,11 @@ discard block |
|
|
block discarded – undo |
|
260
|
260
|
*/ |
|
261
|
261
|
private function define_admin_hooks() { |
|
262
|
262
|
|
|
263
|
|
- $plugin_admin = new Xcloner_Admin( $this->get_plugin_name(), $this->get_version() ); |
|
|
263
|
+ $plugin_admin = new Xcloner_Admin($this->get_plugin_name(), $this->get_version()); |
|
264
|
264
|
$this->plugin_admin = $plugin_admin; |
|
265
|
265
|
|
|
266
|
|
- $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' ); |
|
267
|
|
- $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' ); |
|
|
266
|
+ $this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_styles'); |
|
|
267
|
+ $this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts'); |
|
268
|
268
|
|
|
269
|
269
|
} |
|
270
|
270
|
|
|
@@ -273,13 +273,13 @@ discard block |
|
|
block discarded – undo |
|
273
|
273
|
* |
|
274
|
274
|
* @access private |
|
275
|
275
|
*/ |
|
276
|
|
- private function define_admin_menu(){ |
|
|
276
|
+ private function define_admin_menu() { |
|
277
|
277
|
|
|
278
|
278
|
add_action('admin_menu', array($this->loader, 'xcloner_backup_add_admin_menu')); |
|
279
|
279
|
|
|
280
|
280
|
} |
|
281
|
281
|
|
|
282
|
|
- private function define_plugin_settings(){ |
|
|
282
|
+ private function define_plugin_settings() { |
|
283
|
283
|
/** |
|
284
|
284
|
* register wporg_settings_init to the admin_init action hook |
|
285
|
285
|
*/ |
|
@@ -296,10 +296,10 @@ discard block |
|
|
block discarded – undo |
|
296
|
296
|
*/ |
|
297
|
297
|
private function define_public_hooks() { |
|
298
|
298
|
|
|
299
|
|
- $plugin_public = new Xcloner_Public( $this->get_plugin_name(), $this->get_version() ); |
|
|
299
|
+ $plugin_public = new Xcloner_Public($this->get_plugin_name(), $this->get_version()); |
|
300
|
300
|
|
|
301
|
|
- $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' ); |
|
302
|
|
- $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' ); |
|
|
301
|
+ $this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_styles'); |
|
|
302
|
+ $this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_scripts'); |
|
303
|
303
|
|
|
304
|
304
|
} |
|
305
|
305
|
|
|
@@ -308,20 +308,20 @@ discard block |
|
|
block discarded – undo |
|
308
|
308
|
$logger = new XCloner_Logger("php_system"); |
|
309
|
309
|
$error = error_get_last(); |
|
310
|
310
|
|
|
311
|
|
- if($error['type'] and $logger) |
|
|
311
|
+ if ($error['type'] and $logger) |
|
312
|
312
|
{ |
|
313
|
|
- $logger->info($this->friendly_error_type ($error['type']).": ".var_export($error, true)); |
|
|
313
|
+ $logger->info($this->friendly_error_type($error['type']).": ".var_export($error, true)); |
|
314
|
314
|
} |
|
315
|
315
|
|
|
316
|
316
|
} |
|
317
|
317
|
|
|
318
|
318
|
function friendly_error_type($type) { |
|
319
|
|
- static $levels=null; |
|
320
|
|
- if ($levels===null) { |
|
321
|
|
- $levels=[]; |
|
|
319
|
+ static $levels = null; |
|
|
320
|
+ if ($levels === null) { |
|
|
321
|
+ $levels = []; |
|
322
|
322
|
foreach (get_defined_constants() as $key=>$value) { |
|
323
|
|
- if (strpos($key,'E_')!==0) {continue;} |
|
324
|
|
- $levels[$value]= $key; //substr($key,2); |
|
|
323
|
+ if (strpos($key, 'E_') !== 0) {continue; } |
|
|
324
|
+ $levels[$value] = $key; //substr($key,2); |
|
325
|
325
|
} |
|
326
|
326
|
} |
|
327
|
327
|
return (isset($levels[$type]) ? $levels[$type] : "Error #{$type}"); |
|
@@ -332,27 +332,27 @@ discard block |
|
|
block discarded – undo |
|
332
|
332
|
//$plugin_public = new Xcloner_Public( $this->get_plugin_name(), $this->get_version() ); |
|
333
|
333
|
//$this->loader->add_action( 'wp_ajax_get_database_tables_action', $plugin_public, array('Xcloner_Api','get_database_tables_action') ); |
|
334
|
334
|
|
|
335
|
|
- if(is_admin()) |
|
|
335
|
+ if (is_admin()) |
|
336
|
336
|
{ |
|
337
|
337
|
$xcloner_api = new Xcloner_Api(); |
|
338
|
338
|
|
|
339
|
|
- add_action( 'wp_ajax_get_database_tables_action' , array($xcloner_api,'get_database_tables_action') ); |
|
340
|
|
- add_action( 'wp_ajax_get_file_system_action' , array($xcloner_api,'get_file_system_action') ); |
|
341
|
|
- add_action( 'wp_ajax_scan_filesystem' , array($xcloner_api,'scan_filesystem') ); |
|
342
|
|
- add_action( 'wp_ajax_backup_database' , array($xcloner_api,'backup_database') ); |
|
343
|
|
- add_action( 'wp_ajax_backup_files' , array($xcloner_api,'backup_files') ); |
|
344
|
|
- add_action( 'wp_ajax_save_schedule' , array($xcloner_api,'save_schedule') ); |
|
345
|
|
- add_action( 'wp_ajax_get_schedule_by_id' , array($xcloner_api,'get_schedule_by_id') ); |
|
346
|
|
- add_action( 'wp_ajax_get_scheduler_list' , array($xcloner_api,'get_scheduler_list') ); |
|
347
|
|
- add_action( 'wp_ajax_delete_schedule_by_id' , array($xcloner_api,'delete_schedule_by_id') ); |
|
348
|
|
- add_action( 'wp_ajax_delete_backup_by_name' , array($xcloner_api,'delete_backup_by_name') ); |
|
349
|
|
- add_action( 'wp_ajax_download_backup_by_name' , array($xcloner_api,'download_backup_by_name') ); |
|
350
|
|
- add_action( 'wp_ajax_remote_storage_save_status' , array($xcloner_api,'remote_storage_save_status') ); |
|
351
|
|
- add_action( 'wp_ajax_upload_backup_to_remote' , array($xcloner_api,'upload_backup_to_remote') ); |
|
352
|
|
- add_action( 'wp_ajax_list_backup_files' , array($xcloner_api,'list_backup_files') ); |
|
353
|
|
- add_action( 'wp_ajax_restore_upload_backup' , array($xcloner_api,'restore_upload_backup') ); |
|
354
|
|
- add_action( 'wp_ajax_download_restore_script' , array($xcloner_api,'download_restore_script') ); |
|
355
|
|
- add_action( 'admin_notices', array($this, 'xcloner_error_admin_notices' )); |
|
|
339
|
+ add_action('wp_ajax_get_database_tables_action', array($xcloner_api, 'get_database_tables_action')); |
|
|
340
|
+ add_action('wp_ajax_get_file_system_action', array($xcloner_api, 'get_file_system_action')); |
|
|
341
|
+ add_action('wp_ajax_scan_filesystem', array($xcloner_api, 'scan_filesystem')); |
|
|
342
|
+ add_action('wp_ajax_backup_database', array($xcloner_api, 'backup_database')); |
|
|
343
|
+ add_action('wp_ajax_backup_files', array($xcloner_api, 'backup_files')); |
|
|
344
|
+ add_action('wp_ajax_save_schedule', array($xcloner_api, 'save_schedule')); |
|
|
345
|
+ add_action('wp_ajax_get_schedule_by_id', array($xcloner_api, 'get_schedule_by_id')); |
|
|
346
|
+ add_action('wp_ajax_get_scheduler_list', array($xcloner_api, 'get_scheduler_list')); |
|
|
347
|
+ add_action('wp_ajax_delete_schedule_by_id', array($xcloner_api, 'delete_schedule_by_id')); |
|
|
348
|
+ add_action('wp_ajax_delete_backup_by_name', array($xcloner_api, 'delete_backup_by_name')); |
|
|
349
|
+ add_action('wp_ajax_download_backup_by_name', array($xcloner_api, 'download_backup_by_name')); |
|
|
350
|
+ add_action('wp_ajax_remote_storage_save_status', array($xcloner_api, 'remote_storage_save_status')); |
|
|
351
|
+ add_action('wp_ajax_upload_backup_to_remote', array($xcloner_api, 'upload_backup_to_remote')); |
|
|
352
|
+ add_action('wp_ajax_list_backup_files', array($xcloner_api, 'list_backup_files')); |
|
|
353
|
+ add_action('wp_ajax_restore_upload_backup', array($xcloner_api, 'restore_upload_backup')); |
|
|
354
|
+ add_action('wp_ajax_download_restore_script', array($xcloner_api, 'download_restore_script')); |
|
|
355
|
+ add_action('admin_notices', array($this, 'xcloner_error_admin_notices')); |
|
356
|
356
|
|
|
357
|
357
|
//if (is_admin()) { |
|
358
|
358
|
add_filter('plugin_action_links', array($this, 'add_plugin_action_links'), 10, 2); |
|
@@ -361,7 +361,7 @@ discard block |
|
|
block discarded – undo |
|
361
|
361
|
} |
|
362
|
362
|
|
|
363
|
363
|
function add_plugin_action_links($links, $file) { |
|
364
|
|
- if ($file == plugin_basename(dirname(dirname(__FILE__)) . '/xcloner.php')) |
|
|
364
|
+ if ($file == plugin_basename(dirname(dirname(__FILE__)).'/xcloner.php')) |
|
365
|
365
|
{ |
|
366
|
366
|
$links[] = '<a href="admin.php?page=xcloner_settings_page">'.__('Settings', 'xcloner-backup-and-restore').'</a>'; |
|
367
|
367
|
$links[] = '<a href="admin.php?page=xcloner_generate_backups_page">'.__('Generate Backup', 'xcloner-backup-and-restore').'</a>'; |
|
@@ -371,13 +371,13 @@ discard block |
|
|
block discarded – undo |
|
371
|
371
|
} |
|
372
|
372
|
|
|
373
|
373
|
public function xcloner_error_admin_notices() { |
|
374
|
|
- settings_errors( 'xcloner_error_message' ); |
|
|
374
|
+ settings_errors('xcloner_error_message'); |
|
375
|
375
|
} |
|
376
|
376
|
|
|
377
|
377
|
public function define_cron_hooks() |
|
378
|
378
|
{ |
|
379
|
379
|
//registering new schedule intervals |
|
380
|
|
- add_filter( 'cron_schedules', array($this, 'add_new_intervals')); |
|
|
380
|
+ add_filter('cron_schedules', array($this, 'add_new_intervals')); |
|
381
|
381
|
|
|
382
|
382
|
|
|
383
|
383
|
$xcloner_scheduler = new Xcloner_Scheduler(); |
|
@@ -451,7 +451,7 @@ discard block |
|
|
block discarded – undo |
|
451
|
451
|
|
|
452
|
452
|
public function display($page) |
|
453
|
453
|
{ |
|
454
|
|
- $plugin_admin = new Xcloner_Admin( $this->get_plugin_name(), $this->get_version() ); |
|
|
454
|
+ $plugin_admin = new Xcloner_Admin($this->get_plugin_name(), $this->get_version()); |
|
455
|
455
|
$this->plugin_admin = $plugin_admin; |
|
456
|
456
|
|
|
457
|
457
|
call_user_func_array(array($this->plugin_admin, $page), array()); |