home *** CD-ROM | disk | FTP | other *** search
/ HTML Examples / WP.iso / wordpress2 / wp-includes / customize / class-wp-customize-nav-menu-locations-control.php < prev    next >
Encoding:
PHP Script  |  2017-10-11  |  2.7 KB  |  91 lines

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