𝗖𝗨𝗥𝗥𝗘𝗡𝗧 𝗙𝗜𝗟𝗘 : /home/builxejc/public_html/wp-content/plugins/kinsley-plugin/elementor/widgets//services-custom.php
<?php
namespace Elementor;
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/**
* Kinsley Services Custom Widget.
*
* @since 1.0
*/
class Kinsley_Services_Custom_Widget extends Widget_Base {
public function get_name() {
return 'kinsley-services-custom';
}
public function get_title() {
return esc_html__( 'Services (Custom)', 'kinsley-plugin' );
}
public function get_icon() {
return 'eicon-parallax';
}
public function get_categories() {
return [ 'kinsley-category' ];
}
/**
* Register widget controls.
*
* @since 1.0
*/
protected function register_controls() {
$this->start_controls_section(
'heading_tab',
[
'label' => esc_html__( 'Title', 'kinsley-plugin' ),
'tab' => Controls_Manager::TAB_CONTENT,
]
);
$this->add_control(
'heading',
[
'label' => esc_html__( 'Heading', 'kinsley-plugin' ),
'type' => Controls_Manager::SWITCHER,
'label_on' => __( 'Show', 'kinsley-plugin' ),
'label_off' => __( 'Hide', 'kinsley-plugin' ),
'return_value' => 'yes',
'default' => 'no',
]
);
$this->add_control(
'title',
[
'label' => esc_html__( 'Title', 'kinsley-plugin' ),
'type' => Controls_Manager::TEXTAREA,
'placeholder' => esc_html__( 'Enter title', 'kinsley-plugin' ),
'default' => esc_html__( 'Title', 'kinsley-plugin' ),
'condition' => [
'heading' => 'yes'
],
]
);
$this->add_control(
'title_tag',
[
'label' => esc_html__( 'Title Tag', 'kinsley-plugin' ),
'type' => Controls_Manager::SELECT,
'default' => 'h2',
'options' => [
'h1' => __( 'H1', 'kinsley-plugin' ),
'h2' => __( 'H2', 'kinsley-plugin' ),
'h3' => __( 'H3', 'kinsley-plugin' ),
'h4' => __( 'H4', 'kinsley-plugin' ),
'div' => __( 'DIV', 'kinsley-plugin' ),
],
'condition' => [
'heading' => 'yes'
],
]
);
$this->add_control(
'title_align',
[
'label' => esc_html__( 'Title Align', 'kinsley-plugin' ),
'type' => Controls_Manager::SELECT,
'default' => 'default',
'options' => [
'default' => __( 'Default', 'kinsley-plugin' ),
'left' => __( 'Left', 'kinsley-plugin' ),
],
]
);
$this->add_control(
'description',
[
'label' => esc_html__( 'Description', 'kinsley-plugin' ),
'type' => Controls_Manager::TEXTAREA,
'placeholder' => esc_html__( 'Enter description', 'kinsley-plugin' ),
'default' => esc_html__( 'Description', 'kinsley-plugin' ),
'condition' => [
'heading' => 'yes'
],
]
);
$this->add_control(
'more',
[
'label' => esc_html__( 'Button (label)', 'kinsley-plugin' ),
'label_block' => true,
'type' => Controls_Manager::TEXT,
'placeholder' => esc_html__( 'Button', 'kinsley-plugin' ),
'condition' => [
'heading' => 'yes'
],
]
);
$this->add_control(
'link',
[
'label' => esc_html__( 'Button (link)', 'kinsley-plugin' ),
'type' => Controls_Manager::URL,
'show_external' => true,
'condition' => [
'heading' => 'yes'
],
]
);
$this->end_controls_section();
$this->start_controls_section(
'items_tab',
[
'label' => esc_html__( 'Items', 'kinsley-plugin' ),
'tab' => Controls_Manager::TAB_CONTENT,
]
);
$repeater = new \Elementor\Repeater();
$repeater->add_control(
'image', [
'label' => esc_html__( 'Image', 'kinsley-plugin' ),
'type' => Controls_Manager::MEDIA,
'default' => [
'url' => \Elementor\Utils::get_placeholder_image_src(),
],
]
);
$repeater->add_control(
'title', [
'label' => esc_html__( 'Title', 'kinsley-plugin' ),
'type' => Controls_Manager::TEXTAREA,
'placeholder' => esc_html__( 'Enter title', 'kinsley-plugin' ),
'default' => esc_html__( 'Title', 'kinsley-plugin' ),
]
);
$repeater->add_control(
'price', [
'label' => esc_html__( 'Price', 'kinsley-plugin' ),
'type' => Controls_Manager::TEXT,
'placeholder' => esc_html__( 'Enter price', 'kinsley-plugin' ),
'default' => esc_html__( '$99', 'kinsley-plugin' ),
]
);
$repeater->add_control(
'price_label', [
'label' => esc_html__( 'Price Label', 'kinsley-plugin' ),
'type' => Controls_Manager::TEXT,
'placeholder' => esc_html__( 'Enter price label', 'kinsley-plugin' ),
'default' => '',
]
);
$repeater->add_control(
'excerpt', [
'label' => esc_html__( 'Excerpt', 'kinsley-plugin' ),
'type' => Controls_Manager::TEXTAREA,
'placeholder' => esc_html__( 'Enter excerpt', 'kinsley-plugin' ),
'default' => esc_html__( 'Excerpt', 'kinsley-plugin' ),
]
);
$repeater->add_control(
'button', [
'label' => esc_html__( 'Button', 'kinsley-plugin' ),
'type' => Controls_Manager::TEXTAREA,
'placeholder' => esc_html__( 'Enter button label', 'kinsley-plugin' ),
'default' => esc_html__( 'Read More', 'kinsley-plugin' ),
]
);
$repeater->add_control(
'link', [
'label' => esc_html__( 'Link', 'kinsley-plugin' ),
'type' => Controls_Manager::URL,
'show_external' => true,
]
);
$this->add_control(
'items',
[
'label' => esc_html__( 'Items', 'kinsley-plugin' ),
'type' => Controls_Manager::REPEATER,
'prevent_empty' => false,
'fields' => $repeater->get_controls(),
'title_field' => '{{{ title }}}',
]
);
$this->end_controls_section();
$this->start_controls_section(
'pagination_tab',
[
'label' => esc_html__( 'Pagination', 'kinsley-plugin' ),
'tab' => Controls_Manager::TAB_CONTENT,
]
);
$this->add_control(
'pagination',
[
'label' => esc_html__( 'Pagination Type', 'kinsley-plugin' ),
'type' => Controls_Manager::SELECT,
'default' => 'no',
'options' => [
'button' => __( 'Button', 'kinsley-plugin' ),
'no' => __( 'No', 'kinsley-plugin' ),
],
]
);
$this->add_control(
'more_text',
[
'label' => esc_html__( 'More Text', 'kinsley-plugin' ),
'type' => Controls_Manager::TEXTAREA,
'placeholder' => esc_html__( 'Enter text', 'kinsley-plugin' ),
'condition' => [
'pagination' => 'button'
],
]
);
$this->add_control(
'more_btn_txt',
[
'label' => esc_html__( 'Button (title)', 'kinsley-plugin' ),
'type' => Controls_Manager::TEXT,
'placeholder' => esc_html__( 'Enter button', 'kinsley-plugin' ),
'default' => esc_html__( 'All Posts', 'kinsley-plugin' ),
'condition' => [
'pagination' => 'button'
],
]
);
$this->add_control(
'more_btn_link',
[
'label' => esc_html__( 'Button (link)', 'kinsley-plugin' ),
'type' => Controls_Manager::URL,
'show_external' => true,
'condition' => [
'pagination' => 'button'
],
]
);
$this->end_controls_section();
$this->start_controls_section(
'settings_tab',
[
'label' => esc_html__( 'Settings', 'kinsley-plugin' ),
'tab' => Controls_Manager::TAB_CONTENT,
]
);
$this->add_control(
'layout',
[
'label' => esc_html__( 'Layout', 'kinsley-plugin' ),
'type' => Controls_Manager::SELECT,
'default' => 'column-3',
'options' => [
'column-1' => __( '1 Columns', 'kinsley-plugin' ),
'column-2' => __( '2 Columns', 'kinsley-plugin' ),
'column-3' => __( '3 Columns', 'kinsley-plugin' ),
],
]
);
$this->add_control('attr_title', array(
'type' => Controls_Manager::SELECT,
'label' => __('Title', 'kinsley-plugin'),
'description' => __('Whether to display title of the service type.', 'kinsley-plugin'),
'default' => 'true',
'options' => array(
'true' => __('Yes', 'kinsley-plugin'),
'false' => __('No', 'kinsley-plugin')
)
));
$this->add_control('attr_excerpt', array(
'type' => Controls_Manager::SELECT,
'label' => __('Excerpt', 'kinsley-plugin'),
'description' => __('Whether to display excerpt (short description) of the service type.', 'kinsley-plugin'),
'default' => 'true',
'options' => array(
'true' => __('Yes', 'kinsley-plugin'),
'false' => __('No', 'kinsley-plugin')
)
));
$this->add_control('attr_price', array(
'type' => Controls_Manager::SELECT,
'label' => __('Price', 'kinsley-plugin'),
'description' => __('Whether to display price of the service type.', 'kinsley-plugin'),
'default' => 'true',
'options' => array(
'true' => __('Yes', 'kinsley-plugin'),
'false' => __('No', 'kinsley-plugin')
)
));
$this->add_control('attr_view_button', array(
'type' => Controls_Manager::SELECT,
'label' => __('Read More Button', 'kinsley-plugin'),
'description' => __('Whether to display "Read more" button with the link to service type.', 'kinsley-plugin'),
'default' => 'true',
'options' => array(
'true' => __('Yes', 'kinsley-plugin'),
'false' => __('No', 'kinsley-plugin')
)
));
$this->end_controls_section();
$this->start_controls_section(
'title_styling',
[
'label' => esc_html__( 'Title', 'kinsley-plugin' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'title_color',
[
'label' => esc_html__( 'Title Color', 'kinsley-plugin' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .knsl-title-frame .knsl-title--h' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'title_typography',
'label' => esc_html__( 'Title Typography', 'kinsley-plugin' ),
'selector' => '{{WRAPPER}} .knsl-title-frame .knsl-title--h',
]
);
$this->add_control(
'desc_color',
[
'label' => esc_html__( 'Description Color', 'kinsley-plugin' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .knsl-title-frame .knsl-text' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'desc_typography',
'label' => esc_html__( 'Description Typography', 'kinsley-plugin' ),
'selector' => '{{WRAPPER}} .knsl-title-frame .knsl-text',
]
);
$this->add_control(
'button_color',
[
'label' => esc_html__( 'Button Color', 'kinsley-plugin' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .knsl-title-frame .knsl-btn' => 'color: {{VALUE}};',
],
]
);
$this->add_control(
'button_bgcolor',
[
'label' => esc_html__( 'Button BG Color', 'kinsley-plugin' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .knsl-title-frame .knsl-btn' => 'background-color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'button_typography',
'label' => esc_html__( 'Button Typography', 'kinsley-plugin' ),
'selector' => '{{WRAPPER}} .knsl-title-frame .knsl-btn',
]
);
$this->end_controls_section();
$this->start_controls_section(
'items_styling',
[
'label' => esc_html__( 'Items', 'kinsley-plugin' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'item_title_color',
[
'label' => esc_html__( 'Title Color', 'kinsley-plugin' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .knsl-ath-card .knsl-card-description h3' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'item_title_typography',
'label' => esc_html__( 'Title Typography', 'kinsley-plugin' ),
'selector' => '{{WRAPPER}} .knsl-ath-card .knsl-card-description h3',
]
);
$this->add_control(
'item_desc_color',
[
'label' => esc_html__( 'Description Color', 'kinsley-plugin' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .knsl-ath-card .knsl-card-description .knsl-text--h' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'item_desc_typography',
'label' => esc_html__( 'Description Typography', 'kinsley-plugin' ),
'selector' => '{{WRAPPER}} .knsl-ath-card .knsl-card-description .knsl-text--h',
]
);
$this->add_control(
'item_button_color',
[
'label' => esc_html__( 'Button Color', 'kinsley-plugin' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .knsl-ath-card .knsl-card-description .knsl-btn' => 'color: {{VALUE}};',
],
]
);
$this->add_control(
'item_button_bgcolor',
[
'label' => esc_html__( 'Button BG Color', 'kinsley-plugin' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .knsl-ath-card .knsl-card-description .knsl-btn' => 'background-color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'item_button_typography',
'label' => esc_html__( 'Button Typography', 'kinsley-plugin' ),
'selector' => '{{WRAPPER}} .knsl-ath-card .knsl-card-description .knsl-btn',
]
);
$this->end_controls_section();
$this->start_controls_section(
'pagination_styling',
[
'label' => esc_html__( 'Pagination', 'kinsley-plugin' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'pagination_color',
[
'label' => esc_html__( 'Pagination Links Color', 'kinsley-plugin' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .knsl-pagination a' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'pagination_typography',
'label' => esc_html__( 'Pagination Links Typography', 'kinsley-plugin' ),
'selector' => '{{WRAPPER}} .knsl-pagination',
]
);
$this->add_control(
'more_button_color',
[
'label' => esc_html__( 'More Button Color', 'kinsley-plugin' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .knsl-read-more .knsl-btn' => 'color: {{VALUE}};',
],
]
);
$this->add_control(
'more_button_bgcolor',
[
'label' => esc_html__( 'More Button BG Color', 'kinsley-plugin' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .knsl-read-more .knsl-btn' => 'background-color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'more_button_typography',
'label' => esc_html__( 'More Button Typography', 'kinsley-plugin' ),
'selector' => '{{WRAPPER}} .knsl-read-more .knsl-btn',
]
);
$this->end_controls_section();
}
/**
* Render widget output on the frontend.
*
* @since 1.0
*/
protected function render() {
$settings = $this->get_settings_for_display();
$this->add_inline_editing_attributes( 'more', 'none' );
$this->add_inline_editing_attributes( 'title', 'basic' );
$this->add_inline_editing_attributes( 'description', 'basic' );
if ( $settings['layout'] == 'column-1' ) {
$item_classes = 'col-lg-12';
} elseif ( $settings['layout'] == 'column-2' ) {
$item_classes = 'col-md-6 col-lg-6';
} else {
$item_classes = 'col-md-6 col-lg-4';
}
$attr_classes = '';
if ( $settings['attr_title'] == 'false' ) {
$attr_classes .= ' attr-title-false';
}
if ( $settings['attr_excerpt'] == 'false' ) {
$attr_classes .= ' attr-desc-false';
}
if ( $settings['attr_price'] == 'false' ) {
$attr_classes .= ' attr-price-false';
}
if ( $settings['attr_view_button'] == 'false' ) {
$attr_classes .= ' attr-readmore-false';
}
?>
<!-- services -->
<section class="knsl-p-0-80">
<div class="container">
<div class="row <?php echo esc_attr( $attr_classes ); ?>">
<?php if ( $settings['title'] || $settings['more'] || $settings['description'] ) : ?>
<div class="col-lg-12">
<div class="knsl-center knsl-title-frame knsl-scroll-animation knsl-mb-100<?php if ( $settings['title_align'] == 'left' ) : ?> knsl-title-left<?php endif; ?>">
<?php if ( $settings['title'] ) : ?>
<<?php echo esc_attr( $settings['title_tag'] ); ?> class="knsl-title--h knsl-mb-20">
<span <?php echo $this->get_render_attribute_string( 'title' ); ?>>
<?php echo wp_kses_post( $settings['title'] ); ?>
</span>
</<?php echo esc_attr( $settings['title_tag'] ); ?>>
<?php endif; ?>
<?php if ( $settings['description'] ) : ?>
<div class="knsl-text knsl-mb-30">
<p>
<span <?php echo $this->get_render_attribute_string( 'description' ); ?>>
<?php echo wp_kses_post( $settings['description'] ); ?>
</span>
</p>
</div>
<?php endif; ?>
<?php if ( $settings['more'] ) : ?>
<a<?php if ( $settings['link'] ) : if ( $settings['link']['is_external'] ) : ?> target="_blank"<?php endif; ?><?php if ( $settings['link']['nofollow'] ) : ?> rel="nofollow"<?php endif; ?> href="<?php echo esc_url( $settings['link']['url'] ); ?>"<?php endif; ?> class="knsl-btn knsl-btn-md">
<span <?php echo $this->get_render_attribute_string( 'more' ); ?>>
<?php echo wp_kses_post( $settings['more'] ); ?>
</span>
</a>
<?php endif; ?>
</div>
</div>
<?php endif; ?>
<?php if ( $settings['items'] ) : ?>
<?php $i=0; foreach ( $settings['items'] as $index => $item ) : $i++;
$item_title = $this->get_repeater_setting_key( 'title', 'items', $index );
$this->add_inline_editing_attributes( $item_title, 'none' );
$item_price = $this->get_repeater_setting_key( 'price', 'items', $index );
$this->add_inline_editing_attributes( $item_price, 'none' );
$item_price_label = $this->get_repeater_setting_key( 'price_label', 'items', $index );
$this->add_inline_editing_attributes( $item_price_label, 'none' );
$item_button = $this->get_repeater_setting_key( 'button', 'items', $index );
$this->add_inline_editing_attributes( $item_button, 'none' );
$item_excerpt = $this->get_repeater_setting_key( 'excerpt', 'items', $index );
$this->add_inline_editing_attributes( $item_excerpt, 'basic' );
?>
<div class="<?php echo esc_attr( $item_classes ); ?>">
<?php
//options
$layout = $settings['layout'];
$index = $i;
//content
if ( $layout == 'column-1' ) {
$image = wp_get_attachment_image_url( $item['image']['id'], 'kinsley_1920xAuto' );
} else {
$image = wp_get_attachment_image_url( $item['image']['id'], 'kinsley_950xAuto' );
}
$scroll_animation = false;
if ( $index > 3 && $layout == 'column-3' ) {
$scroll_animation = true;
}
if ( $index > 2 && $layout == 'column-2' ) {
$scroll_animation = true;
}
if ( $index > 1 && $layout == 'column-1' ) {
$scroll_animation = true;
}
?>
<!-- service card -->
<div class="knsl-ath-card <?php if ( $scroll_animation ) : ?> knsl-scroll-animation<?php endif; ?>">
<div class="knsl-cover-frame">
<?php if ( $item['link'] ) : if ( $item['link']['url'] ) : ?>
<a<?php if ( $item['link']['is_external'] ) : ?> target="_blank"<?php endif; ?><?php if ( $item['link']['nofollow'] ) : ?> rel="nofollow"<?php endif; ?> href="<?php echo esc_url( $item['link']['url'] ); ?>">
<?php endif; endif; ?>
<?php if ( $image ) : ?>
<img src="<?php echo esc_url( $image ); ?>" alt="<?php echo esc_attr( get_the_title() ); ?>">
<?php endif; ?>
<?php if ( $item['link'] ) : if ( $item['link']['url'] ) : ?>
</a>
<?php endif; endif; ?>
<?php if ( $item['price'] ) : ?>
<div class="knsl-badge">
<p class="mphb-price-wrapper">
<span class="mphb-price">
<span <?php echo $this->get_render_attribute_string( $item_price ); ?>>
<?php echo wp_kses_post( $item['price'] ); ?>
</span>
</span>
<i <?php echo $this->get_render_attribute_string( $item_price_label ); ?>>
<?php echo wp_kses_post( $item['price_label'] ); ?>
</i>
</p>
</div>
<?php endif; ?>
</div>
<div class="knsl-card-description">
<?php if ( $item['title'] ) : ?>
<h3 class="knsl-mb-10">
<span <?php echo $this->get_render_attribute_string( $item_title ); ?>>
<?php echo wp_kses_post( $item['title'] ); ?>
</span>
</h3>
<?php endif; ?>
<?php if ( $item['excerpt'] ) : ?>
<div class="knsl-text knsl-text--h">
<span <?php echo $this->get_render_attribute_string( $item_excerpt ); ?>>
<?php echo wp_kses_post( $item['excerpt'] ); ?>
</span>
</div>
<?php endif; ?>
<?php if ( $item['link'] ) : if ( $item['link']['url'] ) : ?>
<a<?php if ( $item['link']['is_external'] ) : ?> target="_blank"<?php endif; ?><?php if ( $item['link']['nofollow'] ) : ?> rel="nofollow"<?php endif; ?> href="<?php echo esc_url( $item['link']['url'] ); ?>" class="knsl-btn">
<span <?php echo $this->get_render_attribute_string( $item_button ); ?>>
<?php echo wp_kses_post( $item['button'] ); ?>
</span>
<span class="screen-reader-text">
<?php echo esc_html__( 'Read more', 'kinsley' ) . ' ' . $item['title']; ?>
</span>
</a>
<?php endif; endif; ?>
</div>
</div>
<!-- service card end -->
</div>
<?php endforeach; ?>
<?php endif; ?>
<?php if ( $settings['pagination'] == 'button' ) : ?>
<!-- read more -->
<div class="knsl-read-more">
<?php if ( $settings['more_text'] ) : ?>
<div class="knsl-text">
<span <?php echo $this->get_render_attribute_string( 'more_text' ); ?>>
<?php echo wp_kses_post( $settings['more_text'] ); ?>
</span>
</div>
<?php endif; ?>
<a<?php if ( $settings['more_btn_link'] ) : ?><?php if ( $settings['more_btn_link']['is_external'] ) : ?> target="_blank"<?php endif; ?><?php if ( $settings['more_btn_link']['nofollow'] ) : ?> rel="nofollow"<?php endif; ?> href="<?php echo esc_url( $settings['more_btn_link']['url'] ); ?>"<?php endif; ?> class="knsl-btn">
<span <?php echo $this->get_render_attribute_string( 'more_btn_txt' ); ?>>
<?php echo wp_kses_post( $settings['more_btn_txt'] ); ?>
</span>
</a>
</div>
<!-- read more end -->
<?php endif; ?>
</div>
</div>
</section>
<!-- services end -->
<?php
}
}
Plugin::instance()->widgets_manager->register( new Kinsley_Services_Custom_Widget() );