PluginProbe
UiCore Elements – Free widgets and templates for Elementor / 1.2.1
UiCore Elements – Free widgets and templates for Elementor v1.2.1
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 / post-meta.php

post-meta.php in UiCore Elements – Free widgets and templates for Elementor 1.2.1, at includes/widgets/theme-builder/post-meta.php

167 lines 4.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace UiCoreElements\Widgets\ThemeBuilder;
3
4 use Elementor\Widget_Base;
5 use Elementor\Controls_Manager;
6 use UiCoreElements\Helper;
7 use UiCoreElements\Utils\Meta_Trait;
8
9 defined('ABSPATH') || exit();
10
11 /**
12 * The Title widget.
13 *
14 * @since 1.0.0
15 */
16 class PostMeta extends Widget_Base {
17
18 use Meta_Trait;
19
20 public function get_name() {
21 return 'uicore-post-meta';
22 }
23 public function get_title() {
24 return esc_html__( 'Post Meta', 'uicore-elements' );
25 }
26 public function get_icon() {
27 return 'eicon-post-info ui-e-widget';
28 }
29 public function get_categories() {
30 return ['uicore', 'uicore-theme-builder' ];
31 }
32
33 public function get_style_depends() {
34 return [ 'post-meta' ];
35 }
36 public function get_keywords() {
37 return [ 'post', 'meta', 'info' ];
38 }
39 // TODO: remove or set as false, after 3.30, when the full deprecation of widget innet wrapper is ready
40 public function has_widget_inner_wrapper(): bool {
41 return true;
42 }
43
44 protected function register_controls() {
45 $this->start_controls_section(
46 'section_content',
47 [
48 'label' => esc_html__( 'Content', 'uicore-elements' ),
49 ]
50 );
51
52 $this->add_control('meta_list',[
53 'label' => esc_html__( 'Meta Data', 'uicore-elements' ),
54 'type' => \Elementor\Controls_Manager::REPEATER,
55 'fields' => $this->get_meta_content_controls(),
56 'default' => [
57 [
58 'type' => 'author'
59 ],
60 ],
61 'title_field' => '<span style="text-transform: capitalize">{{{ type }}}</span>',
62 'prevent_empty' => false,
63 'separator'=> 'before'
64 ]
65 );
66 $this->add_responsive_control('content_align',
67 [
68 'label' => esc_html__( 'Content Alignment', 'uicore-elements' ),
69 'type' => Controls_Manager::CHOOSE,
70 'options' => [
71 'left' => [
72 'title' => esc_html__( 'Left', 'uicore-elements' ),
73 'icon' => 'eicon-text-align-left',
74 ],
75 'center' => [
76 'title' => esc_html__( 'Center', 'uicore-elements' ),
77 'icon' => 'eicon-text-align-center',
78 ],
79 ],
80 'selectors' => [
81 '{{WRAPPER}}' => 'text-align: {{VALUE}};',
82 ],
83 ]
84 );
85 $this->end_controls_section();
86
87 $this->start_controls_section(
88 'section_meta_style',
89 [
90 'label' => esc_html__( 'Style', 'uicore-elements' ),
91 'tab' => Controls_Manager::TAB_STYLE,
92 ]
93 );
94 $this->get_meta_style_controls();
95 $this->end_controls_section();
96
97 }
98
99 /**
100 * Match each meta icon size (if SVG) with the correspondent font size set by the user.
101 *
102 * Based on the post component similar function.
103 */
104 function set_meta_font_size_to_svg()
105 {
106 // Required specifically for SVG icons
107 if( \Elementor\Plugin::$instance->experiments->is_feature_active('e_font_icon_svg') == false ){
108 return;
109 }
110
111 $font_size = $this->get_settings_for_display('tb-meta_meta_typography_font_size');
112 $default_size = '16px';
113
114 // Check if theres font-size set.
115 $size = isset( $font_size ) ? $font_size : $default_size;
116
117 // Check if the font-size value is not empty (user might customize other infos but not the font-size)
118 $size = !empty( $size['size'] )
119 ? $size['size'] . $size['unit']
120 : $default_size;
121
122 // Creates the css variable
123 $metas_css = '--post_meta-font-size: ' . esc_html($size) . ';';
124
125 // print it on the main widget wrapper
126 $this->add_render_attribute(
127 '_wrapper',
128 'style',
129 $metas_css
130 );
131 }
132
133 protected function render() {
134
135 if( !\Elementor\Plugin::$instance->editor->is_edit_mode() ) {
136 $title = wp_title(null,false);
137 $title = $title ? $title : get_bloginfo('name');
138 }else{
139 $title = __( 'This is a dummy title.', 'uicore-elements' );
140 }
141
142 $this->set_meta_font_size_to_svg();
143
144 $meta_list = $this->get_settings_for_display( 'meta_list' );
145 if(!isset($meta_list[0]) || $meta_list[0]['type'] == ''){
146 return;
147 }
148
149 echo '<div class="ui-e-post-meta ui-e-tb-meta">';
150 foreach ($meta_list as $meta) {
151 if($meta['type'] != 'none'){
152 $this->display_meta($meta);
153
154 if( next( $meta_list ) && $this->get_settings_for_display( 'tb-meta_meta_separator' ) ) {
155 echo '<span class="ui-e-separator">'.esc_html($this->get_settings_for_display('tb-meta_meta_separator' )).'</span>';
156 }
157 }
158 }
159 echo '</div>';
160
161 }
162
163 protected function content_template() {
164 }
165 }
166 \Elementor\Plugin::instance()->widgets_manager->register(new PostMeta());
167