File: /storage/v6964/iskcon/public_html/wp-content/plugins/tow-widgets/widgets/elementor/tow-timeline.php
<?php
if (!defined("ABSPATH")) {
exit(); // Exit if accessed directly.
}
class Elementor_timeline_Widget extends \Elementor\Widget_Base
{
/**
* Get widget name.
*/
public function get_name()
{
return "timeline";
}
/**
* Get widget title.
*/
public function get_title()
{
return esc_html__("Timeline", "Elementor_timeline_Widget");
}
/**
* Get widget Icon.
*/
public function get_icon()
{
return "eicon-slider-full-screen";
}
/**
* Get widget categories.
*/
public function get_categories()
{
return ["tow-theme-element"];
}
/**
* Get widget keywords.
*/
public function get_keywords()
{
return ["timeline"];
}
/**
* Register widget controls.
*/
protected function register_controls()
{
$this->start_controls_section(
"content_section",
[
"label" => esc_html__(
"Display Content",
"Elementor_timeline_Widget"
),
"tab" => \Elementor\Controls_Manager::TAB_CONTENT,
]
);
$repeater = new \Elementor\Repeater();
$repeater->add_control(
'icon',
[
'label' => __( 'Timeline Icon', 'Elementor_feature_box_Widget' ),
'type' => \Elementor\Controls_Manager::ICONS,
'default' => [
'value' => 'bi bi-bell',
'library' => 'bootstrap-icon',
],
]
);
$repeater->add_control(
'timeline_type',
[
'label' => esc_html__( 'Timeline Type', 'Elementor_feature_box_Widget' ),
'type' => \Elementor\Controls_Manager::SELECT,
'default' => 'all',
'options' => [
'title_desc' => esc_html__( 'Title and description', 'Elementor_feature_box_Widget' ),
'image' => esc_html__( 'Only Image', 'Elementor_feature_box_Widget' ),
'all' => esc_html__( 'All fields', 'Elementor_feature_box_Widget' ),
],
]
);
$repeater->add_control("list_title", [
"label" => esc_html__("Title", "Elementor_timeline_Widget"),
"type" => \Elementor\Controls_Manager::TEXT,
"default" => esc_html__("Title", "Elementor_timeline_Widget"),
"label_block" => true,
]);
$repeater->add_control("list_desc", [
"label" => esc_html__("Desc", "Elementor_timeline_Widget"),
"type" => \Elementor\Controls_Manager::WYSIWYG,
"default" => esc_html__("", "Elementor_timeline_Widget"),
"label_block" => true,
'condition' => [
'timeline_type' => [ 'all', 'title_desc' ],
],
]);
$repeater->add_control(
"list_image",
[
"label" => esc_html__("Choose Image", "Elementor_timeline_Widget"),
"type" => \Elementor\Controls_Manager::MEDIA,
/*
"default" => [
"url" => \Elementor\Utils::get_placeholder_image_src(),
],
*/
'condition' => [
'timeline_type' => [ 'all', 'image' ],
],
]
);
$this->add_control(
"list",
[
"label" => esc_html__("Repeater List", "Elementor_timeline_Widget"),
"type" => \Elementor\Controls_Manager::REPEATER,
"fields" => $repeater->get_controls(),
"default" => [
[
"list_title" => esc_html__(
"Title #1",
"Elementor_timeline_Widget"
),
"list_desc" => esc_html__(
"",
"Elementor_timeline_Widget"
),
"list_image" => esc_html__(
"",
"Elementor_timeline_Widget"
),
],
],
"title_field" => "{{{ list_title }}}",
]
);
$this->end_controls_section();
/************************************ STYLE TAB ***************************************/
$this->start_controls_section("section_style", [
"label" => esc_html__("Style", "textdomain"),
"tab" => \Elementor\Controls_Manager::TAB_STYLE,
]);
$this->add_control(
'icon_color',
[
'label' => esc_html__( 'Timeline Icon Color', 'Elementor_themeht_heading_Widget' ),
'type' => \Elementor\Controls_Manager::SELECT,
'default' => 'text-white',
'options' => [
'text-white' => esc_html__( 'White', 'Elementor_themeht_heading_Widget' ),
'text-grey-400' => esc_html__( 'Grey', 'Elementor_themeht_heading_Widget' ),
'text-black' => esc_html__( 'Black', 'Elementor_themeht_heading_Widget' ),
'col_blue' => esc_html__( 'Blue', 'Elementor_themeht_heading_Widget' ),
'col_oran' => esc_html__( 'Orange', 'Elementor_themeht_heading_Widget' ),
],
]
);
$this->add_control(
'icon-background-color',
[
'label' => esc_html__( 'Timeline Icon Background Color', 'Elementor_themeht_heading_Widget' ),
'type' => \Elementor\Controls_Manager::SELECT,
'default' => 'bg_oran',
'options' => [
'bg-white' => esc_html__( 'White', 'Elementor_themeht_heading_Widget' ),
'bg-grey-400' => esc_html__( 'Grey', 'Elementor_themeht_heading_Widget' ),
'bg_blue' => esc_html__( 'Blue', 'Elementor_themeht_heading_Widget' ),
'bg_oran' => esc_html__( 'Orange', 'Elementor_themeht_heading_Widget' ),
'bg-black' => esc_html__( 'Black', 'Elementor_themeht_heading_Widget' ),
],
]
);
$this->add_control("color", [
"label" => esc_html__("Title Color", "Elementor_custom_title_block_Widget"),
"type" => \Elementor\Controls_Manager::COLOR,
"default" => "#000000",
"selectors" => [
"{{WRAPPER}} .timeline-title" => "color: {{VALUE}}",
],
]);
$this->add_control(
'description_color',
[
'label' => esc_html__( 'Description Text Color', 'Elementor_themeht_heading_Widget' ),
'type' => \Elementor\Controls_Manager::SELECT,
'default' => 'text-white',
'options' => [
'text-white' => esc_html__( 'White', 'Elementor_themeht_heading_Widget' ),
'text-grey-400' => esc_html__( 'Grey', 'Elementor_themeht_heading_Widget' ),
'text-black' => esc_html__( 'Black', 'Elementor_themeht_heading_Widget' ),
'col_blue' => esc_html__( 'Blue', 'Elementor_themeht_heading_Widget' ),
'col_oran' => esc_html__( 'Orange', 'Elementor_themeht_heading_Widget' ),
],
]
);
$this->add_group_control(
\Elementor\Group_Control_Typography::get_type(),
[
"name" => "description_typography",
"label" => __(
"Description Typography",
"Elementor_custom_title_block_Widget"
),
"selector" => "{{WRAPPER}} p",
]
);
$this->end_controls_section();
}
/**
* Render widget output on the frontend.
*/
protected function render()
{
// generate the final HTML on the frontend using PHP
$settings = $this->get_settings_for_display();
if ($settings["list"]) {
?>
<section id="story" class="p_4">
<div class="container-xl">
<div class="row story_2">
<div class="col-md-12">
<ul class="timeline text-end">
<?php
$i = 1;
foreach ($settings["list"] as $item) {
$class = "";
if($i%2==0)
$class = "timeline-inverted";
//print_r($item);
?>
<?php if($item["timeline_type"]=='all'){?>
<li class="<?php echo $class; ?>">
<div class="timeline-badge <?php echo esc_attr($settings["icon_color"]); ?> <?php echo esc_attr($settings["icon-background-color"]); ?>">
<?php
if ( isset($item['icon'] ) && $item['icon'] ) {
\Elementor\Icons_Manager::render_icon( $item['icon'], [ 'aria-hidden' => 'true' ] );
}
else{ ?>
<i class="fa fa-heart"></i>
<?php
}
?>
</div>
<div class="timeline-panel">
<div class="timeline-heading">
<h3 class="timeline-title"><?php echo $item["list_title"]; ?></h3>
</div>
<div class="timeline-body">
<?php if($item["list_desc"] && $item["list_desc"]!=""){?>
<p <?php echo esc_attr($settings["description_color"]); ?>><?php echo $item["list_desc"]; ?></p>
<?php }?>
<?php if($item["list_image"]["url"] && $item["list_image"]["url"]!=""){?>
<img alt="<?php echo $item["list_title"]; ?>" class="w-100" src="<?php echo $item["list_image"]["url"]; ?>">
<?php }?>
</div>
</div>
</li>
<?php
}
else if($item["timeline_type"]=='image')
{
?>
<li class="<?php echo $class; ?>">
<div class="timeline-badge <?php echo esc_attr($settings["icon_color"]); ?> <?php echo esc_attr($settings["icon-background-color"]); ?>">
<?php
if ( isset($item['icon'] ) && $item['icon'] ) {
\Elementor\Icons_Manager::render_icon( $item['icon'], [ 'aria-hidden' => 'true' ] );
}
else{ ?>
<i class="fa fa-heart"></i>
<?php
}
?>
</div>
<div class="timeline-panel">
<img alt="<?php echo $item["list_title"]; ?>" class="w-100" src="<?php echo $item["list_image"]["url"]; ?>">
</div>
</li>
<?php
}
else if($item["timeline_type"]=='title_desc'){?>
<li class="<?php echo $class; ?>">
<div class="timeline-badge <?php echo esc_attr($settings["icon_color"]); ?> <?php echo esc_attr($settings["icon-background-color"]); ?>">
<?php
if ( isset($item['icon'] ) && $item['icon'] ) {
\Elementor\Icons_Manager::render_icon( $item['icon'], [ 'aria-hidden' => 'true' ] );
}
else{ ?>
<i class="fa fa-heart"></i>
<?php
}
?>
</div>
<div class="timeline-panel">
<div class="timeline-heading">
<h3 class="timeline-title"><?php echo $item["list_title"]; ?></h3>
</div>
<div class="timeline-body">
<p <?php echo esc_attr($settings["description_color"]); ?>><?php echo $item["list_desc"]; ?></p>
</div>
</div>
</li>
<?php
}
$i++;
}
?>
</ul>
</div>
</div>
</div>
</section>
<?php } ?>
<?php
}
}