PluginProbe
WPB Addons for Elementor – News Ticker, Timeline, Team & More Widgets / 1.2
WPB Addons for Elementor – News Ticker, Timeline, Team & More Widgets v1.2
trunk 1.0.8.7 1.0.8.8 1.0.8.9 1.0.9 1.2 1.3 1.4 1.5 1.6 1.7
wpb-elementor-addons / templates / timeline.php

timeline.php in WPB Addons for Elementor – News Ticker, Timeline, Team & More Widgets 1.2, at templates/timeline.php

374 lines 11.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @author WpBean
4 * @version 1.0
5 */
6
7 if ( ! defined( 'ABSPATH' ) ) {
8 exit; // Exit if accessed directly.
9 }
10
11 use Elementor\Controls_Manager;
12 use Elementor\Group_Control_Image_Size;
13 use Elementor\Group_Control_Typography;
14
15 class WPB_EA_Widget_Content_Timeline extends \Elementor\Widget_Base {
16
17 public function get_name() {
18 return 'wpb-ea-timeline';
19 }
20
21 public function get_title() {
22 return esc_html__( 'WPB Content Timeline', 'wpb-elementor-addons' );
23 }
24
25 public function get_icon() {
26 return 'eicon-time-line';
27 }
28
29 public function get_categories() {
30 return array( 'wpb_ea_widgets' );
31 }
32
33 /**
34 * Retrieve the list of scripts the counter widget depended on.
35 *
36 * Used to set scripts dependencies required to run the widget.
37 *
38 * @since 1.3.0
39 * @access public
40 *
41 * @return array Widget scripts dependencies.
42 */
43 public function get_script_depends() {
44 return array( 'wpb-ea-super-js' );
45 }
46
47 protected function register_controls() {
48 $wpb_ea_primary_color = wpb_ea_get_option( 'wpb_ea_primary_color', 'wpb_ea_style', '#3878ff' );
49
50 // timeline section
51 $this->start_controls_section(
52 'wpb_ea_testimonial',
53 array(
54 'label' => esc_html__( 'Content Timeline', 'wpb-elementor-addons' ),
55 )
56 );
57
58 $this->add_control(
59 'wpb_ea_timeline_type',
60 array(
61 'label' => esc_html__( 'Timeline Type', 'wpb-elementor-addons' ),
62 'type' => Controls_Manager::SELECT,
63 'default' => 'left-right',
64 'options' => array(
65 'left-right' => esc_html__( 'Left and Right', 'wpb-elementor-addons' ),
66 'left' => esc_html__( 'Left Side Only', 'wpb-elementor-addons' ),
67 'right' => esc_html__( 'Right Side Only', 'wpb-elementor-addons' ),
68 ),
69 )
70 );
71
72 $this->add_group_control(
73 Group_Control_Image_Size::get_type(),
74 array(
75 'name' => 'image_size',
76 'label' => esc_html__( 'Image Size', 'wpb-elementor-addons' ),
77 'default' => 'medium_large',
78 )
79 );
80
81 $this->add_control(
82 'wpb_ea_disable_date',
83 array(
84 'label' => esc_html__( 'Disable date?', 'wpb-elementor-addons' ),
85 'type' => \Elementor\Controls_Manager::SWITCHER,
86 'default' => 'no',
87 'return_value' => 'yes',
88 )
89 );
90
91 $repeater = new \Elementor\Repeater();
92
93 $repeater->add_control(
94 'icon',
95 array(
96 'label' => esc_html__( 'Icon', 'wpb-elementor-addons' ),
97 'type' => \Elementor\Controls_Manager::ICONS,
98 'label_block' => true,
99 'default' => array(
100 'value' => 'fas fa-file',
101 'library' => 'solid',
102 ),
103 )
104 );
105
106 $repeater->add_control(
107 'date',
108 array(
109 'label' => esc_html__( 'Date', 'wpb-elementor-addons' ),
110 'type' => \Elementor\Controls_Manager::DATE_TIME,
111 'label_block' => true,
112 'default' => esc_html__( 'March 23, 2020', 'wpb-elementor-addons' ),
113 'picker_options' => array(
114 'enableTime' => false,
115 ),
116 )
117 );
118
119 $repeater->add_control(
120 'title',
121 array(
122 'label' => esc_html__( 'Title', 'wpb-elementor-addons' ),
123 'type' => \Elementor\Controls_Manager::TEXT,
124 'default' => esc_html__( 'Timeline Item Title', 'wpb-elementor-addons' ),
125 'label_block' => true,
126 )
127 );
128
129 $repeater->add_control(
130 'content',
131 array(
132 'label' => esc_html__( 'Content', 'wpb-elementor-addons' ),
133 'type' => \Elementor\Controls_Manager::WYSIWYG,
134 'show_label' => false,
135 )
136 );
137
138 $repeater->add_control(
139 'image',
140 array(
141 'label' => esc_html__( 'Image', 'wpb-elementor-addons' ),
142 'type' => Controls_Manager::MEDIA,
143 )
144 );
145
146 $repeater->add_control(
147 'shortcode',
148 array(
149 'label' => esc_html__( 'ShortCode', 'wpb-elementor-addons' ),
150 'type' => \Elementor\Controls_Manager::TEXT,
151 'placeholder' => esc_html__( '[products]', 'wpb-elementor-addons' ),
152 'label_block' => true,
153 )
154 );
155
156 $repeater->add_control(
157 'link',
158 array(
159 'label' => esc_html__( 'Link', 'wpb-elementor-addons' ),
160 'type' => Controls_Manager::URL,
161 'dynamic' => array(
162 'active' => true,
163 ),
164 'placeholder' => esc_html__( 'https://your-link.com', 'wpb-elementor-addons' ),
165 )
166 );
167
168 $this->add_control(
169 'wpb_ea_timeline_items',
170 array(
171 'label' => esc_html__( 'Timeline Items', 'wpb-elementor-addons' ),
172 'type' => \Elementor\Controls_Manager::REPEATER,
173 'fields' => $repeater->get_controls(),
174 'default' => array(
175 array(
176 'date' => esc_html__( 'March 23, 2020', 'wpb-elementor-addons' ),
177 'icon' => array(
178 'value' => 'fas fa-file',
179 'library' => 'solid',
180 ),
181 'title' => esc_html__( 'Lorem ipsum dolor sit amet', 'wpb-elementor-addons' ),
182 'content' => esc_html__( 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec odio. Quisque volutpat mattis eros.', 'wpb-elementor-addons' ),
183 ),
184 array(
185 'date' => esc_html__( 'March 23, 2020', 'wpb-elementor-addons' ),
186 'icon' => array(
187 'value' => 'far fa-calendar',
188 'library' => 'regular',
189 ),
190 'title' => esc_html__( 'Donec nec justo eget felis', 'wpb-elementor-addons' ),
191 'content' => esc_html__( 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec odio. Quisque volutpat mattis eros.', 'wpb-elementor-addons' ),
192 ),
193 array(
194 'date' => esc_html__( 'March 23, 2020', 'wpb-elementor-addons' ),
195 'icon' => array(
196 'value' => 'fas fa-cloud',
197 'library' => 'solid',
198 ),
199 'title' => esc_html__( 'Morbi in sem quis dui placerat', 'wpb-elementor-addons' ),
200 'content' => esc_html__( 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec odio. Quisque volutpat mattis eros.', 'wpb-elementor-addons' ),
201 ),
202 ),
203 'title_field' => '{{{ title }}}',
204 )
205 );
206
207 $this->end_controls_section();
208
209 /**
210 * style settings
211 */
212
213 $this->start_controls_section(
214 'wpb_ea_timeline_style',
215 array(
216 'label' => esc_html__( 'Style', 'wpb-elementor-addons' ),
217 'tab' => Controls_Manager::TAB_STYLE,
218 )
219 );
220
221 $this->add_control(
222 'wpb_ea_timeline_bg_color',
223 array(
224 'label' => esc_html__( 'Timeline Background', 'wpb-elementor-addons' ),
225 'type' => Controls_Manager::COLOR,
226 'selectors' => array(
227 '{{WRAPPER}} .wpb-timeline-content' => 'background-color: {{VALUE}};',
228 '{{WRAPPER}} .wpb-timeline-area .wpb-timeline-content::before' => 'background-color: {{VALUE}};',
229 ),
230 'default' => '#fff',
231 )
232 );
233
234 $this->add_control(
235 'wpb_ea_timeline_icon_bg_color',
236 array(
237 'label' => esc_html__( 'Icon Background', 'wpb-elementor-addons' ),
238 'type' => Controls_Manager::COLOR,
239 'selectors' => array(
240 '{{WRAPPER}} .wpb-timeline-icon' => 'background-color: {{VALUE}};',
241 '{{WRAPPER}} .wpb-timeline-date span' => 'background-color: {{VALUE}};',
242 ),
243 'default' => '#3878ff',
244 )
245 );
246
247 $this->add_control(
248 'wpb_ea_timeline_icon_color',
249 array(
250 'label' => esc_html__( 'Icon Color', 'wpb-elementor-addons' ),
251 'type' => Controls_Manager::COLOR,
252 'selectors' => array(
253 '{{WRAPPER}} .wpb-timeline-icon i' => 'color: {{VALUE}};',
254 '{{WRAPPER}} .wpb-timeline-date span' => 'color: {{VALUE}};',
255 ),
256 'default' => '#fff',
257 )
258 );
259
260 $this->add_control(
261 'wpb_ea_timeline_bar_bg_color',
262 array(
263 'label' => esc_html__( 'Timeline Bar Background', 'wpb-elementor-addons' ),
264 'type' => Controls_Manager::COLOR,
265 'selectors' => array(
266 '{{WRAPPER}} .wpb-timeline-area::before' => 'background-color: {{VALUE}};',
267 ),
268 'default' => '#d7e4ed',
269 )
270 );
271
272 $this->add_group_control(
273 Group_Control_Typography::get_type(),
274 array(
275 'name' => 'wpb_ea_timeline_title_typography',
276 'selector' => '{{WRAPPER}} .wpb-timeline-block h3',
277 )
278 );
279
280 $this->add_control(
281 'wpb_ea_timeline_shadow',
282 array(
283 'label' => esc_html__( 'Timeline Shadow', 'wpb-elementor-addons' ),
284 'type' => \Elementor\Controls_Manager::SWITCHER,
285 'label_on' => esc_html__( 'Yes', 'wpb-elementor-addons' ),
286 'label_off' => esc_html__( 'No', 'wpb-elementor-addons' ),
287 'return_value' => 'yes',
288 'default' => 'yes',
289 )
290 );
291
292 $this->end_controls_section();
293 }
294
295 // render image function
296 private function render_image( $item, $settings ) {
297 $image_id = $item['image']['id'];
298 $image_size = $settings['image_size_size'];
299 if ( 'custom' === $image_size ) {
300 $image_src = Group_Control_Image_Size::get_attachment_image_src( $image_id, 'image_size', $settings );
301 } else {
302 $image_src = wp_get_attachment_image_src( $image_id, $image_size );
303 if ( ! empty( $image_src ) ) {
304 $image_src = $image_src[0];
305 }
306 }
307
308 return sprintf( '<img src="%s" alt="%s" />', esc_url( $image_src ), esc_html( $item['title'] ) );
309 }
310
311 protected function render() {
312 $settings = $this->get_settings_for_display();
313 $wpb_ea_timeline_items = $settings['wpb_ea_timeline_items'];
314 $wpb_ea_timeline_type = $settings['wpb_ea_timeline_type'];
315 $wpb_ea_timeline_shadow = $settings['wpb_ea_timeline_shadow'];
316
317 if ( is_array( $settings['wpb_ea_timeline_items'] ) ) : ?>
318 <div class="wpb-timeline-area wpb-timeline-<?php echo esc_attr( $wpb_ea_timeline_type ); ?> wpb-timeline-shadow-<?php echo esc_attr( $wpb_ea_timeline_shadow ); ?>">
319
320 <?php foreach ( $settings['wpb_ea_timeline_items'] as $item ) : ?>
321
322 <div class="wpb-timeline-block">
323 <?php do_action( 'wpb_ea_before_timeline_item', $item ); ?>
324 <?php if ( $item['icon'] ) : ?>
325 <div class="wpb-timeline-icon">
326 <?php \Elementor\Icons_Manager::render_icon( $item['icon'], array( 'aria-hidden' => 'true' ) ); ?>
327 </div>
328 <?php endif; ?>
329 <div class="wpb-timeline-content">
330 <?php if ( $item['date'] && $settings['wpb_ea_disable_date'] != 'yes' ) : ?>
331 <div class="wpb-timeline-date"><span class="wpb-timeline-date-inner"><?php echo esc_html( date_i18n( apply_filters( 'wpb_ea_timeline_date_format', get_option( 'date_format' ) ), strtotime( $item['date'] ) ) ); ?></span></div>
332 <?php endif; ?>
333
334 <?php
335 if ( $item['link']['url'] ) {
336 if ( $item['link']['is_external'] === 'on' ) {
337 $target = 'target= _blank';
338 } else {
339 $target = '';
340 }
341 if ( $item['link']['nofollow'] === 'on' ) {
342 $target .= ' rel= nofollow ';
343 }
344
345 ( $item['title'] ? printf( '<h3><a href="%s" %s>%s</a></h3>', esc_url( $item['link']['url'] ), esc_attr( $target ), esc_html( $item['title'] ) ) : '' );
346
347 } else {
348 ( $item['title'] ? printf( '<h3>%s</h3>', esc_html( $item['title'] ) ) : '' );
349 }
350 ?>
351
352 <?php echo wp_kses_post( wpautop( $item['content'] ) ); ?>
353
354 <?php
355 if ( $item['shortcode'] ) {
356 echo do_shortcode( $item['shortcode'] );
357 }
358 ?>
359
360 <?php
361 echo ( ! empty( $item['image']['url'] ) ? '<div class="wpb-timeline-image">' . wp_kses_post( $this->render_image( $item, $settings ) ) . '</div>' : '' );
362 ?>
363 </div>
364 <?php do_action( 'wpb_ea_after_timeline_item', $item ); ?>
365 </div>
366
367 <?php endforeach; ?>
368
369 </div>
370 <?php endif; ?>
371
372 <?php
373 }
374 }