Support » Plugin: WP-DBManager » 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:


    1) 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:

    <!-- 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>
    <!-- END Add -->
    	<td colspan="2" ...

    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:

    $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:
    	update_option( 'dbmanager_options', $backup_options );
    // END added

    Finally, in wp-dbmanager.php, Around 387:

    if(sizeof($database_files) >= $backup_options['max_backup']) {
    	// ADD:
    		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.