--- a/wp/wp-includes/widgets/class-wp-nav-menu-widget.php Mon Oct 14 18:06:33 2019 +0200
+++ b/wp/wp-includes/widgets/class-wp-nav-menu-widget.php Mon Oct 14 18:28:13 2019 +0200
@@ -23,10 +23,10 @@
*/
public function __construct() {
$widget_ops = array(
- 'description' => __( 'Add a navigation menu to your sidebar.' ),
+ 'description' => __( 'Add a navigation menu to your sidebar.' ),
'customize_selective_refresh' => true,
);
- parent::__construct( 'nav_menu', __('Navigation Menu'), $widget_ops );
+ parent::__construct( 'nav_menu', __( 'Navigation Menu' ), $widget_ops );
}
/**
@@ -59,7 +59,7 @@
$nav_menu_args = array(
'fallback_cb' => '',
- 'menu' => $nav_menu
+ 'menu' => $nav_menu,
);
/**
@@ -114,15 +114,27 @@
*/
public function form( $instance ) {
global $wp_customize;
- $title = isset( $instance['title'] ) ? $instance['title'] : '';
+ $title = isset( $instance['title'] ) ? $instance['title'] : '';
$nav_menu = isset( $instance['nav_menu'] ) ? $instance['nav_menu'] : '';
// Get menus
$menus = wp_get_nav_menus();
+ $empty_menus_style = $not_empty_menus_style = '';
+ if ( empty( $menus ) ) {
+ $empty_menus_style = ' style="display:none" ';
+ } else {
+ $not_empty_menus_style = ' style="display:none" ';
+ }
+
+ $nav_menu_style = '';
+ if ( ! $nav_menu ) {
+ $nav_menu_style = 'display: none;';
+ }
+
// If no menus exists, direct the user to go and create some.
?>
- <p class="nav-menu-widget-no-menus-message" <?php if ( ! empty( $menus ) ) { echo ' style="display:none" '; } ?>>
+ <p class="nav-menu-widget-no-menus-message" <?php echo $not_empty_menus_style; ?>>
<?php
if ( $wp_customize instanceof WP_Customize_Manager ) {
$url = 'javascript: wp.customize.panel( "nav_menus" ).focus();';
@@ -132,9 +144,9 @@
?>
<?php echo sprintf( __( 'No menus have been created yet. <a href="%s">Create some</a>.' ), esc_attr( $url ) ); ?>
</p>
- <div class="nav-menu-widget-form-controls" <?php if ( empty( $menus ) ) { echo ' style="display:none" '; } ?>>
+ <div class="nav-menu-widget-form-controls" <?php echo $empty_menus_style; ?>>
<p>
- <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ) ?></label>
+ <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label>
<input type="text" class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo esc_attr( $title ); ?>"/>
</p>
<p>
@@ -149,8 +161,8 @@
</select>
</p>
<?php if ( $wp_customize instanceof WP_Customize_Manager ) : ?>
- <p class="edit-selected-nav-menu" style="<?php if ( ! $nav_menu ) { echo 'display: none;'; } ?>">
- <button type="button" class="button"><?php _e( 'Edit Menu' ) ?></button>
+ <p class="edit-selected-nav-menu" style="<?php echo $nav_menu_style; ?>">
+ <button type="button" class="button"><?php _e( 'Edit Menu' ); ?></button>
</p>
<?php endif; ?>
</div>