[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-includes/customize/ -> class-wp-customize-nav-menu-location-control.php (source)

   1  <?php
   2  /**
   3   * Customize API: WP_Customize_Nav_Menu_Location_Control class
   4   *
   5   * @package WordPress
   6   * @subpackage Customize
   7   * @since 4.4.0
   8   */
   9  
  10  /**
  11   * Customize Menu Location Control Class.
  12   *
  13   * This custom control is only needed for JS.
  14   *
  15   * @since 4.3.0
  16   *
  17   * @see WP_Customize_Control
  18   */
  19  class WP_Customize_Nav_Menu_Location_Control extends WP_Customize_Control {
  20  
  21      /**
  22       * Control type.
  23       *
  24       * @since 4.3.0
  25       * @var string
  26       */
  27      public $type = 'nav_menu_location';
  28  
  29      /**
  30       * Location ID.
  31       *
  32       * @since 4.3.0
  33       * @var string
  34       */
  35      public $location_id = '';
  36  
  37      /**
  38       * Refresh the parameters passed to JavaScript via JSON.
  39       *
  40       * @since 4.3.0
  41       *
  42       * @see WP_Customize_Control::to_json()
  43       */
  44  	public function to_json() {
  45          parent::to_json();
  46          $this->json['locationId'] = $this->location_id;
  47      }
  48  
  49      /**
  50       * Render content just like a normal select control.
  51       *
  52       * @since 4.3.0
  53       * @since 4.9.0 Added a button to create menus.
  54       */
  55  	public function render_content() {
  56          if ( empty( $this->choices ) ) {
  57              return;
  58          }
  59  
  60          $value_hidden_class    = '';
  61          $no_value_hidden_class = '';
  62          if ( $this->value() ) {
  63              $value_hidden_class = ' hidden';
  64          } else {
  65              $no_value_hidden_class = ' hidden';
  66          }
  67          ?>
  68          <label>
  69              <?php if ( ! empty( $this->label ) ) : ?>
  70              <span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span>
  71              <?php endif; ?>
  72  
  73              <?php if ( ! empty( $this->description ) ) : ?>
  74              <span class="description customize-control-description"><?php echo $this->description; ?></span>
  75              <?php endif; ?>
  76  
  77              <select <?php $this->link(); ?>>
  78                  <?php
  79                  foreach ( $this->choices as $value => $label ) :
  80                      echo '<option value="' . esc_attr( $value ) . '"' . selected( $this->value(), $value, false ) . '>' . esc_html( $label ) . '</option>';
  81                  endforeach;
  82                  ?>
  83              </select>
  84          </label>
  85          <button type="button" class="button-link create-menu<?php echo $value_hidden_class; ?>" data-location-id="<?php echo esc_attr( $this->location_id ); ?>" aria-label="<?php esc_attr_e( 'Create a menu for this location' ); ?>"><?php _e( '+ Create New Menu' ); ?></button>
  86          <button type="button" class="button-link edit-menu<?php echo $no_value_hidden_class; ?>" aria-label="<?php esc_attr_e( 'Edit selected menu' ); ?>"><?php _e( 'Edit Menu' ); ?></button>
  87          <?php
  88      }
  89  }


Generated : Fri Mar 29 08:20:02 2024 Cross-referenced by PHPXref