PluginProbe
King Addons for Elementor – 80+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce, Mega Menu, Popup Builder / 51.1.49
King Addons for Elementor – 80+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce, Mega Menu, Popup Builder v51.1.49
51.1.83 51.1.82 51.1.81 51.1.79 51.1.78 51.1.77 51.1.76 51.1.74 51.1.75 51.1.65 51.1.64 51.1.63 trunk 51.1.14 51.1.2 51.1.35 51.1.36 51.1.37 51.1.38 51.1.39 51.1.44 51.1.45 51.1.46 51.1.47 51.1.49 All 37 releases
king-addons / includes / widgets / Woo_Archive_Title / Woo_Archive_Title.php

Woo_Archive_Title.php in King Addons for Elementor – 80+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce, Mega Menu, Popup Builder 51.1.49, at includes/widgets/Woo_Archive_Title/Woo_Archive_Title.php

171 lines 4.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Woo Archive Title widget.
4 *
5 * @package King_Addons
6 */
7
8 namespace King_Addons;
9
10 use Elementor\Controls_Manager;
11 use Elementor\Group_Control_Typography;
12
13 if (!defined('ABSPATH')) {
14 exit;
15 }
16
17 /**
18 * Displays archive title.
19 */
20 class Woo_Archive_Title extends Abstract_Archive_Widget
21 {
22 public function get_name(): string
23 {
24 return 'woo_archive_title';
25 }
26
27 public function get_title(): string
28 {
29 return esc_html__('Archive Title', 'king-addons');
30 }
31
32 public function get_icon(): string
33 {
34 return 'eicon-heading';
35 }
36
37 public function get_categories(): array
38 {
39 return ['king-addons-woo-builder'];
40 }
41
42 public function get_style_depends(): array
43 {
44 return [KING_ADDONS_ASSETS_UNIQUE_KEY . '-woo-archive-title-style'];
45 }
46
47 protected function register_controls(): void
48 {
49 $this->start_controls_section(
50 'section_content',
51 [
52 'label' => esc_html__('Content', 'king-addons'),
53 'tab' => Controls_Manager::TAB_CONTENT,
54 ]
55 );
56
57 $this->add_control(
58 'html_tag',
59 [
60 'label' => esc_html__('HTML Tag', 'king-addons'),
61 'type' => Controls_Manager::SELECT,
62 'options' => [
63 'h1' => 'H1',
64 'h2' => 'H2',
65 'h3' => 'H3',
66 'div' => 'div',
67 ],
68 'default' => 'h1',
69 ]
70 );
71
72 $this->add_control(
73 'prefix',
74 [
75 'label' => sprintf(__('Prefix (Pro) %s', 'king-addons'), '<i class="eicon-pro-icon"></i>'),
76 'type' => Controls_Manager::TEXT,
77 'default' => '',
78 ]
79 );
80
81 $this->add_control(
82 'custom_format',
83 [
84 'label' => sprintf(__('Custom format %s', 'king-addons'), '<i class="eicon-pro-icon"></i>'),
85 'type' => Controls_Manager::TEXT,
86 'description' => esc_html__('Use {title} and {count} placeholders.', 'king-addons'),
87 'default' => '',
88 ]
89 );
90
91 $this->end_controls_section();
92
93 $this->start_controls_section(
94 'section_style',
95 [
96 'label' => esc_html__('Style', 'king-addons'),
97 'tab' => Controls_Manager::TAB_STYLE,
98 ]
99 );
100
101 $this->add_group_control(
102 Group_Control_Typography::get_type(),
103 [
104 'name' => 'typography',
105 'selector' => '{{WRAPPER}} .ka-woo-archive-title',
106 ]
107 );
108
109 $this->add_control(
110 'color',
111 [
112 'label' => esc_html__('Color', 'king-addons'),
113 'type' => Controls_Manager::COLOR,
114 'selectors' => [
115 '{{WRAPPER}} .ka-woo-archive-title' => 'color: {{VALUE}};',
116 ],
117 ]
118 );
119
120 $this->add_responsive_control(
121 'margin',
122 [
123 'label' => esc_html__('Margin', 'king-addons'),
124 'type' => Controls_Manager::DIMENSIONS,
125 'size_units' => ['px', 'em', '%'],
126 'selectors' => [
127 '{{WRAPPER}} .ka-woo-archive-title' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
128 ],
129 ]
130 );
131
132 $this->end_controls_section();
133 }
134
135 protected function render(): void
136 {
137 if (!is_shop() && !is_product_taxonomy()) {
138 $this->render_missing_archive_notice();
139 return;
140 }
141
142 $settings = $this->get_settings_for_display();
143 $tag = $settings['html_tag'] ?? 'h1';
144 $title = woocommerce_page_title(false);
145 $can_pro = king_addons_can_use_pro();
146 if (!empty($settings['prefix']) && $can_pro) {
147 $title = $settings['prefix'] . ' ' . $title;
148 }
149
150 if (!empty($settings['custom_format']) && $can_pro) {
151 global $wp_query;
152 $count = isset($wp_query->found_posts) ? (int) $wp_query->found_posts : 0;
153 $formatted = str_replace(
154 ['{title}', '{count}'],
155 [$title, number_format_i18n($count)],
156 $settings['custom_format']
157 );
158 $title = $formatted;
159 }
160
161 echo '<' . esc_html($tag) . ' class="ka-woo-archive-title">' . esc_html($title) . '</' . esc_html($tag) . '>';
162 }
163 }
164
165
166
167
168
169
170
171