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 / post-meta.php

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

210 lines 4.7 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 4.0.0
15 */
16 class PostMeta extends Widget_Base {
17
18 use Meta_Trait;
19
20 /**
21 * Get widget name.
22 *
23 * Retrieve heading widget name.
24 *
25 * @since 1.0.0
26 * @access public
27 *
28 * @return string Widget name.
29 */
30 public function get_name() {
31 return 'uicore-post-meta';
32 }
33
34 /**
35 * Get widget title.
36 *
37 * Retrieve heading widget title.
38 *
39 * @since 1.0.0
40 * @access public
41 *
42 * @return string Widget title.
43 */
44 public function get_title() {
45 return esc_html__( 'Post Meta', 'uicore-elements' );
46 }
47
48 /**
49 * Get widget icon.
50 *
51 * Retrieve heading widget icon.
52 *
53 * @since 1.0.0
54 * @access public
55 *
56 * @return string Widget icon.
57 */
58 public function get_icon() {
59 return 'eicon-post-info ui-e-widget';
60 }
61
62 /**
63 * Get widget categories.
64 *
65 * Retrieve the list of categories the heading widget belongs to.
66 *
67 * Used to determine where to display the widget in the editor.
68 *
69 * @since 2.0.0
70 * @access public
71 *
72 * @return array Widget categories.
73 */
74 public function get_categories() {
75 return ['uicore', 'uicore-theme-builder' ];
76 }
77
78 public function get_style_depends() {
79 Helper::register_widget_style('meta');
80 return [ 'ui-e-meta' ];
81 }
82
83 /**
84 * Get widget keywords.
85 *
86 * Retrieve the list of keywords the widget belongs to.
87 *
88 * @since 2.1.0
89 * @access public
90 *
91 * @return array Widget keywords.
92 */
93 public function get_keywords() {
94 return [ 'post', 'meta', 'info' ];
95 }
96
97 /**
98 * Register heading widget controls.
99 *
100 * Adds different input fields to allow the user to change and customize the widget settings.
101 *
102 * @since 3.1.0
103 * @access protected
104 */
105 protected function register_controls() {
106 $this->start_controls_section(
107 'section_content',
108 [
109 'label' => esc_html__( 'Content', 'uicore-elements' ),
110 ]
111 );
112
113 $this->add_control('meta_list',[
114 'label' => esc_html__( 'Meta Data', 'uicore-elements' ),
115 'type' => \Elementor\Controls_Manager::REPEATER,
116 'fields' => $this->get_meta_content_controls(),
117 'default' => [
118 [
119 'type' => 'author'
120 ],
121 ],
122 'title_field' => '<span style="text-transform: capitalize">{{{ type }}}</span>',
123 'prevent_empty' => false,
124 'separator'=> 'before'
125 ]
126 );
127 $this->add_responsive_control('content_align',
128 [
129 'label' => esc_html__( 'Content Alignment', 'uicore-elements' ),
130 'type' => Controls_Manager::CHOOSE,
131 'options' => [
132 'left' => [
133 'title' => esc_html__( 'Left', 'uicore-elements' ),
134 'icon' => 'eicon-text-align-left',
135 ],
136 'center' => [
137 'title' => esc_html__( 'Center', 'uicore-elements' ),
138 'icon' => 'eicon-text-align-center',
139 ],
140 ],
141 'selectors' => [
142 '{{WRAPPER}}' => 'text-align: {{VALUE}};',
143 ],
144 ]
145 );
146 $this->end_controls_section();
147
148 $this->start_controls_section(
149 'section_meta_style',
150 [
151 'label' => esc_html__( 'Style', 'uicore-elements' ),
152 'tab' => Controls_Manager::TAB_STYLE,
153 ]
154 );
155 $this->get_meta_style_controls();
156 $this->end_controls_section();
157
158 }
159
160 /**
161 * Render heading widget output on the frontend.
162 *
163 * Written in PHP and used to generate the final HTML.
164 *
165 * @since 1.0.0
166 * @access protected
167 */
168 protected function render() {
169
170 if( !\Elementor\Plugin::$instance->editor->is_edit_mode() ) {
171 $title = wp_title(null,false);
172 $title = $title ? $title : get_bloginfo('name');
173 }else{
174 $title = __( 'This is a dummy title.', 'uicore-elements' );
175 }
176
177 $meta_list = $this->get_settings_for_display( 'meta_list' );
178 if(!isset($meta_list[0]) || $meta_list[0]['type'] == ''){
179 return;
180 }
181
182 echo '<div class="ui-e-post-meta ui-e-tb-meta">';
183 foreach ($meta_list as $meta) {
184 if($meta['type'] != 'none'){
185 echo '<div class="ui-e-meta-item">';
186 $this->display_meta($meta);
187 echo '</div>';
188
189 if( next( $meta_list ) && $this->get_settings_for_display( 'tb-meta_meta_separator' ) ) {
190 echo '<span class="ui-e-separator">'.esc_html($this->get_settings_for_display('tb-meta_meta_separator' )).'</span>';
191 }
192 }
193 }
194 echo '</div>';
195
196 }
197
198 /**
199 * Render heading widget output in the editor.
200 *
201 * Written as a Backbone JavaScript template and used to generate the live preview.
202 *
203 * @since 2.9.0
204 * @access protected
205 */
206 protected function content_template() {
207 }
208 }
209 \Elementor\Plugin::instance()->widgets_manager->register(new PostMeta());
210