HEX
Server: LiteSpeed
System: Linux l24.yourwebhosting.net 5.14.0-611.54.3.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Thu May 7 16:31:24 EDT 2026 x86_64
User: turkishi (1582)
PHP: 8.1.34
Disabled: NONE
Upload Files
File: //proc/thread-self/cwd/wp-content/themes/kidzieo/includes/elementor/course.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_CourseElement 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_course_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 Course 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 'far fa-newspaper';
	}

	// 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( 'owl-carousel' );
			wp_enqueue_style( 'owl-carousel' );
			wp_enqueue_style( 'owl-carousel-theme' );
		}
		if( isset($data['settings']["sortable"]) && !empty($data['settings']["sortable"]) && $data['settings']["sortable"]=='yes' ){
			wp_enqueue_script( 'isotope' );
		}
	}

	protected function register_controls() {

		// Style
		$this->start_controls_section(
			'style_section',
			[
				'label'	=> esc_attr__( 'Course Style Option', 'kidzieo' ),
				'tab'	=> Controls_Manager::TAB_CONTENT,
			]
		);

		$this->add_control(
			'style',
			[
				'label'			=> esc_attr__( 'Select Course View Style', 'kidzieo' ),
				'description'	=> esc_attr__( 'Select Course View style.', 'kidzieo' ),
				'type'			=> 'pbmit_imgselect',
				'label_block'	=> true,
				'thumb_width'	=> '110px',
				'default'		=> '1',
				'options'		=> pbmit_element_template_list( 'course', true ),
			]
		);

		$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 Course 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' ),
				]
			]
		);

		// Row Column: Heading
		$this->add_control(
			'row_col_options',
			[
				'label'		=> esc_attr__( 'Row-Column Options', 'kidzieo' ),
				'type'		=> Controls_Manager::HEADING,
				'separator'	=> 'before',
				'condition'	=> [
					'view-type'	=> 'row-column',
				]
			]
		);

		// Carousel: Heading
		$this->add_control(
			'carousel_options',
			[
				'label'		=> esc_attr__( 'Carousel Options', 'kidzieo' ),
				'type'		=> Controls_Manager::HEADING,
				'separator'	=> 'before',
				'condition'	=> [
					'view-type'	=> 'carousel',
				]
			]
		);

		// 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'		=> '0',
				'options'		=> [
					'1'				=> esc_attr__( 'Yes', 'kidzieo' ),
					'0'				=> esc_attr__( 'No', 'kidzieo' ),
				],
				'condition'		=> [
					'view-type'		=> 'carousel',
				]
			]
		);

		// 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' ),
					'above'			=> esc_attr__( 'Yes, near heading area', '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 : autoplaySpeed
		$this->add_control(
			'carousel-autoplayspeed',
			[
				'label'			=> esc_attr__( 'Carousel: autoplaySpeed', 'kidzieo' ),
				'description'	=> esc_attr__( 'autoplay speed.', 'kidzieo' ),
				'type'			=> Controls_Manager::TEXT,
				'default'		=> '5000',
				'condition'		=> [
					'view-type'		=> 'carousel',
				]
			]
		);

		// 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'		=> '3',
				'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' ),
					'5'				=> esc_url( get_template_directory_uri() . '/includes/images/column-5.png' ),
					'6'				=> esc_url( get_template_directory_uri() . '/includes/images/column-6.png' ),
				],
			]
		);

		$this->end_controls_section();

		// Heading and Subheading
		$this->start_controls_section(
			'heading_section',
			[
				'label'	=> esc_attr__( 'Heading and Subheading', 'kidzieo' ),
			]
		);

		$this->add_control(
			'heading_style',
			[
				'label'			=> esc_attr__( 'Select Heading/Subheading View Style', 'kidzieo' ),
				'description'	=> esc_attr__( 'Select Heading/Subheading View Style.', 'kidzieo' ),
				'type'			=> 'pbmit_imgselect',
				'label_block'	=> true,
				'thumb_width'	=> '110px',
				'default'		=> '1',
				'options'		=> pbmit_element_template_list( 'heading-subheading', true ),
			]
		);

		$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__( 'Welcome to our site', '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 subtitle', '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 Heading', 'kidzieo' ),
				'description'	=> esc_attr__( 'Show Subheading before Heading', '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,
				],
			]
		);

		$this->end_controls_section();

		//Content
		$this->start_controls_section(
			'data_section',
			[
				'label' => esc_attr__( 'Course Content Options', 'kidzieo' ),
			]
		);

		$this->add_control(
			'offset',
			[
				'label'			=> esc_attr__( 'Skip Course (offset)', 'kidzieo' ),
				'description'	=> esc_attr__( 'How many Course you like to skip.', 'kidzieo' ),
				'type'			=> Controls_Manager::SELECT,
				'label_block'	=> true,
				'default'		=> '',
				'options'		=> [
					''				=> esc_attr__( 'Show All Course (No skip)', 'kidzieo' ),
					'1'				=> esc_attr__( 'Skip first Course', 'kidzieo' ),
					'2'				=> esc_attr__( 'Skip two Courses', 'kidzieo' ),
					'3'				=> esc_attr__( 'Skip three Courses', 'kidzieo' ),
					'4'				=> esc_attr__( 'Skip four Courses', 'kidzieo' ),
					'5'				=> esc_attr__( 'Skip five Courses', 'kidzieo' ),
				]
			]
		);

		$this->add_control(
			'from_category',
			[
				'label'			=> esc_attr__( 'Show Course from selected Course Category?', 'kidzieo' ),
				'type'			=> Controls_Manager::SELECT2,
				'options'		=> $this->select_category(),
				'multiple'		=> true,
				'label_block'	=> true,
				'placeholder'	=> esc_attr__( 'All Categories', 'kidzieo' ),
			]
		);

		$this->add_control(
			'show',
			[
				'label'			=> esc_attr__( 'Course to show', 'kidzieo' ),
				'description'	=> esc_attr__( 'How many Course you want to show.', 'kidzieo' ),
				'separator'		=> 'before',
				'type'			=> Controls_Manager::NUMBER,
				'default'		=> '6',
			]
		);

		$this->add_control(
			'sortable',
			[
				'label'			=> esc_attr__( 'Show Sortable Course Category ?', 'kidzieo' ),
				'description'	=> esc_attr__( 'Select YES to show sortable Course Category.', 'kidzieo' ),
				'type'			=> Controls_Manager::SWITCHER,
				'label_on'		=> esc_attr__( 'Yes', 'kidzieo' ),
				'label_off'		=> esc_attr__( 'No', 'kidzieo' ),
				'return_value'	=> 'yes',
				'default'		=> '',
				'condition'		=> [
					'view-type'		=> 'row-column',
				]
			]
		);

		$this->add_control(
			'order',
			[
				'label'			=> esc_attr__( 'Order', 'kidzieo' ),
				'description'	=> esc_attr__( 'Designates the ascending or descending order.', 'kidzieo' ),
				'type'			=> Controls_Manager::SELECT,
				'separator'		=> 'before',
				'default'		=> 'DESC',
				'options'		=> [
					'ASC'			=> esc_attr__( 'Ascending order (1, 2, 3; a, b, c)', 'kidzieo' ),
					'DESC'			=> esc_attr__( 'Descending order (3, 2, 1; c, b, a)', 'kidzieo' ),
				]
			]
		);

		$this->add_control(
			'orderby',
			[
				'label'			=> esc_attr__( 'Order By', 'kidzieo' ),
				'description'	=> esc_attr__( ' Sort retrieved courses by parameter.', 'kidzieo' ),
				'type'			=> Controls_Manager::SELECT,
				'default'		=> 'DESC',
				'options'		=> [
					'none'			=> esc_attr__( 'No order', 'kidzieo' ),
					'ID'			=> esc_attr__( 'ID', 'kidzieo' ),
					'title'			=> esc_attr__( 'Title', 'kidzieo' ),
					'date'			=> esc_attr__( 'Date', 'kidzieo' ),
					'rand'			=> esc_attr__( 'Random', 'kidzieo' ),
				]
			]
		);

		$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,
			]
		);

		// Tags
		$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__( 'Heading 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__( 'Subheading 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' ),
			]
		);

		// Gap
		$this->add_control(
			'gap_options',
			[
				'label' 		=> esc_attr__( 'Gap between Course boxes', 'kidzieo' ),
				'description'	=> esc_attr__( 'Gap between each Course box.', 'kidzieo' ),
				'type'			=> Controls_Manager::HEADING,
				'separator'		=> 'before',
			]
		);

		$this->add_control(
			'gap',
			[
				'label'			=> esc_attr__( 'Box Gap', 'kidzieo' ),
				'description'	=> esc_attr__( 'Gap Between Each Course box.', 'kidzieo' ),
				'type'			=> Controls_Manager::SELECT,
				'default'		=> '30px',
				'options'		=> [
					'0px'			=> esc_attr__( 'No Gap (0px)', 'kidzieo' ),
					'5px'			=> esc_attr__( '5px', 'kidzieo' ),
					'10px'			=> esc_attr__( '10px', 'kidzieo' ),
					'15px'			=> esc_attr__( '15px', 'kidzieo' ),
					'20px'			=> esc_attr__( '20px', 'kidzieo' ),
					'25px'			=> esc_attr__( '25px', 'kidzieo' ),
					'30px'			=> esc_attr__( '30px', 'kidzieo' ),
					'35px'			=> esc_attr__( '35px', 'kidzieo' ),
					'40px'			=> esc_attr__( '40px', 'kidzieo' ),
					'45px'			=> esc_attr__( '45px', 'kidzieo' ),
					'50px'			=> esc_attr__( '50px', 'kidzieo' ),
				]
			]
		);

		$this->end_controls_section();

	}

	protected function render() {

		$settings	= $this->get_settings_for_display();
		extract($settings);

		?>

		<?php
		// Starting container
		$start_div = pbmit_element_container( array(
			'position'	=> 'start',
			'cpt'		=> 'course',
			'data'		=> $settings
		) );
		echo pbmit_esc_kses($start_div);

		// Preparing $args
		$args = array(
			'post_type'				=> 'lp_course',
			'status'				=> 'publish',
			'posts_per_page'		=> $show,
			'ignore_sticky_posts'	=> true,
		);

		if( !empty($offset) ){
			$args['offset'] = $offset;
		}
		if( !empty($orderby) && $orderby!='none' ){
			$args['orderby'] = $orderby;
			if( !empty($order) ){
				$args['order'] = $order;
			}
		}

		// From selected category/group
		if( !empty($from_category) ){
			$args['tax_query'] = array(
				array(
					'taxonomy'	=> 'course_category',
					'field'		=> 'slug',
					'terms'		=> $from_category,
				),
			);
		};

		// Wp query to fetch posts
		$posts = new \WP_Query( $args );

		if ( $posts->have_posts() ) {

			$user = wp_get_current_user();	
			?>

			<div class="pbmit-ele-header-area">
				<?php pbmit_heading_subheading($settings, true); ?>

				<?php
				/* Sortable Category  */
				if( function_exists('pbmit_sortable_category') ){
					$sortable_html = pbmit_sortable_category( $settings, 'course_category' );
					echo  pbmit_esc_kses($sortable_html);
				}
				?>

			</div>

			<?php if( $style=='1' && $settings['view-type']=='carousel' ){ ?>
				<div class="pbmit-course-expand-right">
			<?php } ?>

			<div class="pbmit-element-posts-wrapper row multi-columns-row <?php if( !empty($settings['view-type']) && trim($settings['view-type'])=='carousel' ){ ?>swiper-container<?php } ?>">

			<?php
			while ( $posts->have_posts() ) {
				$return = '';
				$posts->the_post();

				// Template
				if( file_exists( locate_template( '/theme-parts/course/course-style-'.esc_attr($style).'.php', false, false ) ) ){

					$return .= pbmit_element_block_container( array(
						'position'		=> 'start',
						'column'		=> $columns,
						'cpt'			=> 'course',
						'taxonomy'		=> 'course_category',
						'style'			=> $style,
					) );

					ob_start();
					$r = include( locate_template( '/theme-parts/course/course-style-'.esc_attr($style).'.php', false, false ) );
					$return .= ob_get_contents();
					ob_end_clean();

					$return .= pbmit_element_block_container( array(
						'position'	=> 'end',
					) );

				}

				echo pbmit_esc_kses($return);

			}
			?>

			</div>
			<?php if( $style=='1' && $settings['view-type']=='carousel' ){ ?>
			</div>
			<?php } ?>

			<?php
		} else {
			echo esc_html__( 'No posts found', 'kidzieo');
		}

		?>

		<?php wp_reset_postdata();

		// Ending wrapper of the whole arear
		$end_div = pbmit_element_container( array(
			'position'	=> 'end',
			'cpt'		=> 'blog',
			'data'		=> $settings
		) );
		echo pbmit_esc_kses($end_div);
		?>

		<?php
	}

	protected function content_template() {}

	protected function select_category() {
		$category = get_terms( array( 'taxonomy' => 'course_category', 'hide_empty' => false ) );
	  	$cat = array();
	  	foreach( $category as $item ) {
			$cat_count = get_category( $item );

		 	if( $item ) {
				$cat[$item->slug] = $item->name . ' ('.$cat_count->count.')';
		 	}
	  	}
	  	return $cat;
	}
}
// After the Schedule class is defined, I must register the new widget class with Elementor:
Plugin::instance()->widgets_manager->register( new PBMIT_CourseElement() );