Networks and Sites: Don't display an empty Menu Settings section in network admin if there are no items.

This accounts for returning an empty array from the `mu_menu_items` filter.

Props dlh.
Fixes #49977.
Built from https://develop.svn.wordpress.org/trunk@47616


git-svn-id: http://core.svn.wordpress.org/trunk@47391 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2020-04-23 18:58:05 +00:00
parent b6c70b7712
commit 0dc461c72e
2 changed files with 40 additions and 34 deletions

View File

@ -438,41 +438,47 @@ if ( isset( $_GET['updated'] ) ) {
}
?>
<h2><?php _e( 'Menu Settings' ); ?></h2>
<table id="menu" class="form-table">
<tr>
<th scope="row"><?php _e( 'Enable administration menus' ); ?></th>
<td>
<?php
$menu_perms = get_site_option( 'menu_items' );
/**
* Filters available network-wide administration menu options.
*
* Options returned to this filter are output as individual checkboxes that, when selected,
* enable site administrator access to the specified administration menu in certain contexts.
*
* Adding options for specific menus here hinges on the appropriate checks and capabilities
* being in place in the site dashboard on the other side. For instance, when the single
* default option, 'plugins' is enabled, site administrators are granted access to the Plugins
* screen in their individual sites' dashboards.
*
* @since MU (3.0.0)
*
* @param string[] $admin_menus Associative array of the menu items available.
*/
$menu_items = apply_filters( 'mu_menu_items', array( 'plugins' => __( 'Plugins' ) ) );
<?php
$menu_perms = get_site_option( 'menu_items' );
/**
* Filters available network-wide administration menu options.
*
* Options returned to this filter are output as individual checkboxes that, when selected,
* enable site administrator access to the specified administration menu in certain contexts.
*
* Adding options for specific menus here hinges on the appropriate checks and capabilities
* being in place in the site dashboard on the other side. For instance, when the single
* default option, 'plugins' is enabled, site administrators are granted access to the Plugins
* screen in their individual sites' dashboards.
*
* @since MU (3.0.0)
*
* @param string[] $admin_menus Associative array of the menu items available.
*/
$menu_items = apply_filters( 'mu_menu_items', array( 'plugins' => __( 'Plugins' ) ) );
echo '<fieldset><legend class="screen-reader-text">' . __( 'Enable menus' ) . '</legend>';
foreach ( (array) $menu_items as $key => $val ) {
echo "<label><input type='checkbox' name='menu_items[" . $key . "]' value='1'" . ( isset( $menu_perms[ $key ] ) ? checked( $menu_perms[ $key ], '1', false ) : '' ) . ' /> ' . esc_html( $val ) . '</label><br/>';
}
echo '</fieldset>';
if ( $menu_items ) :
?>
</td>
</tr>
</table>
<h2><?php _e( 'Menu Settings' ); ?></h2>
<table id="menu" class="form-table">
<tr>
<th scope="row"><?php _e( 'Enable administration menus' ); ?></th>
<td>
<?php
echo '<fieldset><legend class="screen-reader-text">' . __( 'Enable menus' ) . '</legend>';
foreach ( (array) $menu_items as $key => $val ) {
echo "<label><input type='checkbox' name='menu_items[" . $key . "]' value='1'" . ( isset( $menu_perms[ $key ] ) ? checked( $menu_perms[ $key ], '1', false ) : '' ) . ' /> ' . esc_html( $val ) . '</label><br/>';
}
echo '</fieldset>';
?>
</td>
</tr>
</table>
<?php
endif;
?>
<?php
/**

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.5-alpha-47615';
$wp_version = '5.5-alpha-47616';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.