config.php
186 lines
| 1 | <?php |
| 2 | namespace ShopPress\Elementor\Widgets\LoopBuilder; |
| 3 | |
| 4 | defined( 'ABSPATH' ) || exit; |
| 5 | |
| 6 | use Elementor\Controls_Manager; |
| 7 | use ShopPress\Elementor\ShopPressWidgets; |
| 8 | |
| 9 | class QuickView extends ShopPressWidgets { |
| 10 | |
| 11 | public function get_name() { |
| 12 | return 'sp-product-quickview'; |
| 13 | } |
| 14 | |
| 15 | public function get_title() { |
| 16 | return __( 'Quick View Button', 'shop-press' ); |
| 17 | } |
| 18 | |
| 19 | public function get_icon() { |
| 20 | return 'sp-widget sp-eicon-quickview'; |
| 21 | } |
| 22 | |
| 23 | public function get_categories() { |
| 24 | return array( 'sp_woo_loop' ); |
| 25 | } |
| 26 | |
| 27 | public function get_style_depends() { |
| 28 | if ( is_rtl() ) { |
| 29 | return array( 'sp-quickview', 'sp-quickview-rtl' ); |
| 30 | } else { |
| 31 | return array( 'sp-quickview' ); |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | public function get_script_depends() { |
| 36 | return array( 'sp-quickview' ); |
| 37 | } |
| 38 | |
| 39 | public function setup_styling_options() { |
| 40 | $this->register_group_styler( |
| 41 | 'wrapper', |
| 42 | __( 'Wrapper', 'shop-press' ), |
| 43 | array( |
| 44 | 'wrapper' => array( |
| 45 | 'label' => esc_html__( 'Button', 'shop-press' ), |
| 46 | 'type' => 'styler', |
| 47 | 'selector' => '.sp-quick-view', |
| 48 | 'wrapper' => '{{WRAPPER}}', |
| 49 | ), |
| 50 | ) |
| 51 | ); |
| 52 | |
| 53 | $this->register_group_styler( |
| 54 | 'icon', |
| 55 | __( 'Icon', 'shop-press' ), |
| 56 | array( |
| 57 | 'icon_wrapper' => array( |
| 58 | 'label' => esc_html__( 'Icon Wrapper', 'shop-press' ), |
| 59 | 'type' => 'styler', |
| 60 | 'selector' => '.sp-quick-view-icon', |
| 61 | 'wrapper' => '{{WRAPPER}} .sp-quick-view', |
| 62 | ), |
| 63 | 'icon' => array( |
| 64 | 'label' => esc_html__( 'Icon', 'shop-press' ), |
| 65 | 'type' => 'styler', |
| 66 | 'selector' => 'i.sp-icon', |
| 67 | 'wrapper' => '{{WRAPPER}} .sp-quick-view .sp-quick-view-icon', |
| 68 | ), |
| 69 | ) |
| 70 | ); |
| 71 | |
| 72 | $this->register_group_styler( |
| 73 | 'label', |
| 74 | __( 'Label', 'shop-press' ), |
| 75 | array( |
| 76 | 'label' => array( |
| 77 | 'label' => esc_html__( 'Label', 'shop-press' ), |
| 78 | 'type' => 'styler', |
| 79 | 'selector' => '.sp-quickview-label', |
| 80 | 'wrapper' => '{{WRAPPER}} .sp-quick-view', |
| 81 | ), |
| 82 | ) |
| 83 | ); |
| 84 | |
| 85 | $this->register_group_styler( |
| 86 | 'tooltip_overlay', |
| 87 | __( 'Tooltip Overlay', 'shop-press' ), |
| 88 | array( |
| 89 | 'tooltip' => array( |
| 90 | 'label' => esc_html__( 'Tooltip', 'shop-press' ), |
| 91 | 'type' => 'styler', |
| 92 | 'selector' => '.sp-quick-view.overlay .sp-quickview-label', |
| 93 | 'wrapper' => '{{WRAPPER}} ', |
| 94 | ), |
| 95 | 'tooltip_arrow' => array( |
| 96 | 'label' => esc_html__( 'Tooltip Arrow', 'shop-press' ), |
| 97 | 'type' => 'styler', |
| 98 | 'selector' => '.sp-quick-view.overlay span:before', |
| 99 | 'wrapper' => '{{WRAPPER}}', |
| 100 | ), |
| 101 | ), |
| 102 | ); |
| 103 | } |
| 104 | |
| 105 | protected function register_controls() { |
| 106 | $this->start_controls_section( |
| 107 | 'section_content', |
| 108 | array( |
| 109 | 'label' => __( 'Settings', 'shop-press' ), |
| 110 | 'tab' => Controls_Manager::TAB_CONTENT, |
| 111 | ) |
| 112 | ); |
| 113 | |
| 114 | $this->add_control( |
| 115 | 'icon', |
| 116 | array( |
| 117 | 'label' => __( 'Icon', 'shop-press' ), |
| 118 | 'type' => Controls_Manager::ICONS, |
| 119 | ) |
| 120 | ); |
| 121 | |
| 122 | $this->add_control( |
| 123 | 'icon_pos', |
| 124 | array( |
| 125 | 'label' => __( 'Icon Position', 'shop-press' ), |
| 126 | 'type' => Controls_Manager::CHOOSE, |
| 127 | 'default' => 'left', |
| 128 | 'toggle' => false, |
| 129 | 'options' => array( |
| 130 | 'left' => array( |
| 131 | 'title' => __( 'Left', 'shop-press' ), |
| 132 | 'icon' => 'eicon-text-align-left', |
| 133 | ), |
| 134 | 'right' => array( |
| 135 | 'title' => __( 'Right', 'shop-press' ), |
| 136 | 'icon' => 'eicon-text-align-right', |
| 137 | ), |
| 138 | ), |
| 139 | ) |
| 140 | ); |
| 141 | |
| 142 | $this->add_control( |
| 143 | 'label', |
| 144 | array( |
| 145 | 'label' => __( 'Label', 'shop-press' ), |
| 146 | 'type' => Controls_Manager::TEXT, |
| 147 | 'placeholder' => __( 'Quick View', 'shop-press' ), |
| 148 | 'default' => __( 'Quick View', 'shop-press' ), |
| 149 | ) |
| 150 | ); |
| 151 | |
| 152 | $this->add_control( |
| 153 | 'overlay', |
| 154 | array( |
| 155 | 'type' => Controls_Manager::SWITCHER, |
| 156 | 'label' => __( 'Floating Position', 'shop-press' ), |
| 157 | 'label_on' => __( 'Yes', 'shop-press' ), |
| 158 | 'label_off' => __( 'No', 'shop-press' ), |
| 159 | 'description' => esc_html__( 'When you activate this option, the button will be positioned as an overlay on the parent section. Its position will be set to "absolute" and you can determine the exact location of this button in the style tab by using the styler associated with the Wrapper.', 'shop-press' ), |
| 160 | ) |
| 161 | ); |
| 162 | |
| 163 | $this->end_controls_section(); |
| 164 | $this->setup_styling_options(); |
| 165 | |
| 166 | do_action( 'shoppress/elementor/widget/register_controls_init', $this ); |
| 167 | } |
| 168 | |
| 169 | protected function render() { |
| 170 | $settings = $this->get_settings_for_display(); |
| 171 | |
| 172 | do_action( 'shoppress/widget/before_render', $settings ); |
| 173 | |
| 174 | $args = array( |
| 175 | 'icon' => $settings['icon'], |
| 176 | 'overlay' => $settings['overlay'], |
| 177 | 'icon_pos' => $settings['icon_pos'], |
| 178 | 'label' => $settings['label'], |
| 179 | ); |
| 180 | |
| 181 | if ( $this->editor_preview() ) { |
| 182 | sp_load_builder_template( 'loop/loop-quick-view', $args ); |
| 183 | } |
| 184 | } |
| 185 | } |
| 186 |