config.php
126 lines
| 1 | <?php |
| 2 | namespace ShopPress\Elementor\Widgets\LoopBuilder; |
| 3 | |
| 4 | use Elementor\Controls_Manager; |
| 5 | |
| 6 | use ShopPress\Elementor\ShopPressWidgets; |
| 7 | |
| 8 | defined( 'ABSPATH' ) || exit; |
| 9 | |
| 10 | class Title extends ShopPressWidgets { |
| 11 | |
| 12 | public function get_name() { |
| 13 | return 'sp-item-title'; |
| 14 | } |
| 15 | |
| 16 | public function get_title() { |
| 17 | return __( 'Product Title', 'shop-press' ); |
| 18 | } |
| 19 | |
| 20 | public function get_icon() { |
| 21 | return 'sp-widget sp-eicon-product-title'; |
| 22 | } |
| 23 | |
| 24 | public function get_categories() { |
| 25 | return array( 'sp_woo_loop' ); |
| 26 | } |
| 27 | |
| 28 | public function setup_styling_options() { |
| 29 | |
| 30 | $this->register_group_styler( |
| 31 | 'wrapper', |
| 32 | __( 'Wrapper', 'shop-press' ), |
| 33 | array( |
| 34 | 'wrapper' => array( |
| 35 | 'label' => esc_html__( 'Title', 'shop-press' ), |
| 36 | 'type' => 'styler', |
| 37 | 'selector' => '.sp-product-title', |
| 38 | ), |
| 39 | ) |
| 40 | ); |
| 41 | } |
| 42 | |
| 43 | protected function register_controls() { |
| 44 | $this->start_controls_section( |
| 45 | 'section_content', |
| 46 | array( |
| 47 | 'label' => __( 'General', 'shop-press' ), |
| 48 | ) |
| 49 | ); |
| 50 | |
| 51 | $this->add_control( |
| 52 | 'tag', |
| 53 | array( |
| 54 | 'label' => __( 'Title HTML Tag', 'shop-press' ), |
| 55 | 'type' => Controls_Manager::SELECT, |
| 56 | 'default' => 'h4', |
| 57 | 'options' => array( |
| 58 | 'h1' => __( 'h1', 'shop-press' ), |
| 59 | 'h2' => __( 'h2', 'shop-press' ), |
| 60 | 'h3' => __( 'h3', 'shop-press' ), |
| 61 | 'h4' => __( 'h4', 'shop-press' ), |
| 62 | 'h5' => __( 'h5', 'shop-press' ), |
| 63 | 'h6' => __( 'h6', 'shop-press' ), |
| 64 | 'p' => __( 'p', 'shop-press' ), |
| 65 | 'span' => __( 'span', 'shop-press' ), |
| 66 | ), |
| 67 | ) |
| 68 | ); |
| 69 | |
| 70 | $this->add_control( |
| 71 | 'link_to_product', |
| 72 | array( |
| 73 | 'label' => __( 'Link to Product', 'shop-press' ), |
| 74 | 'type' => Controls_Manager::SWITCHER, |
| 75 | 'default' => 'yes', |
| 76 | 'return_value' => 'yes', |
| 77 | ) |
| 78 | ); |
| 79 | |
| 80 | $this->add_control( |
| 81 | 'link_target', |
| 82 | array( |
| 83 | 'label' => __( 'Open link in', 'shop-press' ), |
| 84 | 'type' => Controls_Manager::SELECT, |
| 85 | 'default' => '_self', |
| 86 | 'options' => array( |
| 87 | '_blank' => __( 'New Window', 'shop-press' ), |
| 88 | '_self' => __( 'Current Window', 'shop-press' ), |
| 89 | ), |
| 90 | 'condition' => array( |
| 91 | 'link_to_product' => 'yes', |
| 92 | ), |
| 93 | ) |
| 94 | ); |
| 95 | |
| 96 | $this->end_controls_section(); |
| 97 | $this->setup_styling_options(); |
| 98 | |
| 99 | do_action( 'shoppress/elementor/widget/register_controls_init', $this ); |
| 100 | } |
| 101 | |
| 102 | protected function render() { |
| 103 | $settings = $this->get_settings_for_display(); |
| 104 | |
| 105 | do_action( 'shoppress/widget/before_render', $settings ); |
| 106 | |
| 107 | $args = array( |
| 108 | 'link_to_product' => $settings['link_to_product'], |
| 109 | 'link_target' => $settings['link_target'], |
| 110 | 'tag' => $settings['tag'], |
| 111 | ); |
| 112 | |
| 113 | if ( $this->editor_preview() ) { |
| 114 | sp_load_builder_template( 'loop/loop-title', $args ); |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | protected function content_template() { |
| 119 | ?> |
| 120 | <{{{ settings.tag }}} class="product_title entry-title sp-product-title"> |
| 121 | Long Sleeve Tee |
| 122 | </{{{ settings.tag }}}> |
| 123 | <?php |
| 124 | } |
| 125 | } |
| 126 |