@@ 587-627 (lines=41) @@ | ||
584 | * @since 1.0.0 |
|
585 | * @return string |
|
586 | */ |
|
587 | public function generate_select_html( $key, $data ) { |
|
588 | $field = $this->get_field_key( $key ); |
|
589 | $defaults = array( |
|
590 | 'title' => '', |
|
591 | 'disabled' => false, |
|
592 | 'class' => '', |
|
593 | 'css' => '', |
|
594 | 'placeholder' => '', |
|
595 | 'type' => 'text', |
|
596 | 'desc_tip' => false, |
|
597 | 'description' => '', |
|
598 | 'custom_attributes' => array(), |
|
599 | 'options' => array() |
|
600 | ); |
|
601 | ||
602 | $data = wp_parse_args( $data, $defaults ); |
|
603 | ||
604 | ob_start(); |
|
605 | ?> |
|
606 | <tr valign="top"> |
|
607 | <th scope="row" class="titledesc"> |
|
608 | <label for="<?php echo esc_attr( $field ); ?>"><?php echo wp_kses_post( $data['title'] ); ?></label> |
|
609 | <?php echo $this->get_tooltip_html( $data ); ?> |
|
610 | </th> |
|
611 | <td class="forminp"> |
|
612 | <fieldset> |
|
613 | <legend class="screen-reader-text"><span><?php echo wp_kses_post( $data['title'] ); ?></span></legend> |
|
614 | <select class="select <?php echo esc_attr( $data['class'] ); ?>" name="<?php echo esc_attr( $field ); ?>" id="<?php echo esc_attr( $field ); ?>" style="<?php echo esc_attr( $data['css'] ); ?>" <?php disabled( $data['disabled'], true ); ?> <?php echo $this->get_custom_attribute_html( $data ); ?>> |
|
615 | <?php foreach ( (array) $data['options'] as $option_key => $option_value ) : ?> |
|
616 | <option value="<?php echo esc_attr( $option_key ); ?>" <?php selected( $option_key, esc_attr( $this->get_option( $key ) ) ); ?>><?php echo esc_attr( $option_value ); ?></option> |
|
617 | <?php endforeach; ?> |
|
618 | </select> |
|
619 | <?php echo $this->get_description_html( $data ); ?> |
|
620 | </fieldset> |
|
621 | </td> |
|
622 | </tr> |
|
623 | <?php |
|
624 | ||
625 | return ob_get_clean(); |
|
626 | } |
|
627 | ||
628 | /** |
|
629 | * Generate Multiselect HTML. |
|
630 | * |
|
@@ 636-677 (lines=42) @@ | ||
633 | * @since 1.0.0 |
|
634 | * @return string |
|
635 | */ |
|
636 | public function generate_multiselect_html( $key, $data ) { |
|
637 | $field = $this->get_field_key( $key ); |
|
638 | $defaults = array( |
|
639 | 'title' => '', |
|
640 | 'disabled' => false, |
|
641 | 'class' => '', |
|
642 | 'css' => '', |
|
643 | 'placeholder' => '', |
|
644 | 'type' => 'text', |
|
645 | 'desc_tip' => false, |
|
646 | 'description' => '', |
|
647 | 'custom_attributes' => array(), |
|
648 | 'options' => array() |
|
649 | ); |
|
650 | ||
651 | $data = wp_parse_args( $data, $defaults ); |
|
652 | $value = (array) $this->get_option( $key, array() ); |
|
653 | ||
654 | ob_start(); |
|
655 | ?> |
|
656 | <tr valign="top"> |
|
657 | <th scope="row" class="titledesc"> |
|
658 | <label for="<?php echo esc_attr( $field ); ?>"><?php echo wp_kses_post( $data['title'] ); ?></label> |
|
659 | <?php echo $this->get_tooltip_html( $data ); ?> |
|
660 | </th> |
|
661 | <td class="forminp"> |
|
662 | <fieldset> |
|
663 | <legend class="screen-reader-text"><span><?php echo wp_kses_post( $data['title'] ); ?></span></legend> |
|
664 | <select multiple="multiple" class="multiselect <?php echo esc_attr( $data['class'] ); ?>" name="<?php echo esc_attr( $field ); ?>[]" id="<?php echo esc_attr( $field ); ?>" style="<?php echo esc_attr( $data['css'] ); ?>" <?php disabled( $data['disabled'], true ); ?> <?php echo $this->get_custom_attribute_html( $data ); ?>> |
|
665 | <?php foreach ( (array) $data['options'] as $option_key => $option_value ) : ?> |
|
666 | <option value="<?php echo esc_attr( $option_key ); ?>" <?php selected( in_array( $option_key, $value ), true ); ?>><?php echo esc_attr( $option_value ); ?></option> |
|
667 | <?php endforeach; ?> |
|
668 | </select> |
|
669 | <?php echo $this->get_description_html( $data ); ?> |
|
670 | </fieldset> |
|
671 | </td> |
|
672 | </tr> |
|
673 | <?php |
|
674 | ||
675 | return ob_get_clean(); |
|
676 | } |
|
677 | ||
678 | /** |
|
679 | * Generate Title HTML. |
|
680 | * |