Index: wp-admin/options-privacy.php
===================================================================
--- wp-admin/options-privacy.php (revision 11907)
+++ wp-admin/options-privacy.php (working copy)
@@ -9,8 +9,7 @@
/** Load WordPress Administration Bootstrap */
require_once('./admin.php');
-if ( ! current_user_can('manage_options') )
- wp_die(__('You do not have sufficient permissions to manage options for this blog.'));
+check_authorization('manage_options', 'manage options for this blog.');
$title = __('Privacy Settings');
$parent_file = 'options-general.php';
Index: wp-admin/includes/misc.php
===================================================================
--- wp-admin/includes/misc.php (revision 11907)
+++ wp-admin/includes/misc.php (working copy)
@@ -638,4 +638,16 @@
unlink($path);
return true;
}
+
+function check_authorization($capability, $message, $full_message=false){
+ if ( ! current_user_can($capability) ){
+ if ($full_message)
+ $message = __($message);
+ else
+ $message = __("You do not have sufficient permissions to") . ' ' . __($message);
+
+ wp_die($message);
+ }
+}
+
?>
Index: wp-admin/update.php
===================================================================
--- wp-admin/update.php (revision 11907)
+++ wp-admin/update.php (working copy)
@@ -17,8 +17,7 @@
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';
if ( 'upgrade-plugin' == $action ) {
- if ( ! current_user_can('update_plugins') )
- wp_die(__('You do not have sufficient permissions to update plugins for this blog.'));
+ check_authorization('update_plugins', 'update plugins for this blog.');
check_admin_referer('upgrade-plugin_' . $plugin);
@@ -36,8 +35,7 @@
include('admin-footer.php');
} elseif ('activate-plugin' == $action ) {
- if ( ! current_user_can('update_plugins') )
- wp_die(__('You do not have sufficient permissions to update plugins for this blog.'));
+ check_authorization('update_plugins', 'update plugins for this blog.');
check_admin_referer('activate-plugin_' . $plugin);
if( ! isset($_GET['failure']) && ! isset($_GET['success']) ) {
@@ -59,8 +57,7 @@
iframe_footer();
} elseif ( 'install-plugin' == $action ) {
- if ( ! current_user_can('install_plugins') )
- wp_die(__('You do not have sufficient permissions to install plugins for this blog.'));
+ check_authorization('install_plugins', 'install plugins for this blog.');
include_once ABSPATH . 'wp-admin/includes/plugin-install.php'; //for plugins_api..
@@ -87,8 +84,7 @@
} elseif ( 'upload-plugin' == $action ) {
- if ( ! current_user_can('install_plugins') )
- wp_die(__('You do not have sufficient permissions to install plugins for this blog.'));
+ check_authorization('install_plugins', 'install plugins for this blog.');
check_admin_referer('plugin-upload');
@@ -111,8 +107,7 @@
} elseif ( 'upgrade-theme' == $action ) {
- if ( ! current_user_can('update_themes') )
- wp_die(__('You do not have sufficient permissions to update themes for this blog.'));
+ check_authorization('update_themes', 'update themes for this blog.');
check_admin_referer('upgrade-theme_' . $theme);
@@ -133,8 +128,7 @@
} elseif ( 'install-theme' == $action ) {
- if ( ! current_user_can('install_themes') )
- wp_die(__('You do not have sufficient permissions to install themes for this blog.'));
+ check_authorization('install_themes', 'install themes for this blog.');
include_once ABSPATH . 'wp-admin/includes/theme-install.php'; //for themes_api..
@@ -163,8 +157,7 @@
} elseif ( 'upload-theme' == $action ) {
- if ( ! current_user_can('install_themes') )
- wp_die(__('You do not have sufficient permissions to install themes for this blog.'));
+ check_authorization('install_themes', 'install themes for this blog.');
check_admin_referer('theme-upload');
Index: wp-admin/theme-editor.php
===================================================================
--- wp-admin/theme-editor.php (revision 11907)
+++ wp-admin/theme-editor.php (working copy)
@@ -9,8 +9,7 @@
/** WordPress Administration Bootstrap */
require_once('admin.php');
-if ( !current_user_can('edit_themes') )
- wp_die('
'.__('You do not have sufficient permissions to edit templates for this blog.').'
');
+check_authorization('edit_themes', 'edit templates for this blog.');
$title = __("Edit Themes");
$parent_file = 'themes.php';
Index: wp-admin/options-general.php
===================================================================
--- wp-admin/options-general.php (revision 11907)
+++ wp-admin/options-general.php (working copy)
@@ -9,8 +9,7 @@
/** WordPress Administration Bootstrap */
require_once('./admin.php');
-if ( ! current_user_can('manage_options') )
- wp_die(__('You do not have sufficient permissions to manage options for this blog.'));
+check_authorization('manage_options', 'manage options for this blog.');
$title = __('General Settings');
$parent_file = 'options-general.php';
Index: wp-admin/options-media.php
===================================================================
--- wp-admin/options-media.php (revision 11907)
+++ wp-admin/options-media.php (working copy)
@@ -9,8 +9,7 @@
/** WordPress Administration Bootstrap */
require_once('admin.php');
-if ( ! current_user_can('manage_options') )
- wp_die(__('You do not have sufficient permissions to manage options for this blog.'));
+check_authorization('manage_options', 'manage options for this blog.');
$title = __('Media Settings');
$parent_file = 'options-general.php';
Index: wp-admin/options-misc.php
===================================================================
--- wp-admin/options-misc.php (revision 11907)
+++ wp-admin/options-misc.php (working copy)
@@ -9,8 +9,7 @@
/** WordPress Administration Bootstrap */
require_once('admin.php');
-if ( ! current_user_can('manage_options') )
- wp_die(__('You do not have sufficient permissions to manage options for this blog.'));
+check_authorization('manage_options', 'manage options for this blog.');
$title = __('Miscellaneous Settings');
$parent_file = 'options-general.php';
Index: wp-admin/edit-link-category-form.php
===================================================================
--- wp-admin/edit-link-category-form.php (revision 11907)
+++ wp-admin/edit-link-category-form.php (working copy)
@@ -10,8 +10,7 @@
if ( !defined('ABSPATH') )
die('-1');
-if ( !current_user_can('manage_categories') )
- wp_die(__('You do not have sufficient permissions to edit link categories for this blog.'));
+check_authorization('manage_categories', 'edit link categories for this blog.');
/**
* @var object
Index: wp-admin/edit-tag-form.php
===================================================================
--- wp-admin/edit-tag-form.php (revision 11907)
+++ wp-admin/edit-tag-form.php (working copy)
@@ -10,8 +10,7 @@
if ( !defined('ABSPATH') )
die('-1');
-if ( !current_user_can('manage_categories') )
- wp_die(__('You do not have sufficient permissions to edit tags for this blog.'));
+check_authorization('manage_categories', 'edit tags for this blog.');
if ( empty($tag_ID) ) { ?>
Index: wp-admin/plugin-install.php
===================================================================
--- wp-admin/plugin-install.php (revision 11907)
+++ wp-admin/plugin-install.php (working copy)
@@ -9,8 +9,7 @@
/** WordPress Administration Bootstrap */
require_once('admin.php');
-if ( ! current_user_can('install_plugins') )
- wp_die(__('You do not have sufficient permissions to install plugins on this blog.'));
+check_authorization('install_plugins', 'install plugins on this blog.');
include(ABSPATH . 'wp-admin/includes/plugin-install.php');
Index: wp-admin/options-discussion.php
===================================================================
--- wp-admin/options-discussion.php (revision 11907)
+++ wp-admin/options-discussion.php (working copy)
@@ -9,8 +9,7 @@
/** WordPress Administration Bootstrap */
require_once('admin.php');
-if ( ! current_user_can('manage_options') )
- wp_die(__('You do not have sufficient permissions to manage options for this blog.'));
+check_authorization('manage_options', 'manage options for this blog.');
$title = __('Discussion Settings');
$parent_file = 'options-general.php';
Index: wp-admin/plugins.php
===================================================================
--- wp-admin/plugins.php (revision 11907)
+++ wp-admin/plugins.php (working copy)
@@ -9,8 +9,7 @@
/** WordPress Administration Bootstrap */
require_once('admin.php');
-if ( ! current_user_can('activate_plugins') )
- wp_die(__('You do not have sufficient permissions to manage plugins for this blog.'));
+check_authorization('activate_plugins', 'manage plugins for this blog.');
if ( isset($_POST['clear-recent-list']) )
$action = 'clear-recent-list';
@@ -40,8 +39,7 @@
if ( !empty($action) ) {
switch ( $action ) {
case 'activate':
- if ( ! current_user_can('activate_plugins') )
- wp_die(__('You do not have sufficient permissions to activate plugins for this blog.'));
+ check_authorization('activate_plugins', 'activate plugins for this blog.');
check_admin_referer('activate-plugin_' . $plugin);
@@ -59,8 +57,7 @@
exit;
break;
case 'activate-selected':
- if ( ! current_user_can('activate_plugins') )
- wp_die(__('You do not have sufficient permissions to activate plugins for this blog.'));
+ check_authorization('activate_plugins', 'activate plugins for this blog.');
check_admin_referer('bulk-manage-plugins');
@@ -84,8 +81,7 @@
exit;
break;
case 'error_scrape':
- if ( ! current_user_can('activate_plugins') )
- wp_die(__('You do not have sufficient permissions to activate plugins for this blog.'));
+ check_authorization('activate_plugins', 'activate plugins for this blog.');
check_admin_referer('plugin-activation-error_' . $plugin);
@@ -100,8 +96,7 @@
exit;
break;
case 'deactivate':
- if ( ! current_user_can('activate_plugins') )
- wp_die(__('You do not have sufficient permissions to deactivate plugins for this blog.'));
+ check_authorization('activate_plugins', 'deactivate plugins for this blog.');
check_admin_referer('deactivate-plugin_' . $plugin);
deactivate_plugins($plugin);
@@ -110,8 +105,7 @@
exit;
break;
case 'deactivate-selected':
- if ( ! current_user_can('activate_plugins') )
- wp_die(__('You do not have sufficient permissions to deactivate plugins for this blog.'));
+ check_authorization('activate_plugins', 'deactivate plugins for this blog.');
check_admin_referer('bulk-manage-plugins');
@@ -133,8 +127,7 @@
exit;
break;
case 'delete-selected':
- if ( ! current_user_can('delete_plugins') )
- wp_die(__('You do not have sufficient permissions to delete plugins for this blog.'));
+ check_authorization('delete_plugins', 'delete plugins for this blog.');
check_admin_referer('bulk-manage-plugins');
Index: wp-admin/link-add.php
===================================================================
--- wp-admin/link-add.php (revision 11907)
+++ wp-admin/link-add.php (working copy)
@@ -9,8 +9,7 @@
/** Load WordPress Administration Bootstrap */
require_once('admin.php');
-if ( ! current_user_can('manage_links') )
- wp_die(__('You do not have sufficient permissions to add links to this blog.'));
+check_authorization('manage_links', 'add links to this blog.');
$title = __('Add New Link');
$parent_file = 'link-manager.php';
Index: wp-admin/link.php
===================================================================
--- wp-admin/link.php (revision 11907)
+++ wp-admin/link.php (working copy)
@@ -14,8 +14,7 @@
wp_reset_vars(array('action', 'cat_id', 'linkurl', 'name', 'image', 'description', 'visible', 'target', 'category', 'link_id', 'submit', 'order_by', 'links_show_cat_id', 'rating', 'rel', 'notes', 'linkcheck[]'));
-if ( ! current_user_can('manage_links') )
- wp_die( __('You do not have sufficient permissions to edit the links for this blog.') );
+check_authorization('manage_links', 'edit the links for this blog.');
if ( !empty($_POST['deletebookmarks']) )
$action = 'deletebookmarks';
Index: wp-admin/edit-category-form.php
===================================================================
--- wp-admin/edit-category-form.php (revision 11907)
+++ wp-admin/edit-category-form.php (working copy)
@@ -10,8 +10,7 @@
if ( !defined('ABSPATH') )
die('-1');
-if ( !current_user_can('manage_categories') )
- wp_die(__('You do not have sufficient permissions to edit categories for this blog.'));
+check_authorization('manage_categories', 'edit categories for this blog. for this blog.');
/**
* @var object
Index: wp-admin/options-reading.php
===================================================================
--- wp-admin/options-reading.php (revision 11907)
+++ wp-admin/options-reading.php (working copy)
@@ -9,8 +9,7 @@
/** WordPress Administration Bootstrap */
require_once('admin.php');
-if ( ! current_user_can('manage_options') )
- wp_die(__('You do not have sufficient permissions to manage options for this blog.'));
+check_authorization('manage_options', 'manage options for this blog.');
$title = __('Reading Settings');
$parent_file = 'options-general.php';
Index: wp-admin/link-manager.php
===================================================================
--- wp-admin/link-manager.php (revision 11907)
+++ wp-admin/link-manager.php (working copy)
@@ -14,8 +14,7 @@
check_admin_referer('bulk-bookmarks');
$doaction = $_GET['action'] ? $_GET['action'] : $_GET['action2'];
- if ( ! current_user_can('manage_links') )
- wp_die( __('You do not have sufficient permissions to edit the links for this blog.') );
+ check_authorization('manage_links', 'edit the links for this blog.');
if ( 'delete' == $doaction ) {
foreach ( (array) $_GET['linkcheck'] as $link_id ) {
@@ -44,8 +43,7 @@
$this_file = $parent_file = 'link-manager.php';
include_once ("./admin-header.php");
-if (!current_user_can('manage_links'))
- wp_die(__("You do not have sufficient permissions to edit the links for this blog."));
+check_authorization('manage_links', 'edit the links for this blog.');
switch ($order_by) {
case 'order_id' :
Index: wp-admin/theme-install.php
===================================================================
--- wp-admin/theme-install.php (revision 11907)
+++ wp-admin/theme-install.php (working copy)
@@ -9,8 +9,7 @@
/** WordPress Administration Bootstrap */
require_once('admin.php');
-if ( ! current_user_can('install_themes') )
- wp_die(__('You do not have sufficient permissions to install themes on this blog.'));
+check_authorization('install_themes', 'install themes on this blog.');
include(ABSPATH . 'wp-admin/includes/theme-install.php');
Index: wp-admin/update-core.php
===================================================================
--- wp-admin/update-core.php (revision 11907)
+++ wp-admin/update-core.php (working copy)
@@ -9,8 +9,7 @@
/** WordPress Administration Bootstrap */
require_once('admin.php');
-if ( ! current_user_can('update_plugins') )
- wp_die(__('You do not have sufficient permissions to update plugins for this blog.'));
+check_authorization('update_plugins', 'update plugins for this blog.');
function list_core_update( $update ) {
global $wp_local_package;
Index: wp-admin/import.php
===================================================================
--- wp-admin/import.php (revision 11907)
+++ wp-admin/import.php (working copy)
@@ -9,8 +9,7 @@
/** Load WordPress Bootstrap */
require_once ('admin.php');
-if ( !current_user_can('edit_files') )
- wp_die(__('You do not have sufficient permissions to import content in this blog.'));
+check_authorization('edit_files', 'import content in this blog.');
$title = __('Import');
require_once ('admin-header.php');
Index: wp-admin/options-permalink.php
===================================================================
--- wp-admin/options-permalink.php (revision 11907)
+++ wp-admin/options-permalink.php (working copy)
@@ -9,8 +9,7 @@
/** WordPress Administration Bootstrap */
require_once('admin.php');
-if ( ! current_user_can('manage_options') )
- wp_die(__('You do not have sufficient permissions to manage options for this blog.'));
+check_authorization('manage_options', 'manage options for this blog.');
$title = __('Permalink Settings');
$parent_file = 'options-general.php';
Index: wp-admin/options-writing.php
===================================================================
--- wp-admin/options-writing.php (revision 11907)
+++ wp-admin/options-writing.php (working copy)
@@ -9,8 +9,7 @@
/** WordPress Administration Bootstrap */
require_once('admin.php');
-if ( ! current_user_can('manage_options') )
- wp_die(__('You do not have sufficient permissions to manage options for this blog.'));
+check_authorization('manage_options', 'manage options for this blog.');
$title = __('Writing Settings');
$parent_file = 'options-general.php';
Index: wp-admin/export.php
===================================================================
--- wp-admin/export.php (revision 11907)
+++ wp-admin/export.php (working copy)
@@ -9,8 +9,7 @@
/** Load WordPress Bootstrap */
require_once ('admin.php');
-if ( !current_user_can('edit_files') )
- wp_die(__('You do not have sufficient permissions to export the content of this blog.'));
+check_authorization('edit_files', 'export the content of this blog.');
/** Load WordPress export API */
require_once('includes/export.php');
Index: wp-admin/plugin-editor.php
===================================================================
--- wp-admin/plugin-editor.php (revision 11907)
+++ wp-admin/plugin-editor.php (working copy)
@@ -9,8 +9,7 @@
/** WordPress Administration Bootstrap */
require_once('admin.php');
-if ( !current_user_can('edit_plugins') )
- wp_die(''.__('You do not have sufficient permissions to edit plugins for this blog.').'
');
+check_authorization('edit_plugins', 'edit plugins for this blog.');
$title = __("Edit Plugins");
$parent_file = 'plugins.php';