archive-title.php
138 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Elementor; |
| 4 | |
| 5 | defined('ABSPATH') || exit; |
| 6 | |
| 7 | use ShopEngine\Widgets\Products; |
| 8 | |
| 9 | class ShopEngine_Archive_Title extends \ShopEngine\Base\Widget |
| 10 | { |
| 11 | |
| 12 | public function config() { |
| 13 | return new ShopEngine_Archive_Title_Config(); |
| 14 | } |
| 15 | |
| 16 | protected function register_controls() { |
| 17 | |
| 18 | $this->start_controls_section( |
| 19 | 'shopengine_section_archive_title_style', |
| 20 | array( |
| 21 | 'label' => esc_html__('Title', 'shopengine'), |
| 22 | 'tab' => Controls_Manager::TAB_STYLE, |
| 23 | ) |
| 24 | ); |
| 25 | |
| 26 | $this->add_control( |
| 27 | 'shopengine_archive_title_header_size', |
| 28 | [ |
| 29 | 'label' => esc_html__('HTML Tag', 'shopengine'), |
| 30 | 'type' => Controls_Manager::SELECT, |
| 31 | 'options' => [ |
| 32 | 'h1' => 'H1', |
| 33 | 'h2' => 'H2', |
| 34 | 'h3' => 'H3', |
| 35 | 'h4' => 'H4', |
| 36 | 'h5' => 'H5', |
| 37 | 'h6' => 'H6', |
| 38 | 'div' => 'Div', |
| 39 | 'span' => 'Span', |
| 40 | 'p' => 'P', |
| 41 | ], |
| 42 | 'default' => 'h1', |
| 43 | 'selectors' => [ |
| 44 | '{{WRAPPER}} .archive-title' => 'margin: 0; padding: 0;', |
| 45 | ], |
| 46 | ] |
| 47 | ); |
| 48 | |
| 49 | $this->add_responsive_control( |
| 50 | 'shopengine_archive_title_align', |
| 51 | \ShopEngine\Utils\Controls_Helper::get_alignment_conf( |
| 52 | 'elementor%s-align-', '', |
| 53 | [ |
| 54 | '{{WRAPPER}} .shopengine-archive-title' => 'text-align: {{VALUE}}', |
| 55 | '.rtl {{WRAPPER}}.elementor-align-left .shopengine-archive-title' => 'text-align: right;', |
| 56 | '.rtl {{WRAPPER}}.elementor-align-right .shopengine-archive-title' => 'text-align: left;', |
| 57 | ], |
| 58 | ) |
| 59 | ); |
| 60 | |
| 61 | $this->add_control( |
| 62 | 'shopengine_archive_title_archive_title_color', |
| 63 | [ |
| 64 | 'label' => esc_html__('Color', 'shopengine'), |
| 65 | 'type' => Controls_Manager::COLOR, |
| 66 | 'alpha' => false, |
| 67 | 'default' => '#101010', |
| 68 | 'selectors' => [ |
| 69 | '{{WRAPPER}} .archive-title' => 'color: {{VALUE}};', |
| 70 | ], |
| 71 | ] |
| 72 | ); |
| 73 | |
| 74 | $this->add_group_control( |
| 75 | Group_Control_Typography::get_type(), |
| 76 | array( |
| 77 | 'name' => 'shopengine_archive_title_typography', |
| 78 | 'label' => esc_html__('Typography', 'shopengine'), |
| 79 | 'selector' => '{{WRAPPER}} .archive-title', |
| 80 | 'exclude' => ['font_style', 'text_decoration', 'letter_spacing'], |
| 81 | 'fields_options' => [ |
| 82 | 'typography' => [ |
| 83 | 'default' => 'custom', |
| 84 | ], |
| 85 | 'font_weight' => [ |
| 86 | 'default' => '700', |
| 87 | ], |
| 88 | 'font_size' => [ |
| 89 | 'label' => esc_html__('Font Size (px)', 'shopengine'), |
| 90 | 'default' => [ |
| 91 | 'size' => '24', |
| 92 | 'unit' => 'px' |
| 93 | ], |
| 94 | 'size_units' => ['px'], |
| 95 | ], |
| 96 | 'text_transform' => [ |
| 97 | 'default' => 'uppercase', |
| 98 | ], |
| 99 | |
| 100 | 'line_height' => [ |
| 101 | 'size_units' => ['px'], |
| 102 | 'label' => 'Line-height (px)', |
| 103 | ] |
| 104 | |
| 105 | ], |
| 106 | ) |
| 107 | ); |
| 108 | |
| 109 | $this->end_controls_section(); |
| 110 | } |
| 111 | |
| 112 | protected function screen() { |
| 113 | |
| 114 | $settings = $this->get_settings_for_display(); |
| 115 | $options_heading_title_tag = array_keys( |
| 116 | [ |
| 117 | 'h1' => 'H1', |
| 118 | 'h2' => 'H2', |
| 119 | 'h3' => 'H3', |
| 120 | 'h4' => 'H4', |
| 121 | 'h5' => 'H5', |
| 122 | 'h6' => 'H6', |
| 123 | 'div' => 'div', |
| 124 | 'span' => 'span', |
| 125 | 'p' => 'p', |
| 126 | ] |
| 127 | ); |
| 128 | $title_tag = isset($settings['shopengine_archive_title_header_size']) |
| 129 | ? \ShopEngine\Utils\Helper::esc_options($settings['shopengine_archive_title_header_size'], $options_heading_title_tag, 'h1') |
| 130 | : 'h1'; |
| 131 | echo sprintf( |
| 132 | '<div class="shopengine-archive-title"><%1$s class="archive-title">%2$s</%1$s></div>', |
| 133 | esc_html( $title_tag ), |
| 134 | esc_html(woocommerce_page_title(false)) |
| 135 | ); |
| 136 | } |
| 137 | } |
| 138 |