PluginProbe
UiCore Elements – Free widgets and templates for Elementor / 1.0.16
UiCore Elements – Free widgets and templates for Elementor v1.0.16
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.0.16, at includes/widgets/theme-builder/post-meta.php

163 lines 4.4 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
40 protected function register_controls() {
41 $this->start_controls_section(
42 'section_content',
43 [
44 'label' => esc_html__( 'Content', 'uicore-elements' ),
45 ]
46 );
47
48 $this->add_control('meta_list',[
49 'label' => esc_html__( 'Meta Data', 'uicore-elements' ),
50 'type' => \Elementor\Controls_Manager::REPEATER,
51 'fields' => $this->get_meta_content_controls(),
52 'default' => [
53 [
54 'type' => 'author'
55 ],
56 ],
57 'title_field' => '<span style="text-transform: capitalize">{{{ type }}}</span>',
58 'prevent_empty' => false,
59 'separator'=> 'before'
60 ]
61 );
62 $this->add_responsive_control('content_align',
63 [
64 'label' => esc_html__( 'Content Alignment', 'uicore-elements' ),
65 'type' => Controls_Manager::CHOOSE,
66 'options' => [
67 'left' => [
68 'title' => esc_html__( 'Left', 'uicore-elements' ),
69 'icon' => 'eicon-text-align-left',
70 ],
71 'center' => [
72 'title' => esc_html__( 'Center', 'uicore-elements' ),
73 'icon' => 'eicon-text-align-center',
74 ],
75 ],
76 'selectors' => [
77 '{{WRAPPER}}' => 'text-align: {{VALUE}};',
78 ],
79 ]
80 );
81 $this->end_controls_section();
82
83 $this->start_controls_section(
84 'section_meta_style',
85 [
86 'label' => esc_html__( 'Style', 'uicore-elements' ),
87 'tab' => Controls_Manager::TAB_STYLE,
88 ]
89 );
90 $this->get_meta_style_controls();
91 $this->end_controls_section();
92
93 }
94
95 /**
96 * Match each meta icon size (if SVG) with the correspondent font size set by the user.
97 *
98 * Based on the post component similar function.
99 */
100 function set_meta_font_size_to_svg()
101 {
102 // Required specifically for SVG icons
103 if( \Elementor\Plugin::$instance->experiments->is_feature_active('e_font_icon_svg') == false ){
104 return;
105 }
106
107 $font_size = $this->get_settings_for_display('tb-meta_meta_typography_font_size');
108 $default_size = '16px';
109
110 // Check if theres font-size set.
111 $size = isset( $font_size ) ? $font_size : $default_size;
112
113 // Check if the font-size value is not empty (user might customize other infos but not the font-size)
114 $size = !empty( $size['size'] )
115 ? $size['size'] . $size['unit']
116 : $default_size;
117
118 // Creates the css variable
119 $metas_css = '--post_meta-font-size: ' . esc_html($size) . ';';
120
121 // print it on the main widget wrapper
122 $this->add_render_attribute(
123 '_wrapper',
124 'style',
125 $metas_css
126 );
127 }
128
129 protected function render() {
130
131 if( !\Elementor\Plugin::$instance->editor->is_edit_mode() ) {
132 $title = wp_title(null,false);
133 $title = $title ? $title : get_bloginfo('name');
134 }else{
135 $title = __( 'This is a dummy title.', 'uicore-elements' );
136 }
137
138 $this->set_meta_font_size_to_svg();
139
140 $meta_list = $this->get_settings_for_display( 'meta_list' );
141 if(!isset($meta_list[0]) || $meta_list[0]['type'] == ''){
142 return;
143 }
144
145 echo '<div class="ui-e-post-meta ui-e-tb-meta">';
146 foreach ($meta_list as $meta) {
147 if($meta['type'] != 'none'){
148 $this->display_meta($meta);
149
150 if( next( $meta_list ) && $this->get_settings_for_display( 'tb-meta_meta_separator' ) ) {
151 echo '<span class="ui-e-separator">'.esc_html($this->get_settings_for_display('tb-meta_meta_separator' )).'</span>';
152 }
153 }
154 }
155 echo '</div>';
156
157 }
158
159 protected function content_template() {
160 }
161 }
162 \Elementor\Plugin::instance()->widgets_manager->register(new PostMeta());
163