Instructions for Updating
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.
Rediscover and Relocate
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.