PluginProbe
UiCore Elements – Free widgets and templates for Elementor / 1.0.8
UiCore Elements – Free widgets and templates for Elementor v1.0.8
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.0.8, at includes/widgets/theme-builder/the-title.php

297 lines 6.6 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 /**
97 * Register heading widget controls.
98 *
99 * Adds different input fields to allow the user to change and customize the widget settings.
100 *
101 * @since 3.1.0
102 * @access protected
103 */
104 protected function register_controls() {
105 $this->start_controls_section(
106 'section_title',
107 [
108 'label' => esc_html__( 'Title', 'uicore-elements' ),
109 ]
110 );
111
112 $this->add_control(
113 'header_size',
114 [
115 'label' => esc_html__( 'HTML Tag', 'uicore-elements' ),
116 'type' => Controls_Manager::SELECT,
117 'options' => [
118 'h1' => 'H1',
119 'h2' => 'H2',
120 'h3' => 'H3',
121 'h4' => 'H4',
122 'h5' => 'H5',
123 'h6' => 'H6',
124 'div' => 'div',
125 'span' => 'span',
126 'p' => 'p',
127 ],
128 'default' => 'h2',
129 ]
130 );
131
132 $this->add_responsive_control(
133 'align',
134 [
135 'label' => esc_html__( 'Alignment', 'uicore-elements' ),
136 'type' => Controls_Manager::CHOOSE,
137 'options' => [
138 'left' => [
139 'title' => esc_html__( 'Left', 'uicore-elements' ),
140 'icon' => 'eicon-text-align-left',
141 ],
142 'center' => [
143 'title' => esc_html__( 'Center', 'uicore-elements' ),
144 'icon' => 'eicon-text-align-center',
145 ],
146 'right' => [
147 'title' => esc_html__( 'Right', 'uicore-elements' ),
148 'icon' => 'eicon-text-align-right',
149 ],
150 'justify' => [
151 'title' => esc_html__( 'Justified', 'uicore-elements' ),
152 'icon' => 'eicon-text-align-justify',
153 ],
154 ],
155 'default' => '',
156 'selectors' => [
157 '{{WRAPPER}}' => 'text-align: {{VALUE}};',
158 ],
159 ]
160 );
161
162 $this->add_control(
163 'view',
164 [
165 'label' => esc_html__( 'View', 'uicore-elements' ),
166 'type' => Controls_Manager::HIDDEN,
167 'default' => 'traditional',
168 ]
169 );
170
171 $this->end_controls_section();
172
173 $this->start_controls_section(
174 'section_title_style',
175 [
176 'label' => esc_html__( 'Title', 'uicore-elements' ),
177 'tab' => Controls_Manager::TAB_STYLE,
178 ]
179 );
180
181 $this->add_control(
182 'title_color',
183 [
184 'label' => esc_html__( 'Text Color', 'uicore-elements' ),
185 'type' => Controls_Manager::COLOR,
186 'global' => [
187 'default' => Global_Colors::COLOR_PRIMARY,
188 ],
189 'selectors' => [
190 '{{WRAPPER}} .elementor-heading-title' => 'color: {{VALUE}};',
191 ],
192 ]
193 );
194
195 $this->add_group_control(
196 Group_Control_Typography::get_type(),
197 [
198 'name' => 'typography',
199 'global' => [
200 'default' => Global_Typography::TYPOGRAPHY_PRIMARY,
201 ],
202 'selector' => '{{WRAPPER}} .elementor-heading-title',
203 ]
204 );
205
206 $this->add_group_control(
207 Group_Control_Text_Stroke::get_type(),
208 [
209 'name' => 'text_stroke',
210 'selector' => '{{WRAPPER}} .elementor-heading-title',
211 ]
212 );
213
214 $this->add_group_control(
215 Group_Control_Text_Shadow::get_type(),
216 [
217 'name' => 'text_shadow',
218 'selector' => '{{WRAPPER}} .elementor-heading-title',
219 ]
220 );
221
222 $this->add_control(
223 'blend_mode',
224 [
225 'label' => esc_html__( 'Blend Mode', 'uicore-elements' ),
226 'type' => Controls_Manager::SELECT,
227 'options' => [
228 '' => esc_html__( 'Normal', 'uicore-elements' ),
229 'multiply' => 'Multiply',
230 'screen' => 'Screen',
231 'overlay' => 'Overlay',
232 'darken' => 'Darken',
233 'lighten' => 'Lighten',
234 'color-dodge' => 'Color Dodge',
235 'saturation' => 'Saturation',
236 'color' => 'Color',
237 'difference' => 'Difference',
238 'exclusion' => 'Exclusion',
239 'hue' => 'Hue',
240 'luminosity' => 'Luminosity',
241 ],
242 'selectors' => [
243 '{{WRAPPER}} .elementor-heading-title' => 'mix-blend-mode: {{VALUE}}',
244 ],
245 'separator' => 'none',
246 ]
247 );
248
249 $this->end_controls_section();
250
251 }
252
253 /**
254 * Render heading widget output on the frontend.
255 *
256 * Written in PHP and used to generate the final HTML.
257 *
258 * @since 1.0.0
259 * @access protected
260 */
261 protected function render() {
262 $settings = $this->get_settings_for_display();
263
264 $this->add_render_attribute( 'title', 'class', 'elementor-heading-title' );
265
266 if( !\Elementor\Plugin::$instance->editor->is_edit_mode() ) {
267
268 // If there is a post.
269 if ( is_single() || ( is_home() && ! is_front_page() ) || ( is_page() && ! is_front_page() ) ) {
270 $title = single_post_title( '', false );
271 }else{
272 $title = wp_title(null,false);
273 }
274
275 $title = $title ? $title : get_bloginfo('name');
276 }else{
277 $title = __( 'This is a dummy title.', 'uicore-elements' );
278 }
279
280 $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) );
281
282 // PHPCS - the variable $title_html holds safe data.
283 echo $title_html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
284 }
285
286 /**
287 * Render heading widget output in the editor.
288 *
289 * Written as a Backbone JavaScript template and used to generate the live preview.
290 *
291 * @since 2.9.0
292 * @access protected
293 */
294 protected function content_template() {
295 }
296 }
297 \Elementor\Plugin::instance()->widgets_manager->register(new TheTitle());