/** * Setup the HM_Backup class * * @return null */ function hmbkp_setup_hm_backup() { $hm_backup = HM_Backup::get_instance(); $hm_backup->path = hmbkp_path(); $hm_backup->files_only = hmbkp_get_files_only(); $hm_backup->database_only = hmbkp_get_database_only(); if (defined('HMBKP_MYSQLDUMP_PATH')) { $hm_backup->mysql_command_path = HMBKP_MYSQLDUMP_PATH; } if (defined('HMBKP_ZIP_PATH')) { $hm_backup->zip_command_path = HMBKP_ZIP_PATH; } $hm_backup->excludes = hmbkp_valid_custom_excludes(); }
} ?> <p>✓ <?php if (hmbkp_get_disable_automatic_backup() && !wp_next_scheduled('hmbkp_schedule_backup_hook')) { ?> <?php printf(__('Automatic backups are %s.', 'hmbkp'), '<strong>' . __('disabled', 'hmbkp') . '</strong>'); ?> <?php } else { if (!hmbkp_get_database_only() && !hmbkp_get_files_only()) { $what_to_backup = '<code>' . __('database', 'hmbkp') . '</code> ' . __('&', 'hmbkp') . ' <code>' . __('files', 'hmbkp') . '</code>'; } elseif (hmbkp_get_database_only()) { $what_to_backup = '<code>' . __('database', 'hmbkp') . '</code>'; } else { $what_to_backup = '<code>' . __('files', 'hmbkp') . '</code>'; } ?> <?php $offset = current_time('timestamp') - time(); $schedules = wp_get_schedules(); $schedule = $schedules[wp_get_schedule('hmbkp_schedule_backup_hook')]['display']; printf(__('Your %s will be automatically backed up <code>%s</code>. The next backup will occur at %s on %s and be saved to %s.', 'hmbkp'), $what_to_backup, $schedule, '<code>' . date_i18n(get_option('time_format'), wp_next_scheduled('hmbkp_schedule_backup_hook') + $offset) . '</code>', '<code title="' . sprintf(__('It\'s currently %s', 'hmbkp'), date_i18n(get_option('time_format'))) . '">' . date_i18n(get_option('date_format'), wp_next_scheduled('hmbkp_schedule_backup_hook') + $offset) . '</code>', '<code>' . hmbkp_path() . '</code>'); ?>
/** * Displays admin notices for various error / warning * conditions * * @return void */ function hmbkp_admin_notices() { // If the form has been submitted, display updated notification // Display notifications for any errors in the settings form. if (!empty($_POST['hmbkp_settings_submit'])) { function hmbkp_advanced_settings_saved() { echo '<div id="setting-error-settings_updated" class="updated settings-error"><p><strong>Settings saved.</strong></p></div>'; global $hmbkp_errors; if (!empty($hmbkp_errors) && $hmbkp_errors->get_error_code()) { foreach ($hmbkp_errors->get_error_messages() as $hmbkp_error) { echo '<div class="error"><p>' . $hmbkp_error . '</p></div>'; } } } add_action('admin_notices', 'hmbkp_advanced_settings_saved'); } // If the backups directory doesn't exist and can't be automatically created if (!is_dir(hmbkp_path())) { function hmbkp_path_exists_warning() { $php_user = exec('whoami'); $php_group = reset(explode(' ', exec('groups'))); echo '<div id="hmbkp-warning" class="updated fade"><p><strong>' . __('BackUpWordPress is almost ready.', 'hmbkp') . '</strong> ' . sprintf(__('The backups directory can\'t be created because your %s directory isn\'t writable, run %s or %s or create the folder yourself.', 'hmbkp'), '<code>wp-content</code>', '<code>chown ' . $php_user . ':' . $php_group . ' ' . WP_CONTENT_DIR . '</code>', '<code>chmod 777 ' . WP_CONTENT_DIR . '</code>') . '</p></div>'; } add_action('admin_notices', 'hmbkp_path_exists_warning'); } // If the backups directory exists but isn't writable if (is_dir(hmbkp_path()) && !is_writable(hmbkp_path())) { function hmbkp_writable_path_warning() { $php_user = exec('whoami'); $php_group = reset(explode(' ', exec('groups'))); echo '<div id="hmbkp-warning" class="updated fade"><p><strong>' . __('BackUpWordPress is almost ready.', 'hmbkp') . '</strong> ' . sprintf(__('Your backups directory isn\'t writable. run %s or %s or set the permissions yourself.', 'hmbkp'), '<code>chown -R ' . $php_user . ':' . $php_group . ' ' . hmbkp_path() . '</code>', '<code>chmod -R 777 ' . hmbkp_path() . '</code>') . '</p></div>'; } add_action('admin_notices', 'hmbkp_writable_path_warning'); } // If safe mode is active if (hmbkp_is_safe_mode_active()) { function hmbkp_safe_mode_warning() { echo '<div id="hmbkp-warning" class="updated fade"><p><strong>' . __('BackUpWordPress has detected a problem.', 'hmbkp') . '</strong> ' . sprintf(__(' %s is running in %s. Please contact your host and ask them to disable %s.', 'hmbkp'), '<code>PHP</code>', '<a href="http://php.net/manual/en/features.safe-mode.php"><code>Safe Mode</code></a>', '<code>Safe Mode</code>') . '</p></div>'; } add_action('admin_notices', 'hmbkp_safe_mode_warning'); } // If both HMBKP_FILES_ONLY & HMBKP_DATABASE_ONLY are defined at the same time if (hmbkp_get_files_only() && hmbkp_get_database_only()) { function hmbkp_nothing_to_backup_warning() { echo '<div id="hmbkp-warning" class="updated fade"><p><strong>' . __('BackUpWordPress has detected a problem.', 'hmbkp') . '</strong> ' . sprintf(__('You have both %s and %s defined so there isn\'t anything to back up.', 'hmbkp'), '<code>HMBKP_DATABASE_ONLY</code>', '<code>HMBKP_FILES_ONLY</code>') . '</p></div>'; } add_action('admin_notices', 'hmbkp_nothing_to_backup_warning'); } // If the email address is invalid if (hmbkp_get_email_address() && !is_email(hmbkp_get_email_address())) { function hmbkp_email_invalid_warning() { echo '<div id="hmbkp-warning" class="updated fade"><p><strong>' . __('BackUpWordPress has detected a problem.', 'hmbkp') . '</strong> ' . sprintf(__('%s is not a valid email address.', 'hmbkp'), '<code>' . hmbkp_get_email_address() . '</code>') . '</p></div>'; } add_action('admin_notices', 'hmbkp_email_invalid_warning'); } // If the email failed to send if (hmbkp_get_email_address() && get_option('hmbkp_email_error')) { function hmbkp_email_failed_warning() { echo '<div id="hmbkp-warning" class="updated fade"><p><strong>' . __('BackUpWordPress has detected a problem.', 'hmbkp') . '</strong> ' . __('The last backup email failed to send. It\'s likely that the file is to large.', 'hmbkp') . '</p></div>'; } add_action('admin_notices', 'hmbkp_email_failed_warning'); } // If a custom backups directory is defined and it doesn't exist and can't be created if (defined('HMBKP_PATH') && HMBKP_PATH && !is_dir(HMBKP_PATH)) { function hmbkp_custom_path_exists_warning() { echo '<div id="hmbkp-warning" class="updated fade"><p><strong>' . __('BackUpWordPress has detected a problem.', 'hmbkp') . '</strong> ' . sprintf(__('Your custom backups directory %s doesn\'t exist and can\'t be created, your backups will be saved to %s instead.', 'hmbkp'), '<code>' . HMBKP_PATH . '</code>', '<code>' . hmbkp_path() . '</code>') . '</p></div>'; } add_action('admin_notices', 'hmbkp_custom_path_exists_warning'); } // If a custom backups directory is defined and exists but isn't writable if (defined('HMBKP_PATH') && HMBKP_PATH && is_dir(HMBKP_PATH) && !is_writable(HMBKP_PATH)) { function hmbkp_custom_path_writable_notice() { echo '<div id="hmbkp-warning" class="updated fade"><p><strong>' . __('BackUpWordPress has detected a problem.', 'hmbkp') . '</strong> ' . sprintf(__('Your custom backups directory %s isn\'t writable, new backups will be saved to %s instead.', 'hmbkp'), '<code>' . HMBKP_PATH . '</code>', '<code>' . hmbkp_path() . '</code>') . '</p></div>'; } add_action('admin_notices', 'hmbkp_custom_path_writable_notice'); } // If there are custom excludes defined and any of the files or directories don't exist if (hmbkp_invalid_custom_excludes()) { function hmbkp_invalid_exclude_notice() { echo '<div id="hmbkp-warning" class="updated fade"><p><strong>' . __('BackUpWordPress has detected a problem.', 'hmbkp') . '</strong> ' . sprintf(__('You have defined a custom exclude list but the following paths don\'t exist %s, are you sure you entered them correctly?', 'hmbkp'), '<code>' . implode('</code>, <code>', (array) hmbkp_invalid_custom_excludes()) . '</code>') . '</p></div>'; } add_action('admin_notices', 'hmbkp_invalid_exclude_notice'); } // If there are any errors reported in the backup if (hmbkp_backup_errors_message()) { function hmbkp_backup_errors_notice() { echo '<div id="hmbkp-warning" class="updated fade"><p><strong>' . __('BackUpWordPress detected issues with your last backup.', 'hmbkp') . '</strong><a href="' . add_query_arg('action', 'hmbkp_dismiss_error') . '" style="float: right;" class="button">Dismiss</a></p>' . hmbkp_backup_errors_message() . '</div>'; } add_action('admin_notices', 'hmbkp_backup_errors_notice'); } }
<option value="default" <?php selected(!get_option('hmbkp_files_only') && !get_option('hmbkp_database_only')); ?> ><?php _e('database & files', 'hmbkp'); ?> </option> <option <?php selected(hmbkp_get_database_only()); ?> ><?php _e('database only', 'hmbkp'); ?> </option> <option <?php selected(hmbkp_get_files_only()); ?> ><?php _e('files only', 'hmbkp'); ?> </option> </select> </td> </tr> <tr align="top"> <th scope="row"><label for="hmbkp_backup_number"><?php _e('Number of backups', 'hmbkp'); ?>