Skip to content

Commit 11eccae

Browse files
committed
Merge pull request #936 from humanmade/backup-engines
The Great Backup Refactor of 2015
2 parents ccc0ab7 + 7031a2b commit 11eccae

78 files changed

Lines changed: 4917 additions & 5105 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

admin/actions.php

Lines changed: 101 additions & 114 deletions
Large diffs are not rendered by default.

admin/backups-table.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
1+
<?php
2+
3+
namespace HM\BackUpWordPress;
4+
5+
?>
6+
17
<table class="widefat">
28

39
<thead>
410

511
<tr>
612

7-
<th scope="col"><?php hmbkp_backups_number( $schedule ); ?></th>
13+
<th scope="col"><?php backups_number( $schedule ); ?></th>
814
<th scope="col"><?php _e( 'Size', 'backupwordpress' ); ?></th>
915
<th scope="col"><?php _e( 'Type', 'backupwordpress' ); ?></th>
1016
<th scope="col"><?php _e( 'Actions', 'backupwordpress' ); ?></th>
@@ -25,7 +31,7 @@
2531
continue;
2632
}
2733

28-
hmbkp_get_backup_row( $file, $schedule );
34+
get_backup_row( $file, $schedule );
2935

3036
}
3137

admin/backups.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,28 @@
11
<?php
22

3+
namespace HM\BackUpWordPress;
4+
35
// Refresh the schedules from the database to make sure we have the latest changes
4-
HM\BackUpWordPress\Schedules::get_instance()->refresh_schedules();
6+
Schedules::get_instance()->refresh_schedules();
57

6-
$schedules = HM\BackUpWordPress\Schedules::get_instance()->get_schedules();
8+
$schedules = Schedules::get_instance()->get_schedules();
79

810
if ( ! empty( $_GET['hmbkp_schedule_id'] ) ) {
9-
$current_schedule = new HM\BackUpWordPress\Scheduled_Backup( sanitize_text_field( $_GET['hmbkp_schedule_id'] ) );
11+
$current_schedule = new Scheduled_Backup( sanitize_text_field( $_GET['hmbkp_schedule_id'] ) );
1012
} else {
1113
$current_schedule = reset( $schedules );
1214
} ?>
1315

1416
<h2 class="nav-tab-wrapper">
1517

16-
<?php foreach ( $schedules as $schedule ) : ?>
18+
<?php foreach ( $schedules as $schedule ) :
19+
$status = new Backup_Status( $schedule->get_id() ); ?>
1720

18-
<a class="nav-tab<?php if ( $schedule->get_status() ) { ?> hmbkp-running<?php } ?><?php if ( $schedule->get_id() === $current_schedule->get_id() ) { ?> nav-tab-active<?php } ?>" <?php if ( $schedule->get_status() ) { ?>title="<?php echo esc_attr( strip_tags( $schedule->get_status() ) ); ?>"<?php } ?> href="<?php echo esc_url( add_query_arg( 'hmbkp_schedule_id', $schedule->get_id(), HMBKP_ADMIN_URL ) ); ?> "><?php echo esc_html( hmbkp_translated_schedule_title( $schedule->get_slug(), $schedule->get_name() ) ); ?> <span class="count">(<?php echo esc_html( count( $schedule->get_backups() ) ); ?>)</span></a>
21+
<a class="nav-tab<?php if ( $status->get_status() ) { ?> hmbkp-running<?php } ?><?php if ( $schedule->get_id() === $current_schedule->get_id() ) { ?> nav-tab-active<?php } ?>" <?php if ( $status->get_status() ) { ?>title="<?php echo esc_attr( strip_tags( $status->get_status() ) ); ?>"<?php } ?> href="<?php echo esc_url( add_query_arg( 'hmbkp_schedule_id', $schedule->get_id(), HMBKP_ADMIN_URL ) ); ?> "><?php echo esc_html( translated_schedule_title( $schedule->get_slug(), $schedule->get_name() ) ); ?> <span class="count">(<?php echo esc_html( count( $schedule->get_backups() ) ); ?>)</span></a>
1922

2023
<?php endforeach; ?>
2124

22-
<a class="nav-tab<?php if ( ! HM\BackUpWordPress\Schedules::get_instance()->get_schedule( $current_schedule->get_id() ) ) { ?> nav-tab-active<?php } ?>" href="<?php echo esc_url( add_query_arg( array( 'hmbkp_add_schedule' => '1', 'action' => 'hmbkp_edit_schedule', 'hmbkp_schedule_id' => time(), 'hmbkp_panel' => 'hmbkp_edit_schedule_settings' ), HMBKP_ADMIN_URL ) ); ?>"> + <?php _e( 'add schedule', 'backupwordpress' ); ?></a>
25+
<a class="nav-tab<?php if ( ! Schedules::get_instance()->get_schedule( $current_schedule->get_id() ) ) { ?> nav-tab-active<?php } ?>" href="<?php echo esc_url( add_query_arg( array( 'hmbkp_add_schedule' => '1', 'action' => 'hmbkp_edit_schedule', 'hmbkp_schedule_id' => time(), 'hmbkp_panel' => 'hmbkp_edit_schedule_settings' ), HMBKP_ADMIN_URL ) ); ?>"> + <?php _e( 'add schedule', 'backupwordpress' ); ?></a>
2326

2427
</h2>
2528

@@ -34,4 +37,4 @@
3437

3538
<?php require( HMBKP_PLUGIN_PATH . 'admin/backups-table.php' ); ?>
3639

37-
</div>
40+
</div>

admin/constants.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
<?php
2+
3+
namespace HM\BackUpWordPress;
4+
5+
?>
6+
17
<div id="hmbkp-constants">
28

39
<p><?php printf( __( 'You can %1$s any of the following %2$s in your %3$s to control advanced settings. %4$s. Defined %5$s will be highlighted.', 'backupwordpress' ), '<code>define</code>', '<code>' . __( 'Constants', 'backupwordpress' ) . '</code>', '<code>wp-config.php</code>', '<a href="http://codex.wordpress.org/Editing_wp-config.php">' . __( 'The Codex can help', 'backupwordpress' ) . '</a>', '<code>' . __( 'Constants', 'backupwordpress' ) . '</code>' ); ?></p>
@@ -14,7 +20,7 @@
1420
<p><?php printf( __( 'You\'ve set it to: %s', 'backupwordpress' ), '<code>' . esc_html( HMBKP_PATH ) . '</code>' ); ?></p>
1521
<?php } ?>
1622

17-
<p><?php printf( __( 'The path to the folder you would like to store your backup files in, defaults to %s.', 'backupwordpress' ), '<code>' . esc_html( hmbkp_path() ) . '</code>' ); ?> <?php _e( 'e.g.', 'backupwordpress' ); ?> <code>define( 'HMBKP_PATH', '/home/willmot/backups' );</code></p>
23+
<p><?php printf( __( 'The path to the folder you would like to store your backup files in, defaults to %s.', 'backupwordpress' ), '<code>' . esc_html( Path::get_path() ) . '</code>' ); ?> <?php _e( 'e.g.', 'backupwordpress' ); ?> <code>define( 'HMBKP_PATH', '/home/willmot/backups' );</code></p>
1824

1925
</td>
2026

@@ -94,7 +100,7 @@
94100
<p><?php printf( __( 'You\'ve set it to: %s', 'backupwordpress' ), '<code>' . esc_html( HMBKP_ROOT ) . '</code>' ); ?></p>
95101
<?php } ?>
96102

97-
<p><?php printf( __( 'The root directory that is backed up. Defaults to %s.', 'backupwordpress' ), '<code>' . HM\BackUpWordPress\Backup::get_home_path() . '</code>' ); ?> <?php _e( 'e.g.', 'backupwordpress' ); ?> <code>define( 'HMBKP_ROOT', ABSPATH . 'wp/' );</code></p>
103+
<p><?php printf( __( 'The root directory that is backed up. Defaults to %s.', 'backupwordpress' ), '<code>' . Path::get_home_path() . '</code>' ); ?> <?php _e( 'e.g.', 'backupwordpress' ); ?> <code>define( 'HMBKP_ROOT', ABSPATH . 'wp/' );</code></p>
98104

99105
</td>
100106

@@ -116,7 +122,7 @@
116122

117123
</tr>
118124

119-
<?php foreach ( HM\BackUpWordPress\Services::get_services() as $file => $service ) {
125+
<?php foreach ( Services::get_services() as $file => $service ) {
120126
echo wp_kses_post( call_user_func( array( $service, 'constant' ) ) );
121127
} ?>
122128

admin/menu.php

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,32 @@
11
<?php
22

3+
namespace HM\BackUpWordPress;
4+
35
/**
46
* Add the backups menu item
57
* to the tools menu
68
*
79
* @return null
810
*/
9-
function hmbkp_admin_menu() {
11+
function admin_menu() {
1012

1113
if ( is_multisite() ) {
12-
13-
add_submenu_page( 'settings.php', __( 'Manage Backups', 'backupwordpress' ), __( 'Backups', 'backupwordpress' ), ( defined( 'HMBKP_CAPABILITY' ) && HMBKP_CAPABILITY ) ? HMBKP_CAPABILITY : 'manage_options', HMBKP_PLUGIN_SLUG, 'hmbkp_manage_backups' );
14-
14+
add_submenu_page( 'settings.php', __( 'Manage Backups', 'backupwordpress' ), __( 'Backups', 'backupwordpress' ), ( defined( 'HMBKP_CAPABILITY' ) && HMBKP_CAPABILITY ) ? HMBKP_CAPABILITY : 'manage_options', HMBKP_PLUGIN_SLUG, 'HM\BackUpWordPress\manage_backups' );
1515
} else {
16-
17-
add_management_page( __( 'Manage Backups', 'backupwordpress' ), __( 'Backups', 'backupwordpress' ), ( defined( 'HMBKP_CAPABILITY' ) && HMBKP_CAPABILITY ) ? HMBKP_CAPABILITY : 'manage_options', HMBKP_PLUGIN_SLUG, 'hmbkp_manage_backups' );
18-
16+
add_management_page( __( 'Manage Backups', 'backupwordpress' ), __( 'Backups', 'backupwordpress' ), ( defined( 'HMBKP_CAPABILITY' ) && HMBKP_CAPABILITY ) ? HMBKP_CAPABILITY : 'manage_options', HMBKP_PLUGIN_SLUG, 'HM\BackUpWordPress\manage_backups' );
1917
}
2018
}
2119

22-
add_action( 'network_admin_menu', 'hmbkp_admin_menu' );
23-
add_action( 'admin_menu', 'hmbkp_admin_menu' );
20+
add_action( 'network_admin_menu', 'HM\BackUpWordPress\admin_menu' );
21+
add_action( 'admin_menu', 'HM\BackUpWordPress\admin_menu' );
2422

2523
/**
2624
* Load the backups admin page
2725
* when the menu option is clicked
2826
*
2927
* @return null
3028
*/
31-
function hmbkp_manage_backups() {
29+
function manage_backups() {
3230
require_once( HMBKP_PLUGIN_PATH . 'admin/page.php' );
3331
}
3432

@@ -40,7 +38,7 @@ function hmbkp_manage_backups() {
4038
*
4139
* @return array $links
4240
*/
43-
function hmbkp_plugin_action_link( $links, $file ) {
41+
function plugin_action_link( $links, $file ) {
4442

4543
if ( false !== strpos( $file, HMBKP_PLUGIN_SLUG ) ) {
4644
array_push( $links, '<a href="' . esc_url( HMBKP_ADMIN_URL ) . '">' . __( 'Backups', 'backupwordpress' ) . '</a>' );
@@ -50,7 +48,7 @@ function hmbkp_plugin_action_link( $links, $file ) {
5048

5149
}
5250

53-
add_filter( 'plugin_action_links', 'hmbkp_plugin_action_link', 10, 2 );
51+
add_filter( 'plugin_action_links', 'HM\BackUpWordPress\plugin_action_link', 10, 2 );
5452

5553
/**
5654
* Add Contextual Help to Backups tools page.
@@ -59,7 +57,7 @@ function hmbkp_plugin_action_link( $links, $file ) {
5957
*
6058
* @return null
6159
*/
62-
function hmbkp_contextual_help() {
60+
function contextual_help() {
6361

6462
// Pre WordPress 3.3 compat
6563
if ( ! method_exists( get_current_screen(), 'add_help_tab' ) ) {
@@ -104,4 +102,4 @@ function hmbkp_contextual_help() {
104102

105103
}
106104

107-
add_action( 'load-' . HMBKP_ADMIN_PAGE, 'hmbkp_contextual_help' );
105+
add_action( 'load-' . HMBKP_ADMIN_PAGE, 'HM\BackUpWordPress\contextual_help' );

admin/page.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
<?php
2+
3+
namespace HM\BackUpWordPress;
4+
5+
?>
6+
17
<div class="wrap">
28

39
<h1>
@@ -12,7 +18,7 @@
1218

1319
</h1>
1420

15-
<?php if ( hmbkp_possible() ) : ?>
21+
<?php if ( is_backup_possible() ) : ?>
1622

1723
<?php include_once( HMBKP_PLUGIN_PATH . 'admin/backups.php' ); ?>
1824

0 commit comments

Comments
 (0)