File: //proc/self/root/proc/self/cwd/wp-content/themes/kidzieo/includes/elementor/card-box.php
<?php
namespace Elementor; // Custom widgets must be defined in the Elementor namespace
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly (security measure)
/**
* Widget Name: Projects Carousel
*/
class PBMIT_CardBoxElement extends Widget_Base{
// The get_name() method is a simple one, you just need to return a widget name that will be used in the code.
public function get_name() {
return 'pbmit_card_box_element';
}
// The get_title() method, which again, is a very simple one, you need to return the widget title that will be displayed as the widget label.
public function get_title() {
return esc_attr__( 'Kidzieo Card Box Element', 'kidzieo' );
}
// The get_icon() method, is an optional but recommended method, it lets you set the widget icon. you can use any of the eicon or font-awesome icons, simply return the class name as a string.
public function get_icon() {
return 'fas fa-boxes';
}
// The get_categories method, lets you set the category of the widget, return the category name as a string.
public function get_categories() {
return [ 'kidzieo_category' ];
}
public function __construct($data = [], $args = null) {
parent::__construct($data, $args);
if( isset($data['settings']["view-type"]) && !empty($data['settings']["view-type"]) && $data['settings']["view-type"]=='carousel' ){
wp_enqueue_script( 'swiper' );
wp_enqueue_style( 'swiper' );
}
}
protected function register_controls() {
// Style
$this->start_controls_section(
'style_section',
[
'label' => esc_attr__( 'Select Style', 'kidzieo' ),
'tab' => Controls_Manager::TAB_CONTENT,
]
);
$this->add_control(
'style',
[
'label' => esc_attr__( 'Select card box view Style', 'kidzieo' ),
'description' => esc_attr__( 'Select card box view style.', 'kidzieo' ),
'type' => 'pbmit_imgselect',
'label_block' => true,
'thumb_width' => '110px',
'default' => '1',
'options' => pbmit_element_template_list( 'card-box', true ),
]
);
$repeater = new Repeater();
$repeater->add_control(
'image',
[
'label' => esc_attr__( 'Choose Image', 'kidzieo' ),
'description' => esc_attr__( 'This image will appear as box Image. Recommended size is 1200x1000 px JPG or Transparent PNG file.', 'kidzieo' ),
'type' => Controls_Manager::MEDIA,
'dynamic' => [
'active' => true,
],
'default' => [
'url' => get_template_directory_uri() . '/images/card-box.jpg',
],
]
);
$repeater->add_control(
'number',
[
'label' => esc_attr__( 'Number Text', 'kidzieo' ),
'type' => Controls_Manager::TEXT,
'default' => esc_attr__( 'Number Text', 'kidzieo' ),
'placeholder' => esc_attr__( 'Number Text', 'kidzieo' ),
]
);
$repeater->add_control(
'label',
[
'label' => esc_attr__( 'Title Text', 'kidzieo' ),
'type' => Controls_Manager::TEXTAREA,
'default' => esc_attr__( 'Title Text', 'kidzieo' ),
'placeholder' => esc_attr__( 'Title Text', 'kidzieo' ),
'dynamic' => [
'active' => true,
],
]
);
$repeater->add_control(
'smalltext',
[
'label' => esc_attr__( 'Description', 'kidzieo' ),
'default' => esc_attr__( 'Description', 'kidzieo' ),
'placeholder' => esc_attr__( 'Description', 'kidzieo' ),
'type' => Controls_Manager::TEXTAREA,
]
);
$repeater->add_control(
'line1',
[
'label' => esc_attr__( 'Line1', 'kidzieo' ),
'type' => Controls_Manager::TEXT,
'default' => esc_attr__( 'Line Text 1', 'kidzieo' ),
'placeholder' => esc_attr__( 'Line Text 1', 'kidzieo' ),
'label_block' => false,
]
);
$repeater->add_control(
'line2',
[
'label' => esc_attr__( 'Line2', 'kidzieo' ),
'type' => Controls_Manager::TEXT,
'default' => esc_attr__( 'Line Text 2', 'kidzieo' ),
'placeholder' => esc_attr__( 'Line Text 2', 'kidzieo' ),
'label_block' => false,
]
);
$repeater->add_control(
'line3',
[
'label' => esc_attr__( 'Line3', 'kidzieo' ),
'type' => Controls_Manager::TEXT,
'default' => esc_attr__( 'Line Text 3', 'kidzieo' ),
'placeholder' => esc_attr__( 'Line Text 3', 'kidzieo' ),
'label_block' => false,
]
);
$this->add_control(
'boxes',
[
'label' => esc_attr__( 'Each card box Box Content', 'kidzieo' ),
'type' => Controls_Manager::REPEATER,
'fields' => $repeater->get_controls(),
'default' => [
[
'image' => get_template_directory_uri() . '/images/card-box.png',
'number' => esc_attr__( '01', 'kidzieo' ),
'label' => esc_attr__( 'Answer a Few Questions', 'kidzieo' ),
'smalltext' => esc_attr__( 'Interview vetted advisors to find the best fit Lorem ipsum dolor sit amet, consectetur adip iscing elit.', 'kidzieo' ),
],
[
'image' => get_template_directory_uri() . '/images/card-box.png',
'number' => esc_attr__( '02', 'kidzieo' ),
'label' => esc_attr__( 'Complimentary Call', 'kidzieo' ),
'smalltext' => esc_attr__( 'Interview vetted advisors to find the best fit Lorem ipsum dolor sit amet, consectetur adip iscing elit.', 'kidzieo' ),
],
[
'image' => get_template_directory_uri() . '/images/card-box.png',
'number' => esc_attr__( '03', 'kidzieo' ),
'label' => esc_attr__( 'Grow Your Wealth', 'kidzieo' ),
'smalltext' => esc_attr__( 'Interview vetted advisors to find the best fit Lorem ipsum dolor sit amet, consectetur adip iscing elit.', 'kidzieo' ),
],
],
'title_field' => '{{{ label }}}',
]
);
$this->end_controls_section();
// Heading and Subheading
$this->start_controls_section(
'heading_section',
[
'label' => esc_attr__( 'Content Options', 'kidzieo' ),
]
);
$this->add_control(
'title_animation',
[
'label' => esc_attr__( 'Heading Animation', 'kidzieo' ),
'description' => esc_attr__( 'Select Heading Text Animation View style.', 'kidzieo' ) . ' ' . pbmit_esc_kses('<br><a target="_blank" href="' . esc_url('http://kidzieo-demo.pbminfotech.com/demo1/element/#heading-animations') . '">' . esc_attr__( 'See all anmiation demo here.', 'kidzieo' ) . '</a>' ),
'type' => Controls_Manager::SELECT,
'options' => [
'' => esc_attr__( 'No animation', 'kidzieo' ),
'1' => esc_attr__( 'Animation Style 1', 'kidzieo' ),
'2' => esc_attr__( 'Animation Style 2', 'kidzieo' ),
'3' => esc_attr__( 'Animation Style 3', 'kidzieo' ),
],
'separator' => 'before',
]
);
$this->add_control(
'title',
[
'label' => esc_attr__( 'Heading', 'kidzieo' ),
'type' => Controls_Manager::TEXTAREA,
'dynamic' => [
'active' => true,
],
'default' => esc_attr__( 'Card Box', 'kidzieo' ),
'placeholder' => esc_attr__( 'Enter your heading', 'kidzieo' ),
'label_block' => true,
]
);
$this->add_control(
'title_link',
[
'label' => esc_attr__( 'Heading Link', 'kidzieo' ),
'type' => Controls_Manager::URL,
'label_block' => true,
]
);
$this->add_control(
'subtitle',
[
'label' => esc_attr__( 'Subheading', 'kidzieo' ),
'type' => Controls_Manager::TEXTAREA,
'dynamic' => [
'active' => true,
],
'placeholder' => esc_attr__( 'Enter your subheading', 'kidzieo' ),
'label_block' => true,
]
);
$this->add_control(
'subtitle_link',
[
'label' => esc_attr__( 'Subheading Link', 'kidzieo' ),
'type' => Controls_Manager::URL,
'label_block' => true,
]
);
$this->add_control(
'desc',
[
'label' => esc_attr__( 'Description', 'kidzieo' ),
'type' => Controls_Manager::TEXTAREA,
'placeholder' => esc_attr__( 'Type your description here', 'kidzieo' ),
]
);
$this->add_control(
'reverse_title',
[
'label' => esc_attr__( 'Reverse Title', 'kidzieo' ),
'description' => esc_attr__( 'Show sub-title before title', 'kidzieo' ),
'type' => Controls_Manager::SWITCHER,
'label_on' => esc_attr__( 'Yes', 'kidzieo' ),
'label_off' => esc_attr__( 'No', 'kidzieo' ),
'return_value' => 'yes',
'default' => '',
]
);
$this->add_responsive_control(
'text_align',
[
'label' => esc_attr__( 'Alignment', 'kidzieo' ),
'type' => Controls_Manager::CHOOSE,
'options' => [
'left' => [
'title' => esc_attr__( 'Left', 'kidzieo' ),
'icon' => 'fa fa-align-left',
],
'center' => [
'title' => esc_attr__( 'Center', 'kidzieo' ),
'icon' => 'fa fa-align-center',
],
'right' => [
'title' => esc_attr__( 'Right', 'kidzieo' ),
'icon' => 'fa fa-align-right',
],
],
'prefix_class' => 'pbmit-align-',
'selectors' => [
'{{WRAPPER}} .pbmit-heading-subheading' => 'text-align: {{VALUE}};',
],
'dynamic' => [
'active' => true,
],
'default' => 'left',
]
);
$this->end_controls_section();
// HTML Tags
$this->start_controls_section(
'advanced_section',
[
'label' => pbmit_esc_kses('<img class="pbmit-tab-small-logo" src="'.get_template_directory_uri() . '/includes/images/pbm-small-logo.png" /> ') . esc_attr__( 'Tag & Gap Settings', 'kidzieo' ),
'tab' => Controls_Manager::TAB_ADVANCED,
]
);
$this->add_control(
'tag_options',
[
'label' => esc_attr__( 'Tags for SEO', 'kidzieo' ),
'type' => Controls_Manager::HEADING,
'separator' => 'before',
]
);
$this->add_control(
'title_tag',
[
'label' => esc_attr__( 'Title Tag', 'kidzieo' ),
'type' => Controls_Manager::SELECT,
'options' => [
'h1' => esc_attr( 'H1' ),
'h2' => esc_attr( 'H2' ),
'h3' => esc_attr( 'H3' ),
'h4' => esc_attr( 'H4' ),
'h5' => esc_attr( 'H5' ),
'h6' => esc_attr( 'H6' ),
'div' => esc_attr( 'DIV' ),
],
'default' => esc_attr( 'h2' ),
]
);
$this->add_control(
'subtitle_tag',
[
'label' => esc_attr__( 'SubTitle Tag', 'kidzieo' ),
'type' => Controls_Manager::SELECT,
'options' => [
'h1' => esc_attr( 'H1' ),
'h2' => esc_attr( 'H2' ),
'h3' => esc_attr( 'H3' ),
'h4' => esc_attr( 'H4' ),
'h5' => esc_attr( 'H5' ),
'h6' => esc_attr( 'H6' ),
'div' => esc_attr( 'DIV' ),
],
'default' => esc_attr( 'h4' ),
]
);
$this->end_controls_section();
}
protected function render() {
$settings = $this->get_settings_for_display();
extract($settings);
?>
<?php
// Starting container
pbmit_element_container( array(
'position' => 'start',
'cpt' => 'card-box',
'data' => $settings
) );
?>
<div class="pbmit-ele-header-area">
<?php pbmit_heading_subheading($settings, true); ?>
</div>
<div class="pbmit-element-card-box-wrapper">
<?php
$return ='';
if( $settings['style'] == '1') {?>
<div class="pbmit-content-box">
<?php
foreach( $settings['boxes'] as $box ){
$small_text = $title_html = $image_html = $line4 = '';
$title_html = '<div class="pbmit-card-box-title"><h4>'.pbmit_esc_kses($box['label']).'</h4></div>';
$small_text .= ( !empty($box['smalltext']) ) ? '<div class="pbmit-card-box-desc">'.pbmit_esc_kses($box['smalltext']).'</div>' : '' ;
$number = '<div class="pbmit-card-box-number"><h4>'.pbmit_esc_kses($box['number']).'</h4></div>';
$line4 .= ( !empty($box['line1']) ) ? '<div class="pbmit-card-box-line-inner"><p>'.esc_html($box['line1']).'</p></div>' : '' ;
$line4 .= ( !empty($box['line2']) ) ? '<div class="pbmit-card-box-line-inner"><p>'.esc_html($box['line2']).'</p></div>' : '' ;
$line4 .= ( !empty($box['line3']) ) ? '<div class="pbmit-card-box-line-inner"><p>'.esc_html($box['line3']).'</p></div>' : '' ;
if( !empty($box['image']) ){
$image_html .= '<img src="'.$box['image']['url'].'" alt="'.esc_attr($box['label']).'" />';
}
if( !empty($image_html) ){
$image_html = '<div class="pbmit-card-box-item-image">'.$image_html.'</div>';
}
?>
<div class= "pbmit-card-box-wrapper">
<div class="pbmit-card-box-wrapper-inner d-flex align-items-center justify-content-between">
<div class="pbmit-card-box col-lg-6 col-md-12">
<?php echo pbmit_esc_kses($number); ?>
<?php echo pbmit_esc_kses($title_html); ?>
<?php echo pbmit_esc_kses($small_text);?>
<div class="pbmit-card-box-line">
<?php echo pbmit_esc_kses($line4);?>
</div>
</div>
<div class="pbmit-card-box-img col-lg-6 col-md-12">
<?php echo pbmit_esc_kses($image_html); ?>
</div>
</div>
</div>
<?php } // foreach
echo pbmit_esc_kses($return); ?>
</div>
<?php } else {
foreach( $settings['boxes'] as $box ){
//Template
if( file_exists( locate_template( '/theme-parts/card-box/card-box-style-'.esc_attr($style).'.php', false, false ) ) ){
$return .= pbmit_element_block_container( array(
'position' => 'start',
'column' => $columns,
'cpt' => 'card-box',
'style' => $style
) );
ob_start();
include( locate_template( '/theme-parts/card-box/card-box-style-'.esc_attr($style).'.php', false, false ) );
$return .= ob_get_contents();
ob_end_clean();
$return .= pbmit_element_block_container( array(
'position' => 'end',
) );
}
}
}?>
</div>
<?php
// Ending wrapper of the whole arear
pbmit_element_container( array(
'position' => 'end',
'cpt' => 'card-box',
'data' => $settings
) );
?>
<?php
}
protected function content_template() {}
}
// After the Schedule class is defined, I must register the new widget class with Elementor:
Plugin::instance()->widgets_manager->register( new PBMIT_cardboxElement() );