Remeber to add this tag in WPDKHTMLTagName
Автор: =undo= (info@wpxtre.me)
Наследование: extends WPDKHTMLTag
Пример #1
0
    /**
     * Recursive method to build the options and option group for select tag.
     * Display the HTML markup for the option and optgroup tag.
     *
     * @brief Build the options
     *
     * @param array $options A key value pairs array. If the value is an array then an optio group is created.
     */
    private function _options($options)
    {
        if (!empty($this->_first_item)) {
            ?>
      <option value=""
              disabled="disabled"
              selected="selected"
              style="display:none"><?php 
            echo $this->_first_item;
            ?>
</option>
    <?php 
        }
        foreach ($options as $key => $option) {
            ?>
      <?php 
            if (is_array($option)) {
                ?>
        <optgroup class="wpdk-form-optiongroup" label="<?php 
                echo $key;
                ?>
">
        <?php 
                $this->_options($option);
                ?>
      </optgroup>
      <?php 
            } else {
                ?>
        <option class="wpdk-form-option" <?php 
                if (!empty($this->value)) {
                    echo WPDKHTMLTagSelect::selected($this->value, $key);
                }
                ?>
                value="<?php 
                echo $key;
                ?>
"><?php 
                echo $option;
                ?>
</option>
      <?php 
            }
            ?>
    <?php 
        }
    }
Пример #2
0
 /**
  * Commodity to extends selected() WordPress function with array check
  *
  * @param string|array $haystack Single value or array
  * @param mixed        $current  (true) The other value to compare if not just true
  * @param bool         $echo     Whether to echo or just return the string
  *
  * @return string html attribute or empty string
  * @deprecated Since 1.2.0 Use WPDKHTMLTagSelect::selected() instead
  */
 function wpdk_selected($haystack, $current, $echo = true)
 {
     _deprecated_function(__FUNCTION__, '1.2.0', 'WPDKHTMLTagSelect::selected()');
     return WPDKHTMLTagSelect::selected($haystack, $current);
 }
Пример #3
0
 /**
  * Drawing control
  *
  * @brief Draw
  */
 public function draw()
 {
     echo $this->contentWithKey('prepend');
     // Create the label
     $label = $this->label();
     // Display right label
     echo is_null($label) ? '' : $label->html();
     $input = new WPDKHTMLTagSelect($this->item['options'], $this->name, $this->id);
     $input->class = $this->class;
     $input->class[] = 'wpdk-form-select';
     $input->class[] = 'wpdk-form-select-size';
     $input->class[] = 'wpdk-ui-control';
     $input->data = isset($this->item['data']) ? $this->item['data'] : array();
     $input->style = isset($this->item['style']) ? $this->item['style'] : null;
     $input->multiple = 'multiple';
     $input->size = isset($this->item['size']) ? $this->item['size'] : 5;
     $input->value = isset($this->item['value']) ? $this->item['value'] : array();
     $input->setPropertiesByArray(isset($this->item['attrs']) ? $this->item['attrs'] : '');
     $input->display();
     echo $this->contentWithKey('append');
 }