PluginProbe
Easy Elements for Elementor – Addons & Website Templates / 1.0.7
Easy Elements for Elementor – Addons & Website Templates v1.0.7
1.5.3 1.5.2 1.5.1 1.5.0 1.4.9 1.4.6 1.4.7 1.4.8 1.4.5 1.4.4 1.4.3 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 All 47 releases
easy-elements / widgets / post-author / post-author.php

post-author.php in Easy Elements for Elementor – Addons & Website Templates 1.0.7, at widgets/post-author/post-author.php

283 lines 6.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 use Elementor\Widget_Base;
3 use Elementor\Controls_Manager;
4 use Elementor\Group_Control_Typography;
5 use Elementor\Group_Control_Box_Shadow;
6
7 if ( ! defined( 'ABSPATH' ) ) exit;
8
9 if( class_exists("Easyel_Post_Author_Info_Widget")) {
10 return;
11 }
12
13 class Easyel_Post_Author_Info_Widget extends Widget_Base {
14
15 public function get_style_depends() {
16 $handle = 'eel-post-author-info';
17 $css_path = plugin_dir_path( __FILE__ ) . 'css/post-author.css';
18
19 if ( ! wp_style_is( $handle, 'registered' ) && file_exists( $css_path ) ) {
20 wp_register_style(
21 $handle,
22 plugins_url( 'css/post-author.css', __FILE__ ),
23 [],
24 defined( 'WP_DEBUG' ) && WP_DEBUG ? filemtime( $css_path ) : '1.0.0'
25 );
26 }
27
28 return [ $handle ];
29 }
30
31 public function get_name() {
32 return 'eel-post-author-info';
33 }
34
35 public function get_title() {
36 return __( 'Post Author Info', 'easy-elements' );
37 }
38
39 public function get_icon() {
40 return 'easyicon easyelIcon-author';
41 }
42
43 public function get_categories() {
44 return [ 'easyelements_category_pro' ];
45 }
46
47 public function get_keywords() {
48 return [ 'author', 'meta', 'post', 'blog', 'text' ];
49 }
50
51 protected function register_controls() {
52
53 $this->start_controls_section(
54 'author_content',
55 [
56 'label' => __( 'Author Info', 'easy-elements' ),
57 'tab' => Controls_Manager::TAB_CONTENT,
58 ]
59 );
60
61 $this->add_control(
62 'show_avatar',
63 [
64 'label' => __( 'Show Avatar', 'easy-elements' ),
65 'type' => Controls_Manager::SWITCHER,
66 'label_on' => __( 'Yes', 'easy-elements' ),
67 'label_off' => __( 'No', 'easy-elements' ),
68 'default' => 'yes',
69 ]
70 );
71
72 $this->add_control(
73 'show_bio',
74 [
75 'label' => __( 'Show Bio', 'easy-elements' ),
76 'type' => Controls_Manager::SWITCHER,
77 'label_on' => __( 'Yes', 'easy-elements' ),
78 'label_off' => __( 'No', 'easy-elements' ),
79 'default' => 'yes',
80 ]
81 );
82
83 $this->add_control(
84 'show_post_count',
85 [
86 'label' => __( 'Show Total Posts', 'easy-elements' ),
87 'type' => Controls_Manager::SWITCHER,
88 'label_on' => __( 'Yes', 'easy-elements' ),
89 'label_off' => __( 'No', 'easy-elements' ),
90 'default' => 'yes',
91 ]
92 );
93
94 $this->add_responsive_control(
95 'count_middle_space',
96 [
97 'label' => __( 'Spacing', 'easy-elements' ),
98 'type' => Controls_Manager::SLIDER,
99 'size_units' => [ 'px', '%', 'em' ],
100 'range' => [
101 'px' => [
102 'min' => 0,
103 'max' => 100,
104 ],
105 ],
106 'selectors' => [
107 '{{WRAPPER}} .eel-author-info .eel-author-description' => 'padding-left: {{SIZE}}{{UNIT}};',
108 ],
109 ]
110 );
111
112
113 $this->end_controls_section();
114
115 // Style Name
116 $this->start_controls_section(
117 'author_style',
118 [
119 'label' => __( 'Name', 'easy-elements' ),
120 'tab' => Controls_Manager::TAB_STYLE,
121 ]
122 );
123
124 $this->add_group_control(
125 Group_Control_Typography::get_type(),
126 [
127 'name' => 'author_typography',
128 'selector' => '{{WRAPPER}} .eel-author-info .eel-author-name',
129 ]
130 );
131
132 $this->add_control(
133 'author_text_color',
134 [
135 'label' => __( 'Text Color', 'easy-elements' ),
136 'type' => Controls_Manager::COLOR,
137 'selectors' => [
138 '{{WRAPPER}} .eel-author-info .eel-author-name' => 'color: {{VALUE}};',
139 ],
140 ]
141 );
142
143 $this->add_responsive_control(
144 'author_margin',
145 [
146 'label' => __( 'Margin', 'easy-elements' ),
147 'type' => Controls_Manager::DIMENSIONS,
148 'size_units' => [ 'px', '%', 'em' ],
149 'selectors' => [
150 '{{WRAPPER}} .eel-author-info .eel-author-name' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
151 ],
152 ]
153 );
154 $this->end_controls_section();
155
156
157 // Style Description
158 $this->start_controls_section(
159 'bio_style',
160 [
161 'label' => __( 'Biographical Info', 'easy-elements' ),
162 'tab' => Controls_Manager::TAB_STYLE,
163 ]
164 );
165
166 $this->add_group_control(
167 Group_Control_Typography::get_type(),
168 [
169 'name' => 'bio_typography',
170 'selector' => '{{WRAPPER}} .eel-author-info .eel-author-bio',
171 ]
172 );
173
174 $this->add_control(
175 'bio_text_color',
176 [
177 'label' => __( 'Text Color', 'easy-elements' ),
178 'type' => Controls_Manager::COLOR,
179 'selectors' => [
180 '{{WRAPPER}} .eel-author-info .eel-author-bio' => 'color: {{VALUE}};',
181 ],
182 ]
183 );
184
185 $this->add_responsive_control(
186 'bio_margin',
187 [
188 'label' => __( 'Margin', 'easy-elements' ),
189 'type' => Controls_Manager::DIMENSIONS,
190 'size_units' => [ 'px', '%', 'em' ],
191 'selectors' => [
192 '{{WRAPPER}} .eel-author-info .eel-author-bio' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
193 ],
194 ]
195 );
196 $this->end_controls_section();
197
198 // Style Count
199 $this->start_controls_section(
200 'count_style',
201 [
202 'label' => __( 'Post Count', 'easy-elements' ),
203 'tab' => Controls_Manager::TAB_STYLE,
204 ]
205 );
206
207 $this->add_group_control(
208 Group_Control_Typography::get_type(),
209 [
210 'name' => 'count_typography',
211 'selector' => '{{WRAPPER}} .eel-author-post-count',
212 ]
213 );
214
215 $this->add_control(
216 'count_text_color',
217 [
218 'label' => __( 'Text Color', 'easy-elements' ),
219 'type' => Controls_Manager::COLOR,
220 'selectors' => [
221 '{{WRAPPER}} .eel-author-post-count' => 'color: {{VALUE}};',
222 ],
223 ]
224 );
225
226 $this->add_responsive_control(
227 'count_margin',
228 [
229 'label' => __( 'Margin', 'easy-elements' ),
230 'type' => Controls_Manager::DIMENSIONS,
231 'size_units' => [ 'px', '%', 'em' ],
232 'selectors' => [
233 '{{WRAPPER}} .eel-author-post-count' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
234 ],
235 ]
236 );
237 $this->end_controls_section();
238 }
239
240 protected function render() {
241 if ( ! is_singular('post') ) return;
242
243 global $post;
244 $author_id = $post->post_author;
245 $settings = $this->get_settings_for_display();
246
247 $author_name = get_the_author_meta( 'display_name', $author_id );
248
249 echo '<div class="eel-author-info">';
250
251 echo '<div class="eel-author-image">';
252 // Avatar
253 if ( 'yes' === $settings['show_avatar'] ) {
254 echo get_avatar( $author_id, 96, '', get_the_author_meta('display_name', $author_id), ['class' => 'eel-author-avatar'] );
255 }
256 echo '</div>';
257 echo '<div class="eel-author-description">';
258 // Name
259 echo '<h4 class="eel-author-name">' . esc_html( $author_name ) . '</h4>';
260
261 // Bio
262 if ( 'yes' === $settings['show_bio'] ) {
263 $bio = get_the_author_meta('description', $author_id);
264 if ( $bio ) {
265 echo '<p class="eel-author-bio">' . esc_html( $bio ) . '</p>';
266 }
267 }
268
269 // Total Posts
270 if ( 'yes' === $settings['show_post_count'] ) {
271 $post_count = (int) count_user_posts( $author_id, 'post' );
272
273 echo '<span class="eel-author-post-count">' .
274 /* translators: %d: Number of posts written by the author */
275 esc_html( sprintf( _n( '%d post', '%d posts', $post_count, 'easy-elements' ), $post_count ) ) .
276 '</span>';
277 }
278
279 echo '</div>';
280 echo '</div>';
281 }
282 }
283