backup
Last commit date
com
3 years ago
languages
7 years ago
public
3 years ago
BackupGuard.php
3 years ago
README.txt
3 years ago
backup.php
3 years ago
index.php
10 years ago
BackupGuard.php
1139 lines
| 1 | <?php |
| 2 | |
| 3 | //The code that runs during plugin activation. |
| 4 | function activate_backup_guard() |
| 5 | { |
| 6 | //check if database should be updated |
| 7 | if (backupGuardShouldUpdate()) { |
| 8 | SGBoot::install(); |
| 9 | SGBoot::didInstallForFirstTime(); |
| 10 | } |
| 11 | } |
| 12 | |
| 13 | // The code that runs during plugin deactivation. |
| 14 | function uninstall_backup_guard() |
| 15 | { |
| 16 | SGBoot::uninstall(); |
| 17 | } |
| 18 | |
| 19 | function deactivate_backup_guard() |
| 20 | { |
| 21 | $pluginCapabilities = backupGuardGetCapabilities(); |
| 22 | if ($pluginCapabilities != BACKUP_GUARD_CAPABILITIES_FREE) { |
| 23 | include_once SG_LIB_PATH . 'SGAuthClient.php'; |
| 24 | SGAuthClient::getInstance()->logout(); |
| 25 | SGConfig::set('SG_LICENSE_CHECK_TS', 0, true); |
| 26 | SGConfig::set('SG_LOGGED_USER', '', true); |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | function backupGuardMaybeShortenEddFilename($return, $package) |
| 31 | { |
| 32 | if (strpos($package, 'backup-guard') !== false) { |
| 33 | add_filter('wp_unique_filename', 'backupGuardShortenEddFilename', 10, 2); |
| 34 | } |
| 35 | return $return; |
| 36 | } |
| 37 | |
| 38 | function backupGuardShortenEddFilename($filename, $ext) |
| 39 | { |
| 40 | $filename = substr($filename, 0, 20) . $ext; |
| 41 | remove_filter('wp_unique_filename', 'backupGuardShortenEddFilename', 10); |
| 42 | return $filename; |
| 43 | } |
| 44 | |
| 45 | add_filter('upgrader_pre_download', 'backupGuardMaybeShortenEddFilename', 10, 4); |
| 46 | |
| 47 | register_activation_hook(SG_BACKUP_GUARD_MAIN_FILE, 'activate_backup_guard'); |
| 48 | register_uninstall_hook(SG_BACKUP_GUARD_MAIN_FILE, 'uninstall_backup_guard'); |
| 49 | register_deactivation_hook(SG_BACKUP_GUARD_MAIN_FILE, 'deactivate_backup_guard'); |
| 50 | |
| 51 | // Register Admin Menus for single and multisite |
| 52 | if (is_multisite()) { |
| 53 | add_action('network_admin_menu', 'backup_guard_admin_menu'); |
| 54 | } else { |
| 55 | add_action('admin_menu', 'backup_guard_admin_menu'); |
| 56 | } |
| 57 | |
| 58 | function backup_guard_admin_menu() |
| 59 | { |
| 60 | $capability = 'manage_options'; |
| 61 | if (defined('SG_USER_MODE') && SG_USER_MODE) { |
| 62 | $capability = 'read'; |
| 63 | } |
| 64 | |
| 65 | add_menu_page('Backups', 'BackupGuard', $capability, 'backup_guard_backups', 'includeAllPages', 'data:image/svg+xml;base64,PHN2ZyBpZD0iTGF5ZXJfMSIgZGF0YS1uYW1lPSJMYXllciAxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA2MzAuMzQgNjYzLjAzIj48ZGVmcz48c3R5bGU+LmNscy0xe2ZpbGw6I2ZmZjt9PC9zdHlsZT48L2RlZnM+PHRpdGxlPkFydGJvYXJkIDI8L3RpdGxlPjxwYXRoIGNsYXNzPSJjbHMtMSIgZD0iTTUzMC4xMSwxODUuNzljLTcxLjktOC44Mi0xMzcuNzMtNDAtMTkwLTg2LjU3djkyLjY1YTI4MC41OSwyODAuNTksMCwwLDAsMTE2LjUyLDUyYy05LjE0LDg5LjQzLTUyLDE2OS41NS0xMTYuNTIsMjI4Ljg3djkwLjRDNDU5Ljg0LDQ3Ny4xMyw1MzAuNiwzMzMuNDIsNTMwLjExLDE4NS43OVoiLz48cGF0aCBjbGFzcz0iY2xzLTEiIGQ9Ik0xNzQuMjksMjQ0YTI4MC40NiwyODAuNDYsMCwwLDAsMTE1Ljc3LTUxLjExVjEwMGMtNTIuNDQsNDYuMjgtMTE3LjYyLDc3LTE4OS44Myw4NS4xNUM5OS41NCwzMzMsMTcwLjIyLDQ3Ni44MiwyOTAuMDYsNTYzVjQ3Mi4wOUMyMjYsNDEyLjg2LDE4My40MiwzMzMuMDYsMTc0LjI5LDI0NFoiLz48L3N2Zz4=', 74); |
| 66 | |
| 67 | add_submenu_page('backup_guard_backups', _backupGuardT('Backups', true), _backupGuardT('Backups', true), $capability, 'backup_guard_backups', 'includeAllPages'); |
| 68 | add_submenu_page('backup_guard_backups', _backupGuardT('Cloud', true), _backupGuardT('Cloud', true), $capability, 'backup_guard_cloud', 'includeAllPages'); |
| 69 | add_submenu_page('backup_guard_backups', _backupGuardT('Schedule', true), _backupGuardT('Schedule', true), $capability, 'backup_guard_schedule', 'includeAllPages'); |
| 70 | |
| 71 | add_submenu_page('backup_guard_backups', _backupGuardT('Settings', true), _backupGuardT('Settings', true), $capability, 'backup_guard_settings', 'includeAllPages'); |
| 72 | |
| 73 | add_submenu_page('backup_guard_backups', _backupGuardT('System Info.', true), _backupGuardT('System Info.', true), $capability, 'backup_guard_system_info', 'includeAllPages'); |
| 74 | |
| 75 | //add_submenu_page('backup_guard_backups', _backupGuardT('Services', true), _backupGuardT('Services', true), $capability, 'backup_guard_services', 'includeAllPages'); |
| 76 | add_submenu_page('backup_guard_backups', _backupGuardT('Video Tutorials', true), _backupGuardT('Video Tutorials', true), $capability, 'backup_guard_videoTutorials', 'includeAllPages'); |
| 77 | add_submenu_page('backup_guard_backups', _backupGuardT('Support', true), _backupGuardT('Support', true), $capability, 'backup_guard_support', 'includeAllPages'); |
| 78 | |
| 79 | //Check if should show upgrade page |
| 80 | if (SGBoot::isFeatureAvailable('SHOW_UPGRADE_PAGE')) { |
| 81 | add_submenu_page('backup_guard_backups', _backupGuardT('Why upgrade?', true), _backupGuardT('Why upgrade?', true), $capability, 'backup_guard_pro_features', 'includeAllPages'); |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | function getBackupPageContentClassName($pageName = '') |
| 86 | { |
| 87 | $hiddenClassName = 'sg-visibility-hidden'; |
| 88 | $page = sanitize_text_field($_GET['page']); |
| 89 | |
| 90 | if (strpos($page, $pageName)) { |
| 91 | $hiddenClassName = ''; |
| 92 | } |
| 93 | |
| 94 | return $hiddenClassName; |
| 95 | } |
| 96 | |
| 97 | function includeAllPages() |
| 98 | { |
| 99 | if (!backupGuardValidateLicense()) { |
| 100 | return false; |
| 101 | } |
| 102 | backup_guard_backups_page(); |
| 103 | backup_guard_cloud_page(); |
| 104 | backup_guard_system_info_page(); |
| 105 | backup_guard_services_page(); |
| 106 | backup_guard_pro_features_page(); |
| 107 | backup_guard_support_page(); |
| 108 | backup_guard_schedule_page(); |
| 109 | backup_guard_settings_page(); |
| 110 | |
| 111 | include_once plugin_dir_path(__FILE__) . 'public/pagesContent.php'; |
| 112 | |
| 113 | return true; |
| 114 | } |
| 115 | |
| 116 | function backup_guard_system_info_page() |
| 117 | { |
| 118 | if (backupGuardValidateLicense()) { |
| 119 | //require_once(plugin_dir_path(__FILE__).'public/systemInfo.php'); |
| 120 | } |
| 121 | } |
| 122 | |
| 123 | function backup_guard_services_page() |
| 124 | { |
| 125 | if (backupGuardValidateLicense()) { |
| 126 | //require_once(plugin_dir_path(__FILE__).'public/services.php'); |
| 127 | } |
| 128 | } |
| 129 | |
| 130 | //Pro features page |
| 131 | function backup_guard_pro_features_page() |
| 132 | { |
| 133 | // require_once(plugin_dir_path(__FILE__).'public/proFeatures.php'); |
| 134 | } |
| 135 | |
| 136 | function backup_guard_security_page() |
| 137 | { |
| 138 | include_once plugin_dir_path(__FILE__) . 'public/security.php'; |
| 139 | } |
| 140 | |
| 141 | //Support page |
| 142 | function backup_guard_support_page() |
| 143 | { |
| 144 | if (backupGuardValidateLicense()) { |
| 145 | // require_once(plugin_dir_path(__FILE__).'public/support.php'); |
| 146 | } |
| 147 | } |
| 148 | |
| 149 | //Backups Page |
| 150 | function backup_guard_backups_page() |
| 151 | { |
| 152 | if (backupGuardValidateLicense()) { |
| 153 | wp_enqueue_script('backup-guard-iframe-transport-js', plugin_dir_url(__FILE__) . 'public/js/jquery.iframe-transport.js', array('jquery')); |
| 154 | wp_enqueue_script('backup-guard-fileupload-js', plugin_dir_url(__FILE__) . 'public/js/jquery.fileupload.js', array('jquery')); |
| 155 | wp_enqueue_script('backup-guard-jstree-js', plugin_dir_url(__FILE__) . 'public/js/jstree.min.js', array('jquery')); |
| 156 | wp_enqueue_script('backup-guard-jstree-checkbox-js', plugin_dir_url(__FILE__) . 'public/js/jstree.checkbox.js', array('jquery')); |
| 157 | wp_enqueue_script('backup-guard-jstree-wholerow-js', plugin_dir_url(__FILE__) . 'public/js/jstree.wholerow.js', array('jquery')); |
| 158 | wp_enqueue_script('backup-guard-jstree-types-js', plugin_dir_url(__FILE__) . 'public/js/jstree.types.js', array('jquery')); |
| 159 | wp_enqueue_style('backup-guard-jstree-css', plugin_dir_url(__FILE__) . 'public/css/default/style.min.css'); |
| 160 | wp_enqueue_script( |
| 161 | 'backup-guard-backups-js', |
| 162 | plugin_dir_url(__FILE__) . 'public/js/sgbackup.js', |
| 163 | array( |
| 164 | 'jquery', |
| 165 | 'jquery-effects-core', |
| 166 | 'jquery-effects-transfer', |
| 167 | 'jquery-ui-widget') |
| 168 | ); |
| 169 | |
| 170 | // Localize the script with new data |
| 171 | wp_localize_script( |
| 172 | 'backup-guard-backups-js', |
| 173 | 'BG_BACKUP_STRINGS', |
| 174 | array( |
| 175 | 'confirm' => _backupGuardT('Are you sure you want to cancel import?', true), |
| 176 | 'nonce' => wp_create_nonce('backupGuardAjaxNonce'), |
| 177 | 'invalidBackupOption' => _backupGuardT('Please choose at least one option.', true), |
| 178 | 'invalidDirectorySelected' => _backupGuardT('Please choose at least one directory.', true), |
| 179 | 'invalidCloud' => _backupGuardT('Please choose at least one cloud.', true), |
| 180 | 'backupInProgress' => _backupGuardT('Backing Up...', true), |
| 181 | 'errorMessage' => _backupGuardT('Something went wrong. Please try again.', true), |
| 182 | 'noBackupsAvailable' => _backupGuardT('No backups found.', true), |
| 183 | 'invalidImportOption' => _backupGuardT('Please select one of the options.', true), |
| 184 | 'invalidDownloadFile' => _backupGuardT('Please choose one of the files.', true), |
| 185 | 'import' => _backupGuardT('Import', true), |
| 186 | 'importInProgress' => _backupGuardT('Importing please wait...', true), |
| 187 | 'fileUploadFailed' => _backupGuardT('File upload failed.', true) |
| 188 | ) |
| 189 | ); |
| 190 | |
| 191 | // require_once(plugin_dir_path( __FILE__ ).'public/backups.php'); |
| 192 | } |
| 193 | } |
| 194 | |
| 195 | //Cloud Page |
| 196 | function backup_guard_cloud_page() |
| 197 | { |
| 198 | if (backupGuardValidateLicense()) { |
| 199 | wp_enqueue_style('backup-guard-switch-css', plugin_dir_url(__FILE__) . 'public/css/bootstrap-switch.min.css'); |
| 200 | wp_enqueue_script('backup-guard-switch-js', plugin_dir_url(__FILE__) . 'public/js/bootstrap-switch.min.js', array('jquery'), SG_BACKUP_GUARD_VERSION, true); |
| 201 | wp_enqueue_script( |
| 202 | 'backup-guard-jquery-validate-js', |
| 203 | plugin_dir_url(__FILE__) . 'public/js/jquery.validate.min.js', |
| 204 | array( |
| 205 | 'jquery', |
| 206 | 'backup-guard-switch-js'), |
| 207 | SG_BACKUP_GUARD_VERSION, |
| 208 | true |
| 209 | ); |
| 210 | wp_enqueue_script( |
| 211 | 'backup-guard-cloud-js', |
| 212 | plugin_dir_url(__FILE__) . 'public/js/sgcloud.js', |
| 213 | array( |
| 214 | 'jquery', |
| 215 | 'backup-guard-switch-js'), |
| 216 | SG_BACKUP_GUARD_VERSION, |
| 217 | true |
| 218 | ); |
| 219 | |
| 220 | // Localize the script with new data |
| 221 | wp_localize_script( |
| 222 | 'backup-guard-cloud-js', |
| 223 | 'BG_CLOUD_STRINGS', |
| 224 | array( |
| 225 | 'invalidImportFile' => _backupGuardT('Please select a file.', true), |
| 226 | 'invalidFileSize' => _backupGuardT('File is too large.', true), |
| 227 | 'connectionInProgress' => _backupGuardT('Connecting...', true), |
| 228 | 'invalidDestinationFolder' => _backupGuardT('Destination folder is required.', true), |
| 229 | 'invalidDestinationFolderName' => _backupGuardT('Destination folder: type only letters, numbers and ""―".', true), |
| 230 | 'successMessage' => _backupGuardT('Successfully saved.', true) |
| 231 | ) |
| 232 | ); |
| 233 | |
| 234 | //require_once(plugin_dir_path(__FILE__).'public/cloud.php'); |
| 235 | } |
| 236 | } |
| 237 | |
| 238 | //Schedule Page |
| 239 | function backup_guard_schedule_page() |
| 240 | { |
| 241 | if (backupGuardValidateLicense()) { |
| 242 | wp_enqueue_style('backup-guard-switch-css', plugin_dir_url(__FILE__) . 'public/css/bootstrap-switch.min.css'); |
| 243 | wp_enqueue_script('backup-guard-switch-js', plugin_dir_url(__FILE__) . 'public/js/bootstrap-switch.min.js', array('jquery'), '1.0.0', true); |
| 244 | wp_enqueue_script('backup-guard-schedule-js', plugin_dir_url(__FILE__) . 'public/js/sgschedule.js', array('jquery'), '1.0.0', true); |
| 245 | |
| 246 | // Localize the script with new data |
| 247 | wp_localize_script( |
| 248 | 'backup-guard-schedule-js', |
| 249 | 'BG_SCHEDULE_STRINGS', |
| 250 | array( |
| 251 | 'deletionError' => _backupGuardT('Unable to delete schedule', true), |
| 252 | 'confirm' => _backupGuardT('Are you sure?', true), |
| 253 | 'invalidBackupOption' => _backupGuardT('Please choose at least one option.', true), |
| 254 | 'invalidDirectorySelected' => _backupGuardT('Please choose at least one directory.', true), |
| 255 | 'invalidCloud' => _backupGuardT('Please choose at least one cloud.', true), |
| 256 | 'savingInProgress' => _backupGuardT('Saving...', true), |
| 257 | 'successMessage' => _backupGuardT('You have successfully activated schedule.', true), |
| 258 | 'saveButtonText' => _backupGuardT('Save', true) |
| 259 | ) |
| 260 | ); |
| 261 | |
| 262 | // require_once(plugin_dir_path( __FILE__ ).'public/schedule.php'); |
| 263 | } |
| 264 | } |
| 265 | |
| 266 | //Settings Page |
| 267 | function backup_guard_settings_page() |
| 268 | { |
| 269 | if (backupGuardValidateLicense()) { |
| 270 | wp_enqueue_style('backup-guard-switch-css', plugin_dir_url(__FILE__) . 'public/css/bootstrap-switch.min.css'); |
| 271 | wp_enqueue_script('backup-guard-switch-js', plugin_dir_url(__FILE__) . 'public/js/bootstrap-switch.min.js', array('jquery'), '1.0.0', true); |
| 272 | wp_enqueue_script('backup-guard-settings-js', plugin_dir_url(__FILE__) . 'public/js/sgsettings.js', array('jquery'), '1.0.0', true); |
| 273 | |
| 274 | // Localize the script with new data |
| 275 | wp_localize_script( |
| 276 | 'backup-guard-settings-js', |
| 277 | 'BG_SETTINGS_STRINGS', |
| 278 | array( |
| 279 | 'invalidEmailAddress' => _backupGuardT('Please enter valid email.', true), |
| 280 | 'invalidFileName' => _backupGuardT('Please enter valid file name.', true), |
| 281 | 'invalidRetentionNumber' => _backupGuardT('Please enter a valid retention number.', true), |
| 282 | 'successMessage' => _backupGuardT('Successfully saved.', true), |
| 283 | 'savingInProgress' => _backupGuardT('Saving...', true), |
| 284 | 'retentionConfirmationFirstPart' => _backupGuardT('Are you sure you want to keep the latest', true), |
| 285 | 'retentionConfirmationSecondPart' => _backupGuardT('backups? All older backups will be deleted.', true), |
| 286 | 'saveButtonText' => _backupGuardT('Save', true) |
| 287 | ) |
| 288 | ); |
| 289 | |
| 290 | //require_once(plugin_dir_path(__FILE__).'public/settings.php'); |
| 291 | } |
| 292 | } |
| 293 | |
| 294 | function backup_guard_login_page() |
| 295 | { |
| 296 | wp_enqueue_script('backup-guard-login-js', plugin_dir_url(__FILE__) . 'public/js/sglogin.js', array('jquery'), '1.0.0', true); |
| 297 | |
| 298 | include_once plugin_dir_path(__FILE__) . 'public/login.php'; |
| 299 | } |
| 300 | |
| 301 | function backup_guard_link_license_page() |
| 302 | { |
| 303 | wp_enqueue_script('backup-guard-license-js', plugin_dir_url(__FILE__) . 'public/js/sglicense.js', array('jquery'), '1.0.0', true); |
| 304 | // Localize the script with new data |
| 305 | wp_localize_script( |
| 306 | 'backup-guard-license-js', |
| 307 | 'BG_LICENSE_STRINGS', |
| 308 | array( |
| 309 | 'invalidLicense' => _backupGuardT('Please choose a license first', true), |
| 310 | 'availableLicenses' => _backupGuardT('There are no available licenses for using the selected product', true) |
| 311 | ) |
| 312 | ); |
| 313 | |
| 314 | include_once plugin_dir_path(__FILE__) . 'public/link_license.php'; |
| 315 | } |
| 316 | |
| 317 | add_action('admin_enqueue_scripts', 'enqueue_backup_guard_scripts'); |
| 318 | function enqueue_backup_guard_scripts($hook) |
| 319 | { |
| 320 | wp_enqueue_script('backup-guard-discount-notice', plugin_dir_url(__FILE__) . 'public/js/sgNoticeDismiss.js', array('jquery'), '1.0', true); |
| 321 | |
| 322 | if (!strpos($hook, 'backup_guard')) { |
| 323 | if ($hook == "index.php") { |
| 324 | wp_enqueue_script('backup-guard-chart-manager', plugin_dir_url(__FILE__) . 'public/js/chart.umd.min.js'); |
| 325 | } |
| 326 | return; |
| 327 | } |
| 328 | |
| 329 | wp_enqueue_style('backup-guard-spinner', plugin_dir_url(__FILE__) . 'public/css/spinner.css'); |
| 330 | wp_enqueue_style('backup-guard-wordpress', plugin_dir_url(__FILE__) . 'public/css/bgstyle.wordpress.css'); |
| 331 | wp_enqueue_style('backup-guard-less', plugin_dir_url(__FILE__) . 'public/css/bgstyle.less.css'); |
| 332 | wp_enqueue_style('backup-guard-styles', plugin_dir_url(__FILE__) . 'public/css/styles.css'); |
| 333 | |
| 334 | echo '<script type="text/javascript">sgBackup={};'; |
| 335 | $sgAjaxRequestFrequency = SGConfig::get('SG_AJAX_REQUEST_FREQUENCY'); |
| 336 | if (!$sgAjaxRequestFrequency) { |
| 337 | $sgAjaxRequestFrequency = SG_AJAX_DEFAULT_REQUEST_FREQUENCY; |
| 338 | } |
| 339 | echo 'SG_AJAX_REQUEST_FREQUENCY = "' . intval($sgAjaxRequestFrequency) . '";'; |
| 340 | echo 'function getAjaxUrl(url) {' . |
| 341 | 'if (url==="cloudDropbox" || url==="cloudGdrive" || url==="cloudOneDrive" || url==="cloudPCloud" || url==="cloudBox") return "' . admin_url('admin-post.php?action=backup_guard_') . '"+url+"&token=' . wp_create_nonce('backupGuardAjaxNonce') . '";' . |
| 342 | 'return "' . admin_url('admin-ajax.php') . '";}</script>'; |
| 343 | |
| 344 | wp_enqueue_media(); |
| 345 | wp_enqueue_script('backup-guard-less-framework', plugin_dir_url(__FILE__) . 'public/js/less.min.js', array('jquery'), '1.0.0', true); |
| 346 | wp_enqueue_script('backup-guard-bootstrap-framework', plugin_dir_url(__FILE__) . 'public/js/bootstrap.bundle.min.js', array('jquery'), '1.0.0', true); |
| 347 | wp_enqueue_script('backup-guard-sgrequest-js', plugin_dir_url(__FILE__) . 'public/js/sgrequesthandler.js', array('jquery'), '1.0.0', true); |
| 348 | wp_enqueue_script('backup-guard-sgwprequest-js', plugin_dir_url(__FILE__) . 'public/js/sgrequesthandler.wordpress.js', array('jquery'), '1.0.0', true); |
| 349 | |
| 350 | wp_enqueue_style('backup-guard-rateyo-css', plugin_dir_url(__FILE__) . 'public/css/jquery.rateyo.css'); |
| 351 | wp_enqueue_script('backup-guard-rateyo-js', plugin_dir_url(__FILE__) . 'public/js/jquery.rateyo.js'); |
| 352 | |
| 353 | wp_enqueue_script('backup-guard-main-js', plugin_dir_url(__FILE__) . 'public/js/main.js', array('jquery'), '1.0.0', true); |
| 354 | wp_enqueue_script('backup-popup.js', plugin_dir_url(__FILE__) . 'public/js/popup.js', array('jquery'), '1.0.0', true); |
| 355 | wp_enqueue_style('popupTheme.css', plugin_dir_url(__FILE__) . 'public/css/popupTheme.css'); |
| 356 | |
| 357 | // Localize the script with new data |
| 358 | wp_localize_script( |
| 359 | 'backup-guard-main-js', |
| 360 | 'BG_MAIN_STRINGS', |
| 361 | array( |
| 362 | 'confirmCancel' => _backupGuardT('Are you sure you want to cancel?', true) |
| 363 | ) |
| 364 | ); |
| 365 | |
| 366 | wp_localize_script( |
| 367 | 'backup-guard-main-js', |
| 368 | 'BG_BACKUP_STRINGS', |
| 369 | array( |
| 370 | 'nonce' => wp_create_nonce('backupGuardAjaxNonce') |
| 371 | ) |
| 372 | ); |
| 373 | } |
| 374 | |
| 375 | // adding actions to handle modal ajax requests |
| 376 | add_action('wp_ajax_backup_guard_modalManualBackup', 'backup_guard_get_manual_modal'); |
| 377 | add_action('wp_ajax_backup_guard_modalManualRestore', 'backup_guard_get_manual_restore_modal'); |
| 378 | add_action('wp_ajax_backup_guard_modalImport', 'backup_guard_get_import_modal'); |
| 379 | add_action('wp_ajax_backup_guard_modalFtpSettings', 'backup_guard_get_ftp_modal'); |
| 380 | add_action('wp_ajax_backup_guard_modalAmazonSettings', 'backup_guard_get_amazon_modal'); |
| 381 | add_action('wp_ajax_backup_guard_modalPrivacy', 'backup_guard_get_privacy_modal'); |
| 382 | add_action('wp_ajax_backup_guard_modalTerms', 'backup_guard_get_terms_modal'); |
| 383 | add_action('wp_ajax_backup_guard_modalReview', 'backup_guard_get_review_modal'); |
| 384 | add_action('wp_ajax_backup_guard_getFileDownloadProgress', 'backup_guard_get_file_download_progress'); |
| 385 | add_action('wp_ajax_backup_guard_modalCreateSchedule', 'backup_guard_create_schedule'); |
| 386 | add_action('wp_ajax_backup_guard_getBackupContent', 'backup_guard_get_backup_content'); |
| 387 | |
| 388 | add_action('wp_ajax_backup_guard_modalBackupGuardDetails', 'backup_guard_get_backup_guard_modal'); |
| 389 | |
| 390 | function backup_guard_get_backup_guard_modal() |
| 391 | { |
| 392 | check_ajax_referer('backupGuardAjaxNonce', 'token'); |
| 393 | include_once SG_PUBLIC_AJAX_PATH . 'modalBackupGuardDetails.php'; |
| 394 | exit(); |
| 395 | } |
| 396 | |
| 397 | function backup_guard_get_file_download_progress() |
| 398 | { |
| 399 | check_ajax_referer('backupGuardAjaxNonce', 'token'); |
| 400 | include_once SG_PUBLIC_AJAX_PATH . 'getFileDownloadProgress.php'; |
| 401 | exit(); |
| 402 | } |
| 403 | |
| 404 | function backup_guard_create_schedule() |
| 405 | { |
| 406 | check_ajax_referer('backupGuardAjaxNonce', 'token'); |
| 407 | include_once SG_PUBLIC_AJAX_PATH . 'modalCreateSchedule.php'; |
| 408 | exit(); |
| 409 | } |
| 410 | |
| 411 | function backup_guard_get_manual_modal() |
| 412 | { |
| 413 | check_ajax_referer('backupGuardAjaxNonce', 'token'); |
| 414 | if (current_user_can('activate_plugins') || (defined('SG_USER_MODE') && SG_USER_MODE)) { |
| 415 | include_once SG_PUBLIC_AJAX_PATH . 'modalManualBackup.php'; |
| 416 | } |
| 417 | exit(); |
| 418 | } |
| 419 | |
| 420 | function backup_guard_get_manual_restore_modal() |
| 421 | { |
| 422 | check_ajax_referer('backupGuardAjaxNonce', 'token'); |
| 423 | include_once SG_PUBLIC_AJAX_PATH . 'modalManualRestore.php'; |
| 424 | exit(); |
| 425 | } |
| 426 | |
| 427 | function backup_guard_get_backup_content() |
| 428 | { |
| 429 | check_ajax_referer('backupGuardAjaxNonce', 'token'); |
| 430 | include_once SG_PUBLIC_AJAX_PATH . 'getBackupContent.php'; |
| 431 | exit(); |
| 432 | } |
| 433 | |
| 434 | function backup_guard_get_import_modal() |
| 435 | { |
| 436 | check_ajax_referer('backupGuardAjaxNonce', 'token'); |
| 437 | include_once SG_PUBLIC_AJAX_PATH . 'modalImport.php'; |
| 438 | exit(); |
| 439 | } |
| 440 | |
| 441 | function backup_guard_get_ftp_modal() |
| 442 | { |
| 443 | check_ajax_referer('backupGuardAjaxNonce', 'token'); |
| 444 | include_once SG_PUBLIC_AJAX_PATH . 'modalFtpSettings.php'; |
| 445 | exit(); |
| 446 | } |
| 447 | |
| 448 | function backup_guard_get_amazon_modal() |
| 449 | { |
| 450 | check_ajax_referer('backupGuardAjaxNonce', 'token'); |
| 451 | include_once SG_PUBLIC_AJAX_PATH . 'modalAmazonSettings.php'; |
| 452 | exit(); |
| 453 | } |
| 454 | |
| 455 | function backup_guard_get_privacy_modal() |
| 456 | { |
| 457 | include_once SG_PUBLIC_AJAX_PATH . 'modalPrivacy.php'; |
| 458 | } |
| 459 | |
| 460 | function backup_guard_get_terms_modal() |
| 461 | { |
| 462 | include_once SG_PUBLIC_AJAX_PATH . 'modalTerms.php'; |
| 463 | exit(); |
| 464 | } |
| 465 | |
| 466 | function backup_guard_get_review_modal() |
| 467 | { |
| 468 | check_ajax_referer('backupGuardAjaxNonce', 'token'); |
| 469 | include_once SG_PUBLIC_AJAX_PATH . 'modalReview.php'; |
| 470 | exit(); |
| 471 | } |
| 472 | |
| 473 | function backup_guard_register_ajax_callbacks() |
| 474 | { |
| 475 | if (is_super_admin() || (defined('SG_USER_MODE') && SG_USER_MODE)) { |
| 476 | // adding actions to handle ajax and post requests |
| 477 | add_action('wp_ajax_backup_guard_cancelBackup', 'backup_guard_cancel_backup'); |
| 478 | add_action('wp_ajax_backup_guard_checkBackupCreation', 'backup_guard_check_backup_creation'); |
| 479 | add_action('wp_ajax_backup_guard_checkRestoreCreation', 'backup_guard_check_restore_creation'); |
| 480 | add_action('wp_ajax_backup_guard_cloudDropbox', 'backup_guard_cloud_dropbox'); |
| 481 | add_action('wp_ajax_backup_guard_send_usage_status', 'backup_guard_send_usage_status'); |
| 482 | |
| 483 | $pluginCapabilities = backupGuardGetCapabilities(); |
| 484 | if ($pluginCapabilities != BACKUP_GUARD_CAPABILITIES_FREE) { |
| 485 | include_once dirname(__FILE__) . '/BackupGuardPro.php'; |
| 486 | } |
| 487 | add_action('wp_ajax_backup_guard_curlChecker', 'backup_guard_curl_checker'); |
| 488 | add_action('wp_ajax_backup_guard_deleteBackup', 'backup_guard_delete_backup'); |
| 489 | add_action('wp_ajax_backup_guard_getAction', 'backup_guard_get_action'); |
| 490 | add_action('wp_ajax_backup_guard_getRunningActions', 'backup_guard_get_running_actions'); |
| 491 | add_action('wp_ajax_backup_guard_importBackup', 'backup_guard_get_import_backup'); |
| 492 | add_action('wp_ajax_backup_guard_resetStatus', 'backup_guard_reset_status'); |
| 493 | add_action('wp_ajax_backup_guard_restore', 'backup_guard_restore'); |
| 494 | add_action('wp_ajax_backup_guard_saveCloudFolder', 'backup_guard_save_cloud_folder'); |
| 495 | add_action('wp_ajax_backup_guard_schedule', 'backup_guard_schedule'); |
| 496 | add_action('wp_ajax_backup_guard_settings', 'backup_guard_settings'); |
| 497 | add_action('wp_ajax_backup_guard_setReviewPopupState', 'backup_guard_set_review_popup_state'); |
| 498 | add_action('wp_ajax_backup_guard_sendUsageStatistics', 'backup_guard_send_usage_statistics'); |
| 499 | add_action('wp_ajax_backup_guard_hideNotice', 'backup_guard_hide_notice'); |
| 500 | add_action('wp_ajax_backup_guard_downloadFromCloud', 'backup_guard_download_from_cloud'); |
| 501 | add_action('wp_ajax_backup_guard_listStorage', 'backup_guard_list_storage'); |
| 502 | add_action('wp_ajax_backup_guard_cancelDownload', 'backup_guard_cancel_download'); |
| 503 | add_action('wp_ajax_backup_guard_awake', 'backup_guard_awake'); |
| 504 | add_action('wp_ajax_backup_guard_manualBackup', 'backup_guard_manual_backup'); |
| 505 | add_action('admin_post_backup_guard_downloadBackup', 'backup_guard_download_backup'); |
| 506 | add_action('wp_ajax_backup_guard_login', 'backup_guard_login'); |
| 507 | add_action('wp_ajax_backup_guard_logout', 'backup_guard_logout'); |
| 508 | add_action('wp_ajax_backup_guard_link_license', 'backup_guard_link_license'); |
| 509 | add_action('wp_ajax_backup_guard_importKeyFile', 'backup_guard_import_key_file'); |
| 510 | add_action('wp_ajax_backup_guard_isFeatureAvailable', 'backup_guard_is_feature_available'); |
| 511 | add_action('wp_ajax_backup_guard_dismiss_discount_notice', 'backup_guard_dismiss_discount_notice'); |
| 512 | add_action('wp_ajax_backup_guard_checkFreeMigration', 'backup_guard_check_free_migration'); |
| 513 | add_action('wp_ajax_backup_guard_checkPHPVersionCompatibility', 'backup_guard_check_php_version_compatibility'); |
| 514 | add_action('wp_ajax_backup_guard_setUserInfoVerificationPopupState', 'backup_guard_set_user_info_verification_popup_state'); |
| 515 | add_action('wp_ajax_backup_guard_storeSubscriberInfo', 'backup_guard_store_subscriber_info'); |
| 516 | add_action('wp_ajax_backup_guard_reviewDontShow', 'backup_guard_review_dont_show'); |
| 517 | add_action('wp_ajax_backup_guard_review_later', 'backup_guard_review_later'); |
| 518 | add_action('wp_ajax_backup_guard_closeFreeBanner', 'wp_ajax_backup_guard_close_free_banner'); |
| 519 | // related to cloud |
| 520 | add_action('wp_ajax_backup_guard_isBgUserExists', 'backup_guard_is_bg_user_exists'); |
| 521 | add_action('wp_ajax_backup_guard_createCloudUser', 'backup_guard_create_cloud_user'); |
| 522 | add_action('wp_ajax_backup_guard_bgAutoLogin', 'backup_guard_bg_auto_login'); |
| 523 | add_action('wp_ajax_backup_guard_bgLogin', 'backup_guard_bg_login'); |
| 524 | add_action('wp_ajax_backup_guard_chooseProfile', 'backup_guard_choose_profile'); |
| 525 | } |
| 526 | } |
| 527 | |
| 528 | function wp_ajax_backup_guard_close_free_banner() |
| 529 | { |
| 530 | check_ajax_referer('backupGuardAjaxNonce', 'token'); |
| 531 | SGConfig::set('SG_CLOSE_FREE_BANNER', 1); |
| 532 | wp_die(); |
| 533 | } |
| 534 | |
| 535 | function backup_guard_review_dont_show() |
| 536 | { |
| 537 | check_ajax_referer('backupGuardAjaxNonce', 'token'); |
| 538 | SGConfig::set('closeReviewBanner', 1); |
| 539 | wp_die(); |
| 540 | } |
| 541 | |
| 542 | function backup_guard_review_later() |
| 543 | { |
| 544 | check_ajax_referer('backupGuardAjaxNonce', 'token'); |
| 545 | include_once SG_PUBLIC_AJAX_PATH . 'reviewBannerActions.php'; |
| 546 | wp_die(); |
| 547 | } |
| 548 | |
| 549 | function backup_guard_choose_profile() |
| 550 | { |
| 551 | check_ajax_referer('backupGuardAjaxNonce', 'token'); |
| 552 | include_once SG_PUBLIC_AJAX_PATH . 'chooseProfile.php'; |
| 553 | } |
| 554 | |
| 555 | function backup_guard_bg_login() |
| 556 | { |
| 557 | check_ajax_referer('backupGuardAjaxNonce', 'token'); |
| 558 | include_once SG_PUBLIC_AJAX_PATH . 'bgLogin.php'; |
| 559 | } |
| 560 | |
| 561 | function backup_guard_bg_auto_login() |
| 562 | { |
| 563 | check_ajax_referer('backupGuardAjaxNonce', 'token'); |
| 564 | include_once SG_PUBLIC_AJAX_PATH . 'bgAutoLogin.php'; |
| 565 | } |
| 566 | |
| 567 | function backup_guard_create_cloud_user() |
| 568 | { |
| 569 | check_ajax_referer('backupGuardAjaxNonce', 'token'); |
| 570 | include_once SG_PUBLIC_AJAX_PATH . 'createCloudUser.php'; |
| 571 | } |
| 572 | |
| 573 | function backup_guard_is_bg_user_exists() |
| 574 | { |
| 575 | check_ajax_referer('backupGuardAjaxNonce', 'token'); |
| 576 | include_once SG_PUBLIC_AJAX_PATH . 'isBgUserExists.php'; |
| 577 | } |
| 578 | |
| 579 | function backup_guard_store_subscriber_info() |
| 580 | { |
| 581 | check_ajax_referer('backupGuardAjaxNonce', 'token'); |
| 582 | include_once SG_PUBLIC_AJAX_PATH . 'storeSubscriberInfo.php'; |
| 583 | } |
| 584 | |
| 585 | function backup_guard_set_user_info_verification_popup_state() |
| 586 | { |
| 587 | check_ajax_referer('backupGuardAjaxNonce', 'token'); |
| 588 | include_once SG_PUBLIC_AJAX_PATH . 'setUserInfoVerificationPopupState.php'; |
| 589 | } |
| 590 | |
| 591 | function backup_guard_dismiss_discount_notice() |
| 592 | { |
| 593 | check_ajax_referer('backupGuardAjaxNonce', 'token'); |
| 594 | include_once SG_PUBLIC_AJAX_PATH . 'dismissDiscountNotice.php'; |
| 595 | } |
| 596 | |
| 597 | function backup_guard_is_feature_available() |
| 598 | { |
| 599 | include_once SG_PUBLIC_AJAX_PATH . 'isFeatureAvailable.php'; |
| 600 | } |
| 601 | |
| 602 | function backup_guard_check_free_migration() |
| 603 | { |
| 604 | check_ajax_referer('backupGuardAjaxNonce', 'token'); |
| 605 | include_once SG_PUBLIC_AJAX_PATH . 'checkFreeMigration.php'; |
| 606 | die; |
| 607 | } |
| 608 | |
| 609 | function backup_guard_check_php_version_compatibility() |
| 610 | { |
| 611 | check_ajax_referer('backupGuardAjaxNonce', 'token'); |
| 612 | include_once SG_PUBLIC_AJAX_PATH . 'checkPHPVersionCompatibility.php'; |
| 613 | } |
| 614 | |
| 615 | add_action('init', 'backup_guard_init'); |
| 616 | add_action('wp_ajax_nopriv_backup_guard_awake', 'backup_guard_awake_nopriv'); |
| 617 | add_action('admin_post_backup_guard_cloudDropbox', 'backup_guard_cloud_dropbox'); |
| 618 | |
| 619 | function backup_guard_import_key_file() |
| 620 | { |
| 621 | check_ajax_referer('backupGuardAjaxNonce', 'token'); |
| 622 | include_once SG_PUBLIC_AJAX_PATH . 'importKeyFile.php'; |
| 623 | } |
| 624 | |
| 625 | function backup_guard_awake() |
| 626 | { |
| 627 | $method = SG_RELOAD_METHOD_AJAX; |
| 628 | include_once SG_PUBLIC_AJAX_PATH . 'awake.php'; |
| 629 | } |
| 630 | |
| 631 | function backup_guard_awake_nopriv() |
| 632 | { |
| 633 | $token = ''; |
| 634 | if (!empty($_GET['token'])) { |
| 635 | $token = sanitize_text_field($_GET['token']); |
| 636 | } |
| 637 | |
| 638 | global $method; |
| 639 | $method = ''; |
| 640 | if (!empty($_GET['method'])) { |
| 641 | $method = sanitize_text_field($_GET['method']); |
| 642 | } |
| 643 | |
| 644 | if (backupGuardValidateApiCall($token)) { |
| 645 | include_once SG_PUBLIC_AJAX_PATH . 'awake.php'; |
| 646 | } |
| 647 | } |
| 648 | |
| 649 | function backup_guard_cancel_download() |
| 650 | { |
| 651 | check_ajax_referer('backupGuardAjaxNonce', 'token'); |
| 652 | include_once SG_PUBLIC_AJAX_PATH . 'cancelDownload.php'; |
| 653 | } |
| 654 | |
| 655 | function backup_guard_list_storage() |
| 656 | { |
| 657 | check_ajax_referer('backupGuardAjaxNonce', 'token'); |
| 658 | include_once SG_PUBLIC_AJAX_PATH . 'listStorage.php'; |
| 659 | } |
| 660 | |
| 661 | function backup_guard_download_from_cloud() |
| 662 | { |
| 663 | check_ajax_referer('backupGuardAjaxNonce', 'token'); |
| 664 | include_once SG_PUBLIC_AJAX_PATH . 'downloadFromCloud.php'; |
| 665 | } |
| 666 | |
| 667 | function backup_guard_hide_notice() |
| 668 | { |
| 669 | check_ajax_referer('backupGuardAjaxNonce', 'token'); |
| 670 | include_once SG_PUBLIC_AJAX_PATH . 'hideNotice.php'; |
| 671 | } |
| 672 | |
| 673 | function backup_guard_cancel_backup() |
| 674 | { |
| 675 | check_ajax_referer('backupGuardAjaxNonce', 'token'); |
| 676 | include_once SG_PUBLIC_AJAX_PATH . 'cancelBackup.php'; |
| 677 | } |
| 678 | |
| 679 | function backup_guard_check_backup_creation() |
| 680 | { |
| 681 | check_ajax_referer('backupGuardAjaxNonce', 'token'); |
| 682 | include_once SG_PUBLIC_AJAX_PATH . 'checkBackupCreation.php'; |
| 683 | } |
| 684 | |
| 685 | function backup_guard_check_restore_creation() |
| 686 | { |
| 687 | check_ajax_referer('backupGuardAjaxNonce', 'token'); |
| 688 | include_once SG_PUBLIC_AJAX_PATH . 'checkRestoreCreation.php'; |
| 689 | } |
| 690 | |
| 691 | function backup_guard_cloud_dropbox() |
| 692 | { |
| 693 | if (current_user_can('activate_plugins') || (defined('SG_USER_MODE') && SG_USER_MODE)) { |
| 694 | check_ajax_referer('backupGuardAjaxNonce', 'token'); |
| 695 | include_once SG_PUBLIC_AJAX_PATH . 'cloudDropbox.php'; |
| 696 | } |
| 697 | } |
| 698 | |
| 699 | function backup_guard_send_usage_status() |
| 700 | { |
| 701 | |
| 702 | if (current_user_can('activate_plugins') || (defined('SG_USER_MODE') && SG_USER_MODE)) { |
| 703 | check_ajax_referer('backupGuardAjaxNonce', 'token'); |
| 704 | include_once SG_PUBLIC_AJAX_PATH . 'sendUsageStatus.php'; |
| 705 | } |
| 706 | } |
| 707 | |
| 708 | function backup_guard_curl_checker() |
| 709 | { |
| 710 | check_ajax_referer('backupGuardAjaxNonce', 'token'); |
| 711 | include_once SG_PUBLIC_AJAX_PATH . 'curlChecker.php'; |
| 712 | } |
| 713 | |
| 714 | function backup_guard_delete_backup() |
| 715 | { |
| 716 | check_ajax_referer('backupGuardAjaxNonce', 'token'); |
| 717 | include_once SG_PUBLIC_AJAX_PATH . 'deleteBackup.php'; |
| 718 | } |
| 719 | |
| 720 | function backup_guard_download_backup() |
| 721 | { |
| 722 | include_once SG_PUBLIC_AJAX_PATH . 'downloadBackup.php'; |
| 723 | } |
| 724 | |
| 725 | function backup_guard_get_action() |
| 726 | { |
| 727 | check_ajax_referer('backupGuardAjaxNonce', 'token'); |
| 728 | include_once SG_PUBLIC_AJAX_PATH . 'getAction.php'; |
| 729 | } |
| 730 | |
| 731 | function backup_guard_get_running_actions() |
| 732 | { |
| 733 | include_once SG_PUBLIC_AJAX_PATH . 'getRunningActions.php'; |
| 734 | } |
| 735 | |
| 736 | function backup_guard_get_import_backup() |
| 737 | { |
| 738 | check_ajax_referer('backupGuardAjaxNonce', 'token'); |
| 739 | include_once SG_PUBLIC_AJAX_PATH . 'importBackup.php'; |
| 740 | } |
| 741 | |
| 742 | function backup_guard_manual_backup() |
| 743 | { |
| 744 | check_ajax_referer('backupGuardAjaxNonce', 'token'); |
| 745 | include_once SG_PUBLIC_AJAX_PATH . 'manualBackup.php'; |
| 746 | } |
| 747 | |
| 748 | function backup_guard_reset_status() |
| 749 | { |
| 750 | check_ajax_referer('backupGuardAjaxNonce', 'token'); |
| 751 | include_once SG_PUBLIC_AJAX_PATH . 'resetStatus.php'; |
| 752 | } |
| 753 | |
| 754 | function backup_guard_restore() |
| 755 | { |
| 756 | include_once SG_PUBLIC_AJAX_PATH . 'restore.php'; |
| 757 | } |
| 758 | |
| 759 | function backup_guard_save_cloud_folder() |
| 760 | { |
| 761 | check_ajax_referer('backupGuardAjaxNonce', 'token'); |
| 762 | include_once SG_PUBLIC_AJAX_PATH . 'saveCloudFolder.php'; |
| 763 | } |
| 764 | |
| 765 | function backup_guard_schedule() |
| 766 | { |
| 767 | check_ajax_referer('backupGuardAjaxNonce', 'token'); |
| 768 | include_once SG_PUBLIC_AJAX_PATH . 'schedule.php'; |
| 769 | } |
| 770 | |
| 771 | function backup_guard_settings() |
| 772 | { |
| 773 | check_ajax_referer('backupGuardAjaxNonce', 'token'); |
| 774 | include_once SG_PUBLIC_AJAX_PATH . 'settings.php'; |
| 775 | } |
| 776 | |
| 777 | function backup_guard_set_review_popup_state() |
| 778 | { |
| 779 | check_ajax_referer('backupGuardAjaxNonce', 'token'); |
| 780 | include_once SG_PUBLIC_AJAX_PATH . 'setReviewPopupState.php'; |
| 781 | } |
| 782 | |
| 783 | function backup_guard_send_usage_statistics() |
| 784 | { |
| 785 | include_once SG_PUBLIC_AJAX_PATH . 'sendUsageStatistics.php'; |
| 786 | } |
| 787 | |
| 788 | function backup_guard_login() |
| 789 | { |
| 790 | check_ajax_referer('backupGuardAjaxNonce', 'token'); |
| 791 | include_once SG_PUBLIC_AJAX_PATH . 'login.php'; |
| 792 | } |
| 793 | |
| 794 | function backup_guard_logout() |
| 795 | { |
| 796 | check_ajax_referer('backupGuardAjaxNonce', 'token'); |
| 797 | include_once SG_PUBLIC_AJAX_PATH . 'logout.php'; |
| 798 | } |
| 799 | |
| 800 | function backup_guard_link_license() |
| 801 | { |
| 802 | check_ajax_referer('backupGuardAjaxNonce', 'token'); |
| 803 | include_once SG_PUBLIC_AJAX_PATH . 'linkLicense.php'; |
| 804 | } |
| 805 | |
| 806 | //adds once weekly to the existing schedules. |
| 807 | add_filter('cron_schedules', 'backup_guard_cron_add_weekly'); |
| 808 | function backup_guard_cron_add_weekly($schedules) |
| 809 | { |
| 810 | $schedules['weekly'] = array( |
| 811 | 'interval' => 60 * 60 * 24 * 7, |
| 812 | 'display' => 'Once weekly' |
| 813 | ); |
| 814 | return $schedules; |
| 815 | } |
| 816 | |
| 817 | //adds once monthly to the existing schedules. |
| 818 | add_filter('cron_schedules', 'backup_guard_cron_add_monthly'); |
| 819 | function backup_guard_cron_add_monthly($schedules) |
| 820 | { |
| 821 | $schedules['monthly'] = array( |
| 822 | 'interval' => 60 * 60 * 24 * 30, |
| 823 | 'display' => 'Once monthly' |
| 824 | ); |
| 825 | return $schedules; |
| 826 | } |
| 827 | |
| 828 | //adds once yearly to the existing schedules. |
| 829 | add_filter('cron_schedules', 'backup_guard_cron_add_yearly'); |
| 830 | function backup_guard_cron_add_yearly($schedules) |
| 831 | { |
| 832 | $schedules['yearly'] = array( |
| 833 | 'interval' => 60 * 60 * 24 * 30 * 12, |
| 834 | 'display' => 'Once yearly' |
| 835 | ); |
| 836 | return $schedules; |
| 837 | } |
| 838 | |
| 839 | function backup_guard_init() |
| 840 | { |
| 841 | backup_guard_register_ajax_callbacks(); |
| 842 | // backupGuardPluginRedirect(); |
| 843 | |
| 844 | //check if database should be updated |
| 845 | if (backupGuardShouldUpdate()) { |
| 846 | SGBoot::install(); |
| 847 | } |
| 848 | |
| 849 | backupGuardSymlinksCleanup(SG_SYMLINK_PATH); |
| 850 | } |
| 851 | |
| 852 | add_action(SG_SCHEDULE_ACTION, 'backup_guard_schedule_action', 10, 1); |
| 853 | |
| 854 | function backup_guard_schedule_action($id) |
| 855 | { |
| 856 | include_once SG_PUBLIC_PATH . 'cron/sg_backup.php'; |
| 857 | } |
| 858 | |
| 859 | function sgBackupAdminInit() |
| 860 | { |
| 861 | //load pro plugin updater |
| 862 | $pluginCapabilities = backupGuardGetCapabilities(); |
| 863 | $isLoggedIn = is_user_logged_in(); |
| 864 | |
| 865 | if ($pluginCapabilities != BACKUP_GUARD_CAPABILITIES_FREE && $isLoggedIn) { |
| 866 | include_once dirname(__FILE__) . '/plugin-update-checker/plugin-update-checker.php'; |
| 867 | include_once dirname(__FILE__) . '/plugin-update-checker/Puc/v4/Utils.php'; |
| 868 | include_once dirname(__FILE__) . '/plugin-update-checker/Puc/v4/UpdateChecker.php'; |
| 869 | include_once dirname(__FILE__) . '/plugin-update-checker/Puc/v4/Scheduler.php'; |
| 870 | include_once SG_LIB_PATH . 'SGAuthClient.php'; |
| 871 | |
| 872 | $licenseKey = SGConfig::get('SG_LICENSE_KEY'); |
| 873 | |
| 874 | $updateChecker = Puc_v4_Factory::buildUpdateChecker( |
| 875 | BackupGuard\Config::URL . '/products/details/' . $licenseKey . '/' . SG_PRODUCT_IDENTIFIER, |
| 876 | SG_BACKUP_GUARD_MAIN_FILE, |
| 877 | SG_PRODUCT_IDENTIFIER |
| 878 | ); |
| 879 | |
| 880 | $updateChecker->addHttpRequestArgFilter( |
| 881 | array( |
| 882 | SGAuthClient::getInstance(), |
| 883 | 'filterUpdateChecks' |
| 884 | ) |
| 885 | ); |
| 886 | } |
| 887 | |
| 888 | include_once SG_LIB_PATH . 'SGStatsRequests.php'; |
| 889 | SGStatsRequests::initialSync(); |
| 890 | } |
| 891 | |
| 892 | add_action('admin_init', 'sgBackupAdminInit'); |
| 893 | |
| 894 | if (SGBoot::isFeatureAvailable('ALERT_BEFORE_UPDATE')) { |
| 895 | add_filter('upgrader_pre_download', 'backupGuardOnBeforeUpdateDownload', 10, 3); |
| 896 | add_action('core_upgrade_preamble', 'backupGuardOnUpgradeScreenActivate'); |
| 897 | add_action('current_screen', 'backupGuardOnScreenActivate'); |
| 898 | } |
| 899 | |
| 900 | // Register the new dashboard widget with the 'wp_dashboard_setup' action |
| 901 | add_action('wp_dashboard_setup', 'backup_guard_add_dashboard_widgets'); |
| 902 | |
| 903 | function backup_guard_add_dashboard_widgets() |
| 904 | { |
| 905 | include_once SG_CORE_PATH . 'SGConfig.php'; |
| 906 | |
| 907 | $userId = get_current_user_id(); |
| 908 | $userData = get_userdata($userId); |
| 909 | $userRoles = $userData->roles; |
| 910 | $isAdminUser = false; |
| 911 | for ($i = 0; $i < count($userRoles); $i++) { |
| 912 | if ($userRoles[$i] == "administrator") { |
| 913 | $isAdminUser = true; |
| 914 | break; |
| 915 | } |
| 916 | } |
| 917 | |
| 918 | if (!$isAdminUser) { |
| 919 | return; |
| 920 | } |
| 921 | |
| 922 | $isShowStatisticsWidgetEnabled = SGConfig::get('SG_SHOW_STATISTICS_WIDGET'); |
| 923 | if (!$isShowStatisticsWidgetEnabled) { |
| 924 | return; |
| 925 | } |
| 926 | |
| 927 | |
| 928 | include_once plugin_dir_path(__FILE__) . 'public/dashboardWidget.php'; |
| 929 | wp_add_dashboard_widget('backupGuardWidget', 'Backup Guard', 'backup_guard_dashboard_widget_function'); |
| 930 | } |
| 931 | |
| 932 | add_action('plugins_loaded', 'backupGuardloadTextDomain'); |
| 933 | function backupGuardloadTextDomain() |
| 934 | { |
| 935 | $backupGuardLangDir = plugin_dir_path(__FILE__) . 'languages/'; |
| 936 | $backupGuardLangDir = apply_filters('backupguardLanguagesDirectory', $backupGuardLangDir); |
| 937 | |
| 938 | $locale = apply_filters('bg_plugin_locale', get_locale(), BACKUP_GUARD_TEXTDOMAIN); |
| 939 | $mofile = sprintf('%1$s-%2$s.mo', BACKUP_GUARD_TEXTDOMAIN, $locale); |
| 940 | |
| 941 | $mofileLocal = $backupGuardLangDir . $mofile; |
| 942 | |
| 943 | if (file_exists($mofileLocal)) { |
| 944 | // Look in local /wp-content/plugins/popup-builder/languages/ folder |
| 945 | load_textdomain(BACKUP_GUARD_TEXTDOMAIN, $mofileLocal); |
| 946 | } else { |
| 947 | // Load the default language files |
| 948 | load_plugin_textdomain(BACKUP_GUARD_TEXTDOMAIN, false, $backupGuardLangDir); |
| 949 | } |
| 950 | } |
| 951 | |
| 952 | if (backupGuardShouldShowDiscountNotice() && checkDueDateDiscount()) { |
| 953 | add_action('admin_notices', 'backup_guard_discount_notice'); |
| 954 | } |
| 955 | |
| 956 | function backup_guard_discount_notice() |
| 957 | { |
| 958 | /*$capabilities = backupGuardGetCapabilities(); |
| 959 | $upgradeUrl = BG_UPGRADE_URL;*/ |
| 960 | ?> |
| 961 | <div class="backup-guard-discount-notice updated notice is-dismissible"> |
| 962 | <div class="sgbg-col sgbg-col1"></div> |
| 963 | <div class="sgbg-col sgbg-col2"></div> |
| 964 | <div class="sgbg-col sgbg-col3"> |
| 965 | <div class="sgbg-text-col-1"> |
| 966 | -50% |
| 967 | </div> |
| 968 | <div class="sgbg-text-col-2"> |
| 969 | <div class="sgbg-discount-text-1">Discount</div> |
| 970 | <div class="sgbg-discount-text-2">All Backup Guard Solutions</div> |
| 971 | </div> |
| 972 | </div> |
| 973 | <div class="sgbg-col sgbg-col4"> |
| 974 | <a href="https://backup-guard.com/products/backup-wordpress" target="_blank"> |
| 975 | <button class="sgbg-button">Click Here</button> |
| 976 | </a> |
| 977 | </div> |
| 978 | </div> |
| 979 | <style> |
| 980 | .backup-guard-discount-notice.updated.notice.is-dismissible { |
| 981 | padding: 0; |
| 982 | border-left-color: #FFFFFF !important; |
| 983 | background-color: #000000; |
| 984 | height: 160px; |
| 985 | } |
| 986 | |
| 987 | .backup-guard-discount-notice button:before { |
| 988 | color: #ffffff !important; |
| 989 | } |
| 990 | |
| 991 | .sgbg-col { |
| 992 | display: inline-block; |
| 993 | width: 25%; |
| 994 | height: 100%; |
| 995 | padding: 0 25px; |
| 996 | box-sizing: border-box; |
| 997 | } |
| 998 | |
| 999 | .sgbg-col1 { |
| 1000 | width: 10%; |
| 1001 | background-color: #FFFFFF; |
| 1002 | background-image: url("<?php echo SG_IMAGE_URL ?>BgBFLogo.jpg"); |
| 1003 | background-size: 80%; |
| 1004 | background-repeat: no-repeat; |
| 1005 | background-position: center; |
| 1006 | } |
| 1007 | |
| 1008 | .sgbg-col2 { |
| 1009 | width: 20%; |
| 1010 | background-image: url("<?php echo SG_IMAGE_URL ?>BF.png"); |
| 1011 | background-size: contain; |
| 1012 | margin-left: 70px; |
| 1013 | background-position: center; |
| 1014 | background-repeat: no-repeat; |
| 1015 | } |
| 1016 | |
| 1017 | .sgbg-col3 { |
| 1018 | vertical-align: top; |
| 1019 | width: 45%; |
| 1020 | margin-top: 55px; |
| 1021 | } |
| 1022 | |
| 1023 | .sgbg-col4 { |
| 1024 | width: 10%; |
| 1025 | } |
| 1026 | |
| 1027 | .sgbg-text-col-1, |
| 1028 | .sgbg-text-col-2 { |
| 1029 | width: 49%; |
| 1030 | display: inline-block; |
| 1031 | color: #FFFFFF; |
| 1032 | } |
| 1033 | |
| 1034 | .sgbg-text-col-1 { |
| 1035 | font-size: 100px; |
| 1036 | line-height: 0; |
| 1037 | font-weight: bold; |
| 1038 | text-align: right; |
| 1039 | padding-right: 26px; |
| 1040 | box-sizing: border-box; |
| 1041 | } |
| 1042 | |
| 1043 | .sgbg-discount-text-2 { |
| 1044 | font-size: 19px; |
| 1045 | } |
| 1046 | |
| 1047 | .sgbg-discount-text-1 { |
| 1048 | font-size: 60px; |
| 1049 | padding-bottom: 27px; |
| 1050 | font-weight: bold; |
| 1051 | } |
| 1052 | |
| 1053 | .sgbg-col4 { |
| 1054 | vertical-align: top; |
| 1055 | } |
| 1056 | |
| 1057 | .sgbg-button { |
| 1058 | width: 183px; |
| 1059 | height: 67px; |
| 1060 | font-size: 20px; |
| 1061 | border: #ffffff; |
| 1062 | border-radius: 10px; |
| 1063 | margin-top: 48px; |
| 1064 | background-color: #FFFFFF; |
| 1065 | color: #000000; |
| 1066 | cursor: pointer !important; |
| 1067 | } |
| 1068 | |
| 1069 | .sgbg-button:hover { |
| 1070 | background-color: #000000; |
| 1071 | border: 1px solid #FFFFFF; |
| 1072 | color: #FFFFFF; |
| 1073 | } |
| 1074 | |
| 1075 | .backup-guard-discount-notice .notice-dismiss::before { |
| 1076 | content: "x"; |
| 1077 | font-weight: 300; |
| 1078 | font-family: Arial, sans-serif; |
| 1079 | } |
| 1080 | |
| 1081 | @media (max-width: 1810px) { |
| 1082 | .sgbg-text-col-1 { |
| 1083 | font-size: 80px; |
| 1084 | } |
| 1085 | |
| 1086 | .sgbg-discount-text-1 { |
| 1087 | font-size: 43px; |
| 1088 | } |
| 1089 | |
| 1090 | .sgbg-discount-text-2 { |
| 1091 | font-size: 15px; |
| 1092 | } |
| 1093 | |
| 1094 | .sgbg-discount-text-1 { |
| 1095 | padding-bottom: 18px; |
| 1096 | } |
| 1097 | |
| 1098 | .sgbg-col3 { |
| 1099 | margin-top: 60px; |
| 1100 | } |
| 1101 | } |
| 1102 | |
| 1103 | @media (max-width: 1477px) { |
| 1104 | .sgbg-discount-text-2 { |
| 1105 | font-size: 12px; |
| 1106 | } |
| 1107 | |
| 1108 | .sgbg-discount-text-1 { |
| 1109 | font-size: 35px; |
| 1110 | } |
| 1111 | |
| 1112 | .sgbg-discount-text-1 { |
| 1113 | padding-bottom: 13px; |
| 1114 | } |
| 1115 | |
| 1116 | .sgbg-col { |
| 1117 | padding: 0; |
| 1118 | } |
| 1119 | |
| 1120 | .sgbg-col2 { |
| 1121 | margin-left: 40px; |
| 1122 | } |
| 1123 | |
| 1124 | .sgbg-col2 { |
| 1125 | margin-left: 0; |
| 1126 | } |
| 1127 | } |
| 1128 | </style> |
| 1129 | <?php |
| 1130 | } |
| 1131 | |
| 1132 | add_action('admin_notices', 'backup_guard_review_banner'); |
| 1133 | function backup_guard_review_banner() |
| 1134 | { |
| 1135 | include_once SG_LIB_PATH . 'SGReviewManager.php'; |
| 1136 | $reviewManager = new SGReviewManager(); |
| 1137 | $reviewManager->renderContent(); |
| 1138 | } |
| 1139 |