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