PluginProbe
King Addons for Elementor – 100+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce Builder, Mega Menu, Popup Builder / 51.1.65
King Addons for Elementor – 100+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce Builder, Mega Menu, Popup Builder v51.1.65
51.1.86 51.1.84 51.1.85 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 All 40 releases
king-addons / includes / widgets / Woo_Archive_Title / Woo_Archive_Title.php

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

174 lines 4.6 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 (!class_exists('WooCommerce') || !function_exists('is_shop') || !function_exists('is_product_taxonomy')) {
138 return;
139 }
140
141 if (!$this->should_render()) {
142 $this->render_missing_archive_notice();
143 return;
144 }
145
146 $settings = $this->get_settings_for_display();
147 $tag = $settings['html_tag'] ?? 'h1';
148 $title = woocommerce_page_title(false);
149 $can_pro = king_addons_can_use_pro();
150 if (!empty($settings['prefix']) && $can_pro) {
151 $title = $settings['prefix'] . ' ' . $title;
152 }
153
154 if (!empty($settings['custom_format']) && $can_pro) {
155 global $wp_query;
156 $count = isset($wp_query->found_posts) ? (int) $wp_query->found_posts : 0;
157 $formatted = str_replace(
158 ['{title}', '{count}'],
159 [$title, number_format_i18n($count)],
160 $settings['custom_format']
161 );
162 $title = $formatted;
163 }
164
165 echo '<' . esc_html($tag) . ' class="ka-woo-archive-title">' . esc_html($title) . '</' . esc_html($tag) . '>';
166 }
167 }
168
169
170
171
172
173
174