WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

WP_Nav_Menu_Widget::form() WP 3.0.0

Outputs the settings form for the Navigation Menu widget.

Это метод класса: WP_Nav_Menu_Widget

Хуков нет.

Возвращает

Null. Ничего.

Использование

$WP_Nav_Menu_Widget = new WP_Nav_Menu_Widget();
$var = $WP_Nav_Menu_Widget->form( $instance );
$instance(массив) (обязательный)
Current settings.

Заметки

  • Global. WP_Customize_Manager. $wp_customize

Список изменений

С версии 3.0.0 Введена.

Код WP Nav Menu Widget::form: wp-includes/widgets/class-wp-nav-menu-widget.php WP 5.2.2

<?php
public function form( $instance ) {
	global $wp_customize;
	$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 echo $not_empty_menus_style; ?>>
		<?php
		if ( $wp_customize instanceof WP_Customize_Manager ) {
			$url = 'javascript: wp.customize.panel( "nav_menus" ).focus();';
		} else {
			$url = admin_url( 'nav-menus.php' );
		}
		?>
		<?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 echo $empty_menus_style; ?>>
		<p>
			<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>
			<label for="<?php echo $this->get_field_id( 'nav_menu' ); ?>"><?php _e( 'Select Menu:' ); ?></label>
			<select id="<?php echo $this->get_field_id( 'nav_menu' ); ?>" name="<?php echo $this->get_field_name( 'nav_menu' ); ?>">
				<option value="0"><?php _e( '&mdash; Select &mdash;' ); ?></option>
				<?php foreach ( $menus as $menu ) : ?>
					<option value="<?php echo esc_attr( $menu->term_id ); ?>" <?php selected( $nav_menu, $menu->term_id ); ?>>
						<?php echo esc_html( $menu->name ); ?>
					</option>
				<?php endforeach; ?>
			</select>
		</p>
		<?php if ( $wp_customize instanceof WP_Customize_Manager ) : ?>
			<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>
	<?php
}