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 / Selectbox.php

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

85 lines 2.0 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 Selectbox {
15
16 protected static $args;
17
18 protected static $type = '';
19
20 public function selectbox_meta( $args ) {
21 self::$type = 'meta';
22 $this->selectbox( $args );
23
24 }
25
26 public function selectbox( $args ) {
27
28 $default = [
29 'title' => '',
30 'name' => '',
31 'description' => '',
32 'class' => '',
33 'condition' => '',
34 'options' => []
35 ];
36
37 self::$args = wp_parse_args( $args, $default );
38 self::selectbox_markup();
39
40 }
41
42 protected static function selectbox_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 <?php echo esc_attr( $wrapTypeClass ); ?>" 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 ); ?>">
69 <?php
70 foreach( $args['options'] as $key => $option ) {
71 echo '<option value="'.esc_attr( $key ).'" '.selected( $value, $key, false ).'>'.esc_html( $option ).'</option>';
72 }
73 ?>
74 </select>
75 <?php
76 if( !empty( $args['description'] ) ) {
77 echo '<p>'.esc_html( $args['description'] ).'</p>';
78 }
79 ?>
80 </div>
81 </div>
82 <?php
83 }
84 }
85