class-pro.php
6.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
<?php
/**
* Class for calling the BackWPup Pro Features
*/
final class BackWPup_Pro {
private static $instance = NULL;
/**
*
*/
private function __construct() {
//Add menu page after logs
add_filter( 'backwpup_admin_pages', array( $this, 'admin_page_wizards'), 4 );
//Add or overwrite destinations
add_filter( 'backwpup_register_destination', array( $this, 'register_destination' ), 5 );
//Add or overwrite job types
add_filter( 'backwpup_job_types', array( $this, 'job_types' ), 5 );
//Add or overwrite wizards
add_filter( 'backwpup_pro_wizards', array( $this, 'wizards' ), 5 );
//Add Export Job things
add_filter( 'backwpup_page_jobs_get_bulk_actions',array( 'BackWPup_Pro_Export_Jobs', 'page_jobs_get_bulk_actions' ) );
add_filter( 'backwpup_page_jobs_actions',array( 'BackWPup_Pro_Export_Jobs', 'page_jobs_actions' ), 10, 3);
add_action( 'backwpup_page_jobs_load', array( 'BackWPup_Pro_Export_Jobs', 'page_jobs_load' ) );
//add admin menu points for prp
if ( ! defined( 'DOING_CRON' ) ) {
add_action( 'admin_bar_menu', array( $this, 'admin_bar_menu' ), 101 );
}
//add owen API Keys
if ( isset( $_REQUEST['page'] ) && $_REQUEST['page'] == 'backwpupsettings' ) {
add_action( 'admin_init', array( 'BackWPup_Pro_Settings_APIKeys', 'get_instance' ), 5 );
}
if ( file_exists( dirname( __FILE__ ) . '/autoupdate.php' ) ) {
include dirname( __FILE__ ) . '/autoupdate.php';
}
}
/**
* @static
* @return \BackWPup_Pro
*/
public static function get_instance() {
if (NULL === self::$instance) {
self::$instance = new self;
}
return self::$instance;
}
/**
* Add extra Destinations or overwrite
*
* @param $destinations
* @return array
*/
public function register_destination( $destinations ) {
//add/overwrite BackWPup Destinations
// to folder
$destinations[ 'FOLDER' ][ 'class'] = 'BackWPup_Pro_Destination_Folder';
$destinations[ 'FOLDER' ][ 'can_sync'] = TRUE;
// backup with mail
$destinations[ 'EMAIL' ][ 'class'] = 'BackWPup_Pro_Destination_Email';
// backup to ftp
$destinations[ 'FTP' ][ 'class'] = 'BackWPup_Pro_Destination_Ftp';
// backup to dropbox
$destinations[ 'DROPBOX' ][ 'class'] = 'BackWPup_Pro_Destination_Dropbox';
$destinations[ 'DROPBOX' ][ 'can_sync'] = TRUE;
// Backup to S3
$destinations[ 'S3' ][ 'class'] = 'BackWPup_Pro_Destination_S3';
$destinations[ 'S3' ][ 'can_sync'] = TRUE;
// backup to MS Azure
$destinations[ 'MSAZURE' ][ 'class'] = 'BackWPup_Pro_Destination_MSAzure';
$destinations[ 'MSAZURE' ][ 'can_sync'] = TRUE;
// backup to Rackspace Cloud
$destinations[ 'RSC' ][ 'class'] = 'BackWPup_Pro_Destination_RSC';
$destinations[ 'RSC' ][ 'can_sync'] = TRUE;
// backup to Sugarsync
$destinations[ 'SUGARSYNC' ][ 'class'] = 'BackWPup_Pro_Destination_SugarSync';
// backup to Amazon Glacier
$destinations[ 'GLACIER' ] = array(
'class' => 'BackWPup_Pro_Destination_Glacier',
'info' => array(
'ID' => 'GLACIER',
'name' => __( 'Glacier', 'backwpup' ),
'description' => __( 'Backup to Amazon Glacier', 'backwpup' ),
),
'can_sync' => FALSE,
'needed' => array(
'php_version' => '5.3.3',
'functions' => array( 'curl_exec' ),
'classes' => array( 'XMLWriter' )
),
'autoload' => array( 'Aws\\Common' => BackWPup::get_plugin_data( 'plugindir' ) . '/vendor',
'Aws\\Glacier' => BackWPup::get_plugin_data( 'plugindir' ) . '/vendor',
'Symfony\\Component\\EventDispatcher' => BackWPup::get_plugin_data( 'plugindir' ) . '/vendor',
'Guzzle' => BackWPup::get_plugin_data( 'plugindir' ) . '/vendor' )
);
// backup to Google Drive
$destinations[ 'GDRIVE' ] = array(
'class' => 'BackWPup_Pro_Destination_GDrive',
'info' => array(
'ID' => 'GDRIVE',
'name' => __( 'GDrive', 'backwpup' ),
'description' => __( 'Backup to Google Drive', 'backwpup' ),
),
'can_sync' => TRUE,
'needed' => array(
'php_version' => '',
'functions' => array( 'curl_init', 'json_decode', 'http_build_query' ),
'classes' => array()
),
'autoload' => array()
);
return $destinations;
}
/**
* Add extra Job types or overwrite
*
* @param $job_types
* @return array
*/
public function job_types( $job_types ) {
if ( class_exists( 'mysqli' ) )
$job_types[ 'DBDUMP' ] = new BackWPup_Pro_JobType_DBDump;
$job_types[ 'FILE' ] = new BackWPup_Pro_JobType_File;
$job_types[ 'WPEXP' ] = new BackWPup_Pro_JobType_WPEXP;
$job_types[ 'WPPLUGIN' ] = new BackWPup_Pro_JobType_WPPlugin;
$job_types[ 'DBCHECK' ] = new BackWPup_Pro_JobType_DBCheck;
return $job_types;
}
/**
* Add extra Wizards or overwrite
*
* @param $wizards
* @return array
*/
public function wizards( $wizards ) {
$wizards[ 'SYSTEMTEST' ] = new BackWPup_Pro_Wizard_SystemTest; //first in the list
$wizards[ 'JOB' ] = new BackWPup_Pro_Wizard_Job;
$wizards[ 'JOBIMPORT' ] = new BackWPup_Pro_Wizard_JobImport;
return $wizards;
}
/**
* Add wizards Page
*/
public function admin_page_wizards( $page_hooks ) {
$page_hooks[ 'backwpupwizards' ] = add_submenu_page( 'backwpup', __( 'Wizards', 'backwpup' ), __( 'Wizards', 'backwpup' ), 'backwpup', 'backwpupwizard', array( 'BackWPup_Pro_Page_Wizard', 'page' ) );
add_action( 'load-' . $page_hooks[ 'backwpupwizards' ], array( 'BackWPup_Admin', 'init_general' ) );
add_action( 'load-' . $page_hooks[ 'backwpupwizards' ], array( 'BackWPup_Pro_Page_Wizard', 'load' ) );
add_action( 'admin_print_styles-' . $page_hooks[ 'backwpupwizards' ], array( 'BackWPup_Pro_Page_Wizard', 'admin_print_styles' ) );
add_action( 'admin_print_scripts-' . $page_hooks[ 'backwpupwizards' ], array( 'BackWPup_Pro_Page_Wizard', 'admin_print_scripts' ) );
return $page_hooks;
}
/**
* Add admin bar menu points for pro
*/
public function admin_bar_menu() {
global $wp_admin_bar;
if ( ! current_user_can( 'backwpup' ) || ! get_site_option( 'backwpup_cfg_showadminbar' ) ) {
return;
}
/* @var WP_Admin_bar $wp_admin_bar */
$wizards = BackWPup::get_wizards();
$wp_admin_bar->add_menu( array(
'id' => 'backwpup_wizard',
'parent' => 'backwpup',
'title' => __( 'Wizards', 'backwpup' ),
'href' => network_admin_url( 'admin.php?page=backwpupwizard' )
) );
foreach ( $wizards as $wizard_class ) {
if ( ! current_user_can( $wizard_class->info[ 'cap' ] ) )
continue;
$wp_admin_bar->add_menu( array(
'id' => 'backwpup_wizard_' . $wizard_class->info[ 'ID' ],
'parent' => 'backwpup_wizard',
'title' => $wizard_class->info[ 'name' ],
'href' => network_admin_url( 'admin.php?page=backwpupwizard&wizard_start=' . $wizard_class->info[ 'ID' ] )
) );
}
}
private function __clone() {}
}