PluginProbe
Enter Addons – Ultimate Template Builder for Elementor / trunk
Enter Addons – Ultimate Template Builder for Elementor vtrunk
trunk 2.2.10 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7 2.2.8 2.2.9 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4
enteraddons / core / settingsfields / MultipleSelect.php

MultipleSelect.php in Enter Addons – Ultimate Template Builder for Elementor trunk, at core/settingsfields/MultipleSelect.php

91 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Enteraddons\Core;
3 /**
4 * Enteraddons Post Type Meta class
5 *
6 * @package EnterAddons Pro
7 * @author ThemeLooks
8 * @copyright 2022 ThemeLooks
9 * @license GPL-2.0-or-later
10 *
11 *
12 */
13
14 trait MultipleSelect {
15
16 protected static $args;
17
18 protected static $type = '';
19
20 public function multiple_select_meta( $args ) {
21 self::$type = 'meta';
22 $this->multiple_select( $args );
23 }
24
25 public function multiple_select( $args ) {
26
27 $default = [
28 'title' => '',
29 'name' => '',
30 'description' => '',
31 'class' => '',
32 'condition' => '',
33 'options' => ''
34 ];
35
36 self::$args = wp_parse_args( $args, $default );
37
38 self::multiple_select_markup();
39
40 }
41
42 protected static function multiple_select_markup() {
43
44 $args = self::$args;
45 $uniqName = $args['name'];
46
47 if( self::$type != 'meta' ) {
48 $wrapTypeClass = '';
49 $optionName = self::$optionName;
50 $getData = self::$getOptionData;
51 $fieldName = esc_attr( $optionName ).'['.$uniqName.']';
52 $value = !empty( $getData[$uniqName] ) ? $getData[$uniqName] : '';
53
54 } else {
55 $wrapTypeClass = 'ea-meta-field ';
56 $fieldName = $uniqName;
57 $value = get_post_meta( get_the_ID(), $uniqName, true );
58 }
59
60 $conditionData = '';
61 if( !empty( $args['condition'] ) ) {
62 $conditionData = wp_json_encode( $args['condition'] );
63 }
64 ?>
65 <div class="eap-admin-field" data-condition="<?php echo esc_html($conditionData); ?>">
66 <h4><?php echo esc_html( $args['title'] ); ?></h4>
67 <div class="fb-field-group">
68 <select name="<?php echo esc_attr( $fieldName ); ?>[]" multiple>
69 <?php
70 foreach( $args['options'] as $key => $option ) {
71
72 $v = '';
73 if( !empty( $value ) && in_array( $key , $value ) ) {
74 $v = $key;
75 }
76
77 echo '<option value="'.esc_attr( $key ).'" '.selected( $key, $v, false ).'>'.esc_html( $option ).'</option>';
78 }
79 ?>
80 </select>
81 <?php
82 if( !empty( $args['description'] ) ) {
83 echo '<p>'.esc_html( $args['description'] ).'</p>';
84 }
85 ?>
86 </div>
87 </div>
88 <?php
89 }
90 }
91