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