model() ->course() ->ofCourse() ->where('post_status', 'publish') ->pluck('post_title', 'ID') ->toArray(); $this->start_controls_section( 'course_prerequisite_general_settings', array( 'label' => __('General Settings', 'acadlix-addon-for-elementor'), 'tab' => Controls_Manager::TAB_CONTENT, ) ); $this->add_control( 'course_prerequisite_course', array( 'label' => __('Course', 'acadlix-addon-for-elementor'), 'type' => Controls_Manager::SELECT2, 'options' => $courses, 'default' => array(), ) ); $this->add_control( 'course_prerequisite_html_tag', array( 'label' => esc_html__('Select Tag', 'acadlix-addon-for-elementor'), 'type' => Controls_Manager::SELECT, 'options' => array( 'h1' => esc_html('h1'), 'h2' => esc_html('h2'), 'h3' => esc_html('h3'), 'h4' => esc_html('h4'), 'h5' => esc_html('h5'), 'h6' => esc_html('h6'), ), 'default' => 'h2', ) ); $this->add_control( 'course_prerequisite_title', array( 'label' => __('Title', 'acadlix-addon-for-elementor'), 'type' => Controls_Manager::TEXTAREA, 'default' => __('Prerequisite(s):', 'acadlix-addon-for-elementor'), 'placeholder' => __('Type your title here', 'acadlix-addon-for-elementor'), 'rows' => 3, ) ); $this->add_control( 'course_prerequisite_title_display', array( 'label' => __('Show Title', 'acadlix-addon-for-elementor'), 'type' => Controls_Manager::SWITCHER, 'label_on' => __('Show', 'acadlix-addon-for-elementor'), 'label_off' => __('Hide', 'acadlix-addon-for-elementor'), 'return_value' => 'yes', 'default' => 'yes', ) ); $this->add_responsive_control( 'course_prerequisite_align', $this->aelms_alignment( array( '{{WRAPPER}} .aelms-course-prerequisite-title' => 'text-align: {{VALUE}};', ), ) ); $this->add_control( 'course_prerequisite_warning_message', array( 'label' => __('Warning Message', 'acadlix-addon-for-elementor'), 'type' => Controls_Manager::TEXTAREA, 'default' => __('You must complete the prerequisites before you can start this course.', 'acadlix-addon-for-elementor'), 'placeholder' => __('Type your warning message here', 'acadlix-addon-for-elementor'), 'rows' => 3, ) ); $this->add_control( 'course_prerequisite_warning_message_display', array( 'label' => __('Show Warning Message', 'acadlix-addon-for-elementor'), 'type' => Controls_Manager::SWITCHER, 'label_on' => __('Show', 'acadlix-addon-for-elementor'), 'label_off' => __('Hide', 'acadlix-addon-for-elementor'), 'return_value' => 'yes', 'default' => 'yes', ) ); $this->end_controls_section(); } protected function register_style_controls() { $label_selector = '{{WRAPPER}} .aelms-course-prerequisite-title'; $this->start_controls_section( 'course_prerequisite_label_style_section', array( 'label' => __('Label', 'acadlix-addon-for-elementor'), 'tab' => Controls_Manager::TAB_STYLE, ) ); $this->add_responsive_control( 'course_prerequisite_label_color', array( 'label' => __('Color', 'acadlix-addon-for-elementor'), 'type' => Controls_Manager::COLOR, 'selectors' => array( $label_selector => 'color: {{VALUE}};', ), 'default' => '#161616', ) ); $this->add_group_control( Group_Control_Typography::get_type(), array( 'name' => 'course_prerequisite_label_typography', 'label' => __('Typography', 'acadlix-addon-for-elementor'), 'selector' => $label_selector, ) ); $this->add_responsive_control( 'course_prerequisite_label_gap', array( 'label' => __('Gap', 'acadlix-addon-for-elementor'), 'type' => Controls_Manager::SLIDER, 'size_units' => array('px'), 'range' => array( 'px' => array( 'min' => -100, 'max' => 100, ), ), 'selectors' => array( $label_selector => 'margin-bottom: {{SIZE}}{{UNIT}};', ), ) ); $this->end_controls_section(); $warning_selector = '{{WRAPPER}} .aelms-course-prerequisite-warning'; $this->start_controls_section( 'course_prerequisite_warning_style_section', array( 'label' => __('Warning Message', 'acadlix-addon-for-elementor'), 'tab' => Controls_Manager::TAB_STYLE, ) ); $this->add_responsive_control( 'course_prerequisite_warning_color', array( 'label' => __('Color', 'acadlix-addon-for-elementor'), 'type' => Controls_Manager::COLOR, 'selectors' => array( $warning_selector => 'color: {{VALUE}};', ), 'default' => '#161616', ) ); $this->add_responsive_control( 'course_prerequisite_warning_background_color', array( 'label' => __('Background Color', 'acadlix-addon-for-elementor'), 'type' => Controls_Manager::COLOR, 'selectors' => array( $warning_selector => 'background-color: {{VALUE}};', ), ) ); $this->add_group_control( Group_Control_Typography::get_type(), array( 'name' => 'course_prerequisite_warning_typography', 'label' => __('Typography', 'acadlix-addon-for-elementor'), 'selector' => $warning_selector, ) ); $this->add_responsive_control( 'course_prerequisite_warning_gap', array( 'label' => __('Gap', 'acadlix-addon-for-elementor'), 'type' => Controls_Manager::SLIDER, 'size_units' => array('px'), 'range' => array( 'px' => array( 'min' => -100, 'max' => 100, ), ), 'selectors' => array( $warning_selector => 'margin-bottom: {{SIZE}}{{UNIT}};', ), ) ); $this->add_responsive_control( 'course_prerequisite_warning_padding', array( 'label' => __('Padding', 'acadlix-addon-for-elementor'), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => ['px', '%', 'em'], 'selectors' => array( "{$warning_selector}" => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ), 'default' => [ 'top' => 0, 'right' => 0, 'bottom' => 0, 'left' => 0, 'unit' => 'px', 'isLinked' => true ], ) ); $this->add_responsive_control( 'course_prerequisite_warning_margin', array( 'label' => __('Margin', 'acadlix-addon-for-elementor'), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => ['px', '%', 'em'], 'selectors' => array( "{$warning_selector}" => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ), 'default' => [ 'top' => 0, 'right' => 0, 'bottom' => 0, 'left' => 0, 'unit' => 'px', 'isLinked' => true ], ) ); $this->end_controls_section(); $prerequisite_item = '{{WRAPPER}} .aelms-course-prerequisite-item'; $this->start_controls_section( 'course_prerequisite_list_text_style_section', array( 'label' => __('List Item', 'acadlix-addon-for-elementor'), 'tab' => Controls_Manager::TAB_STYLE, ) ); $this->add_group_control( \Elementor\Group_Control_Border::get_type(), [ 'name' => 'course_prerequisite_section_border', 'selector' => "{$prerequisite_item}", ] ); $this->add_responsive_control( 'course_prerequisite_section_border_radius', [ 'label' => __('Border Radius', 'acadlix-addon-for-elementor'), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => ['px', '%'], 'selectors' => [ "{$prerequisite_item}" => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], 'default' => [ 'top' => 0, 'right' => 0, 'bottom' => 0, 'left' => 0, 'unit' => 'px', 'isLinked' => true ], ] ); $this->add_group_control( \Elementor\Group_Control_Box_Shadow::get_type(), [ 'name' => 'course_prerequisite_section_box_shadow', 'label' => __('Box Shadow', 'acadlix-addon-for-elementor'), 'selector' => "{$prerequisite_item}", ] ); $prerequisite_item_thumbnail = '{{WRAPPER}} .aelms-course-prerequisite-thumbnail'; $this->add_control( 'course_prerequisite_thumbnail_divider', array( 'type' => Controls_Manager::DIVIDER, ) ); $this->add_responsive_control( 'course_prerequisite_list_thumbnail_height', array( 'label' => __('Thumbnail Height', 'acadlix-addon-for-elementor'), 'type' => Controls_Manager::SLIDER, 'size_units' => ['px', 'em', '%'], 'selectors' => array( "{$prerequisite_item_thumbnail}" => 'height: {{SIZE}}{{UNIT}};', ), 'range' => array( 'px' => array( 'min' => 10, 'max' => 300, ), ), 'default' => [ 'size' => 90, 'unit' => 'px', ], ) ); $this->add_responsive_control( 'course_prerequisite_list_thumbnail_width', array( 'label' => __('Thumbnail Width', 'acadlix-addon-for-elementor'), 'type' => Controls_Manager::SLIDER, 'size_units' => ['px', 'em', '%'], 'selectors' => array( "{$prerequisite_item_thumbnail}" => 'width: {{SIZE}}{{UNIT}};', ), 'range' => array( 'px' => array( 'min' => 10, 'max' => 300, ), ), 'default' => [ 'size' => 140, 'unit' => 'px', ], ) ); $this->add_responsive_control( 'course_prerequisite_list_thumbnail_border_radius', [ 'label' => __('Border Radius', 'acadlix-addon-for-elementor'), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => ['px', '%'], 'selectors' => [ "{$prerequisite_item_thumbnail}" => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], 'default' => [ 'top' => 6, 'right' => 6, 'bottom' => 6, 'left' => 6, 'unit' => 'px', 'isLinked' => true ], ] ); $this->add_responsive_control( 'course_prerequisite_list_thumbnail_margin', array( 'label' => __('Thumbnail Margin', 'acadlix-addon-for-elementor'), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => array('px', 'em', '%'), 'selectors' => array( "{$prerequisite_item_thumbnail}" => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ), 'default' => array( 'top' => 4, 'right' => 4, 'bottom' => 4, 'left' => 4, 'unit' => 'px', 'isLinked' => true, ), ) ); $prerequisite_item_course_name = '{{WRAPPER}} .aelms-course-prerequisite-course-name'; $this->add_control( 'course_prerequisite_list_course_name_divider', array( 'type' => Controls_Manager::DIVIDER, ) ); $this->add_responsive_control( 'course_prerequisite_list_course_name_color', array( 'label' => __('Course Name Color', 'acadlix-addon-for-elementor'), 'type' => Controls_Manager::COLOR, 'selectors' => array( "{$prerequisite_item_course_name}" => 'color: {{VALUE}};', ), 'default' => '#161616', ) ); $this->add_group_control( Group_Control_Typography::get_type(), array( 'name' => 'course_prerequisite_list_course_name_typography', 'label' => __('Course Name Typography', 'acadlix-addon-for-elementor'), 'selector' => "{$prerequisite_item_course_name}", ) ); $this->add_responsive_control( 'course_prerequisite_list_course_name_padding', array( 'label' => __('Course Name Padding', 'acadlix-addon-for-elementor'), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => array('px', 'em', '%'), 'selectors' => array( "{$prerequisite_item_course_name}" => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ), 'default' => array( 'top' => 0, 'right' => 0, 'bottom' => 0, 'left' => 0, 'unit' => 'px', 'isLinked' => true, ), ) ); $prerequisite_item_completion_percentage = '{{WRAPPER}} .aelms-course-prerequisite-completion-percentage'; $this->add_control( 'course_prerequisite_list_completion_percentage_divider', array( 'type' => Controls_Manager::DIVIDER, ) ); $this->add_responsive_control( 'course_prerequisite_list_completion_percentage_color', array( 'label' => __('Completion Percentage Color', 'acadlix-addon-for-elementor'), 'type' => Controls_Manager::COLOR, 'selectors' => array( "{$prerequisite_item_completion_percentage}" => 'color: {{VALUE}};', ), 'default' => '#161616', ) ); $this->add_group_control( Group_Control_Typography::get_type(), array( 'name' => 'course_prerequisite_list_completion_percentage_typography', 'label' => __('Completion Percentage Typography', 'acadlix-addon-for-elementor'), 'selector' => "{$prerequisite_item_completion_percentage}", ) ); $this->add_responsive_control( 'course_prerequisite_list_completion_percentage_padding', array( 'label' => __('Completion Percentage Padding', 'acadlix-addon-for-elementor'), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => array('px', 'em', '%'), 'selectors' => array( "{$prerequisite_item_completion_percentage}" => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ), 'default' => array( 'top' => 0, 'right' => 0, 'bottom' => 0, 'left' => 0, 'unit' => 'px', 'isLinked' => true, ), ) ); $this->end_controls_section(); $this->start_controls_section( 'course_prerequisite_style_section', array( 'label' => __('General Settings', 'acadlix-addon-for-elementor'), 'tab' => Controls_Manager::TAB_STYLE, ) ); $this->add_responsive_control( 'course_prerequisite_padding', array( 'label' => __('Prerequisite Padding', 'acadlix-addon-for-elementor'), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => array('px', 'em', '%'), 'selectors' => array( '{{WRAPPER}} .aelms-course-prerequisite-item' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ), 'default' => array( 'top' => 0, 'right' => 0, 'bottom' => 0, 'left' => 0, 'unit' => 'px', 'isLinked' => true, ), ) ); $this->end_controls_section(); } protected function render() { $course = aelms_get_course(); if ($course) { ob_start(); $settings = $this->get_settings_for_display(); include AELMS_PLUGIN_DIR . 'templates/course/prerequisite.php'; $html = ob_get_clean(); echo wp_kses($html, aelms_allowed_html()); } } }