call-for-price.php
304 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Elementor; |
| 4 | |
| 5 | defined('ABSPATH') || exit; |
| 6 | |
| 7 | class ShopEngine_Call_For_Price extends \ShopEngine\Base\Widget |
| 8 | { |
| 9 | |
| 10 | public function config() |
| 11 | { |
| 12 | return new ShopEngine_Call_For_Price_Config(); |
| 13 | } |
| 14 | |
| 15 | protected function register_controls() |
| 16 | { |
| 17 | |
| 18 | $this->start_controls_section( |
| 19 | 'shopengine_section_product_call_for_price', |
| 20 | array( |
| 21 | 'label' => esc_html__('Call for Price', 'shopengine'), |
| 22 | 'tab' => Controls_Manager::TAB_CONTENT, |
| 23 | ) |
| 24 | ); |
| 25 | |
| 26 | $this->add_control( |
| 27 | 'shopengine_call_for_price_btn_text', |
| 28 | [ |
| 29 | 'label' => esc_html__('Button Text', 'shopengine'), |
| 30 | 'type' => Controls_Manager::TEXT, |
| 31 | 'default' => 'Call for Price', |
| 32 | 'frontend_available' => true, |
| 33 | ] |
| 34 | ); |
| 35 | |
| 36 | $this->add_control( |
| 37 | 'shopengine_call_for_price_btn_phone_number', |
| 38 | [ |
| 39 | 'label' => esc_html__('Button Phone Number', 'shopengine'), |
| 40 | 'type' => Controls_Manager::TEXT, |
| 41 | 'default' => '123-456-789', |
| 42 | 'frontend_available' => true, |
| 43 | ] |
| 44 | ); |
| 45 | |
| 46 | $this->end_controls_section(); |
| 47 | |
| 48 | /* |
| 49 | * Style Tab - Call for price |
| 50 | */ |
| 51 | $this->start_controls_section( |
| 52 | 'shopengine_section_product_call_for_price_style', |
| 53 | array( |
| 54 | 'label' => esc_html__('Button Style', 'shopengine'), |
| 55 | 'tab' => Controls_Manager::TAB_STYLE, |
| 56 | ) |
| 57 | ); |
| 58 | |
| 59 | $this->add_group_control( |
| 60 | Group_Control_Typography::get_type(), |
| 61 | array( |
| 62 | 'name' => 'shopengine_product_call_for_price_typography', |
| 63 | 'label' => esc_html__('Typography', 'shopengine'), |
| 64 | 'selector' => '{{WRAPPER}} .shopengine-call-for-price-btn', |
| 65 | 'exclude' => ['text_decoration'], |
| 66 | 'fields_options' => [ |
| 67 | 'typography' => [ |
| 68 | 'default' => 'custom', |
| 69 | ], |
| 70 | 'font_weight' => [ |
| 71 | 'default' => '600', |
| 72 | ], |
| 73 | 'font_size' => [ |
| 74 | 'label' => esc_html__('Font Size (px)', 'shopengine'), |
| 75 | 'default' => [ |
| 76 | 'size' => '15', |
| 77 | 'unit' => 'px' |
| 78 | ], |
| 79 | 'size_units' => ['px'] |
| 80 | ], |
| 81 | 'text_transform' => [ |
| 82 | 'default' => 'uppercase', |
| 83 | ], |
| 84 | 'line_height' => [ |
| 85 | 'label' => esc_html__('Line Height (px)', 'shopengine'), |
| 86 | 'default' => [ |
| 87 | 'size' => '18', |
| 88 | 'unit' => 'px' |
| 89 | ], |
| 90 | 'size_units' => ['px'], |
| 91 | 'tablet_default' => [ |
| 92 | 'unit' => 'px', |
| 93 | ], |
| 94 | 'mobile_default' => [ |
| 95 | 'unit' => 'px', |
| 96 | ], |
| 97 | 'selectors' => [ |
| 98 | '{{WRAPPER}} .shopengine-call-for-price-btn' => 'line-height: {{SIZE}}{{UNIT}};', |
| 99 | ], |
| 100 | ], |
| 101 | ], |
| 102 | ) |
| 103 | ); |
| 104 | |
| 105 | $this->start_controls_tabs('shopengine_product_call_for_price_style_tabs'); |
| 106 | |
| 107 | $this->start_controls_tab( |
| 108 | 'shopengine_product_call_for_price_style_normal', |
| 109 | [ |
| 110 | 'label' => esc_html__('Normal', 'shopengine'), |
| 111 | ] |
| 112 | ); |
| 113 | |
| 114 | $this->add_control( |
| 115 | 'shopengine_product_call_for_price_text_color_normal', |
| 116 | [ |
| 117 | 'label' => esc_html__('Color', 'shopengine'), |
| 118 | 'type' => Controls_Manager::COLOR, |
| 119 | 'alpha' => false, |
| 120 | 'default' => '#FFFFFF', |
| 121 | 'selectors' => [ |
| 122 | '{{WRAPPER}} .shopengine-call-for-price-btn' => 'color: {{VALUE}};', |
| 123 | ], |
| 124 | ] |
| 125 | ); |
| 126 | |
| 127 | $this->add_control( |
| 128 | 'shopengine_product_call_for_price_bg_color_normal', |
| 129 | [ |
| 130 | 'label' => esc_html__('Background Color', 'shopengine'), |
| 131 | 'type' => Controls_Manager::COLOR, |
| 132 | 'alpha' => false, |
| 133 | 'default' => '#101010', |
| 134 | 'selectors' => [ |
| 135 | '{{WRAPPER}} .shopengine-call-for-price-btn' => 'background-color: {{VALUE}};', |
| 136 | ], |
| 137 | ] |
| 138 | ); |
| 139 | |
| 140 | $this->end_controls_tab(); |
| 141 | |
| 142 | $this->start_controls_tab( |
| 143 | 'shopengine_product_call_for_price_style_hover', |
| 144 | [ |
| 145 | 'label' => esc_html__('Hover', 'shopengine'), |
| 146 | ] |
| 147 | ); |
| 148 | |
| 149 | $this->add_control( |
| 150 | 'shopengine_product_call_for_price_text_color_hover', |
| 151 | [ |
| 152 | 'label' => esc_html__('Color', 'shopengine'), |
| 153 | 'type' => Controls_Manager::COLOR, |
| 154 | 'alpha' => false, |
| 155 | 'default' => '#FFFFFF', |
| 156 | 'selectors' => [ |
| 157 | '{{WRAPPER}} .shopengine-call-for-price-btn:hover' => 'color: {{VALUE}};', |
| 158 | ], |
| 159 | ] |
| 160 | ); |
| 161 | |
| 162 | $this->add_control( |
| 163 | 'shopengine_product_call_for_price_bg_color_hover', |
| 164 | [ |
| 165 | 'label' => esc_html__('Background Color', 'shopengine'), |
| 166 | 'type' => Controls_Manager::COLOR, |
| 167 | 'alpha' => false, |
| 168 | 'default' => '#312b2b', |
| 169 | 'selectors' => [ |
| 170 | '{{WRAPPER}} .shopengine-call-for-price-btn:hover' => 'background-color: {{VALUE}};', |
| 171 | ], |
| 172 | ] |
| 173 | ); |
| 174 | |
| 175 | $this->add_control( |
| 176 | 'shopengine_product_call_for_price_border_color_hover', |
| 177 | [ |
| 178 | 'label' => esc_html__('Border Color', 'shopengine'), |
| 179 | 'type' => Controls_Manager::COLOR, |
| 180 | 'alpha' => false, |
| 181 | 'default' => '#312b2b', |
| 182 | 'selectors' => [ |
| 183 | '{{WRAPPER}} .shopengine-call-for-price-btn:hover' => 'border-color: {{VALUE}};', |
| 184 | ], |
| 185 | ] |
| 186 | ); |
| 187 | |
| 188 | $this->end_controls_tab(); |
| 189 | $this->end_controls_tabs(); |
| 190 | |
| 191 | $this->add_group_control( |
| 192 | Group_Control_Border::get_type(), |
| 193 | [ |
| 194 | 'name' => 'shopengine_product_call_for_price_border', |
| 195 | 'selector' => '{{WRAPPER}} .shopengine-call-for-price-btn', |
| 196 | 'size_units' => ['px'], |
| 197 | 'fields_options' => [ |
| 198 | 'border' => [ |
| 199 | 'default' => 'solid', |
| 200 | ], |
| 201 | 'width' => [ |
| 202 | 'default' => [ |
| 203 | 'top' => '1', |
| 204 | 'right' => '1', |
| 205 | 'bottom' => '1', |
| 206 | 'left' => '1', |
| 207 | 'isLinked' => true, |
| 208 | ], |
| 209 | 'selectors' => [ |
| 210 | '{{WRAPPER}} .shopengine-call-for-price-btn' => 'border-width: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 211 | '.rtl {{WRAPPER}} .shopengine-call-for-price-btn' => 'border-width: {{TOP}}{{UNIT}} {{LEFT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{RIGHT}}{{UNIT}};', |
| 212 | ] |
| 213 | ], |
| 214 | 'color' => [ |
| 215 | 'default' => '#101010', |
| 216 | 'alpha' => false, |
| 217 | ] |
| 218 | ], |
| 219 | 'separator' => 'before', |
| 220 | ] |
| 221 | ); |
| 222 | |
| 223 | $this->add_control( |
| 224 | 'shopengine_product_call_for_price_border_radius', |
| 225 | [ |
| 226 | 'label' => esc_html__('Border Radius (px)', 'shopengine'), |
| 227 | 'type' => Controls_Manager::DIMENSIONS, |
| 228 | 'default' => [ |
| 229 | 'top' => '5', |
| 230 | 'right' => '5', |
| 231 | 'bottom' => '5', |
| 232 | 'left' => '5', |
| 233 | 'unit' => 'px', |
| 234 | 'isLinked' => true, |
| 235 | ], |
| 236 | 'size_units' => ['px'], |
| 237 | 'selectors' => [ |
| 238 | '{{WRAPPER}} .shopengine-call-for-price-btn' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 239 | '.rtl {{WRAPPER}} .shopengine-call-for-price-btn' => 'border-radius: {{TOP}}{{UNIT}} {{LEFT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{RIGHT}}{{UNIT}};', |
| 240 | ], |
| 241 | ] |
| 242 | ); |
| 243 | |
| 244 | $this->add_responsive_control( |
| 245 | 'shopengine_product_call_for_price_padding', |
| 246 | [ |
| 247 | 'label' => esc_html__('Padding (px)', 'shopengine'), |
| 248 | 'type' => Controls_Manager::DIMENSIONS, |
| 249 | 'size_units' => ['px'], |
| 250 | 'default' => [ |
| 251 | 'top' => '12', |
| 252 | 'right' => '25', |
| 253 | 'bottom' => '12', |
| 254 | 'left' => '25', |
| 255 | 'unit' => 'px', |
| 256 | 'isLinked' => false, |
| 257 | ], |
| 258 | 'selectors' => [ |
| 259 | '{{WRAPPER}} .shopengine-call-for-price-btn' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 260 | '.rtl {{WRAPPER}} .shopengine-call-for-price-btn' => 'padding: {{TOP}}{{UNIT}} {{LEFT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{RIGHT}}{{UNIT}};', |
| 261 | ], |
| 262 | 'separator' => 'before', |
| 263 | ] |
| 264 | ); |
| 265 | |
| 266 | $this->add_responsive_control( |
| 267 | 'shopengine_product_call_for_price_margin', |
| 268 | [ |
| 269 | 'label' => esc_html__('Margin (px)', 'shopengine'), |
| 270 | 'type' => Controls_Manager::DIMENSIONS, |
| 271 | 'size_units' => ['px'], |
| 272 | 'default' => [ |
| 273 | 'top' => '0', |
| 274 | 'right' => '10', |
| 275 | 'bottom' => '0', |
| 276 | 'left' => '0', |
| 277 | 'unit' => 'px', |
| 278 | 'isLinked' => false, |
| 279 | ], |
| 280 | 'selectors' => [ |
| 281 | '{{WRAPPER}} .shopengine-call-for-price-btn' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 282 | '.rtl {{WRAPPER}} .shopengine-call-for-price-btn' => 'margin: {{TOP}}{{UNIT}} {{LEFT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{RIGHT}}{{UNIT}};', |
| 283 | ], |
| 284 | 'separator' => 'before', |
| 285 | ] |
| 286 | ); |
| 287 | |
| 288 | $this->end_controls_section(); |
| 289 | } |
| 290 | |
| 291 | protected function screen() |
| 292 | { |
| 293 | |
| 294 | $settings = $this->get_settings_for_display(); |
| 295 | |
| 296 | $btn_text = !empty($settings['shopengine_call_for_price_btn_text']) ? esc_html($settings['shopengine_call_for_price_btn_text']) : 'Call for Price'; |
| 297 | $phone_number = !empty($settings['shopengine_call_for_price_btn_phone_number']) ? esc_attr($settings['shopengine_call_for_price_btn_phone_number']) : ''; |
| 298 | |
| 299 | ?> |
| 300 | <div class="shopengine-call-for-prie"><a href="tel:<?php echo esc_html($phone_number); ?>" class="shopengine-call-for-price-btn"><?php echo esc_html($btn_text) ?></a></div> |
| 301 | <?php |
| 302 | } |
| 303 | } |
| 304 |