id = 'backup'; $this->title = __( 'Database Backups', 'better-wp-security' ); $this->description = __( 'Create backups of your site\'s database. The backups can be created manually and on a schedule.', 'better-wp-security' ); $this->type = 'recommended'; parent::__construct(); } public function enqueue_scripts_and_styles() { wp_enqueue_script( 'jquery-multi-select', plugins_url( 'js/jquery.multi-select.js', __FILE__ ), array( 'jquery' ), $this->script_version, true ); $vars = array( 'default_backup_location' => ITSEC_Modules::get_default( $this->id, 'location' ), 'available_tables_label' => __( 'Tables for Backup', 'better-wp-security' ), 'excluded_tables_label' => __( 'Excluded Tables', 'better-wp-security' ), 'creating_backup_text' => __( 'Creating Backup...', 'better-wp-security' ), ); wp_enqueue_script( 'itsec-backup-settings-page-script', plugins_url( 'js/settings-page.js', __FILE__ ), array( 'jquery', 'jquery-multi-select' ), $this->script_version, true ); wp_localize_script( 'itsec-backup-settings-page-script', 'itsec_backup', $vars ); wp_enqueue_style( 'itsec-backup-settings-page-style', plugins_url( 'css/settings-page.css', __FILE__ ), array(), $this->script_version ); } public function handle_ajax_request( $data ) { global $itsec_backup; if ( ! isset( $itsec_backup ) ) { require_once( 'class-itsec-backup.php' ); $itsec_backup = new ITSEC_Backup(); $itsec_backup->run(); } $result = $itsec_backup->do_backup( true ); $message = ''; if ( is_wp_error( $result ) ) { $errors = ITSEC_Response::get_error_strings( $result ); foreach ( $errors as $error ) { $message .= '

' . $error . '

'; } } else if ( is_string( $result ) ) { $message = '

' . $result . '

'; } else { $message = '

' . sprintf( __( 'The backup request returned an unexpected response. It returned a response of type %1$s.', 'better-wp-security' ), gettype( $result ) ) . '

'; } ITSEC_Response::set_response( $message ); } protected function render_description( $form ) { ?>

get_options(); $methods = array( 0 => __( 'Save Locally and Email', 'better-wp-security' ), 1 => __( 'Email Only', 'better-wp-security' ), 2 => __( 'Save Locally Only', 'better-wp-security' ), ); $excludes = $this->get_excludable_tables( $settings ); ?>

add_button( 'create_backup', array( 'value' => __( 'Create a Database Backup', 'better-wp-security' ), 'class' => 'button-primary' ) ); ?>

add_checkbox( 'all_sites' ); ?>
add_select( 'method', $methods ); ?>

add_text( 'location', array( 'class' => 'large-text' ) ); ?>

add_button( 'reset_backup_location', array( 'value' => __( 'Restore Default Location', 'better-wp-security' ), 'class' => 'button-secondary' ) ); ?>
add_text( 'retain', array( 'class' => 'small-text' ) ); ?>

add_checkbox( 'zip' ); ?>

add_multi_select( 'exclude', $excludes ); ?>

add_checkbox( 'enabled', array( 'class' => 'itsec-settings-toggle' ) ); ?>
add_text( 'interval', array( 'class' => 'small-text' ) ); ?>

prepare( 'SHOW TABLES LIKE %s', "{$wpdb->base_prefix}%" ); } $tables = $wpdb->get_results( $query, ARRAY_N ); $excludes = array(); foreach ( $tables as $table ) { $short_table = substr( $table[0], strlen( $wpdb->prefix ) ); if ( in_array( $short_table, $ignored_tables ) ) { continue; } $excludes[$short_table] = $table[0]; } return $excludes; } } new ITSEC_Backup_Settings_Page();