ru-se.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

class-wp-customize-nav-menu-locations-control.php (2799B)


      1 <?php
      2 /**
      3  * Customize API: WP_Customize_Nav_Menu_Locations_Control class
      4  *
      5  * @package WordPress
      6  * @subpackage Customize
      7  * @since 4.9.0
      8  */
      9 
     10 /**
     11  * Customize Nav Menu Locations Control Class.
     12  *
     13  * @since 4.9.0
     14  *
     15  * @see WP_Customize_Control
     16  */
     17 class WP_Customize_Nav_Menu_Locations_Control extends WP_Customize_Control {
     18 
     19 	/**
     20 	 * Control type.
     21 	 *
     22 	 * @since 4.9.0
     23 	 * @var string
     24 	 */
     25 	public $type = 'nav_menu_locations';
     26 
     27 	/**
     28 	 * Don't render the control's content - it uses a JS template instead.
     29 	 *
     30 	 * @since 4.9.0
     31 	 */
     32 	public function render_content() {}
     33 
     34 	/**
     35 	 * JS/Underscore template for the control UI.
     36 	 *
     37 	 * @since 4.9.0
     38 	 */
     39 	public function content_template() {
     40 		if ( current_theme_supports( 'menus' ) ) :
     41 			?>
     42 			<# var elementId; #>
     43 			<ul class="menu-location-settings">
     44 				<li class="customize-control assigned-menu-locations-title">
     45 					<span class="customize-control-title">{{ wp.customize.Menus.data.l10n.locationsTitle }}</span>
     46 					<# if ( data.isCreating ) { #>
     47 						<p>
     48 							<?php echo _x( 'Where do you want this menu to appear?', 'menu locations' ); ?>
     49 							<?php
     50 							printf(
     51 								/* translators: 1: Documentation URL, 2: Additional link attributes, 3: Accessibility text. */
     52 								_x( '(If you plan to use a menu <a href="%1$s" %2$s>widget%3$s</a>, skip this step.)', 'menu locations' ),
     53 								__( 'https://wordpress.org/support/article/wordpress-widgets/' ),
     54 								' class="external-link" target="_blank"',
     55 								sprintf(
     56 									'<span class="screen-reader-text"> %s</span>',
     57 									/* translators: Accessibility text. */
     58 									__( '(opens in a new tab)' )
     59 								)
     60 							);
     61 							?>
     62 						</p>
     63 					<# } else { #>
     64 						<p><?php echo _x( 'Here&#8217;s where this menu appears. If you&#8217;d like to change that, pick another location.', 'menu locations' ); ?></p>
     65 					<# } #>
     66 				</li>
     67 
     68 				<?php foreach ( get_registered_nav_menus() as $location => $description ) : ?>
     69 					<# elementId = _.uniqueId( 'customize-nav-menu-control-location-' ); #>
     70 					<li class="customize-control customize-control-checkbox assigned-menu-location">
     71 						<span class="customize-inside-control-row">
     72 							<input id="{{ elementId }}" type="checkbox" data-menu-id="{{ data.menu_id }}" data-location-id="<?php echo esc_attr( $location ); ?>" class="menu-location" />
     73 							<label for="{{ elementId }}">
     74 								<?php echo $description; ?>
     75 								<span class="theme-location-set">
     76 									<?php
     77 									printf(
     78 										/* translators: %s: Menu name. */
     79 										_x( '(Current: %s)', 'menu location' ),
     80 										'<span class="current-menu-location-name-' . esc_attr( $location ) . '"></span>'
     81 									);
     82 									?>
     83 								</span>
     84 							</label>
     85 						</span>
     86 					</li>
     87 				<?php endforeach; ?>
     88 			</ul>
     89 			<?php
     90 		endif;
     91 	}
     92 }