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