assets
1 year ago
ajax-select2.php
1 year ago
control-manager.php
1 year ago
image-choose.php
4 years ago
init.php
3 years ago
image-choose.php
95 lines
| 1 | <?php |
| 2 | namespace ShopEngine\Core\Elementor_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 | // styles |
| 30 | wp_register_style( 'shopengine-css-image-choose-control', Init::get_url() . 'assets/css/imagechoose.css', [], '1.0.0' ); |
| 31 | wp_enqueue_style( 'shopengine-css-image-choose-control' ); |
| 32 | |
| 33 | // script |
| 34 | wp_register_script( 'shopengine-js-image-choose-control', Init::get_url() . 'assets/js/imagechoose.js' ); |
| 35 | wp_enqueue_script( 'shopengine-js-image-choose-control' ); |
| 36 | } |
| 37 | |
| 38 | /** |
| 39 | * Render choose control output in the editor. |
| 40 | * |
| 41 | * Used to generate the control HTML in the editor using Underscore JS |
| 42 | * template. The variables for the class are available using `data` JS |
| 43 | * object. |
| 44 | * |
| 45 | * @since 1.0.0 |
| 46 | * @access public |
| 47 | */ |
| 48 | public function content_template() { |
| 49 | $control_uid = $this->get_control_uid( '{{value}}' ); |
| 50 | ?> |
| 51 | <div class="elementor-control-field"> |
| 52 | <label class="elementor-control-title">{{{ data.label }}}</label> |
| 53 | <div class="elementor-control-input-wrapper"> |
| 54 | <div class="elementor-image-choices"> |
| 55 | <# _.each( data.options, function( options, value ) { #> |
| 56 | <div class="image-choose-label-block" |
| 57 | style="width:{{ options.width }}"> |
| 58 | <input id="<?php echo esc_attr($control_uid); ?>" type="radio" name="elementor-choose-{{ data.name }}-{{ data._cid }}" value="{{ value }}"> |
| 59 | <label class="elementor-image-choices-label" for="<?php echo esc_attr($control_uid); ?>" title="{{ options.title }}"> |
| 60 | <img class="imagesmall" src="{{ options.imagesmall }}" alt="{{ options.title }}" /> |
| 61 | <span class="imagelarge"> |
| 62 | <img src="{{ options.imagelarge }}" alt="{{ options.title }}" /> |
| 63 | </span> |
| 64 | <span class="elementor-screen-only">{{{ options.title }}}</span> |
| 65 | </label> |
| 66 | </div> |
| 67 | <# } ); #> |
| 68 | </div> |
| 69 | </div> |
| 70 | </div> |
| 71 | |
| 72 | <# if ( data.description ) { #> |
| 73 | <div class="elementor-control-field-description">{{{ data.description }}}</div> |
| 74 | <# } #> |
| 75 | <?php |
| 76 | } |
| 77 | |
| 78 | /** |
| 79 | * Get choose control default settings. |
| 80 | * |
| 81 | * Retrieve the default settings of the choose control. Used to return the |
| 82 | * default settings while initializing the choose control. |
| 83 | * |
| 84 | * @since 1.0.0 |
| 85 | * @access protected |
| 86 | * |
| 87 | * @return array Control default settings. |
| 88 | */ |
| 89 | protected function get_default_settings() { |
| 90 | return [ |
| 91 | 'label_block' => true, |
| 92 | 'options' => [] |
| 93 | ]; |
| 94 | } |
| 95 | } |