PluginProbe ʕ •ᴥ•ʔ
ShopPress – Shop Builder for Elementor and WooCommerce / trunk
ShopPress – Shop Builder for Elementor and WooCommerce vtrunk
shop-press / Elementor / control / product-select / product-select.php
shop-press / Elementor / control / product-select Last commit date
product-select.php 1 year ago
product-select.php
50 lines
1 <?php
2 defined( 'ABSPATH' ) || exit;
3
4 use Elementor\Base_Data_Control;
5
6 class ShopPressSelectProduct extends Base_Data_Control {
7
8 public function get_type() {
9 return 'shoppress_product_select';
10 }
11
12 public function enqueue() {
13 wp_enqueue_script( 'select2' );
14 wp_enqueue_style( 'select2' );
15
16 wp_enqueue_script( 'sp-woo-product-select', SHOPPRESS_URL . 'public/admin/elementor/controls/product-select/product-select.js', array( 'jquery' ), '1.0.0', true );
17 wp_localize_script(
18 'sp-woo-product-select',
19 'SPWooProductSelect',
20 array(
21 'restUrl' => esc_url_raw( rest_url( 'wc/v3/products' ) ),
22 'restNonce' => wp_create_nonce( 'wp_rest' ),
23 )
24 );
25 }
26
27 protected function get_default_settings() {
28 return array(
29 'label_block' => true,
30 'multiple' => false,
31 );
32 }
33
34 public function content_template() {
35 $control_uid = $this->get_control_uid();
36 ?>
37 <div class="elementor-control-field">
38 <label for="<?php echo esc_attr( $control_uid ); ?>" class="elementor-control-title">{{{ data.label }}}</label>
39 <div class="elementor-control-input-wrapper">
40 <select id="<?php echo esc_attr( $control_uid ); ?>" class="sp-woo-product-select" data-setting="{{ data.name }}" multiple>
41 </select>
42 </div>
43 </div>
44 <# if ( data.description ) { #>
45 <div class="elementor-control-field-description">{{{ data.description }}}</div>
46 <# } #>
47 <?php
48 }
49 }
50