WP Database Backup: Quick Fix

Please note this plugin is no longer supported. Recent versions of the WordPress Database Backup plugin have corrected the issue this temporary fix was solving. This plugin will remain only for users who do not wish to upgrade.

The WordPress Plugin, WordPress Database Backup by Austin Matzko is one of the more intuitive backup plugins currently available and with no stern warnings to scare off the faint of heart it has held its own as a very effective and useful tool. However, a small issue exists for users of WordPress 1.9.1 – 2.8 wherein the navigation menu has simply disappeared. This applies only to WordPress Database Backup version 2.2.2. The plugin performs correctly if setup prior to upgrading but no longer provides an easy way to make changes or force a manual backup. We that our clients needed immediate access and so we created a quick fix and provided a download until the issue is corrected by the author.

Although the issue is a lack of management capabilities, we will be covering two modifications within this tutorial. The first alteration is rediscovering and relocating the menu to a more suitable position under the Settings dropdown and the second alteration will be Granting Permissions to users other than the administrator.

Download the Plugin


Instructions for Updating


Rediscover and Relocate

In order to access the plugin's settings page, we will relocate the menu by altering the current page_hook from "add_management_page" to one of the many other options available ( see Adding Administration Menus codex ) provided by WordPress for more information. For our purposes, we will be moving it to the Settings dropdown by using "add_options_page". Begin by locating the "wp-db-backup.php" file and look for the following line of code at 593:

function admin_menu() {
  $_page_hook = add_management_page(__('Backup','wp-db-backup'), __('Backup','wp-db-backup'), 'import', $this->basename, array(&$this, 'backup_menu'));
    add_action('load-' . $_page_hook, array(&$this, 'admin_load'));
    if ( function_exists('add_contextual_help') ) {
    $text = $this->help_menu();
    add_contextual_help($_page_hook, $text);
   }
  }

and alter it from "add_management_page" to "add_options_page" which will move it from the Edit drop-down to the Settings drop-down helping to keep the menu structure clean and organized.

function admin_menu() {
  $_page_hook = add_options_page(__('Backup','wp-db-backup'), __('Backup','wp-db-backup'), '1', $this->basename, array(&$this, 'backup_menu'));
    add_action('load-' . $_page_hook, array(&$this, 'admin_load'));
    if ( function_exists('add_contextual_help') ) {
    $text = $this->help_menu();
    add_contextual_help($_page_hook, $text);
   }
  }

To complete the move locate this next line of code starting at 601:

function fragment_menu() {
  $page_hook = add_management_page(__('Backup','wp-db-backup'), __('Backup','wp-db-backup'), 'import', $this->basename, array(&$this, 'build_backup_script'));
    add_action('load-' . $page_hook, array(&$this, 'admin_load'));
   }

and again alter it from "add_management_page" to "add_options_page".

function fragment_menu() {
  $page_hook = add_options_page(__('Backup','wp-db-backup'), __('Backup','wp-db-backup'), 'import', $this->basename, array(&$this, 'build_backup_script'));
    add_action('load-' . $page_hook, array(&$this, 'admin_load'));
   }

This completes the Rediscovery and Relocation and at this point, it is not necessary to move forward with the next step for Administrative access only. Because we needed to grant permissions to the Backup option for all users, we will demonstrate this as well.

 

Grant Permissions

In order to grant usage permissions, WordPress provides a very intuitive and useful sliding scale ranging from 1 to 10 as well as a myriad of other capabilities specific to a user level to determine the access a particular user may have. For further information on this subject please see the Roles and Capabilities codex provided by WordPress.

Currently WordPress Database Backup utilizes the "import" role granting access by the site administrator only. We will be making a minor alteration to grant all but subscribers access by using "level_1". Locate the following function starting at 592:

function admin_menu() {
  $_page_hook = add_management_page(__('Backup','wp-db-backup'), __('Backup','wp-db-backup'), 'import',

and alter "import" to "level_1".

function admin_menu() {
  $_page_hook = add_options_page(__('Backup','wp-db-backup'), __('Backup','wp-db-backup'), 'level_1',

Next, locate the following function starting on line 601:

function fragment_menu() {
  $page_hook = add_management_page(__('Backup','wp-db-backup'), __('Backup','wp-db-backup'), 'import',

and again alter "import" to "level_1".

function fragment_menu() {
  $page_hook = add_management_page(__('Backup','wp-db-backup'), __('Backup','wp-db-backup'), 'level_1',

To complete the user access permissions locate the following on line 1389:

if ( ( $this->wp_secure('fatal', $loc) ) && current_user_can('import') )
  $can = $this->verify_nonce($_REQUEST['_wpnonce'], $this->referer_check_key, $loc);

and alter "import" to "level_1".

if ( ( $this->wp_secure('fatal', $loc) ) && current_user_can('level_1') )
  $can = $this->verify_nonce($_REQUEST['_wpnonce'], $this->referer_check_key, $loc);

Please note that any role or capability access can be used, we simply needed this particular role.