PluginProbe
UiCore Elements – Free widgets and templates for Elementor / 1.2.2
UiCore Elements – Free widgets and templates for Elementor v1.2.2
1.3.17 1.3.16 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 All 41 releases
uicore-elements / includes / widgets / theme-builder / the-title.php

the-title.php in UiCore Elements – Free widgets and templates for Elementor 1.2.2, at includes/widgets/theme-builder/the-title.php

302 lines 6.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace UiCoreElements\ThemeBuilder\Widgets;
3
4 use Elementor\Widget_Base;
5 use Elementor\Controls_Manager;
6 use Elementor\Core\Kits\Documents\Tabs\Global_Colors;
7 use Elementor\Core\Kits\Documents\Tabs\Global_Typography;
8 use Elementor\Group_Control_Typography;
9 use Elementor\Group_Control_Text_Shadow;
10 use Elementor\Group_Control_Text_Stroke;
11 use Elementor\Utils;
12 //use UiCoreElements\Extender;
13
14
15 defined('ABSPATH') || exit();
16
17 /**
18 * The Title widget.
19 *
20 * @since 4.0.0
21 */
22 class TheTitle extends Widget_Base {
23
24 /**
25 * Get widget name.
26 *
27 * Retrieve heading widget name.
28 *
29 * @since 1.0.0
30 * @access public
31 *
32 * @return string Widget name.
33 */
34 public function get_name() {
35 return 'uicore-the-title';
36 }
37
38 /**
39 * Get widget title.
40 *
41 * Retrieve heading widget title.
42 *
43 * @since 1.0.0
44 * @access public
45 *
46 * @return string Widget title.
47 */
48 public function get_title() {
49 return esc_html__( 'The Title', 'uicore-elements' );
50 }
51
52 /**
53 * Get widget icon.
54 *
55 * Retrieve heading widget icon.
56 *
57 * @since 1.0.0
58 * @access public
59 *
60 * @return string Widget icon.
61 */
62 public function get_icon() {
63 return 'eicon-t-letter ui-e-widget';
64 }
65
66 /**
67 * Get widget categories.
68 *
69 * Retrieve the list of categories the heading widget belongs to.
70 *
71 * Used to determine where to display the widget in the editor.
72 *
73 * @since 2.0.0
74 * @access public
75 *
76 * @return array Widget categories.
77 */
78 public function get_categories() {
79 return ['uicore', 'uicore-theme-builder' ];
80 }
81
82 /**
83 * Get widget keywords.
84 *
85 * Retrieve the list of keywords the widget belongs to.
86 *
87 * @since 2.1.0
88 * @access public
89 *
90 * @return array Widget keywords.
91 */
92 public function get_keywords() {
93 return [ 'heading', 'title', 'text' ];
94 }
95
96 public function has_widget_inner_wrapper(): bool {
97 // TODO: remove after 3.30, when the full deprecation of widget innet wrapper is ready
98 return ! \Elementor\Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' );
99 }
100
101 /**
102 * Register heading widget controls.
103 *
104 * Adds different input fields to allow the user to change and customize the widget settings.
105 *
106 * @since 3.1.0
107 * @access protected
108 */
109 protected function register_controls() {
110 $this->start_controls_section(
111 'section_title',
112 [
113 'label' => esc_html__( 'Title', 'uicore-elements' ),
114 ]
115 );
116
117 $this->add_control(
118 'header_size',
119 [
120 'label' => esc_html__( 'HTML Tag', 'uicore-elements' ),
121 'type' => Controls_Manager::SELECT,
122 'options' => [
123 'h1' => 'H1',
124 'h2' => 'H2',
125 'h3' => 'H3',
126 'h4' => 'H4',
127 'h5' => 'H5',
128 'h6' => 'H6',
129 'div' => 'div',
130 'span' => 'span',
131 'p' => 'p',
132 ],
133 'default' => 'h2',
134 ]
135 );
136
137 $this->add_responsive_control(
138 'align',
139 [
140 'label' => esc_html__( 'Alignment', 'uicore-elements' ),
141 'type' => Controls_Manager::CHOOSE,
142 'options' => [
143 'left' => [
144 'title' => esc_html__( 'Left', 'uicore-elements' ),
145 'icon' => 'eicon-text-align-left',
146 ],
147 'center' => [
148 'title' => esc_html__( 'Center', 'uicore-elements' ),
149 'icon' => 'eicon-text-align-center',
150 ],
151 'right' => [
152 'title' => esc_html__( 'Right', 'uicore-elements' ),
153 'icon' => 'eicon-text-align-right',
154 ],
155 'justify' => [
156 'title' => esc_html__( 'Justified', 'uicore-elements' ),
157 'icon' => 'eicon-text-align-justify',
158 ],
159 ],
160 'default' => '',
161 'selectors' => [
162 '{{WRAPPER}}' => 'text-align: {{VALUE}};',
163 ],
164 ]
165 );
166
167 $this->add_control(
168 'view',
169 [
170 'label' => esc_html__( 'View', 'uicore-elements' ),
171 'type' => Controls_Manager::HIDDEN,
172 'default' => 'traditional',
173 ]
174 );
175
176 $this->end_controls_section();
177
178 $this->start_controls_section(
179 'section_title_style',
180 [
181 'label' => esc_html__( 'Title', 'uicore-elements' ),
182 'tab' => Controls_Manager::TAB_STYLE,
183 ]
184 );
185
186 $this->add_control(
187 'title_color',
188 [
189 'label' => esc_html__( 'Text Color', 'uicore-elements' ),
190 'type' => Controls_Manager::COLOR,
191 'global' => [
192 'default' => Global_Colors::COLOR_PRIMARY,
193 ],
194 'selectors' => [
195 '{{WRAPPER}} .elementor-heading-title' => 'color: {{VALUE}};',
196 ],
197 ]
198 );
199
200 $this->add_group_control(
201 Group_Control_Typography::get_type(),
202 [
203 'name' => 'typography',
204 'global' => [
205 'default' => Global_Typography::TYPOGRAPHY_PRIMARY,
206 ],
207 'selector' => '{{WRAPPER}} .elementor-heading-title',
208 ]
209 );
210
211 $this->add_group_control(
212 Group_Control_Text_Stroke::get_type(),
213 [
214 'name' => 'text_stroke',
215 'selector' => '{{WRAPPER}} .elementor-heading-title',
216 ]
217 );
218
219 $this->add_group_control(
220 Group_Control_Text_Shadow::get_type(),
221 [
222 'name' => 'text_shadow',
223 'selector' => '{{WRAPPER}} .elementor-heading-title',
224 ]
225 );
226
227 $this->add_control(
228 'blend_mode',
229 [
230 'label' => esc_html__( 'Blend Mode', 'uicore-elements' ),
231 'type' => Controls_Manager::SELECT,
232 'options' => [
233 '' => esc_html__( 'Normal', 'uicore-elements' ),
234 'multiply' => 'Multiply',
235 'screen' => 'Screen',
236 'overlay' => 'Overlay',
237 'darken' => 'Darken',
238 'lighten' => 'Lighten',
239 'color-dodge' => 'Color Dodge',
240 'saturation' => 'Saturation',
241 'color' => 'Color',
242 'difference' => 'Difference',
243 'exclusion' => 'Exclusion',
244 'hue' => 'Hue',
245 'luminosity' => 'Luminosity',
246 ],
247 'selectors' => [
248 '{{WRAPPER}} .elementor-heading-title' => 'mix-blend-mode: {{VALUE}}',
249 ],
250 'separator' => 'none',
251 ]
252 );
253
254 $this->end_controls_section();
255
256 }
257
258 /**
259 * Render heading widget output on the frontend.
260 *
261 * Written in PHP and used to generate the final HTML.
262 *
263 * @since 1.0.0
264 * @access protected
265 */
266 protected function render() {
267 $settings = $this->get_settings_for_display();
268
269 $this->add_render_attribute( 'title', 'class', 'elementor-heading-title' );
270
271 if( !\Elementor\Plugin::$instance->editor->is_edit_mode() ) {
272
273 // If there is a post.
274 if ( is_single() || ( is_home() && ! is_front_page() ) || ( is_page() && ! is_front_page() ) ) {
275 $title = single_post_title( '', false );
276 }else{
277 $title = wp_title(null,false);
278 }
279
280 $title = $title ? $title : get_bloginfo('name');
281 }else{
282 $title = __( 'This is a dummy title.', 'uicore-elements' );
283 }
284
285 $title_html = sprintf( '<%1$s %2$s>%3$s</%1$s>', Utils::validate_html_tag($settings['header_size']), $this->get_render_attribute_string( 'title' ), \esc_html($title) );
286
287 // PHPCS - the variable $title_html holds safe data.
288 echo $title_html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
289 }
290
291 /**
292 * Render heading widget output in the editor.
293 *
294 * Written as a Backbone JavaScript template and used to generate the live preview.
295 *
296 * @since 2.9.0
297 * @access protected
298 */
299 protected function content_template() {
300 }
301 }
302 \Elementor\Plugin::instance()->widgets_manager->register(new TheTitle());