PluginProbe ʕ •ᴥ•ʔ
Spider Elements – Premium Elementor Widgets & Addons Library / 1.5.0
Spider Elements – Premium Elementor Widgets & Addons Library v1.5.0
trunk 1.0.0 1.1.0 1.5.0 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.7.0 1.8.0 1.9.0
spider-elements / widgets / Timeline.php
spider-elements / widgets Last commit date
templates 1 year ago Accordion.php 1 year ago Alerts_Box.php 1 year ago Animated_Heading.php 1 year ago Before_after.php 1 year ago Blog_Grid.php 1 year ago Buttons.php 1 year ago Cheat_sheet.php 1 year ago Counter.php 1 year ago Fullscreen_Slider.php 1 year ago Icon_box.php 1 year ago Instagram.php 1 year ago Integrations.php 1 year ago List_Item.php 1 year ago Pricing_Table_Switcher.php 1 year ago Pricing_Table_Tabs.php 1 year ago Tabs.php 1 year ago Team_Carousel.php 1 year ago Testimonial.php 1 year ago Timeline.php 1 year ago Video_Playlist.php 1 year ago Video_Popup.php 1 year ago
Timeline.php
340 lines
1 <?php
2 /**
3 * Use namespace to avoid conflict
4 */
5
6 namespace SPEL\Widgets;
7
8 use Elementor\Widget_Base;
9 use Elementor\Repeater;
10 use Elementor\Controls_Manager;
11 use Elementor\Group_Control_Typography;
12
13 if ( ! defined( 'ABSPATH' ) ) {
14 exit; // Exit if accessed directly.
15 }
16
17 /**
18 * Class Timeline
19 * @package spider\Widgets
20 */
21 class Timeline extends Widget_Base {
22
23 public function get_name(): string
24 {
25 return 'spe_timeline_widget'; // ID of the widget (Don't change this name)
26 }
27
28
29 public function get_title(): string
30 {
31 return esc_html__( 'Timeline', 'spider-elements' );
32 }
33
34 public function get_icon(): string
35 {
36 return 'eicon-time-line spel-icon';
37 }
38
39 public function get_categories(): array
40 {
41 return [ 'spider-elements' ];
42 }
43
44 /**
45 * Name: get_style_depends()
46 * Desc: Register the required CSS dependencies for the frontend.
47 */
48 public function get_style_depends(): array
49 {
50 return [ 'spel-main' ];
51 }
52
53
54 /**
55 * Name: register_controls()
56 * Desc: Register controls for these widgets
57 * Params: no params
58 * Return: @void
59 * Since: @1.0.0
60 * Package: @spider-elements
61 * Author: spider-themes
62 */
63 protected function register_controls() {
64 $this->elementor_content_control();
65 $this->elementor_style_control();
66 }
67
68 /**
69 * Name: elementor_content_control()
70 * Desc: Register the Content Tab output on the Elementor editor.
71 * Params: no params
72 * Return: @void
73 * Since: @1.0.0
74 * Package: @spider-elements
75 * Author: spider-themes
76 */
77 protected function elementor_content_control() {
78
79 //=======================Timeline Content====================//
80 $this->start_controls_section(
81 'section_timeline',
82 [
83 'label' => esc_html__( 'Timeline', 'spider-elements' ),
84 'tab' => Controls_Manager::TAB_CONTENT,
85 ]
86 );
87
88 $repeater = new Repeater();
89
90 $repeater->add_control(
91 'timestamp',
92 [
93 'label' => esc_html__( 'Timestamp', 'spider-elements' ),
94 'type' => Controls_Manager::TEXT,
95 'default' => esc_html__( '11.05.2013', 'spider-elements' ),
96 'label_block' => true,
97 ]
98 );
99
100 $repeater->add_control(
101 'title',
102 [
103 'label' => esc_html__( 'Title', 'spider-elements' ),
104 'type' => Controls_Manager::TEXT,
105 'default' => esc_html__( 'Davidson College', 'spider-elements' ),
106 'label_block' => true,
107 ]
108 );
109
110 $repeater->add_control(
111 'location',
112 [
113 'label' => esc_html__( 'Location', 'spider-elements' ),
114 'type' => Controls_Manager::TEXT,
115 'default' => esc_html__( 'North Carolina', 'spider-elements' ),
116 'label_block' => true,
117 ]
118 );
119
120 $repeater->add_control(
121 'content',
122 [
123 'label' => esc_html__( 'Content', 'spider-elements' ),
124 'type' => Controls_Manager::WYSIWYG,
125 'default' => esc_html__( 'Vitae adipiscing turpis...', 'spider-elements' ),
126 'show_label' => false,
127 ]
128 );
129
130
131 $this->add_control(
132 'timeline_items',
133 [
134 'label' => esc_html__( 'Timeline Items', 'spider-elements' ),
135 'type' => Controls_Manager::REPEATER,
136 'fields' => $repeater->get_controls(),
137 'default' => [
138 [
139 'timestamp' => esc_html__( '11.05.2013', 'spider-elements' ),
140 'title' => esc_html__( 'Davidson College', 'spider-elements' ),
141 'location' => esc_html__( 'North Carolina', 'spider-elements' ),
142 'content' => esc_html__( 'Vitae adipiscing turpis...', 'spider-elements' ),
143 ],
144 // Add more default timeline items here...
145 ],
146 'title_field' => '{{{ title }}}',
147 ]
148 );
149
150
151 $this->add_group_control(
152 \Elementor\Group_Control_Background::get_type(),
153 [
154 'name' => 'background',
155 'types' => [ 'classic', 'gradient', ],
156 'selector' => '{{WRAPPER}} .timeline-wrapper .timeline-panel p::after',
157 ]
158 );
159
160 $this->end_controls_section(); //End Timeline Content
161 }
162
163
164 /**
165 * Name: elementor_style_control()
166 * Desc: Register the Style Tab output on the Elementor editor.
167 * Params: no params
168 * Return: @void
169 * Since: @1.0.0
170 * Package: @spider-elements
171 * Author: spider-themes
172 */
173 public function elementor_style_control() {
174
175 //============================= Timeline Content Style =============================//
176 $this->start_controls_section(
177 'timeline_content_style', [
178 'label' => esc_html__( 'Timeline Content', 'spider-elements' ),
179 'tab' => Controls_Manager::TAB_STYLE,
180 ]
181 );
182
183 //=== Timeline Title
184 $this->add_control(
185 'timeline_title', [
186 'label' => esc_html__( 'Title', 'spider-elements' ),
187 'type' => Controls_Manager::HEADING,
188 'separator' => 'before',
189 ]
190 );
191
192 $this->add_control(
193 'timeline', [
194 'label' => esc_html__( 'Text Color', 'spider-elements' ),
195 'type' => Controls_Manager::COLOR,
196 'selectors' => [
197 '{{WRAPPER}} .timeline-wrapper .timeline-panel h3' => 'color: {{VALUE}};',
198 ],
199 ]
200 );
201
202 $this->add_group_control(
203 Group_Control_Typography::get_type(), [
204 'name' => 'timeline_title_typo',
205 'selector' => '{{WRAPPER}} .timeline-wrapper .timeline-panel h3',
206 ]
207 ); //End TImeline Title
208
209
210 //=== Timeline Location
211 $this->add_control(
212 'timeline_location', [
213 'label' => esc_html__( 'Location', 'spider-elements' ),
214 'type' => Controls_Manager::HEADING,
215 'separator' => 'before',
216 ]
217 );
218
219 $this->add_control(
220 'timeline_location_color', [
221 'label' => esc_html__( 'Text Color', 'spider-elements' ),
222 'type' => Controls_Manager::COLOR,
223 'selectors' => [
224 '{{WRAPPER}} .timeline-wrapper .timeline-panel span' => 'color: {{VALUE}};',
225 ],
226 ]
227 );
228
229 $this->add_group_control(
230 Group_Control_Typography::get_type(), [
231 'name' => 'timeline_location_typo',
232 'selector' => '{{WRAPPER}} .timeline-wrapper .timeline-panel span',
233 ]
234 ); //End Timeline Location
235
236
237 //=== Timeline Content
238 $this->add_control(
239 'timeline_content', [
240 'label' => esc_html__( 'Timeline Content', 'spider-elements' ),
241 'type' => Controls_Manager::HEADING,
242 'separator' => 'before',
243 ]
244 );
245
246 $this->add_control(
247 'timeline_content_color', [
248 'label' => esc_html__( 'Text Color', 'spider-elements' ),
249 'type' => Controls_Manager::COLOR,
250 'selectors' => [
251 '{{WRAPPER}} .timeline-wrapper .timeline-panel p' => 'color: {{VALUE}};',
252 ],
253 ]
254 );
255
256 $this->add_group_control(
257 Group_Control_Typography::get_type(), [
258 'name' => 'timeline_content_typo',
259 'selector' => '{{WRAPPER}} .timeline-wrapper .timeline-panel p',
260 ]
261 ); //End Timeline content
262
263
264 //=== Timeline Date Option
265 $this->add_control(
266 'timeline_date', [
267 'label' => esc_html__( 'Date', 'spider-elements' ),
268 'type' => Controls_Manager::HEADING,
269 'separator' => 'before',
270 ]
271 );
272
273 $this->add_group_control(
274 \Elementor\Group_Control_Background::get_type(),
275 [
276 'name' => 'timeline_date_bg_color',
277 'types' => [ 'classic', 'gradient' ],
278 'exclude' => [ 'image' ],
279 'selector' => '{{WRAPPER}} .timeline-wrapper .timestamp'
280 ]
281 );
282
283 $this->add_control(
284 'timeline_date_color', [
285 'label' => esc_html__( 'Text Color', 'spider-elements' ),
286 'type' => Controls_Manager::COLOR,
287 'selectors' => [
288 '{{WRAPPER}} .timeline-wrapper .timestamp' => 'color: {{VALUE}};',
289 ],
290 ]
291 );
292
293 $this->add_group_control(
294 Group_Control_Typography::get_type(), [
295 'name' => 'timeline_meta_typo',
296 'selector' => '{{WRAPPER}} .timeline-wrapper .timestamp',
297 ]
298 ); //End Timeline Date Option
299
300
301 $this->end_controls_section();
302
303 } //End Timeline Content Style
304
305
306 /**
307 * Name: elementor_render()
308 * Desc: Render the widget output on the frontend.
309 * Params: no params
310 * Return: @void
311 * Since: @1.0.0
312 * Package: @spider-elements
313 * Author: spider-themes
314 */
315 protected function render() {
316 $settings = $this->get_settings_for_display();
317
318 if ( !empty( $settings['timeline_items'] ) ) {
319 echo '<div class="timeline-widget">';
320 $is_inverted = false;
321 foreach ( $settings[ 'timeline_items' ] as $item ) {
322 $timestamp = !empty($item[ 'timestamp' ]) ? $item[ 'timestamp' ] : '';
323 $title = !empty($item[ 'title' ]) ? $item[ 'title' ] : '';
324 $location = !empty($item[ 'location' ]) ? $item[ 'location' ] : '';
325 $content = !empty($item[ 'content' ]) ? $item[ 'content' ] : '';
326 echo '<div class="timeline-wrapper wow fadeInUp' . ($is_inverted ? ' timeline-inverted' : '') . '" data-wow-delay="0.1s">';
327 echo '<div class="timestamp">' . esc_html($timestamp) . '</div>';
328 echo '<div class="timeline-panel">';
329 echo '<h3>' . esc_html($title) . '</h3>';
330 echo '<span>' . esc_html($location) . '</span>';
331 echo spel_kses_post(wpautop($content));
332 echo '</div>';
333 echo '</div>';
334 $is_inverted = !$is_inverted;
335 }
336 echo '</div>';
337 echo '</div>';
338 }
339 }
340 }