| @@ -1,153 +1,153 @@ | ||
| 1 | -<?php | |
| 2 | -/** | |
| 3 | - * Elementor Controls for widget Become a teacher settings. | |
| 4 | - * | |
| 5 | - * @since 4.2.3 | |
| 6 | - * @version 1.0.0 | |
| 7 | - */ | |
| 8 | - | |
| 9 | -use Elementor\Controls_Manager; | |
| 10 | -use LearnPress\ExternalPlugin\Elementor\LPElementorControls; | |
| 11 | -use LearnPress\Models\Courses; | |
| 12 | - | |
| 13 | -$filter = new LP_Course_Filter(); | |
| 14 | -$filter->limit = -1; | |
| 15 | -$filter->only_fields = array( 'ID', 'post_title' ); | |
| 16 | -$filter->post_status = [ 'publish' ]; | |
| 17 | -$courses_obj = (array) Courses::get_courses( $filter ); | |
| 18 | -$courses = []; | |
| 19 | -$categories = []; | |
| 20 | - | |
| 21 | -// Only show courses and categories in Admin | |
| 22 | -if ( is_admin() ) { | |
| 23 | - foreach ( $courses_obj as $course ) { | |
| 24 | - $courses[ $course->ID ] = $course->post_title; | |
| 25 | - } | |
| 26 | - | |
| 27 | - $categories_obj = LP_Course::get_all_categories(); | |
| 28 | - foreach ( $categories_obj as $category ) { | |
| 29 | - $categories[ $category->term_id ] = $category->name; | |
| 30 | - } | |
| 31 | -} | |
| 32 | - | |
| 33 | -// Fields tab content | |
| 34 | -$content_fields = LPElementorControls::add_fields_in_section( | |
| 35 | - 'content', | |
| 36 | - esc_html__( 'Content', 'learnpress' ), | |
| 37 | - Controls_Manager::TAB_CONTENT, | |
| 38 | - [ | |
| 39 | - 'layout' => LPElementorControls::add_control_type_select( | |
| 40 | - 'layout', | |
| 41 | - esc_html__( 'Layout', 'learnpress' ), | |
| 42 | - [ | |
| 43 | - 'list' => esc_html__( 'List', 'learnpress' ), | |
| 44 | - 'grid' => esc_html__( 'Grid', 'learnpress' ), | |
| 45 | - ], | |
| 46 | - 'grid' | |
| 47 | - ), | |
| 48 | - 'courses_ids' => LPElementorControls::add_control_type( | |
| 49 | - 'courses_ids', | |
| 50 | - esc_html__( 'Select Courses', 'learnpress' ), | |
| 51 | - [], | |
| 52 | - Controls_Manager::SELECT2, | |
| 53 | - [ | |
| 54 | - 'multiple' => true, | |
| 55 | - 'options' => $courses, | |
| 56 | - ] | |
| 57 | - ), | |
| 58 | - 'category_ids' => LPElementorControls::add_control_type( | |
| 59 | - 'category_ids', | |
| 60 | - esc_html__( 'Select Categories', 'learnpress' ), | |
| 61 | - [], | |
| 62 | - Controls_Manager::SELECT2, | |
| 63 | - [ | |
| 64 | - 'multiple' => true, | |
| 65 | - 'options' => $categories, | |
| 66 | - ] | |
| 67 | - ), | |
| 68 | - 'sort_in' => LPElementorControls::add_control_type_select( | |
| 69 | - 'sort_in', | |
| 70 | - esc_html__( 'Sort In', 'learnpress' ), | |
| 71 | - [ | |
| 72 | - '' => esc_html__( 'Default', 'learnpress' ), | |
| 73 | - 'recent' => esc_html__( 'Recent', 'learnpress' ), | |
| 74 | - 'popular' => esc_html__( 'Popular', 'learnpress' ), | |
| 75 | - 'featured' => esc_html__( 'Featured', 'learnpress' ), | |
| 76 | - ], | |
| 77 | - '' | |
| 78 | - ), | |
| 79 | - 'order_by' => LPElementorControls::add_control_type_select( | |
| 80 | - 'order_by', | |
| 81 | - esc_html__( 'Order By', 'learnpress' ), | |
| 82 | - [ | |
| 83 | - 'DESC' => esc_html__( 'DESC', 'learnpress' ), | |
| 84 | - 'ASC' => esc_html__( 'ASC', 'learnpress' ), | |
| 85 | - ], | |
| 86 | - 'ASC' | |
| 87 | - ), | |
| 88 | - 'limit' => LPElementorControls::add_control_type( | |
| 89 | - 'limit', | |
| 90 | - esc_html__( 'Limit', 'learnpress' ), | |
| 91 | - 5, | |
| 92 | - Controls_Manager::NUMBER, | |
| 93 | - [ | |
| 94 | - 'min' => -1, | |
| 95 | - 'max' => 100, | |
| 96 | - ] | |
| 97 | - ), | |
| 98 | - ] | |
| 99 | -); | |
| 100 | - | |
| 101 | -// Fields tab style | |
| 102 | -$style_fields = array_merge( | |
| 103 | - LPElementorControls::add_fields_in_section( | |
| 104 | - 'title', | |
| 105 | - esc_html__( 'Title Course', 'learnpress' ), | |
| 106 | - Controls_Manager::TAB_STYLE, | |
| 107 | - LPElementorControls::add_controls_style_text( | |
| 108 | - 'title', | |
| 109 | - '.learn-press-courses .course-item .course-title' | |
| 110 | - ) | |
| 111 | - ), | |
| 112 | - LPElementorControls::add_fields_in_section( | |
| 113 | - 'instructor', | |
| 114 | - esc_html__( 'Title Instructor', 'learnpress' ), | |
| 115 | - Controls_Manager::TAB_STYLE, | |
| 116 | - LPElementorControls::add_controls_style_text( | |
| 117 | - 'instructor', | |
| 118 | - '.learn-press-courses .course-item .course-instructor a' | |
| 119 | - ) | |
| 120 | - ), | |
| 121 | - LPElementorControls::add_fields_in_section( | |
| 122 | - 'price', | |
| 123 | - esc_html__( 'Price', 'learnpress' ), | |
| 124 | - Controls_Manager::TAB_STYLE, | |
| 125 | - LPElementorControls::add_controls_style_text( | |
| 126 | - 'price', | |
| 127 | - '.learn-press-courses .course-item .course-price' | |
| 128 | - ) | |
| 129 | - ), | |
| 130 | - LPElementorControls::add_fields_in_section( | |
| 131 | - 'course_image', | |
| 132 | - esc_html__( 'Course Image', 'learnpress' ), | |
| 133 | - Controls_Manager::TAB_STYLE, | |
| 134 | - LPElementorControls::add_controls_style_image( | |
| 135 | - 'course_image', | |
| 136 | - '.learn-press-courses .course-item img' | |
| 137 | - ) | |
| 138 | - ) | |
| 139 | -); | |
| 140 | - | |
| 141 | -return apply_filters( | |
| 142 | - 'learn-press/elementor/course/list-courses', | |
| 143 | - array_merge( | |
| 144 | - apply_filters( | |
| 145 | - 'learn-press/elementor/course/list-courses/tab-content', | |
| 146 | - $content_fields | |
| 147 | - ), | |
| 148 | - apply_filters( | |
| 149 | - 'learn-press/elementor/course/list-courses/tab-styles', | |
| 150 | - $style_fields | |
| 151 | - ) | |
| 152 | - ) | |
| 153 | -); | |
| 1 | +<?php | |
| 2 | +/** | |
| 3 | + * Elementor Controls for widget Become a teacher settings. | |
| 4 | + * | |
| 5 | + * @since 4.2.3 | |
| 6 | + * @version 1.0.0 | |
| 7 | + */ | |
| 8 | + | |
| 9 | +use Elementor\Controls_Manager; | |
| 10 | +use LearnPress\ExternalPlugin\Elementor\LPElementorControls; | |
| 11 | +use LearnPress\Models\Courses; | |
| 12 | + | |
| 13 | +$filter = new LP_Course_Filter(); | |
| 14 | +$filter->limit = -1; | |
| 15 | +$filter->only_fields = array( 'ID', 'post_title' ); | |
| 16 | +$filter->post_status = [ 'publish' ]; | |
| 17 | +$courses_obj = (array) Courses::get_courses( $filter ); | |
| 18 | +$courses = []; | |
| 19 | +$categories = []; | |
| 20 | + | |
| 21 | +// Only show courses and categories in Admin | |
| 22 | +if ( is_admin() ) { | |
| 23 | + foreach ( $courses_obj as $course ) { | |
| 24 | + $courses[ $course->ID ] = $course->post_title; | |
| 25 | + } | |
| 26 | + | |
| 27 | + $categories_obj = LP_Course::get_all_categories(); | |
| 28 | + foreach ( $categories_obj as $category ) { | |
| 29 | + $categories[ $category->term_id ] = $category->name; | |
| 30 | + } | |
| 31 | +} | |
| 32 | + | |
| 33 | +// Fields tab content | |
| 34 | +$content_fields = LPElementorControls::add_fields_in_section( | |
| 35 | + 'content', | |
| 36 | + esc_html__( 'Content', 'learnpress' ), | |
| 37 | + Controls_Manager::TAB_CONTENT, | |
| 38 | + [ | |
| 39 | + 'layout' => LPElementorControls::add_control_type_select( | |
| 40 | + 'layout', | |
| 41 | + esc_html__( 'Layout', 'learnpress' ), | |
| 42 | + [ | |
| 43 | + 'list' => esc_html__( 'List', 'learnpress' ), | |
| 44 | + 'grid' => esc_html__( 'Grid', 'learnpress' ), | |
| 45 | + ], | |
| 46 | + 'grid' | |
| 47 | + ), | |
| 48 | + 'courses_ids' => LPElementorControls::add_control_type( | |
| 49 | + 'courses_ids', | |
| 50 | + esc_html__( 'Select Courses', 'learnpress' ), | |
| 51 | + [], | |
| 52 | + Controls_Manager::SELECT2, | |
| 53 | + [ | |
| 54 | + 'multiple' => true, | |
| 55 | + 'options' => $courses, | |
| 56 | + ] | |
| 57 | + ), | |
| 58 | + 'category_ids' => LPElementorControls::add_control_type( | |
| 59 | + 'category_ids', | |
| 60 | + esc_html__( 'Select Categories', 'learnpress' ), | |
| 61 | + [], | |
| 62 | + Controls_Manager::SELECT2, | |
| 63 | + [ | |
| 64 | + 'multiple' => true, | |
| 65 | + 'options' => $categories, | |
| 66 | + ] | |
| 67 | + ), | |
| 68 | + 'sort_in' => LPElementorControls::add_control_type_select( | |
| 69 | + 'sort_in', | |
| 70 | + esc_html__( 'Sort In', 'learnpress' ), | |
| 71 | + [ | |
| 72 | + '' => esc_html__( 'Default', 'learnpress' ), | |
| 73 | + 'recent' => esc_html__( 'Recent', 'learnpress' ), | |
| 74 | + 'popular' => esc_html__( 'Popular', 'learnpress' ), | |
| 75 | + 'featured' => esc_html__( 'Featured', 'learnpress' ), | |
| 76 | + ], | |
| 77 | + '' | |
| 78 | + ), | |
| 79 | + 'order_by' => LPElementorControls::add_control_type_select( | |
| 80 | + 'order_by', | |
| 81 | + esc_html__( 'Order By', 'learnpress' ), | |
| 82 | + [ | |
| 83 | + 'DESC' => esc_html__( 'DESC', 'learnpress' ), | |
| 84 | + 'ASC' => esc_html__( 'ASC', 'learnpress' ), | |
| 85 | + ], | |
| 86 | + 'ASC' | |
| 87 | + ), | |
| 88 | + 'limit' => LPElementorControls::add_control_type( | |
| 89 | + 'limit', | |
| 90 | + esc_html__( 'Limit', 'learnpress' ), | |
| 91 | + 5, | |
| 92 | + Controls_Manager::NUMBER, | |
| 93 | + [ | |
| 94 | + 'min' => -1, | |
| 95 | + 'max' => 100, | |
| 96 | + ] | |
| 97 | + ), | |
| 98 | + ] | |
| 99 | +); | |
| 100 | + | |
| 101 | +// Fields tab style | |
| 102 | +$style_fields = array_merge( | |
| 103 | + LPElementorControls::add_fields_in_section( | |
| 104 | + 'title', | |
| 105 | + esc_html__( 'Title Course', 'learnpress' ), | |
| 106 | + Controls_Manager::TAB_STYLE, | |
| 107 | + LPElementorControls::add_controls_style_text( | |
| 108 | + 'title', | |
| 109 | + '.learn-press-courses .course-item .course-title' | |
| 110 | + ) | |
| 111 | + ), | |
| 112 | + LPElementorControls::add_fields_in_section( | |
| 113 | + 'instructor', | |
| 114 | + esc_html__( 'Title Instructor', 'learnpress' ), | |
| 115 | + Controls_Manager::TAB_STYLE, | |
| 116 | + LPElementorControls::add_controls_style_text( | |
| 117 | + 'instructor', | |
| 118 | + '.learn-press-courses .course-item .course-instructor a' | |
| 119 | + ) | |
| 120 | + ), | |
| 121 | + LPElementorControls::add_fields_in_section( | |
| 122 | + 'price', | |
| 123 | + esc_html__( 'Price', 'learnpress' ), | |
| 124 | + Controls_Manager::TAB_STYLE, | |
| 125 | + LPElementorControls::add_controls_style_text( | |
| 126 | + 'price', | |
| 127 | + '.learn-press-courses .course-item .course-price' | |
| 128 | + ) | |
| 129 | + ), | |
| 130 | + LPElementorControls::add_fields_in_section( | |
| 131 | + 'course_image', | |
| 132 | + esc_html__( 'Course Image', 'learnpress' ), | |
| 133 | + Controls_Manager::TAB_STYLE, | |
| 134 | + LPElementorControls::add_controls_style_image( | |
| 135 | + 'course_image', | |
| 136 | + '.learn-press-courses .course-item img' | |
| 137 | + ) | |
| 138 | + ) | |
| 139 | +); | |
| 140 | + | |
| 141 | +return apply_filters( | |
| 142 | + 'learn-press/elementor/course/list-courses', | |
| 143 | + array_merge( | |
| 144 | + apply_filters( | |
| 145 | + 'learn-press/elementor/course/list-courses/tab-content', | |
| 146 | + $content_fields | |
| 147 | + ), | |
| 148 | + apply_filters( | |
| 149 | + 'learn-press/elementor/course/list-courses/tab-styles', | |
| 150 | + $style_fields | |
| 151 | + ) | |
| 152 | + ) | |
| 153 | +); | |