config.php
210 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 Compare extends ShopPressWidgets { |
| 10 | |
| 11 | public function get_name() { |
| 12 | return 'sp-product-compare'; |
| 13 | } |
| 14 | |
| 15 | public function get_title() { |
| 16 | return __( 'Compare Button', 'shop-press' ); |
| 17 | } |
| 18 | |
| 19 | public function get_icon() { |
| 20 | return 'sp-widget sp-eicon-compare-loop'; |
| 21 | } |
| 22 | |
| 23 | public function get_categories() { |
| 24 | return array( 'sp_woo_loop' ); |
| 25 | } |
| 26 | |
| 27 | public function get_script_depends() { |
| 28 | return array( 'sp-compare' ); |
| 29 | } |
| 30 | |
| 31 | public function get_style_depends() { |
| 32 | |
| 33 | if ( is_rtl() ) { |
| 34 | return array( 'sp-compare', 'sp-wishlist', 'sp-compare-rtl', 'sp-wishlist-rtl' ); |
| 35 | } else { |
| 36 | return array( 'sp-compare', 'sp-wishlist' ); |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | public function setup_styling_options() { |
| 41 | $this->register_group_styler( |
| 42 | 'wrapper', |
| 43 | __( 'Wrapper', 'shop-press' ), |
| 44 | array( |
| 45 | 'wrapper' => array( |
| 46 | 'label' => esc_html__( 'Wrapper', 'shop-press' ), |
| 47 | 'type' => 'styler', |
| 48 | 'selector' => '.sp-product-compare', |
| 49 | 'wrapper' => '{{WRAPPER}}', |
| 50 | ), |
| 51 | 'button' => array( |
| 52 | 'label' => esc_html__( 'Button', 'shop-press' ), |
| 53 | 'type' => 'styler', |
| 54 | 'selector' => '.sp-compare-button-loop', |
| 55 | 'wrapper' => '{{WRAPPER}} .sp-product-compare', |
| 56 | ), |
| 57 | ) |
| 58 | ); |
| 59 | |
| 60 | $this->register_group_styler( |
| 61 | 'icon', |
| 62 | __( 'Icon', 'shop-press' ), |
| 63 | array( |
| 64 | 'icon_wrapper' => array( |
| 65 | 'label' => esc_html__( 'Icon Wrapper', 'shop-press' ), |
| 66 | 'type' => 'styler', |
| 67 | 'selector' => '.sp-compare-icon', |
| 68 | 'wrapper' => '{{WRAPPER}} .sp-product-compare', |
| 69 | ), |
| 70 | 'icon' => array( |
| 71 | 'label' => esc_html__( 'Icon', 'shop-press' ), |
| 72 | 'type' => 'styler', |
| 73 | 'selector' => 'i.sp-icon', |
| 74 | 'wrapper' => '{{WRAPPER}} .sp-product-compare .sp-compare-icon', |
| 75 | ), |
| 76 | 'active_icon' => array( |
| 77 | 'label' => esc_html__( 'Active Icon', 'shop-press' ), |
| 78 | 'type' => 'styler', |
| 79 | 'selector' => 'i.sp-icon', |
| 80 | 'wrapper' => '{{WRAPPER}} .sp-product-compare[data-status="yes"] .sp-compare-icon', |
| 81 | ), |
| 82 | ) |
| 83 | ); |
| 84 | |
| 85 | $this->register_group_styler( |
| 86 | 'label', |
| 87 | __( 'Label', 'shop-press' ), |
| 88 | array( |
| 89 | 'label' => array( |
| 90 | 'label' => esc_html__( 'Label', 'shop-press' ), |
| 91 | 'type' => 'styler', |
| 92 | 'selector' => '.sp-compare-label', |
| 93 | 'wrapper' => '{{WRAPPER}} .sp-product-compare', |
| 94 | ), |
| 95 | ) |
| 96 | ); |
| 97 | |
| 98 | $this->register_group_styler( |
| 99 | 'tooltip_overlay', |
| 100 | __( 'Tooltip Overlay', 'shop-press' ), |
| 101 | array( |
| 102 | 'tooltip' => array( |
| 103 | 'label' => esc_html__( 'Tooltip', 'shop-press' ), |
| 104 | 'type' => 'styler', |
| 105 | 'selector' => '.sp-product-compare.overlay .sp-compare-label', |
| 106 | 'wrapper' => '{{WRAPPER}}', |
| 107 | ), |
| 108 | 'tooltip_arrow' => array( |
| 109 | 'label' => esc_html__( 'Tooltip Arrow', 'shop-press' ), |
| 110 | 'type' => 'styler', |
| 111 | 'selector' => '.sp-product-compare.overlay span:before', |
| 112 | 'wrapper' => '{{WRAPPER}}', |
| 113 | ), |
| 114 | ), |
| 115 | ); |
| 116 | } |
| 117 | |
| 118 | protected function register_controls() { |
| 119 | $this->start_controls_section( |
| 120 | 'section_content', |
| 121 | array( |
| 122 | 'label' => __( 'Settings', 'shop-press' ), |
| 123 | 'tab' => Controls_Manager::TAB_CONTENT, |
| 124 | ) |
| 125 | ); |
| 126 | $this->add_control( |
| 127 | 'icon', |
| 128 | array( |
| 129 | 'label' => __( 'Icon', 'shop-press' ), |
| 130 | 'type' => Controls_Manager::ICONS, |
| 131 | ) |
| 132 | ); |
| 133 | |
| 134 | $this->add_control( |
| 135 | 'icon_pos', |
| 136 | array( |
| 137 | 'label' => __( 'Icon Position', 'shop-press' ), |
| 138 | 'type' => Controls_Manager::CHOOSE, |
| 139 | 'default' => 'left', |
| 140 | 'toggle' => false, |
| 141 | 'options' => array( |
| 142 | 'left' => array( |
| 143 | 'title' => __( 'Left', 'shop-press' ), |
| 144 | 'icon' => 'eicon-text-align-left', |
| 145 | ), |
| 146 | 'right' => array( |
| 147 | 'title' => __( 'Right', 'shop-press' ), |
| 148 | 'icon' => 'eicon-text-align-right', |
| 149 | ), |
| 150 | ), |
| 151 | ) |
| 152 | ); |
| 153 | |
| 154 | $this->add_control( |
| 155 | 'show_label', |
| 156 | array( |
| 157 | 'type' => Controls_Manager::SWITCHER, |
| 158 | 'label' => __( 'Show Label', 'shop-press' ), |
| 159 | 'label_on' => __( 'Yes', 'shop-press' ), |
| 160 | 'label_off' => __( 'No', 'shop-press' ), |
| 161 | 'return_value' => 'yes', |
| 162 | 'default' => 'yes', |
| 163 | ) |
| 164 | ); |
| 165 | |
| 166 | $this->add_control( |
| 167 | 'overlay', |
| 168 | array( |
| 169 | 'type' => Controls_Manager::SWITCHER, |
| 170 | 'label' => __( 'Floating Position', 'shop-press' ), |
| 171 | 'label_on' => __( 'Yes', 'shop-press' ), |
| 172 | 'label_off' => __( 'No', 'shop-press' ), |
| 173 | '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' ), |
| 174 | ) |
| 175 | ); |
| 176 | |
| 177 | $this->end_controls_section(); |
| 178 | $this->setup_styling_options(); |
| 179 | |
| 180 | do_action( 'shoppress/elementor/widget/register_controls_init', $this ); |
| 181 | } |
| 182 | |
| 183 | protected function render() { |
| 184 | $settings = $this->get_settings_for_display(); |
| 185 | |
| 186 | do_action( 'shoppress/widget/before_render', $settings ); |
| 187 | |
| 188 | $args = array( |
| 189 | 'icon' => $settings['icon'], |
| 190 | 'overlay' => $settings['overlay'], |
| 191 | 'icon_pos' => $settings['icon_pos'], |
| 192 | 'show_label' => $settings['show_label'], |
| 193 | ); |
| 194 | |
| 195 | if ( $this->editor_preview() ) { |
| 196 | |
| 197 | if ( $this->is_editor() ) { |
| 198 | ?> |
| 199 | <script> |
| 200 | (function($){ |
| 201 | shoppress_compare_init($); |
| 202 | })(jQuery); |
| 203 | </script> |
| 204 | <?php |
| 205 | } |
| 206 | sp_load_builder_template( 'loop/loop-compare', $args ); |
| 207 | } |
| 208 | } |
| 209 | } |
| 210 |