| 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 Elementor\Group_Control_Border; |
| 11 |
use LearnPress\ExternalPlugin\Elementor\LPElementorControls; |
| 12 |
|
| 13 |
$option_data = []; |
| 14 |
if ( isset( $options ) ) { |
| 15 |
$option_data = $options; |
| 16 |
} |
| 17 |
|
| 18 |
// Fields tab content |
| 19 |
$content_fields = array_merge( |
| 20 |
LPElementorControls::add_fields_in_section( |
| 21 |
'layouts', |
| 22 |
esc_html__( 'Layout Item Instructor', 'learnpress' ), |
| 23 |
Controls_Manager::TAB_CONTENT, |
| 24 |
[ |
| 25 |
LPElementorControls::add_control_type( |
| 26 |
'item_layouts', |
| 27 |
esc_html__( 'Add layout and drag to top to set Active', 'learnpress' ), |
| 28 |
[ |
| 29 |
[ |
| 30 |
'layout_name' => 'Layout Default', |
| 31 |
'layout_html' => '{{instructor_avatar}}<a href="{{instructor_url}}" style="display: block">{{instructor_display_name}}</a><p>{{instructor_total_courses}}</p>{{instructor_total_students}}', |
| 32 |
], |
| 33 |
], |
| 34 |
Controls_Manager::REPEATER, |
| 35 |
[ |
| 36 |
'fields' => [ |
| 37 |
[ |
| 38 |
'name' => 'layout_name', |
| 39 |
'label' => esc_html__( 'Layout Name', 'learnpress' ), |
| 40 |
'type' => Controls_Manager::TEXT, |
| 41 |
'label_block' => true, |
| 42 |
], |
| 43 |
[ |
| 44 |
'name' => 'layout_html', |
| 45 |
'label' => esc_html__( 'Layout HTML', 'learnpress' ), |
| 46 |
'type' => Controls_Manager::WYSIWYG, |
| 47 |
'description' => 'Sections: {{instructor_avatar}}, {{instructor_url}}, {{instructor_display_name}}, {{instructor_total_courses}}, {{instructor_total_students}}', |
| 48 |
'label_block' => true, |
| 49 |
], |
| 50 |
// Toggle Style Ul |
| 51 |
[ |
| 52 |
'name' => 'toggle-ul-style', |
| 53 |
'label' => esc_html__( 'Ul Style', 'learnpress' ), |
| 54 |
'type' => Controls_Manager::POPOVER_TOGGLE, |
| 55 |
'label_off' => esc_html__( 'Default', 'learnpress' ), |
| 56 |
'label_on' => esc_html__( 'Custom', 'learnpress' ), |
| 57 |
'return_value' => 'yes', |
| 58 |
], |
| 59 |
[ |
| 60 |
'method' => 'start_popover', |
| 61 |
], |
| 62 |
[ |
| 63 |
'name' => 'grid_columns', |
| 64 |
'label' => esc_html__( 'Column number', 'learnpress' ), |
| 65 |
'method' => 'add_responsive_control', |
| 66 |
'type' => Controls_Manager::NUMBER, |
| 67 |
'min' => 1, |
| 68 |
'max' => 6, |
| 69 |
'default' => 2, |
| 70 |
'description' => 'Number of columns to show.', |
| 71 |
'selectors' => [ |
| 72 |
'{{WRAPPER}} {{CURRENT_ITEM}} .list-instructors' => 'display: grid;list-style: none;grid-template-columns: repeat({{VALUE}}, 1fr);padding: 0;margin: 0;', |
| 73 |
], |
| 74 |
], |
| 75 |
[ |
| 76 |
'name' => 'gap_column', |
| 77 |
'label' => esc_html__( 'Gap', 'learnpress' ), |
| 78 |
'method' => 'add_responsive_control', |
| 79 |
'type' => Controls_Manager::SLIDER, |
| 80 |
'default' => [ |
| 81 |
'unit' => 'px', |
| 82 |
'size' => 10, |
| 83 |
], |
| 84 |
'unit' => 'px', |
| 85 |
'min' => 0, |
| 86 |
'max' => 100, |
| 87 |
'description' => 'Space between items. (px)', |
| 88 |
'selectors' => [ |
| 89 |
'{{WRAPPER}} {{CURRENT_ITEM}} .list-instructors' => 'grid-gap: {{SIZE}}{{UNIT}};', |
| 90 |
], |
| 91 |
], |
| 92 |
[ |
| 93 |
'name' => 'item_padding', |
| 94 |
'label' => esc_html__( 'Item Padding', 'learnpress' ), |
| 95 |
'method' => 'add_responsive_control', |
| 96 |
'type' => Controls_Manager::DIMENSIONS, |
| 97 |
'default' => [ |
| 98 |
'top' => '10', |
| 99 |
'right' => '10', |
| 100 |
'bottom' => '10', |
| 101 |
'left' => '10', |
| 102 |
], |
| 103 |
'selectors' => [ |
| 104 |
'{{WRAPPER}} {{CURRENT_ITEM}} .list-instructors .item-instructor' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 105 |
], |
| 106 |
], |
| 107 |
[ 'method' => 'end_popover' ], |
| 108 |
// Toggle Item Border |
| 109 |
[ |
| 110 |
'name' => 'toggle-item-border', |
| 111 |
'label' => esc_html__( 'Item border', 'learnpress' ), |
| 112 |
'type' => Controls_Manager::POPOVER_TOGGLE, |
| 113 |
], |
| 114 |
[ |
| 115 |
'method' => 'start_popover', |
| 116 |
], |
| 117 |
[ |
| 118 |
'name' => 'item_border', |
| 119 |
'label' => esc_html__( 'Item Border', 'learnpress' ), |
| 120 |
'method' => 'add_group_control', |
| 121 |
'type' => Group_Control_Border::get_type(), |
| 122 |
'description' => 'Number of columns to show.', |
| 123 |
'selector' => '{{WRAPPER}} {{CURRENT_ITEM}} .list-instructors .item-instructor', |
| 124 |
'fields_options' => [ |
| 125 |
'border' => [ |
| 126 |
'default' => 'none', |
| 127 |
], |
| 128 |
'width' => [ |
| 129 |
'default' => [ |
| 130 |
'top' => '1', |
| 131 |
'right' => '1', |
| 132 |
'bottom' => '1', |
| 133 |
'left' => '1', |
| 134 |
'isLinked' => true, |
| 135 |
], |
| 136 |
], |
| 137 |
'color' => [ |
| 138 |
'default' => '#D4D4D4', |
| 139 |
], |
| 140 |
], |
| 141 |
], |
| 142 |
[ |
| 143 |
'name' => 'item_border_radius', |
| 144 |
'label' => esc_html__( 'Border Radius', 'learnpress' ), |
| 145 |
'type' => Controls_Manager::DIMENSIONS, |
| 146 |
'selectors' => [ |
| 147 |
'{{WRAPPER}} {{CURRENT_ITEM}} .list-instructors .item-instructor' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 148 |
], |
| 149 |
], |
| 150 |
[ 'method' => 'end_popover' ], |
| 151 |
// Toggle Custom Css |
| 152 |
[ |
| 153 |
'name' => 'toggle-custom-css', |
| 154 |
'label' => esc_html__( 'Advanced Css', 'learnpress' ), |
| 155 |
'type' => Controls_Manager::POPOVER_TOGGLE, |
| 156 |
], |
| 157 |
[ |
| 158 |
'method' => 'start_popover', |
| 159 |
], |
| 160 |
[ |
| 161 |
'name' => 'layout_custom_css', |
| 162 |
'label' => esc_html__( 'Custom CSS', 'learnpress' ), |
| 163 |
'type' => Controls_Manager::CODE, |
| 164 |
'label_block' => true, |
| 165 |
'language' => 'css', |
| 166 |
'description' => 'Should start with selector before style. Ex: selector .[className] {color: red;}', |
| 167 |
], |
| 168 |
[ 'method' => 'end_popover' ], |
| 169 |
], |
| 170 |
'prevent_empty' => false, |
| 171 |
'title_field' => '{{{ layout_name }}}', |
| 172 |
] |
| 173 |
), |
| 174 |
] |
| 175 |
), |
| 176 |
LPElementorControls::add_fields_in_section( |
| 177 |
'content', |
| 178 |
esc_html__( 'Content', 'learnpress' ), |
| 179 |
Controls_Manager::TAB_CONTENT, |
| 180 |
[ |
| 181 |
/*'instructor_ids' => LPElementorControls::add_control_type( |
| 182 |
'instructor_ids', |
| 183 |
esc_html__( 'Select Instructor ID', 'learnpress' ), |
| 184 |
[], |
| 185 |
Controls_Manager::TEXT, |
| 186 |
[ |
| 187 |
'description' => 'ID of Instructor separated by comma. Ex: 1,2,3', |
| 188 |
] |
| 189 |
), |
| 190 |
'item_per_page' => LPElementorControls::add_control_type( |
| 191 |
'item_per_page', |
| 192 |
esc_html__( 'Item per page', 'learnpress' ), |
| 193 |
5, |
| 194 |
Controls_Manager::NUMBER, |
| 195 |
[ |
| 196 |
'min' => -1, |
| 197 |
'max' => 100, |
| 198 |
] |
| 199 |
),*/ |
| 200 |
'order_by' => LPElementorControls::add_control_type_select( |
| 201 |
'order_by', |
| 202 |
esc_html__( 'Order By', 'learnpress' ), |
| 203 |
[ |
| 204 |
'name' => esc_html__( 'Name a-z', 'learnpress' ), |
| 205 |
'desc_name' => esc_html__( 'Name z-a', 'learnpress' ), |
| 206 |
], |
| 207 |
'name' |
| 208 |
), |
| 209 |
'limit' => LPElementorControls::add_control_type( |
| 210 |
'limit', |
| 211 |
esc_html__( 'Limit', 'learnpress' ), |
| 212 |
5, |
| 213 |
Controls_Manager::NUMBER, |
| 214 |
[ |
| 215 |
'min' => - 1, |
| 216 |
'max' => 100, |
| 217 |
'description' => 'Number of items to show. Enter -1 to show all instructors.', |
| 218 |
] |
| 219 |
), |
| 220 |
] |
| 221 |
), |
| 222 |
[] |
| 223 |
); |
| 224 |
|
| 225 |
// Fields tab style |
| 226 |
$style_fields = []; |
| 227 |
|
| 228 |
return apply_filters( |
| 229 |
'learn-press/elementor/list-instructors', |
| 230 |
array_merge( |
| 231 |
apply_filters( |
| 232 |
'learn-press/elementor/list-instructors/tab-content', |
| 233 |
$content_fields |
| 234 |
), |
| 235 |
apply_filters( |
| 236 |
'learn-press/elementor/list-instructors/tab-styles', |
| 237 |
$style_fields |
| 238 |
) |
| 239 |
) |
| 240 |
); |
| 241 |
|