model() ->courseBundle() ->ofCourseBundle() ->pluck('post_title', 'ID') ->toArray(); $defaultCourseBundle = !empty($courseBundle) ? array_key_first($courseBundle) : ''; $this->start_controls_section( 'bundle_courses_content', [ 'label' => __('General Settings', 'acadlix-addon-for-elementor'), 'tab' => Controls_Manager::TAB_CONTENT, ] ); $this->add_control( 'course_bundle', array( 'label' => __('Course Bundle', 'acadlix-addon-for-elementor'), 'type' => Controls_Manager::SELECT2, 'options' => $courseBundle, 'default' => $defaultCourseBundle, ) ); $this->add_control( 'bundle_courses_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' => 'h3', ) ); $this->add_responsive_control( 'bundle_courses_title', [ 'label' => __('Title', 'acadlix-addon-for-elementor'), 'type' => Controls_Manager::TEXTAREA, 'default' => __('Courses in the Bundle:', 'acadlix-addon-for-elementor'), 'placeholder' => __('Type your title here', 'acadlix-addon-for-elementor'), 'rows' => 3, ] ); $this->add_responsive_control( 'bundle_courses_title_display', [ '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_control( 'bundle_courses_title_divider', [ 'type' => \Elementor\Controls_Manager::DIVIDER, ] ); $this->add_responsive_control( 'bundle_courses_thumbnail_display', [ 'label' => __('Display Thumbnail', '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_control( 'bundle_courses_display_course_title', [ 'label' => __('Display Course 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_control( 'bundle_courses_display_course_instructor', [ 'label' => __('Display Course Instructor', '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_control( 'bundle_courses_link', array( 'label' => __('Link', 'acadlix-addon-for-elementor'), 'type' => Controls_Manager::SELECT, 'options' => array( 'new_window' => 'New Window', 'same_window' => 'Same Window', ), 'default' => 'new_window', ) ); $this->end_controls_section(); $this->start_controls_section( 'bundle_courses_display_content_section', [ 'label' => __('Display Settings', 'acadlix-addon-for-elementor'), 'tab' => Controls_Manager::TAB_CONTENT, ] ); $selector = '{{WRAPPER}} .aelms-bundle-courses'; $this->add_responsive_control( 'bundle_courses_display', [ 'label' => __('Display', 'acadlix-addon-for-elementor'), 'type' => Controls_Manager::SELECT, 'options' => [ 'block' => __('Block', 'acadlix-addon-for-elementor'), 'flex' => __('Flex', 'acadlix-addon-for-elementor'), ], 'selectors' => [ $selector => 'display: {{VALUE}};', ], 'default' => 'flex', ] ); $this->add_responsive_control( 'bundle_courses_flex_direction', [ 'label' => __('Flex Direction', 'acadlix-addon-for-elementor'), 'type' => Controls_Manager::SELECT, 'options' => [ 'row' => __('Row', 'acadlix-addon-for-elementor'), 'row-reverse' => __('Row Reverse', 'acadlix-addon-for-elementor'), 'column' => __('Column', 'acadlix-addon-for-elementor'), 'column-reverse' => __('Column Reverse', 'acadlix-addon-for-elementor'), ], 'selectors' => [ $selector => 'flex-direction: {{VALUE}};', ], 'default' => 'row', 'condition' => [ 'bundle_courses_display' => 'flex', ], ] ); $this->add_responsive_control( 'bundle_courses_justify_content', [ 'label' => __('Justify Content', 'acadlix-addon-for-elementor'), 'type' => Controls_Manager::SELECT, 'options' => [ 'flex-start' => __('Flex Start', 'acadlix-addon-for-elementor'), 'flex-end' => __('Flex End', 'acadlix-addon-for-elementor'), 'center' => __('Center', 'acadlix-addon-for-elementor'), 'space-between' => __('Space Between', 'acadlix-addon-for-elementor'), 'space-around' => __('Space Around', 'acadlix-addon-for-elementor'), 'space-evenly' => __('Space Evenly', 'acadlix-addon-for-elementor'), 'stretch' => __('Stretch', 'acadlix-addon-for-elementor'), ], 'selectors' => [ $selector => 'justify-content: {{VALUE}};', ], 'default' => 'flex-start', 'condition' => [ 'bundle_courses_display' => 'flex', ], ] ); $this->add_responsive_control( 'bundle_courses_align_items', [ 'label' => __('Align Items', 'acadlix-addon-for-elementor'), 'type' => Controls_Manager::SELECT, 'options' => [ 'flex-start' => __('Flex Start', 'acadlix-addon-for-elementor'), 'flex-end' => __('Flex End', 'acadlix-addon-for-elementor'), 'center' => __('Center', 'acadlix-addon-for-elementor'), 'baseline' => __('Baseline', 'acadlix-addon-for-elementor'), 'stretch' => __('Stretch', 'acadlix-addon-for-elementor'), ], 'selectors' => [ $selector => 'align-items: {{VALUE}};', ], 'default' => 'center', 'condition' => [ 'bundle_courses_display' => 'flex', ], ] ); $this->add_responsive_control( 'bundle_courses_gap', [ 'label' => __('Gap', 'acadlix-addon-for-elementor'), 'type' => \Elementor\Controls_Manager::SLIDER, 'size_units' => ['px', '%', 'em', 'rem', 'custom'], 'range' => [ 'px' => [ 'min' => 0, 'max' => 100, 'step' => 1, ], '%' => [ 'min' => 0, 'max' => 100, ], ], 'default' => [ 'unit' => 'px', 'size' => 8, ], 'selectors' => [ "{$selector}" => 'gap: {{SIZE}}{{UNIT}};', ], 'condition' => [ 'bundle_courses_display' => 'flex', ], ] ); $this->end_controls_section(); } protected function register_style_controls() { $course_bundle_title_selector = '{{WRAPPER}} .aelms-course-bundle-title'; $this->start_controls_section( 'course_bundle_title_style_section', [ 'label' => __('Title', 'acadlix-addon-for-elementor'), 'tab' => Controls_Manager::TAB_STYLE, ] ); $this->add_responsive_control( 'course_bundle_title_color', [ 'label' => __('Color', 'acadlix-addon-for-elementor'), 'type' => Controls_Manager::COLOR, 'selectors' => [ $course_bundle_title_selector => 'color: {{VALUE}};', ], 'default' => '#161616', ] ); $this->add_group_control( Group_Control_Typography::get_type(), [ 'name' => 'course_bundle_title_typography', 'label' => __('Typography', 'acadlix-addon-for-elementor'), 'selector' => $course_bundle_title_selector, ] ); $this->end_controls_section(); // course thumbnail $course_thumbnail_selector = '{{WRAPPER}} .aelms-bundle-course-thumbnail'; $this->start_controls_section( 'course_thumbnail_style_section', [ 'label' => __('Thumbnail', 'acadlix-addon-for-elementor'), 'tab' => Controls_Manager::TAB_STYLE, ] ); $this->add_control( 'course_thumbnail_height', array( 'label' => __('Image Height', 'acadlix-addon-for-elementor'), 'type' => Controls_Manager::SLIDER, 'size_units' => array('px'), 'range' => array( 'px' => array( 'min' => 10, 'max' => 200, ), ), 'default' => array( 'size' => 52, 'unit' => 'px', ), 'selectors' => array( "{$course_thumbnail_selector}" => 'height: {{SIZE}}{{UNIT}};', ), ) ); $this->add_control( 'course_thumbnail_width', array( 'label' => __('Image Width', 'acadlix-addon-for-elementor'), 'type' => Controls_Manager::SLIDER, 'size_units' => array('px'), 'range' => array( 'px' => array( 'min' => 10, 'max' => 200, ), ), 'default' => array( 'size' => 52, 'unit' => 'px', ), 'selectors' => array( "{$course_thumbnail_selector}" => 'width: {{SIZE}}{{UNIT}};', ), ) ); $this->add_group_control( \Elementor\Group_Control_Css_Filter::get_type(), [ 'name' => 'course_thumbnail_filters', 'selector' => "{$course_thumbnail_selector}", ] ); $this->add_group_control( \Elementor\Group_Control_Border::get_type(), [ 'name' => 'course_thumbnail_border', 'selector' => "{$course_thumbnail_selector}", ] ); $this->add_responsive_control( 'course_thumbnail_border_radius', [ 'label' => __('Border Radius', 'acadlix-addon-for-elementor'), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => ['px', '%'], 'selectors' => [ "{$course_thumbnail_selector}" => '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_thumbnail_box_shadow', 'label' => __('Box Shadow', 'acadlix-addon-for-elementor'), 'selector' => "{$course_thumbnail_selector}", ] ); $this->end_controls_section(); // instructors name and link $course_title_selector = '{{WRAPPER}} .aelms-bundle-course-title'; $this->start_controls_section( 'course_title_style_section', array( 'label' => __('Course Title', 'acadlix-addon-for-elementor'), 'tab' => Controls_Manager::TAB_STYLE, ) ); $this->start_controls_tabs('course_title_color_tabs'); $this->start_controls_tab( 'course_title_color_normal', array( 'label' => __('Normal', 'acadlix-addon-for-elementor'), ) ); $this->add_responsive_control( 'course_title_color', array( 'label' => __('Color', 'acadlix-addon-for-elementor'), 'type' => Controls_Manager::COLOR, 'selectors' => array( "{$course_title_selector} a" => 'color: {{VALUE}};', ), 'default' => '#161616', ) ); $this->add_group_control( Group_Control_Typography::get_type(), array( 'name' => 'course_title_typography', 'label' => __('Typography', 'acadlix-addon-for-elementor'), 'selector' => $course_title_selector, ) ); $this->end_controls_tab(); $this->start_controls_tab( 'course_title_color_hover', array( 'label' => __('Hover', 'acadlix-addon-for-elementor'), ) ); $this->add_responsive_control( 'course_title_hover_color', array( 'label' => __('Hover', 'acadlix-addon-for-elementor'), 'type' => Controls_Manager::COLOR, 'selectors' => array( "{$course_title_selector} a:hover" => 'color: {{VALUE}};', ), 'default' => '#161616', ) ); $this->add_group_control( Group_Control_Typography::get_type(), array( 'name' => 'course_title_hover_typography', 'label' => __('Typography', 'acadlix-addon-for-elementor'), 'selector' => "{$course_title_selector} a:hover", ) ); $this->end_controls_tab(); $this->end_controls_tabs(); $this->end_controls_section(); // instructors bio style $course_instructor_selector = '{{WRAPPER}} .aelms-bundle-course-instructor'; $this->start_controls_section( 'course_instructor_style_section', [ 'label' => __('Instructor', 'acadlix-addon-for-elementor'), 'tab' => Controls_Manager::TAB_STYLE, ] ); $this->add_responsive_control( 'course_instructor_color', [ 'label' => __('Color', 'acadlix-addon-for-elementor'), 'type' => Controls_Manager::COLOR, 'selectors' => [ $course_instructor_selector => 'color: {{VALUE}};', ], 'default' => '#161616', ] ); $this->add_group_control( Group_Control_Typography::get_type(), [ 'name' => 'course_instructor_typography', 'label' => __('Typography', 'acadlix-addon-for-elementor'), 'selector' => $course_instructor_selector, ] ); $this->end_controls_section(); } protected function render() { global $post; $settings = $this->get_settings_for_display(); $course_bundle_id = null; if(\Elementor\Plugin::$instance->editor->is_edit_mode() && $settings['course_bundle']) { $course_bundle_id = $settings['course_bundle']; } elseif ($post->post_type == acadlix()->cpt()->course_bundle()->get_post_type()) { $course_bundle_id = $post->ID; } if ($course_bundle_id) { $aelms_item = acadlix() ->model() ->courseBundle() ->ofCourseBundle() ->with('courses') ->find($course_bundle_id); if ($aelms_item) { ob_start(); include AELMS_PLUGIN_DIR . 'templates/bundle/courses.php'; $html = ob_get_clean(); echo wp_kses($html, aelms_allowed_html()); } } } }