File: //proc/self/root/proc/self/cwd/wp-content/themes/kidzieo/includes/elementor/award-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: Section Heading
*/
class PBMIT_AwardBox 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_award_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 Award 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-award';
}
// 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);
}
protected function register_controls() {
// Style
$this->start_controls_section(
'select_style_section',
[
'label' => esc_attr__( 'Select Style', 'kidzieo' ),
'tab' => Controls_Manager::TAB_CONTENT,
]
);
$this->add_control(
'style',
[
'label' => esc_attr__( 'Select Award Box View Style', 'kidzieo' ),
'description' => esc_attr__( 'Select Award Box View style.', 'kidzieo' ),
'type' => 'pbmit_imgselect',
'label_block' => true,
'thumb_width' => '110px',
'default' => '1',
'prefix' => 'pbmit-award-box pbmit-award-box-style-',
'options' => pbmit_element_template_list( 'award-box', true ),
]
);
$this->end_controls_section();
//Content Service box
$this->start_controls_section(
'content_section',
[
'label' => esc_attr__( 'Award Box Content Option', 'kidzieo' ),
'tab' => Controls_Manager::TAB_CONTENT,
]
);
$repeater = new Repeater();
$repeater->add_control(
'icon_image',
[
'label' => esc_attr__( 'Select Image for Award Box', 'kidzieo' ),
'description' => esc_attr__( 'Recommended size is 300x300 px transparent PNG file.', 'kidzieo' ),
'type' => \Elementor\Controls_Manager::MEDIA,
'default' => [
'url' => get_template_directory_uri() . '/images/award-box.png',
],
]
);
$repeater->add_control(
'title',
[
'label' => esc_attr__( 'Heading', 'kidzieo' ),
'type' => Controls_Manager::TEXTAREA,
'dynamic' => [
'active' => true,
],
'default' => esc_attr__( 'Welcome to our site', 'kidzieo' ),
'placeholder' => esc_attr__( 'Enter your heading', 'kidzieo' ),
'label_block' => true,
]
);
$this->add_control(
'boxes',
[
'label' => esc_attr__( 'Each Award Box Content', 'kidzieo' ),
'type' => Controls_Manager::REPEATER,
'fields' => $repeater->get_controls(),
'default' => [
[
'icon_image' => get_template_directory_uri() . '/images/award-box.png',
'title' => esc_attr__( 'This is first box', 'kidzieo' ),
],
],
'icon_image_field' => '{{{ icon_image }}}',
]
);
$this->end_controls_section();
// Appearance
$this->start_controls_section(
'appearance_section',
[
'label' => esc_attr__( 'Column and Carousel Options', 'kidzieo' ),
'tab' => Controls_Manager::TAB_CONTENT,
]
);
$this->add_control(
'view-type',
[
'label' => esc_attr__( 'How you like to view each Post box?', 'kidzieo' ),
'description' => esc_attr__( 'Show as carousel view or simple row-column view.', 'kidzieo' ),
'type' => 'pbmit_imgselect',
'label_block' => true,
'thumb_width' => '110px',
'default' => 'row-column',
'options' => [
'row-column' => esc_url( get_template_directory_uri() . '/includes/images/row-column.png' ),
'carousel' => esc_url( get_template_directory_uri() . '/includes/images/carousel.png' ),
],
]
);
// Carousel: Heading
$this->add_control(
'carousel_options',
[
'label' => esc_attr__( 'Carousel Options', 'kidzieo' ),
'type' => Controls_Manager::HEADING,
'separator' => 'before',
]
);
// Carousel : Loop
$this->add_control(
'carousel-loop',
[
'label' => esc_attr__( 'Carousel: Loop', 'kidzieo' ),
'description' => esc_attr__( 'Infinity loop. Duplicate last and first items to get loop illusion.', 'kidzieo' ),
'type' => Controls_Manager::SELECT,
'default' => '1',
'options' => [
'1' => esc_attr__( 'Yes', 'kidzieo' ),
'0' => esc_attr__( 'No', 'kidzieo' ),
],
'condition' => [
'view-type' => 'carousel',
]
]
);
// Carousel : Autoplay
$this->add_control(
'carousel-autoplay',
[
'label' => esc_attr__( 'Carousel: Autoplay', 'kidzieo' ),
'description' => esc_attr__( 'Autoplay of carousel.', 'kidzieo' ),
'type' => Controls_Manager::SELECT,
'default' => '1',
'options' => [
'1' => esc_attr__( 'Yes', 'kidzieo' ),
'0' => esc_attr__( 'No', 'kidzieo' ),
],
'condition' => [
'view-type' => 'carousel',
]
]
);
// Carousel : delay
$this->add_control(
'carousel-delay',
[
'label' => esc_attr__( 'Carousel: delay', 'kidzieo' ),
'description' => esc_attr__( 'Slide hold time (in ms).', 'kidzieo' ),
'type' => Controls_Manager::TEXT,
'default' => '4000',
'condition' => [
'view-type' => 'carousel',
'carousel-autoplay' => '1',
]
]
);
// Carousel : Center
$this->add_control(
'carousel-center',
[
'label' => esc_attr__( 'Carousel: Center', 'kidzieo' ),
'description' => esc_attr__( 'Center item. Works well with even an odd number of items.', 'kidzieo' ),
'type' => Controls_Manager::SELECT,
'default' => '0',
'options' => [
'1' => esc_attr__( 'Yes', 'kidzieo' ),
'0' => esc_attr__( 'No', 'kidzieo' ),
],
'condition' => [
'view-type' => 'carousel',
]
]
);
// Carousel : Nav
$this->add_control(
'carousel-nav',
[
'label' => esc_attr__( 'Carousel: Nav', 'kidzieo' ),
'description' => esc_attr__( 'Show next/prev buttons.', 'kidzieo' ),
'type' => Controls_Manager::SELECT,
'default' => '0',
'options' => [
'1' => esc_attr__( 'Yes', 'kidzieo' ),
'0' => esc_attr__( 'No', 'kidzieo' ),
],
'condition' => [
'view-type' => 'carousel',
]
]
);
// Carousel : Dots
$this->add_control(
'carousel-dots',
[
'label' => esc_attr__( 'Carousel: Dots', 'kidzieo' ),
'description' => esc_attr__( 'Show dots navigation.', 'kidzieo' ),
'type' => Controls_Manager::SELECT,
'default' => '0',
'options' => [
'1' => esc_attr__( 'Yes', 'kidzieo' ),
'0' => esc_attr__( 'No', 'kidzieo' ),
],
'condition' => [
'view-type' => 'carousel',
]
]
);
// Carousel : Speed
$this->add_control(
'carousel-speed',
[
'label' => esc_attr__( 'Carousel:Speed', 'kidzieo' ),
'description' => esc_attr__( 'Slider animation time (in ms.)', 'kidzieo' ),
'type' => Controls_Manager::TEXT,
'default' => '3000',
'condition' => [
'view-type' => 'carousel',
]
]
);
// Row Column: Heading
$this->add_control(
'row_col_options',
[
'label' => esc_attr__( 'Row-Column Options', 'kidzieo' ),
'type' => Controls_Manager::HEADING,
'separator' => 'before',
]
);
// Columns
$this->add_control(
'columns',
[
'label' => esc_attr__( 'View in Column', 'kidzieo' ),
'description' => esc_attr__( 'Select how many column to show.', 'kidzieo' ),
'type' => 'pbmit_imgselect',
'label_block' => true,
'thumb_width' => '110px',
'default' => '1',
'options' => [
'1' => esc_url( get_template_directory_uri() . '/includes/images/column-1.png' ),
'2' => esc_url( get_template_directory_uri() . '/includes/images/column-2.png' ),
'3' => esc_url( get_template_directory_uri() . '/includes/images/column-3.png' ),
'4' => esc_url( get_template_directory_uri() . '/includes/images/column-4.png' ),
],
]
);
$this->end_controls_section();
}
protected function render() {
$settings = $this->get_settings_for_display();
extract($settings);
// Starting container
pbmit_element_container( array(
'position' => 'start',
'cpt' => 'award-box',
'data' => $settings
) );
?>
<div class="pbmit-element-posts-wrapper <?php if( !empty($settings['view-type']) && trim($settings['view-type'])=='carousel' ){ ?>swiper-container<?php } ?> row multi-columns-row">
<?php
$return = '';
foreach( $settings['boxes'] as $box ){
$image_html = $title_html = '';
// Award Image
if( $box['icon_image']){
$icon_alt = (!empty($box['title'])) ? trim($box['title']) : esc_attr__('img', 'kidzieo') ;
$icon_image = '<img src="'.esc_url($box['icon_image']['url']).'" alt="'.esc_attr($icon_alt).'" />';
$icon_html = '<div class="pbmit-award-box-image">' . $icon_image . '</div>';
}
// Flip text
if( !empty($box['title']) ) {
$title_tag = ( !empty($box['title_tag']) ) ? $box['title_tag'] : 'h2' ;
$title_html = '<'. pbmit_esc_kses($title_tag) . ' class="pbmit-element-title">
'.pbmit_esc_kses($box['title']).'</'. pbmit_esc_kses($title_tag) . '>
';
}
// Template
if( file_exists( locate_template( '/theme-parts/award-box/award-box-style-'.esc_attr($style).'.php', false, false ) ) ){
$return .= pbmit_element_block_container( array(
'position' => 'start',
'column' => $columns,
'cpt' => 'award-box',
'style' => $style
) );
ob_start();
include( locate_template( '/theme-parts/award-box/award-box-style-'.esc_attr($style).'.php', false, false ) );
$return .= ob_get_contents();
ob_end_clean();
$return .= pbmit_element_block_container( array(
'position' => 'end',
) );
}
} // foreach
echo pbmit_esc_kses($return);
?>
</div>
<?php
// Ending wrapper of the whole arear
pbmit_element_container( array(
'position' => 'end',
'cpt' => 'award-box',
'data' => $settings
) );
}
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_AwardBox() );