Don't show Appearance > Widgets if the theme has no sidebars defined. props SergeyBiryukov for the initial patch. fixes #21761.

git-svn-id: https://develop.svn.wordpress.org/trunk@21825 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Nacin 2012-09-12 02:16:46 +00:00
parent f8d075eca3
commit 5d3c3fcfba
2 changed files with 6 additions and 17 deletions

View File

@ -68,23 +68,8 @@ get_current_screen()->set_help_sidebar(
'<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>' '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
); );
if ( empty($wp_registered_sidebars) ) { if ( ! current_theme_supports( 'widgets' ) ) {
// the theme has no sidebars, die. wp_die( __( 'The theme you are currently using isn&#8217;t widget-aware, meaning that it has no sidebars that you are able to change. For information on making your theme widget-aware, please <a href="http://codex.wordpress.org/Widgetizing_Themes">follow these instructions</a>.' ) );
require_once( './admin-header.php' );
?>
<div class="wrap">
<?php screen_icon(); ?>
<h2><?php echo esc_html( $title ); ?></h2>
<div class="error">
<p><?php _e( 'No Sidebars Defined' ); ?></p>
</div>
<p><?php _e( 'The theme you are currently using isn&#8217;t widget-aware, meaning that it has no sidebars that you are able to change. For information on making your theme widget-aware, please <a href="http://codex.wordpress.org/Widgetizing_Themes">follow these instructions</a>.' ); ?></p>
</div>
<?php
require_once( './admin-footer.php' );
exit;
} }
// These are the widgets grouped by sidebar // These are the widgets grouped by sidebar

View File

@ -2549,6 +2549,10 @@ function wp_maybe_load_widgets() {
*/ */
function wp_widgets_add_menu() { function wp_widgets_add_menu() {
global $submenu; global $submenu;
if ( ! current_theme_supports( 'widgets' ) )
return;
$submenu['themes.php'][7] = array( __( 'Widgets' ), 'edit_theme_options', 'widgets.php' ); $submenu['themes.php'][7] = array( __( 'Widgets' ), 'edit_theme_options', 'widgets.php' );
ksort( $submenu['themes.php'], SORT_NUMERIC ); ksort( $submenu['themes.php'], SORT_NUMERIC );
} }