assets
3 weeks ago
ajax-select2-api.php
3 weeks ago
ajax-select2.php
2 years ago
control-manager.php
4 years ago
image-choose.php
2 years ago
init.php
4 years ago
widget-area-modal.php
3 years ago
widget-area-utils.php
6 months ago
widget-area.php
2 years ago
image-choose.php
98 lines
| 1 | <?php |
| 2 | namespace ElementsKit_Lite\Modules\Controls; |
| 3 | |
| 4 | defined( 'ABSPATH' ) || exit; |
| 5 | |
| 6 | class Image_Choose extends \Elementor\Base_Data_Control { |
| 7 | |
| 8 | /** |
| 9 | * Get choose control type. |
| 10 | * |
| 11 | * Retrieve the control type, in this case `choose`. |
| 12 | * |
| 13 | * @since 1.0.0 |
| 14 | * @access public |
| 15 | * |
| 16 | * @return string Control type. |
| 17 | */ |
| 18 | public function get_type() { |
| 19 | return 'imagechoose'; |
| 20 | } |
| 21 | |
| 22 | /** |
| 23 | * Enqueue ontrol scripts and styles. |
| 24 | * |
| 25 | * @since 1.0.0 |
| 26 | * @access public |
| 27 | */ |
| 28 | public function enqueue() { |
| 29 | // Define script dependencies if needed. |
| 30 | $dependencies = array('jquery'); // Replace 'jquery' with the appropriate dependency. |
| 31 | |
| 32 | // styles |
| 33 | wp_register_style( 'elementskit-css-image-choose-control', Init::get_url() . 'assets/css/imagechoose.css', array(), '1.0.0' ); |
| 34 | wp_enqueue_style( 'elementskit-css-image-choose-control' ); |
| 35 | |
| 36 | // script |
| 37 | wp_register_script( 'elementskit-js-image-choose-control', Init::get_url() . 'assets/js/imagechoose.js', $dependencies, '1.0.0', true); |
| 38 | wp_enqueue_script( 'elementskit-js-image-choose-control' ); |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * Render choose control output in the editor. |
| 43 | * |
| 44 | * Used to generate the control HTML in the editor using Underscore JS |
| 45 | * template. The variables for the class are available using `data` JS |
| 46 | * object. |
| 47 | * |
| 48 | * @since 1.0.0 |
| 49 | * @access public |
| 50 | */ |
| 51 | public function content_template() { |
| 52 | $control_uid = $this->get_control_uid( '{{value}}' ); |
| 53 | ?> |
| 54 | <div class="elementor-control-field"> |
| 55 | <label class="elementor-control-title">{{{ data.label }}}</label> |
| 56 | <div class="elementor-control-input-wrapper"> |
| 57 | <div class="elementor-image-choices"> |
| 58 | <# _.each( data.options, function( options, value ) { #> |
| 59 | <div class="image-choose-label-block" style="width:{{ options.width }}"> |
| 60 | <input id="<?php echo esc_attr( $control_uid ); ?>" type="radio" name="elementor-choose-{{ data.name }}-{{ data._cid }}" value="{{ value }}"> |
| 61 | <label class="elementor-image-choices-label" for="<?php echo esc_attr( $control_uid ); ?>" title="{{ options.title }}"> |
| 62 | <img class="imagesmall" src="{{ options.imagesmall }}" alt="{{ options.title }}" {{ options.imagesmallheight ? `style=height:` + options.imagesmallheight : `` }} /> |
| 63 | <span class="imagelarge"> |
| 64 | <img src="{{ options.imagelarge }}" alt="{{ options.title }}" /> |
| 65 | </span> |
| 66 | <span class="elementor-screen-only">{{{ options.title }}}</span> |
| 67 | </label> |
| 68 | </div> |
| 69 | <# } ); #> |
| 70 | </div> |
| 71 | </div> |
| 72 | </div> |
| 73 | |
| 74 | <# if ( data.description ) { #> |
| 75 | <div class="elementor-control-field-description">{{{ data.description }}}</div> |
| 76 | <# } #> |
| 77 | <?php |
| 78 | } |
| 79 | |
| 80 | /** |
| 81 | * Get choose control default settings. |
| 82 | * |
| 83 | * Retrieve the default settings of the choose control. Used to return the |
| 84 | * default settings while initializing the choose control. |
| 85 | * |
| 86 | * @since 1.0.0 |
| 87 | * @access protected |
| 88 | * |
| 89 | * @return array Control default settings. |
| 90 | */ |
| 91 | protected function get_default_settings() { |
| 92 | return array( |
| 93 | 'label_block' => true, |
| 94 | 'options' => array(), |
| 95 | ); |
| 96 | } |
| 97 | } |
| 98 |