/** * 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(); }
<?php } ?> </p> <p>✓ <span class="hmbkp_estimated-size"><?php printf(__('Your site is %s. Backups will be compressed and should be smaller than this.', 'hmbkp'), get_transient('hmbkp_estimated_filesize') ? '<code>' . hmbkp_calculate() . '</code>' : '<code class="calculate">' . __('Calculating Size...', 'hmbkp') . '</code>'); ?> </span></p> <?php if (hmbkp_get_email_address()) { ?> <p>✓ <?php printf(__('A copy of each backup will be emailed to %s.', 'hmbkp'), '<code>' . hmbkp_get_email_address() . '</code>'); ?> </p> <?php } ?> <?php if (($valid_excludes = hmbkp_valid_custom_excludes()) && !hmbkp_get_database_only()) { ?> <p>✓ <?php printf(__('The following paths will be excluded from your backups %s.', 'hmbkp'), '<code>' . implode('</code>, <code>', $valid_excludes) . '</code>'); ?> </p> <?php }
/** * 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'); } }
</span></td> </tr> <tr align="top"> <th scope="row"><label for="hmbkp_excludes"><?php _e('Excludes', 'hmbkp'); ?> </th> <td> <textarea class="code large-text<?php if (defined('HMBKP_EXCLUDE') || hmbkp_get_database_only()) { echo ' disabled'; } ?> " name="hmbkp_excludes" id="hmbkp_excludes" <?php disabled(defined('HMBKP_EXCLUDE') || hmbkp_get_database_only()); ?> ><?php echo hmbkp_get_excludes(); ?> </textarea> <span class="description"><?php _e('A comma separated list of file and directory paths that you do <strong>not</strong> want to backup.', 'hmbkp'); ?> </span><br/> <?php _e('e.g.', 'hmbkp'); ?> <code>file.php, /directory/, /directory/file.jpg</code> </td> </tr>