Easy Trix: How to add notes to WP DBManager
-
We requested “notes” a few years ago and meanwhile we using this hack to add notes to each Manual backup. When working on an install the same day, the dates does not help us revert easy to our test cases.
We ADD (not delete or replace anything) a small pice of code in 3 files:
wp-dbmanager.php
database-backup.php
database-manage.php1) ADD Notes
database-backup.php, On around line 62:$text = '<p style="color: green;">'.sprintf(__('Database Backed Up Successfully On \'%s\'.', 'wp-dbmanager'), $current_date).'</p>'; // ADD: if(!empty($_POST['wp-dbmanager-note'])) $backup_options[$backup['filename']] = sanitize_text_field( $_POST['wp-dbmanager-note'] ); else $backup_options[$backup['filename']] = __('Manual', 'wp-dbmanager'); update_option( 'dbmanager_options', $backup_options );
Then Add a table row at the end of the same file, around line 250:
</tr> <!-- ADD: --> <tr style="background-color: #eee;"> <th><?php _e('Database Backup Note:', 'wp-dbmanager'); ?></th> <td><input type="text" style="width: 100%;" name="wp-dbmanager-note" id="wp-dbmanager-note" value=""></td> </tr> <!-- END Add --> <tr> <td colspan="2" ...
Next,
In file: database-manage.php, Around line 120, the rendering of the “manage backups” table:<th><?php _e('Date/Time', 'wp-dbmanager'); ?></th> <!-- ADD Th row: --> <th><?php _e('Note', 'wp-dbmanager'); ?></th>
And the in the tbody loop in the same table:
$no++; $database_text = substr($database_files[$i], 13); echo "<td>$date_text</td>"; // ADD if(isset($backup_options[$database_files[$i]]) && $backup_options[$database_files[$i]]) $note = $backup_options[$database_files[$i]]; else $note = __('Auto', 'wp-dbmanager'); echo "<td>$note</td>"; // END Add
2) DELETE Notes from deleted files
To clean up deleted notes (optional), in the same file: database-manage.php, UP Around line 91$text .= '<p style="color: green;">'.sprintf(__('Database Backup File On \'%s\' Deleted Successfully', 'wp-dbmanager'), $nice_file_date).'</p>'; // Add: if(isset($backup_options[$database_files[0]])){ unset($backup_options[$database_files[0]]); update_option( 'dbmanager_options', $backup_options ); } // END added
Finally, in wp-dbmanager.php, Around 387:
if(sizeof($database_files) >= $backup_options['max_backup']) { @unlink($backup_options['path'].'/'.$database_files[0]); // ADD: if(isset($backup_options[$database_files[0]])){ unset($backup_options[$database_files[0]]); update_option( 'dbmanager_options', $backup_options ); } // END Add }
Hope the posting doesnt break anything.
- The topic ‘Easy Trix: How to add notes to WP DBManager’ is closed to new replies.