Current File : /home/mdkeenpw/www/wp-content/plugins/logistik-core/addons/widgets/logistik-section-title.php |
<?php
use \Elementor\Widget_Base;
use \Elementor\Controls_Manager;
use \Elementor\Group_Control_Typography;
use \Elementor\Group_Control_Border;
use \Elementor\Utils;
/**
*
* Section Title Widget .
*
*/
class Logistik_Section_Title extends Widget_Base {
public function get_name() {
return 'logistiksectiontitle';
}
public function get_title() {
return __( 'Section Title', 'logistik' );
}
public function get_icon() {
return 'themeholy-icon';
}
public function get_categories() {
return [ 'logistik' ];
}
protected function register_controls() {
$this->start_controls_section(
'section_title_section',
[
'label' => __( 'Section Title', 'logistik' ),
'tab' => Controls_Manager::TAB_CONTENT,
]
);
$this->add_control(
'layout_style',
[
'label' => __( 'Layout Style', 'logistik' ),
'type' => Controls_Manager::SELECT,
'default' => '1',
'options' => [
'1' => __( 'Style One', 'logistik' ),
// '2' => __( 'Style Two', 'logistik' ),
],
]
);
$this->add_control(
'image',
[
'label' => __( 'Subtitle Shape', 'logistik' ),
'type' => Controls_Manager::MEDIA,
'dynamic' => [
'active' => true,
],
]
);
$this->add_control(
'section_subtitle',
[
'label' => __( 'Section Subtitle', 'logistik' ),
'type' => Controls_Manager::TEXTAREA,
'default' => __( 'Section Subtitle', 'logistik' ),
'rows' => '2',
]
);
$this->add_control(
'section_subtitle_tag',
[
'label' => __( 'Subitle Tag', 'logistik' ),
'type' => Controls_Manager::SELECT,
'options' => [
'h1' => 'H1',
'h2' => 'H2',
'h3' => 'H3',
'h4' => 'H4',
'h5' => 'H5',
'h6' => 'H6',
'p' => 'P',
'span' => 'span',
],
'default' => 'span',
'condition' => [
'section_subtitle!' => '',
]
]
);
$this->add_control(
'section_title',
[
'label' => __( 'Section Title', 'logistik' ),
'type' => Controls_Manager::TEXTAREA,
'default' => __( 'Section Title', 'logistik' )
]
);
$this->add_control(
'section_title_tag',
[
'label' => __( 'Title Tag', 'logistik' ),
'type' => Controls_Manager::SELECT,
'options' => [
'h1' => 'H1',
'h2' => 'H2',
'h3' => 'H3',
'h4' => 'H4',
'h5' => 'H5',
'h6' => 'H6',
'span' => 'span',
],
'default' => 'h2',
]
);
$this->add_control(
'section_desc',
[
'label' => __( 'Section Description', 'logistik' ),
'type' => Controls_Manager::TEXTAREA,
'default' => __( 'Section Description', 'logistik' ),
]
);
$this->add_responsive_control(
'section_align',
[
'label' => __( 'Alignment', 'logistik' ),
'type' => Controls_Manager::CHOOSE,
'options' => [
'left' => [
'title' => __( 'Left', 'logistik' ),
'icon' => 'eicon-text-align-left',
],
'center' => [
'title' => __( 'Center', 'logistik' ),
'icon' => 'eicon-text-align-center',
],
'right' => [
'title' => __( 'Right', 'logistik' ),
'icon' => 'eicon-text-align-right',
],
],
'default' => 'left',
'toggle' => true,
'selectors' => [
'{{WRAPPER}} .title-area' => 'text-align: {{VALUE}};',
]
]
);
$this->end_controls_section();
//---------------------------------------
//Style Section Start
//---------------------------------------
//---------------------------------General styling-------------------------------//
$this->start_controls_section(
'general_style_section',
[
'label' => __( 'General Style', 'logistik' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_responsive_control(
'general_margin',
[
'label' => __( 'Margin', 'logistik' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%', 'em' ],
'selectors' => [
'{{WRAPPER}} .title-area' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->end_controls_section();
//---------------------------------------Subtitle Style---------------------------------------//
$this->start_controls_section(
'subtitle_style',
[
'label' => __( 'Subtitle Style', 'logistik' ),
'tab' => Controls_Manager::TAB_STYLE,
'condition' => [
'section_subtitle!' => '',
],
]
);
$this->add_control(
'subtitle_color',
[
'label' => __( 'Color', 'logistik' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .th-sub' => 'color: {{VALUE}}',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'subtitle_typography',
'label' => __( 'Typography', 'logistik' ),
'selector' => '{{WRAPPER}} .th-sub',
]
);
$this->add_responsive_control(
'subtitle_margin',
[
'label' => __( 'Margin', 'logistik' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%', 'em' ],
'selectors' => [
'{{WRAPPER}} .th-sub' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
]
]
);
$this->add_responsive_control(
'subtitle_padding',
[
'label' => __( 'Padding', 'logistik' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%', 'em' ],
'selectors' => [
'{{WRAPPER}} .th-sub' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
]
]
);
$this->end_controls_section();
//---------------------------------------Title Style---------------------------------------//
$this->start_controls_section(
'title_style',
[
'label' => __( 'Title Style', 'tayde' ),
'tab' => Controls_Manager::TAB_STYLE,
'condition' => [
'section_title!' => ''
]
]
);
$this->add_control(
'title_color',
[
'label' => __( 'Color', 'tayde' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .th-title' => 'color: {{VALUE}} !important',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'title_typography',
'label' => __( 'Typography', 'tayde' ),
'selector' => '{{WRAPPER}} .th-title',
]
);
$this->add_responsive_control(
'title_margin',
[
'label' => __( 'Margin', 'tayde' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%', 'em' ],
'selectors' => [
'{{WRAPPER}} .th-title' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
]
]
);
$this->add_responsive_control(
'title_padding',
[
'label' => __( 'Padding', 'tayde' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%', 'em' ],
'selectors' => [
'{{WRAPPER}} .th-title' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
]
]
);
$this->end_controls_section();
//---------------------------------------Description Style---------------------------------------//
$this->start_controls_section(
'desc_style',
[
'label' => __( 'Description Style', 'logistik' ),
'tab' => Controls_Manager::TAB_STYLE,
'condition' => [
'section_desc!' => '',
],
]
);
$this->add_control(
'desc_color',
[
'label' => __( 'Color', 'logistik' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .th-desc' => 'color: {{VALUE}}',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'desc_typography',
'label' => __( 'Typography', 'logistik' ),
'selector' => '{{WRAPPER}} .th-desc',
]
);
$this->add_responsive_control(
'desc_margin',
[
'label' => __( 'Margin', 'logistik' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%', 'em' ],
'selectors' => [
'{{WRAPPER}} .th-desc' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
]
]
);
$this->add_responsive_control(
'desc_padding',
[
'label' => __( 'Padding', 'logistik' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%', 'em' ],
'selectors' => [
'{{WRAPPER}} .th-desc' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
]
]
);
$this->end_controls_section();
}
protected function render() {
$settings = $this->get_settings_for_display();
$this->add_render_attribute('title_args', 'class', 'sec-title th-title');
// $this->add_render_attribute('subtitle_args', 'class', 'sub-title th-sub');
?>
<div class="title-area">
<?php if( ! empty( $settings['section_subtitle'] ) ) : ?>
<<?php echo esc_attr($settings['section_subtitle_tag']); ?> class="sub-title th-sub">
<?php
if(!empty($settings['image']['url'])){
echo logistik_img_tag( array(
'url' => esc_url( $settings['image']['url'] ),
));
}
echo wp_kses_post( $settings['section_subtitle'] );
?>
</<?php echo esc_attr($settings['section_subtitle_tag']); ?>>
<?php endif; ?>
<?php
// if ( !empty($settings['section_subtitle' ]) ){
// printf( '<%1$s %2$s>%3$s %4$s</%1$s>',
// $settings['section_subtitle_tag'],
// $this->get_render_attribute_string( 'subtitle_args' ),
// $subtitle_shape,
// wp_kses_post( $settings['section_subtitle' ] )
// );
// }
if ( !empty($settings['section_title' ]) ) :
printf( '<%1$s %2$s>%3$s</%1$s>',
$settings['section_title_tag'],
$this->get_render_attribute_string( 'title_args' ),
wp_kses_post( $settings['section_title' ] )
);
endif;
if( ! empty( $settings['section_desc'] ) ){
echo logistik_paragraph_tag( array(
'text' => wp_kses_post( $settings['section_desc'] ),
'class' => 'th-desc'
) );
}
?>
</div>
<?php
}
}