Show a better message ondmins on link-manager.php, link-add.php, link.php when links are disabled.

Props nacin
fixes #22569


git-svn-id: http://core.svn.wordpress.org/trunk@22855 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Ryan Boren 2012-11-27 00:20:27 +00:00
parent eb404cc867
commit e55bebac25
2 changed files with 23 additions and 1 deletions

View File

@ -266,3 +266,25 @@ function wp_update_link( $linkdata ) {
return wp_insert_link( $linkdata );
}
/**
* @since 3.5.0
* @access private
*/
function wp_link_manager_disabled_message() {
global $pagenow;
if ( 'link-manager.php' != $pagenow && 'link-add.php' != $pagenow && 'link.php' != $pagenow )
return;
add_filter( 'pre_option_link_manager_enabled', '__return_true', 100 );
$really_can_manage_links = current_user_can( 'manage_links' );
remove_filter( 'pre_option_link_manager_enabled', '__return_true', 100 );
if ( $really_can_manage_links && current_user_can( 'install_plugins' ) ) {
$link = network_admin_url( 'plugin-install.php?tab=search&s=Link+Manager' );
wp_die( sprintf( __( 'If you are looking to use the link manager, please install the <a href="%s">Link Manager</a> plugin.' ), $link ) );
}
wp_die( __( 'You do not have sufficient permissions to edit the links for this site.' ) );
}
add_action( 'admin_page_access_denied', 'wp_link_manager_disabled_message' );

View File

@ -15,7 +15,7 @@ require_once ('admin.php');
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 site.') );
wp_link_manager_disabled_message();
if ( !empty($_POST['deletebookmarks']) )
$action = 'deletebookmarks';