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