featured-color.php
3 years ago
icon-select.php
3 years ago
media-select.php
3 years ago
query.php
6 years ago
visual-select.php
3 years ago
icon-select.php
93 lines
| 1 | <?php |
| 2 | namespace Auxin\Plugin\CoreElements\Elementor\Controls; |
| 3 | |
| 4 | use Elementor\Plugin; |
| 5 | use Elementor\Base_Data_Control; |
| 6 | |
| 7 | if ( ! defined( 'ABSPATH' ) ) { |
| 8 | exit; // Exit if accessed directly. |
| 9 | } |
| 10 | |
| 11 | /** |
| 12 | * Auxin icon select control. |
| 13 | * |
| 14 | * A base control for creating icon select control. Displays radio buttons styled as |
| 15 | * groups of buttons with icons for each option. |
| 16 | * |
| 17 | * @since 1.0.0 |
| 18 | */ |
| 19 | class Control_Icon_Select extends Base_Data_Control { |
| 20 | |
| 21 | |
| 22 | /** |
| 23 | * Get select control type. |
| 24 | * |
| 25 | * Retrieve the control type, in this case `aux-icon`. |
| 26 | * |
| 27 | * @since 1.0.0 |
| 28 | * @access public |
| 29 | * |
| 30 | * @return string Control type. |
| 31 | */ |
| 32 | public function get_type() { |
| 33 | return 'aux-icon'; |
| 34 | } |
| 35 | |
| 36 | /** |
| 37 | * Get icons control default settings. |
| 38 | * |
| 39 | * Retrieve the default settings of the icons control. Used to return the default |
| 40 | * settings while initializing the icons control. |
| 41 | * |
| 42 | * @since 1.0.0 |
| 43 | * @access protected |
| 44 | * |
| 45 | * @return array Control default settings. |
| 46 | */ |
| 47 | protected function get_default_settings() { |
| 48 | return [ |
| 49 | 'icons' => Auxin()->Font_Icons->get_icons_list( 'fontastic' ), |
| 50 | 'include' => '', |
| 51 | 'exclude' => '', |
| 52 | ]; |
| 53 | } |
| 54 | |
| 55 | public function enqueue() { |
| 56 | wp_enqueue_style('auxin-front-icon'); |
| 57 | wp_enqueue_style( 'auxin-elementor-editor' ); |
| 58 | wp_enqueue_script( 'auxin-elementor-editor' ); |
| 59 | } |
| 60 | |
| 61 | /** |
| 62 | * Render icons control output in the editor. |
| 63 | * |
| 64 | * Used to generate the control HTML in the editor using Underscore JS |
| 65 | * template. The variables for the class are available using `data` JS |
| 66 | * object. |
| 67 | * |
| 68 | * @since 1.0.0 |
| 69 | * @access public |
| 70 | */ |
| 71 | public function content_template() { |
| 72 | $control_uid = $this->get_control_uid(); |
| 73 | ?> |
| 74 | <div class="elementor-control-field"> |
| 75 | <label for="<?php echo esc_attr( $control_uid ); ?>" class="elementor-control-title">{{{ data.label }}}</label> |
| 76 | <div class="elementor-control-input-wrapper"> |
| 77 | <select id="<?php echo esc_attr( $control_uid ); ?>" class="elementor-control-icon" data-setting="{{ data.name }}" data-placeholder="<?php echo esc_attr__( 'Select Icon', 'auxin-elements' ); ?>"> |
| 78 | <option value=""><?php echo esc_html__( 'Select Icon', 'auxin-elements' ); ?></option> |
| 79 | <# _.each( data.icons, function( icon, key ) { |
| 80 | var icon_value = icon.classname.replace(/\./g, ""); |
| 81 | #> |
| 82 | <option value="{{ icon_value }}">{{{ icon.name }}}</option> |
| 83 | <# } ); #> |
| 84 | </select> |
| 85 | </div> |
| 86 | </div> |
| 87 | <# if ( data.description ) { #> |
| 88 | <div class="elementor-control-field-description">{{ data.description }}</div> |
| 89 | <# } #> |
| 90 | <?php |
| 91 | } |
| 92 | } |
| 93 |