'', 'author' => 'AcademyLMS', 'author_uri' => 'https://academylms.net/', ); public function init() { $this->name = esc_html__( 'Academy Course Grid', 'academy-divi-modules' ); $this->icon_path = plugin_dir_path( __FILE__ ) . 'icon.svg'; // settings toggles $this->settings_modal_toggles = array( 'general' => array( 'toggles' => array( 'content' => esc_html__( 'Content', 'academy-divi-modules' ), 'layout' => esc_html__( 'Layout', 'academy-divi-modules' ), 'query' => esc_html__( 'Query', 'academy-divi-modules' ), ), ), 'advanced' => array( 'toggles' => array( 'course_card' => esc_html__( 'Course Card', 'academy-divi-modules' ), 'course_title' => esc_html__( 'Course Title', 'academy-divi-modules' ), 'course_category' => esc_html__( 'Course Category', 'academy-divi-modules' ), 'course_by' => esc_html__( 'Course By', 'academy-divi-modules' ), 'course_author' => esc_html__( 'Course Author', 'academy-divi-modules' ), 'course_rating' => esc_html__( 'Course Rating', 'academy-divi-modules' ), 'course_price' => esc_html__( 'Course Price', 'academy-divi-modules' ), 'wishlist_icon' => esc_html__( 'Wishlist Icon', 'academy-divi-modules' ), ), ), ); $this->advanced_fields = array( // Typography Controls 'fonts' => array( 'course_title_font' => array( 'css' => array( 'main' => '.academy-course-grid .academy-courses .academy-course__title a', ), 'hide_text_align' => true, 'tab_slug' => 'advanced', 'toggle_slug' => 'course_title', ), 'course_category_font' => array( 'css' => array( 'main' => '.academy-course-grid .academy-courses .academy-course__meta--categroy a', ), 'hide_text_align' => true, 'tab_slug' => 'advanced', 'toggle_slug' => 'course_category', ), 'course_by_font' => array( 'css' => array( 'main' => '%%order_class%% .academy-course-grid .academy-courses .academy-course__author .author', ), 'hide_text_align' => true, 'tab_slug' => 'advanced', 'toggle_slug' => 'course_by', ), 'course_author_font' => array( 'css' => array( 'main' => '%%order_class%% .academy-course-grid .academy-courses .academy-course__author .author a', ), 'hide_text_align' => true, 'tab_slug' => 'advanced', 'toggle_slug' => 'course_author', ), 'course_rating_font' => array( 'css' => array( 'main' => '.academy-course-grid .academy-courses .academy-course__rating', ), 'hide_text_align' => true, 'tab_slug' => 'advanced', 'toggle_slug' => 'course_rating', ), 'course_price_font' => array( 'css' => array( 'main' => '.academy-course-grid .academy-courses .academy-course__price', ), 'hide_text_align' => true, 'tab_slug' => 'advanced', 'toggle_slug' => 'course_price', ), ), 'borders' => array( 'default' => false, 'card_border' => array( 'css' => array( 'main' => array( 'border_radii' => '%%order_class%% .academy-course-grid .academy-courses .academy-course', 'border_styles' => '%%order_class%% .academy-course-grid .academy-courses .academy-course', ), 'important' => true, ), 'tab_slug' => 'advanced', 'toggle_slug' => 'course_card', ), ), 'margin_padding' => array(), ); } public function get_fields() { return array( 'course_count' => array( 'label' => esc_html__( 'Course Count', 'academy-divi-modules' ), 'type' => 'number', 'option_category' => 'basic_option', 'toggle_slug' => 'layout', 'default' => 3, 'mobile_options' => true, 'computed_affects' => array( '__shortcode', ), ), 'order_by' => array( 'label' => esc_html__( 'Order By', 'academy-divi-modules' ), 'type' => 'select', 'option_category' => 'basic_option', 'tab_slug' => 'general', 'toggle_slug' => 'query', 'options' => array( 'date' => 'Date', 'title' => 'Title', 'modified' => 'Modified', ), 'default' => 'date', 'computed_affects' => array( '__shortcode', ), ), 'order' => array( 'label' => esc_html__( 'Order', 'academy-divi-modules' ), 'type' => 'select', 'option_category' => 'basic_option', 'tab_slug' => 'general', 'toggle_slug' => 'query', 'options' => array( 'ASC' => 'Ascending', 'DESC' => 'Descending', ), 'default' => 'DESC', 'computed_affects' => array( '__shortcode', ), ), 'price_type' => array( 'label' => esc_html__( 'Price Type', 'academy-divi-modules' ), 'type' => 'select', 'option_category' => 'basic_option', 'toggle_slug' => 'query', 'options' => array( 'free,paid' => 'All', 'free' => 'Free', 'paid' => 'Paid', ), 'default' => 'free,paid', 'computed_affects' => array( '__shortcode', ), ), 'course_level' => array( 'label' => esc_html__( 'Course Level', 'academy-divi-modules' ), 'type' => 'select', 'option_category' => 'basic_option', 'toggle_slug' => 'query', 'options' => array( 'beginner,intermediate,experts' => 'All', 'beginner' => 'Beginner', 'intermediate' => 'Intermediate', 'experts' => 'Experts', ), 'default' => 'beginner,intermediate,experts', 'computed_affects' => array( '__shortcode', ), ), 'course_categories' => array( 'label' => esc_html__( 'Course Categories', 'academy-divi-modules' ), 'type' => 'adcm-multiple-checkbox', 'options' => Helper::get_terms_list( 'academy_courses_category' ), 'tab_slug' => 'general', 'toggle_slug' => 'query', 'default' => '', 'computed_affects' => array( '__shortcode', ), ), 'course_tags' => array( 'label' => esc_html__( 'Course Tags', 'academy-divi-modules' ), 'type' => 'adcm-multiple-checkbox', 'options' => Helper::get_terms_list( 'academy_courses_tag' ), 'tab_slug' => 'general', 'toggle_slug' => 'query', 'default' => '', 'computed_affects' => array( '__shortcode', ), ), 'course_include_exclude' => array( 'label' => esc_html__( 'Courses IDs', 'academy-divi-modules' ), 'tab_slug' => 'general', 'toggle_slug' => 'query', 'attr_suffix' => '', 'type' => 'composite', 'composite_type' => 'default', 'composite_structure' => array( 'include' => array( 'label' => esc_html( 'Include', 'academy-divi-modules' ), 'controls' => array( 'include_ids' => array( 'label' => esc_html__( 'Include Courses IDs', 'academy-divi-modules' ), 'type' => 'textarea', 'computed_affects' => array( '__shortcode', ), ), ), ), 'exclude' => array( 'label' => esc_html( 'Exclude', 'academy-divi-modules' ), 'controls' => array( 'exclude_ids' => array( 'label' => esc_html__( 'Exclude Courses IDs', 'academy-divi-modules' ), 'type' => 'textarea', 'computed_affects' => array( '__shortcode', ), ), ), ), ), ), 'allow_course_pagination' => array( 'label' => esc_html__( 'Show Pagination', 'academy-divi-modules' ), 'type' => 'yes_no_button', 'default' => '', 'options' => array( 'yes' => esc_html__( 'Show', 'academy-divi-modules' ), 'no' => esc_html__( 'Hide', 'academy-divi-modules' ), ), 'tab_slug' => 'general', 'toggle_slug' => 'layout', 'mobile_options' => true, 'computed_affects' => array( '__shortcode', ), ), // Shortcode for render in edit mode '__shortcode' => array( 'type' => 'computed', // Change type to computed 'toggle_slug' => 'content', 'computed_callback' => array( 'ACDM_AcademyCourseGrid', 'get_shortcode', ), 'computed_depends_on' => array( 'course_count', 'price_type', 'course_level', 'order', 'order_by', 'course_categories', 'course_tags', 'include_ids', 'exclude_ids', 'allow_course_pagination' ), ), // Course Card Styles 'card_colors' => array( 'label' => esc_html__( 'Background Color', 'academy-divi-modules' ), 'tab_slug' => 'advanced', 'toggle_slug' => 'course_card', 'type' => 'composite', 'composite_type' => 'default', 'composite_structure' => array( 'normal_color' => array( 'label' => esc_html( 'Normal', 'academy-divi-modules' ), 'controls' => array( 'card_background_color' => array( 'type' => 'color', 'tab_slug' => 'advanced', 'toggle_slug' => 'course_card', ), ), ), 'hover_color' => array( 'label' => esc_html( 'Hover', 'academy-divi-modules' ), 'controls' => array( 'card_background_hover_color' => array( 'type' => 'color', 'tab_slug' => 'advanced', 'toggle_slug' => 'course_card', ), ), ), ), ), 'card_margin' => array( 'label' => esc_html__( 'Margin', 'academy-divi-modules' ), 'type' => 'range', 'tab_slug' => 'advanced', 'toggle_slug' => 'course_card', 'mobile_options' => true, ), 'card_padding' => array( 'label' => esc_html__( 'Padding', 'academy-divi-modules' ), 'type' => 'range', 'tab_slug' => 'advanced', 'toggle_slug' => 'course_card', 'mobile_options' => true, ), // Course Title Styles 'title_hover_color' => array( 'label' => esc_html__( 'Hover Color', 'academy-divi-modules' ), 'type' => 'color', 'tab_slug' => 'advanced', 'toggle_slug' => 'course_title', ), // Course Category Styles 'category_hover_color' => array( 'label' => esc_html__( 'Hover Color', 'academy-divi-modules' ), 'type' => 'color', 'tab_slug' => 'advanced', 'toggle_slug' => 'course_category', ), // Course Author Styles 'author_hover_color' => array( 'label' => esc_html__( 'Hover Color', 'academy-divi-modules' ), 'type' => 'color', 'tab_slug' => 'advanced', 'toggle_slug' => 'course_author', ), // Course Rating Styles 'rating_hover_color' => array( 'label' => esc_html__( 'Hover Color', 'academy-divi-modules' ), 'type' => 'color', 'tab_slug' => 'advanced', 'toggle_slug' => 'course_rating', ), // Course Price Styles 'price_hover_color' => array( 'label' => esc_html__( 'Hover Color', 'academy-divi-modules' ), 'type' => 'color', 'tab_slug' => 'advanced', 'toggle_slug' => 'course_price', ), // Wishlist Icon Styles 'wishlist_icon_colors' => array( 'label' => esc_html__( 'Color', 'academy-divi-modules' ), 'tab_slug' => 'advanced', 'toggle_slug' => 'wishlist_icon', 'type' => 'composite', 'composite_type' => 'default', 'composite_structure' => array( 'normal_color' => array( 'label' => esc_html( 'Normal', 'academy-divi-modules' ), 'controls' => array( 'wishlist_icon_color' => array( 'type' => 'color', 'tab_slug' => 'advanced', 'toggle_slug' => 'wishlist_icon', ), ), ), 'hover_color' => array( 'label' => esc_html( 'Hover', 'academy-divi-modules' ), 'controls' => array( 'wishlist_icon_hover_color' => array( 'type' => 'color', 'tab_slug' => 'advanced', 'toggle_slug' => 'wishlist_icon', ), ), ), ), ), 'wishlist_icon_bg_colors' => array( 'label' => esc_html__( 'Background Color', 'academy-divi-modules' ), 'tab_slug' => 'advanced', 'toggle_slug' => 'wishlist_icon', 'type' => 'composite', 'composite_type' => 'default', 'composite_structure' => array( 'normal_bg_color' => array( 'label' => esc_html( 'Normal', 'academy-divi-modules' ), 'controls' => array( 'wishlist_icon_bg_color' => array( 'type' => 'color', 'tab_slug' => 'advanced', 'toggle_slug' => 'wishlist_icon', ), ), ), 'hover_bg_color' => array( 'label' => esc_html( 'Hover', 'academy-divi-modules' ), 'controls' => array( 'wishlist_icon_bg_hover_color' => array( 'type' => 'color', 'tab_slug' => 'advanced', 'toggle_slug' => 'wishlist_icon', ), ), ), ), ), 'wishlist_position_left' => array( 'label' => esc_html__( 'Position Left', 'academy-divi-modules' ), 'type' => 'range', 'tab_slug' => 'advanced', 'toggle_slug' => 'wishlist_icon', 'mobile_options' => true, ), 'wishlist_position_top' => array( 'label' => esc_html__( 'Position Top', 'academy-divi-modules' ), 'type' => 'range', 'tab_slug' => 'advanced', 'toggle_slug' => 'wishlist_icon', 'mobile_options' => true, ), ); } public static function get_shortcode($settings = array()) { $attr_array = [ 'ids' => $settings['include_ids'], 'exclude_ids' => $settings['exclude_ids'], 'category' => $settings['course_categories'], 'course_level' => $settings['course_level'], 'price_type' => $settings['price_type'], 'tag' => $settings['course_tags'], 'orderby' => $settings['order_by'], 'order' => $settings['order'], 'count' => $settings['course_count'] ? $settings['course_count'] : -1, 'has_pagination' => 'on' === $settings['allow_course_pagination'] ? 'true' : '', ]; $shortcode_output = '
[academy_courses ' . Helper::attr_shortcide( $attr_array ) . ']
'; return do_shortcode($shortcode_output); } public function render( $attrs, $content = null, $render_slug = null ) { ET_Builder_Element::set_style( $render_slug, array( 'selector' => '.academy-course-grid .academy-courses .academy-course', 'declaration' => sprintf( 'background-color: %1$s;', esc_html( $this->props['card_background_color'] ) ), )); ET_Builder_Element::set_style( $render_slug, array( 'selector' => '%%order_class%% .academy-course:hover', 'declaration' => sprintf( 'background-color: %1$s;', esc_html( $this->props['card_background_hover_color'] ) ), )); ET_Builder_Element::set_style( $render_slug, array( 'selector' => '.academy-course-grid .academy-courses .academy-course', 'declaration' => sprintf( 'margin: %1$s;', esc_html( $this->props['card_margin'].'px') ), )); ET_Builder_Element::set_style( $render_slug, array( 'selector' => '.academy-course-grid .academy-courses .academy-course', 'declaration' => sprintf( 'padding: %1$s;', esc_html( $this->props['card_padding'].'px') ), )); ET_Builder_Element::set_style( $render_slug, array( 'selector' => '.academy-course-grid .academy-course:hover .academy-course__title a', 'declaration' => sprintf( 'color: %1$s;', esc_html( $this->props['title_hover_color'] ) ), )); ET_Builder_Element::set_style( $render_slug, array( 'selector' => '.academy-course:hover .academy-course__meta--categroy a', 'declaration' => sprintf( 'color: %1$s;', esc_html( $this->props['category_hover_color'] ) ), )); ET_Builder_Element::set_style( $render_slug, array( 'selector' => '.academy-course-grid .academy-course:hover .academy-course__author a', 'declaration' => sprintf( 'color: %1$s;', esc_html( $this->props['author_hover_color'] ) ), )); ET_Builder_Element::set_style( $render_slug, array( 'selector' => '.academy-course-grid .academy-course:hover .academy-course__rating .academy-group-star i::before', 'declaration' => sprintf( 'color: %1$s;', esc_html( $this->props['rating_hover_color'] ) ), )); ET_Builder_Element::set_style( $render_slug, array( 'selector' => '.academy-course-grid .academy-course:hover .academy-course__price', 'declaration' => sprintf( 'color: %1$s;', esc_html( $this->props['price_hover_color'] ) ), )); ET_Builder_Element::set_style( $render_slug, array( 'selector' => '.academy-course-grid .academy-courses .academy-course__header .academy-course-header-meta__wishlist', 'declaration' => sprintf( 'color: %1$s;', esc_html( $this->props['wishlist_icon_color'] ) ), )); ET_Builder_Element::set_style( $render_slug, array( 'selector' => '.academy-course-grid .academy-course-header-meta__wishlist.academy-add-to-wishlist-btn:hover', 'declaration' => sprintf( 'color: %1$s;', esc_html( $this->props['wishlist_icon_hover_color'] ) ), )); ET_Builder_Element::set_style( $render_slug, array( 'selector' => '.academy-course-grid .academy-courses .academy-course__header .academy-course-header-meta__wishlist', 'declaration' => sprintf( 'background-color: %1$s;', esc_html( $this->props['wishlist_icon_bg_color'] ) ), )); ET_Builder_Element::set_style( $render_slug, array( 'selector' => '.academy-course-grid .academy-course-header-meta__wishlist.academy-add-to-wishlist-btn:hover', 'declaration' => sprintf( 'background-color: %1$s;', esc_html( $this->props['wishlist_icon_bg_hover_color'] ) ), )); ET_Builder_Element::set_style( $render_slug, array( 'selector' => '.academy-course-grid .academy-courses .academy-course__header .academy-course-header-meta', 'declaration' => sprintf( 'left: %1$s;', esc_html( $this->props['wishlist_position_left'] ) ), )); ET_Builder_Element::set_style( $render_slug, array( 'selector' => '.academy-course-grid .academy-courses .academy-course__header .academy-course-header-meta', 'declaration' => sprintf( 'top: %1$s;', esc_html( $this->props['wishlist_position_top'] ) ), )); $output = self::get_shortcode( $this->props ); // Render empty string if no output is generated to avoid unwanted vertical space. if ( '' === $output ) { return ''; } return $this->_render_module_wrapper( $output, $render_slug ); } } new ACDM_AcademyCourseGrid();