File: //home/parhudrw/roflma.it/wp-content/plugins/lesya-plugin/elementor/widgets/service-details-nav.php
<?php
namespace Elementor;
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/**
* Lesya Services Details Nav Widget.
*
* @since 1.0
*/
class Lesya_Services_Details_Nav_Widget extends Widget_Base {
public function get_name() {
return 'lesya-services-details-nav';
}
public function get_title() {
return esc_html__( 'Services Details Nav', 'lesya-plugin' );
}
public function get_icon() {
return 'eicon-parallax';
}
public function get_categories() {
return [ 'lesya-category' ];
}
/**
* Register widget controls.
*
* @since 1.0
*/
protected function register_controls() {
$this->start_controls_section(
'heading_tab',
[
'label' => esc_html__( 'Heading', 'lesya-plugin' ),
'tab' => Controls_Manager::TAB_CONTENT,
]
);
$this->add_control(
'back',
[
'label' => esc_html__( 'Back Link', 'lesya-plugin' ),
'type' => Controls_Manager::SWITCHER,
'label_on' => __( 'Show', 'lesya-plugin' ),
'label_off' => __( 'Hide', 'lesya-plugin' ),
'return_value' => 'yes',
'default' => 'no',
]
);
$this->add_control(
'back_link',
[
'label' => esc_html__( 'Back Link (URL)', 'lesya-plugin' ),
'label_block' => true,
'type' => Controls_Manager::URL,
'show_external' => true,
'dynamic' => [
'active' => true,
],
]
);
$this->end_controls_section();
$this->start_controls_section(
'settings_tab',
[
'label' => esc_html__( 'Settings', 'lesya-plugin' ),
'tab' => Controls_Manager::TAB_CONTENT,
]
);
$this->add_control(
'top_line',
[
'label' => esc_html__( 'Top Line', 'lesya-plugin' ),
'type' => Controls_Manager::SWITCHER,
'label_on' => __( 'Show', 'lesya-plugin' ),
'label_off' => __( 'Hide', 'lesya-plugin' ),
'return_value' => 'yes',
'default' => 'no',
]
);
$this->add_control(
'featured',
[
'label' => esc_html__( 'Featured Image', 'lesya-plugin' ),
'type' => Controls_Manager::SWITCHER,
'label_on' => __( 'Show', 'lesya-plugin' ),
'label_off' => __( 'Hide', 'lesya-plugin' ),
'return_value' => 'yes',
'default' => 'no',
]
);
$this->add_control(
'readmore',
[
'label' => esc_html__( 'Read more button', 'lesya-plugin' ),
'type' => Controls_Manager::SWITCHER,
'label_on' => __( 'Show', 'lesya-plugin' ),
'label_off' => __( 'Hide', 'lesya-plugin' ),
'return_value' => 'yes',
'default' => 'no',
]
);
$this->end_controls_section();
$this->start_controls_section(
'content_styling',
[
'label' => esc_html__( 'Content Styling', 'lesya-plugin' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'title_color',
[
'label' => esc_html__( 'Title Color', 'lesya-plugin' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .next-prev-service .nps-item .nps-content h6' => 'color: {{VALUE}};',
'{{WRAPPER}} .next-prev-service .nps-item .nps-content h6 a' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'title_typography',
'label' => esc_html__( 'Title Typography', 'lesya-plugin' ),
'selector' => '{{WRAPPER}} .next-prev-service .nps-item .nps-content h6',
]
);
$this->add_control(
'more_color',
[
'label' => esc_html__( 'More Color', 'lesya-plugin' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .next-prev-service .nps-item .nps-content .read-more' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'more_typography',
'label' => esc_html__( 'More Typography', 'lesya-plugin' ),
'selector' => '{{WRAPPER}} .next-prev-service .nps-item .nps-content .read-more',
]
);
$this->end_controls_section();
}
/**
* Render widget output on the frontend.
*
* @since 1.0
*/
protected function render() {
$settings = $this->get_settings_for_display();
$post_id = get_the_ID();
$next_post = get_adjacent_post( false, '', false );
$prev_post = get_adjacent_post( false, '', true );
$next_url = false;
$next_title = false;
$prev_url = false;
$prev_title = false;
if ( is_a( $next_post, 'WP_Post' ) ) :
$next_url = get_permalink( $next_post->ID );
$next_title = get_the_title( $next_post->ID );
$next_image = get_the_post_thumbnail_url( $next_post->ID, 'lesya_900x900' );
endif;
if ( is_a( $prev_post, 'WP_Post' ) ) :
$prev_url = get_permalink( $prev_post->ID );
$prev_title = get_the_title( $prev_post->ID );
$prev_image = get_the_post_thumbnail_url( $prev_post->ID, 'lesya_900x900' );
endif;
?>
<?php if ( $settings['top_line'] == 'yes' ) : ?><hr><?php endif; ?>
<div class="next-prev-service mt-60">
<?php if ( $prev_url ) : ?>
<div class="nps-item prev-item wow fadeInLeft delay-0-2s">
<?php if ( $prev_image && $settings['featured'] == 'yes' ) : ?>
<a href="<?php echo esc_url( $prev_url ); ?>"><img src="<?php echo esc_url( $prev_image ); ?>" alt="<?php echo esc_attr( $prev_title ); ?>" /></a>
<?php endif; ?>
<div class="nps-content">
<?php if ( $prev_title ) : ?>
<h6><a href="<?php echo esc_url( $prev_url ); ?>"><?php echo esc_html( $prev_title ); ?></a></h6>
<?php endif; ?>
<?php if ( $settings['readmore'] == 'yes' && $prev_url ) : ?>
<a href="<?php echo esc_url( $prev_url ); ?>" class="read-more"><?php echo esc_html__( 'read more', 'lesya-plugin' ); ?> <i class="fas fa-long-arrow-alt-right"></i></a>
<?php endif; ?>
</div>
</div>
<?php endif; ?>
<?php if ( $settings['back'] == 'yes' ) : ?>
<a href="<?php echo esc_url( $settings['back_link']['url'] ); ?>" class="all-services">
<i class="fas fa-th-large"></i>
</a>
<?php endif; ?>
<?php if ( $next_url ) : ?>
<div class="nps-item next-item wow fadeInRight delay-0-2s">
<div class="nps-content">
<?php if ( $next_title ) : ?>
<h6><a href="<?php echo esc_url( $next_url ); ?>"><?php echo esc_html( $next_title ); ?></a></h6>
<?php endif; ?>
<?php if ( $settings['readmore'] == 'yes' && $next_url ) : ?>
<a href="<?php echo esc_url( $next_url ); ?>" class="read-more"><?php echo esc_html__( 'read more', 'lesya-plugin' ); ?> <i class="fas fa-long-arrow-alt-right"></i></a>
<?php endif; ?>
</div>
<?php if ( $next_image && $settings['featured'] == 'yes' ) : ?>
<a href="<?php echo esc_url( $next_url ); ?>"><img src="<?php echo esc_url( $next_image ); ?>" alt="<?php echo esc_attr( $next_title ); ?>"></a>
<?php endif; ?>
</div>
<?php endif; ?>
</div>
<?php
}
}
Plugin::instance()->widgets_manager->register_widget_type( new Lesya_Services_Details_Nav_Widget() );