control-type-animation.php
4 years ago
control-type-background.php
2 years ago
control-type-border.php
2 years ago
control-type-box-shadow.php
4 years ago
control-type-choose.php
4 years ago
control-type-code.php
4 years ago
control-type-color.php
4 years ago
control-type-date-time.php
1 year ago
control-type-dimensions.php
4 years ago
control-type-font.php
4 years ago
control-type-gallery.php
4 years ago
control-type-hover.php
4 years ago
control-type-icons.php
4 years ago
control-type-image-dimensions.php
4 years ago
control-type-image-size.php
4 years ago
control-type-input.php
4 years ago
control-type-media.php
4 years ago
control-type-number.php
4 years ago
control-type-select.php
4 years ago
control-type-select2.php
4 years ago
control-type-slider.php
4 years ago
control-type-switch.php
4 years ago
control-type-text-area.php
4 years ago
control-type-text-shadow.php
4 years ago
control-type-typography.php
4 years ago
control-type-url.php
4 years ago
control-type-wys.php
4 years ago
ct-base.php
4 years ago
ct-contract.php
4 years ago
ct-factory.php
4 years ago
widget-writer.php
3 weeks ago
control-type-select2.php
82 lines
| 1 | <?php |
| 2 | |
| 3 | namespace ElementsKit_Lite\Modules\Widget_Builder\Controls; |
| 4 | |
| 5 | defined( 'ABSPATH' ) || exit; |
| 6 | |
| 7 | class Control_Type_Select2 extends CT_Base { |
| 8 | |
| 9 | |
| 10 | public function start_writing_conf( $file_handler, $conf ) { |
| 11 | |
| 12 | $ret = ''; |
| 13 | |
| 14 | if ( ! empty( $conf->description ) ) { |
| 15 | $ret .= "\t\t\t\t" . '\'description\' => esc_html( \'' . esc_html( $conf->description ) . '\' ),' . PHP_EOL; |
| 16 | } |
| 17 | |
| 18 | if ( ! empty( $conf->default ) ) { |
| 19 | |
| 20 | if ( gettype( $conf->default ) == 'string' ) { |
| 21 | $ret .= "\t\t\t\t" . '\'default\' => esc_html( \'' . esc_html( $conf->default ) . '\' ),' . PHP_EOL; |
| 22 | } else { |
| 23 | $ret .= "\t\t\t\t" . '\'default\' => array(' . PHP_EOL; |
| 24 | $defaults = (array) $conf->default; |
| 25 | foreach ( $defaults as $key ) { |
| 26 | $ret .= "\t\t\t\t\t" . '\'' . esc_html( $key ) . '\',' . PHP_EOL; |
| 27 | } |
| 28 | $ret .= "\t\t\t\t" . '),' . PHP_EOL; |
| 29 | } |
| 30 | } |
| 31 | |
| 32 | if ( ! empty( $conf->separator ) ) { |
| 33 | $ret .= "\t\t\t\t" . '\'separator\' => \'' . esc_html( $conf->separator ) . '\' ,' . PHP_EOL; |
| 34 | } |
| 35 | |
| 36 | if ( isset( $conf->multiple ) ) { |
| 37 | $ret .= "\t\t\t\t" . '\'multiple\' => ' . ( $conf->multiple == 1 ? 'true' : 'false' ) . ' ,' . PHP_EOL; |
| 38 | } |
| 39 | |
| 40 | if ( isset( $conf->show_label ) ) { |
| 41 | $ret .= "\t\t\t\t" . '\'show_label\' => ' . ( $conf->show_label == 1 ? 'true' : 'false' ) . ' ,' . PHP_EOL; |
| 42 | } |
| 43 | |
| 44 | if ( isset( $conf->label_block ) ) { |
| 45 | $ret .= "\t\t\t\t" . '\'label_block\' => ' . ( $conf->label_block == 1 ? 'true' : 'false' ) . ' ,' . PHP_EOL; |
| 46 | } |
| 47 | |
| 48 | $ret .= "\t\t\t\t" . '\'options\' => array(' . PHP_EOL; |
| 49 | |
| 50 | if ( ! empty( $conf->options ) ) { |
| 51 | |
| 52 | $realArray = (array) $conf->options; |
| 53 | |
| 54 | foreach ( $realArray as $val => $label ) { |
| 55 | |
| 56 | $ret .= "\t\t\t\t\t" . '\'' . esc_html( $val ) . '\' => esc_html( \'' . esc_html( $label ) . '\' ),' . PHP_EOL; |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | $ret .= "\t\t\t\t" . '),' . PHP_EOL; |
| 61 | |
| 62 | if ( ! empty( $conf->selectors ) ) { |
| 63 | |
| 64 | $selectors = (array) $conf->selectors; |
| 65 | $ret .= "\t\t\t\t" . '\'selectors\' => array(' . PHP_EOL; |
| 66 | |
| 67 | foreach ( $selectors as $selectorName => $selectorValue ) { |
| 68 | $selectorProperty = str_replace( ',', ', {{WRAPPER}} ', $selectorName ); |
| 69 | $ret .= "\t\t\t\t\t" . '\'{{WRAPPER}} ' . $selectorProperty . '\' => \'' . esc_html( $selectorValue ) . '\',' . PHP_EOL; |
| 70 | } |
| 71 | |
| 72 | $ret .= "\t\t\t\t" . '),' . PHP_EOL; |
| 73 | } |
| 74 | |
| 75 | if ( ! empty( $conf->classes ) ) { |
| 76 | $ret .= "\t\t\t\t" . '\'classes\' => \'' . esc_html( $conf->classes ) . '\',' . PHP_EOL; |
| 77 | } |
| 78 | |
| 79 | return $ret; |
| 80 | } |
| 81 | } |
| 82 |