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