File: /mnt/data/truelysell-wp/wp-content/plugins/truelysell-elementor/widgets/class-hero10.php
<?php
/**
* Awesomesauce class.
*
* @category Class
* @package ElementorAwesomesauce
* @subpackage WordPress
* @author Ben Marshall <[email protected]>
* @copyright 2020 Ben Marshall
* @license https://opensource.org/licenses/GPL-3.0 GPL-3.0-only
* @link link(https://www.benmarshall.me/build-custom-elementor-widgets/,
* Build Custom Elementor Widgets)
* @since 1.0.0
* php version 7.3.9
*/
namespace ElementorTruelysell\Widgets;
use Elementor\Widget_Base;
use Elementor\Controls_Manager;
use Elementor\Utils;
use Elementor\Scheme_Color;
if ( ! defined( 'ABSPATH' ) ) {
// Exit if accessed directly.
exit;
}
/**
* Awesomesauce widget class.
*
* @since 1.0.0
*/
class Truelysell_HomeHero10 extends Widget_Base {
/**
* Retrieve the widget name.
*
* @since 1.0.0
*
* @access public
*
* @return string Widget name.
*/
public function get_name() {
return 'truelysell-hero10';
}
/**
* Retrieve the widget title.
*
* @since 1.0.0
*
* @access public
*
* @return string Widget title.
*/
public function get_title() {
return __( 'Truelysell Hero 10', 'truelysell_elementor' );
}
/**
* Retrieve the widget icon.
*
* @since 1.0.0
*
* @access public
*
* @return string Widget icon.
*/
public function get_icon() {
return 'eicon-slides';
}
/**
* Retrieve the list of categories the widget belongs to.
*
* Used to determine where to display the widget in the editor.
*
* Note that currently Elementor supports only one category.
* When multiple categories passed, Elementor uses the first one.
*
* @since 1.0.0
*
* @access public
*
* @return array Widget categories.
*/
public function get_categories() {
return array( 'truelysell' );
}
/**
* Register the widget controls.
*
* Adds different input fields to allow the user to change and customize the widget settings.
*
* @since 1.0.0
*
* @access protected
*/
protected function register_controls() {
$this->start_controls_section(
'content_section',
[
'label' => __( 'Content', 'plugin-name' ),
'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
]
);
$this->add_control(
'title',
array(
'label' => __( 'Title', 'truelysell_elementor' ),
'type' => Controls_Manager::TEXT,
'default' => __( 'Connect with Nearby Top-rated Professional', 'truelysell_elementor' ),
)
);
$this->add_control(
'ttitle',
array(
'label' => __( 'Typed Title', 'truelysell_elementor' ),
'type' => Controls_Manager::TEXT,
'default' => __( 'Carpenders', 'truelysell_elementor' ),
)
);
$this->add_control(
'subtitle',
array(
'label' => __( 'Sub-Title', 'truelysell_elementor' ),
'type' => Controls_Manager::TEXT,
'default' => __( 'We can connect you to the right Service, first time and every time.', 'truelysell_elementor' ),
)
);
$this->add_control(
'listing_category',
[
'label' => __( 'Popular Searches', 'truelysell_elementor' ),
'type' => Controls_Manager::SELECT2,
'multiple' => true,
'options' => $this->get_taxonomy_terms( 'listing_category' ),
'default' => [],
'label_block' => true,
]
);
$this->add_control(
'booking_completed',
array(
'label' => __( 'Booking Completed', 'truelysell_elementor' ),
'type' => Controls_Manager::TEXT,
'default' => __( '300 Booking Completed', 'truelysell_elementor' ),
)
);
$this->add_control(
'reviews',
array(
'label' => __( 'Reviews', 'truelysell_elementor' ),
'type' => Controls_Manager::TEXT,
'default' => __( '4.9 / 5', 'truelysell_elementor' ),
)
);
$this->add_control(
'total_reviews',
array(
'label' => __( 'Total Reviews', 'truelysell_elementor' ),
'type' => Controls_Manager::TEXT,
'default' => __( '255 reviews', 'truelysell_elementor' ),
)
);
$this->add_control(
'search_placeholder',
array(
'label' => __( 'Search Pleaceholder', 'truelysell_elementor' ),
'type' => Controls_Manager::TEXT,
'default' => __( 'Search for Service', 'truelysell_elementor' ),
)
);
$this->add_control(
'location_placeholder',
array(
'label' => __( 'Location Pleaceholder', 'truelysell_elementor' ),
'type' => Controls_Manager::TEXT,
'default' => __( 'Enter Location', 'truelysell_elementor' ),
)
);
$this->add_control(
'search_url',
[
'label' => __( 'Search URL','truelysell_elementor' ),
'type' => \Elementor\Controls_Manager::URL,
'placeholder' => __( 'https://your-link.com', 'truelysell_elementor' ),
'show_external' => false,
'default' => [
'url' => 'https://truelysell-wp.dreamstechnologies.com/grid-with-sidebar/',
],
]
);
$this->add_control(
'searchlabel',
array(
'label' => __( 'Search Button', 'truelysell_elementor' ),
'type' => Controls_Manager::TEXT,
'default' => __( 'Search', 'truelysell_elementor' ),
)
);
$this->add_control(
'bannerimage',
[
'label' => __( 'Banner Image', 'dreamslms_elementor' ),
'type' => \Elementor\Controls_Manager::MEDIA,
'default' => [
'url' => \Elementor\Utils::get_placeholder_image_src(),
]
]
);
$this->end_controls_section();
$this->start_controls_section(
'section_toggle',
[
'label' => esc_html__( 'Toggle', 'truelysell_elementor' ),
]
);
$repeater = new \Elementor\Repeater();
$repeater->add_control(
'tab_count',
[
'label' => __( 'Count', 'truelysell_elementor' ),
'type' => Controls_Manager::TEXT,
'default' => __( '3000+', 'truelysell_elementor' ),
]
);
$repeater->add_control(
'tab_title',
[
'label' => esc_html__( 'Title & Description', 'truelysell_elementor' ),
'type' => \Elementor\Controls_Manager::TEXT,
'default' => esc_html__( 'Toggle Title', 'truelysell_elementor' ),
'label_block' => true,
]
);
$repeater->add_control(
'backgroundimage',
[
'label' => __( 'Left Image', 'truelysell_elementor' ),
'type' => \Elementor\Controls_Manager::MEDIA,
]
);
$this->add_control(
'tabs',
[
'label' => esc_html__( 'Toggle Items', 'truelysell_elementor' ),
'type' => \Elementor\Controls_Manager::REPEATER,
'fields' => $repeater->get_controls(),
'default' => [
[
'tab_count' => esc_html__( '215,292 +', 'truelysell_elementor' ),
'tab_title' => esc_html__( 'Verified Providers', 'truelysell_elementor' ),
],
[
'tab_count' => esc_html__( '90,000+', 'truelysell_elementor' ),
'tab_title' => esc_html__( 'Services Completed', 'truelysell_elementor' ),
],
[
'tab_count' => esc_html__( '2,390,968', 'truelysell_elementor' ),
'tab_title' => esc_html__( 'Reviews Globally', 'truelysell_elementor' ),
]
],
'title_field' => '{{{ tab_title }}}',
]
);
$this->end_controls_section();
}
/**
* Render the widget output on the frontend.
*
* Written in PHP and used to generate the final HTML.
*
* @since 1.0.0
*
* @access protected
*/
protected function render() {
$settings = $this->get_settings_for_display();
$id_int = substr( $this->get_id_int(), 0, 3 );
$this->add_inline_editing_attributes( 'title', 'none' );
$this->add_inline_editing_attributes( 'subtitle', 'none' );
$search_url = $settings['search_url']['url'];
?>
<!-- Banner
================================================== -->
<!-- Hero Section -->
<section class="hero-section-ten" id="home">
<div class="hero-content position-relative overflow-hidden">
<div class="container">
<div class="row align-items-center">
<div class="col-lg-6">
<div class="wow fadeInUp" data-wow-duration="1s" data-wow-delay=".25s">
<h1 class="mb-2"><?php echo $settings['title']; ?> <span class="typed" data-type-text="<?php echo $settings['ttitle']; ?>"></span></h1>
<p class="mb-3 sub-title"><?php echo $settings['subtitle']; ?></p>
<div class="banner-form bg-white border mb-3">
<form action="<?php if(!empty( $search_url )) { echo $search_url; } else {?><?php echo esc_url( home_url() ); ?>/grid-with-sidebar<?php } ?>" method="GET">
<div class="d-md-flex align-items-center">
<div class="input-group mb-2">
<span class="input-group-text px-1"><i class="ti ti-search"></i></span>
<input type="text" name="keyword_search" class="form-control" placeholder="<?php echo $settings['search_placeholder']; ?>">
</div>
<div class="input-group mb-2">
<span class="input-group-text px-1"><i class="ti ti-map-pin"></i></span>
<input type="text" name="location_search" class="form-control" placeholder="<?php echo $settings['location_placeholder']; ?>">
</div>
<input type="hidden" name="action" value="truelysell_get_listings">
<div class="mb-2">
<button class="btn btn-linear-primary w-100" type="submit"><?php echo $settings['searchlabel']; ?></button>
</div>
</div>
<div id="search-results"></div>
</form>
<img src="<?php echo get_template_directory_uri(); ?>/assets/images/bgs/bg-06.svg" alt="img" class="shape-06 round-animate">
</div>
<?php // Get the selected category IDs
$selected_categories = $settings['listing_category'];
if ( ! empty( $selected_categories ) ) {
// Fetch terms based on selected category IDs
$terms = get_terms( [
'taxonomy' => 'listing_category',
'include' => $selected_categories,
'hide_empty' => false,
] );
if ( ! is_wp_error( $terms ) && ! empty( $terms ) ) { ?>
<div class="d-flex align-items-center flex-wrap">
<h6 class="mb-2 me-2 fw-medium">Popular Searches</h6>
<?php foreach ( $terms as $term ) {
$term_link = get_term_link( $term );
?>
<a href="<?php echo esc_url( $term_link ); ?>"
class="badge badge-dark-transparent fs-14 fw-normal mb-2 me-2"><?php echo esc_html( $term->name ); ?></a>
<?php } ?>
</div>
<?php
}
}
?>
<div class="d-flex align-items-center flex-wrap banner-info">
<?php
foreach ( $settings['tabs'] as $index => $item ) :
$tab_count = $index + 1;
$tab_title_setting_key = $this->get_repeater_setting_key( 'tab_title', 'tabs', $index );
$tab_content_setting_key = $this->get_repeater_setting_key( 'tab_content', 'tabs', $index );
$this->add_render_attribute( $tab_title_setting_key, [
'id' => 'elementor-tab-title-' . $id_int . $tab_count,
'class' => [ 'elementor-tab-title' ],
'data-tab' => $tab_count,
'role' => 'tab',
'aria-controls' => 'elementor-tab-content-' . $id_int . $tab_count,
'aria-expanded' => 'false',
] );
$this->add_render_attribute( $tab_content_setting_key, [
'id' => 'elementor-tab-content-' . $id_int . $tab_count,
'class' => [ 'elementor-tab-content', 'elementor-clearfix' ],
'data-tab' => $tab_count,
'role' => 'tabpanel',
'aria-labelledby' => 'elementor-tab-title-' . $id_int . $tab_count,
] );
$this->add_inline_editing_attributes( $tab_content_setting_key, 'advanced' );
?>
<div class="d-flex align-items-center me-4 mt-4">
<img src="<?php Utils::print_unescaped_internal_string( $this->parse_text_editor( $item['backgroundimage']['url']) ); ?>" alt="icon">
<div class="ms-2">
<h6><?php $this->print_unescaped_setting( 'tab_count', 'tabs', $index ); ?></h6>
<p><?php $this->print_unescaped_setting( 'tab_title', 'tabs', $index ); ?></p>
</div>
</div>
<?php endforeach; ?>
</div>
</div>
</div>
<div class="banner-img wow fadeInUp" data-wow-duration="1s" data-wow-delay=".25s">
<img src="<?php echo $settings['bannerimage']['url']; ?>" alt="img" class="img-fluid animation-float">
</div>
</div>
</div>
<div class="hero-image">
<div class="d-inline-flex bg-white p-2 rounded align-items-center shape-01 floating-x">
<span class="avatar avatar-md bg-warning rounded-circle me-2"><i class="ti ti-star-filled"></i></span>
<span><?php echo $settings['reviews']; ?><small class="d-block">(<?php echo $settings['total_reviews']; ?>)</small></span>
<i class="border-edge"></i>
</div>
<div class="d-inline-flex bg-white p-2 rounded align-items-center shape-02 floating-x">
<span class="me-2"><img src="<?php echo get_template_directory_uri(); ?>/assets/images/tick-banner.svg" alt=""></span>
<p class="fs-12 text-dark mb-0"> <?php echo $settings['booking_completed']; ?></p>
<i class="border-edge"></i>
</div>
<img src="<?php echo get_template_directory_uri(); ?>/assets/images/bgs/bg-03.svg" alt="img" class="shape-03">
<img src="<?php echo get_template_directory_uri(); ?>/assets/images/bgs/bg-04.svg" alt="img" class="shape-04">
<img src="<?php echo get_template_directory_uri(); ?>/assets/images/bgs/bg-05.svg" alt="img" class="shape-05">
</div>
</div>
</section>
<!-- /Hero Section -->
<?php
}
protected function get_taxonomy_terms( $taxonomy ) {
$terms = get_terms( [
'taxonomy' => $taxonomy,
'hide_empty' => false,
] );
$options = [];
if ( ! is_wp_error( $terms ) && ! empty( $terms ) ) {
foreach ( $terms as $term ) {
$options[ $term->term_id ] = $term->name;
}
}
return $options;
}
protected function get_terms($taxonomy) {
$taxonomies = get_terms( array( 'taxonomy' =>$taxonomy,'hide_empty' => false) );
$options = [ '' => '' ];
if ( !empty($taxonomies) ) :
foreach ( $taxonomies as $taxonomy ) {
$options[ $taxonomy->term_id ] = $taxonomy->name;
}
endif;
return $options;
}
}