PluginProbe ʕ •ᴥ•ʔ
Tutor LMS – eLearning and online course solution / 2.1.6
Tutor LMS – eLearning and online course solution v2.1.6
3.9.14 3.9.13 3.9.12 3.9.11 trunk 1.0.0 1.0.0-alpha 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.2.0 1.2.1 1.2.11 1.2.12 1.2.13 1.2.20 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.9 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.6.9 1.7.0 1.7.1 1.7.2 1.7.3 1.7.4 1.7.5 1.7.6 1.7.7 1.7.8 1.7.9 1.8.0 1.8.1 1.8.10 1.8.2 1.8.3 1.8.4 1.8.5 1.8.6 1.8.7 1.8.8 1.8.9 1.9.0 1.9.1 1.9.10 1.9.11 1.9.12 1.9.13 1.9.14 1.9.15 1.9.16 1.9.2 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0.0 2.0.1 2.0.10 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.1.0 2.1.1 2.1.10 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.3.0 2.4.0 2.5.0 2.6.0 2.6.1 2.6.2 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 3.0.0 3.0.1 3.0.2 3.1.0 3.2.0 3.2.1 3.2.2 3.2.3 3.3.0 3.3.1 3.4.0 3.4.1 3.4.2 3.5.0 3.6.0 3.6.1 3.6.2 3.6.3 3.6.4 3.7.0 3.7.1 3.7.2 3.7.3 3.7.4 3.8.0 3.8.1 3.8.2 3.8.3 3.9.0 3.9.1 3.9.10 3.9.2 3.9.3 3.9.4 3.9.5 3.9.6 3.9.7 3.9.8 3.9.9
tutor / classes / Tutor_Setup.php
tutor / classes Last commit date
Addons.php 3 years ago Admin.php 3 years ago Ajax.php 3 years ago Announcements.php 3 years ago Assets.php 3 years ago Backend_Page_Trait.php 3 years ago Course.php 3 years ago Course_Embed.php 3 years ago Course_Filter.php 3 years ago Course_List.php 3 years ago Course_Settings_Tabs.php 3 years ago Course_Widget.php 3 years ago Custom_Validation.php 3 years ago Dashboard.php 3 years ago FormHandler.php 3 years ago Frontend.php 3 years ago Gutenberg.php 3 years ago Input.php 3 years ago Instructor.php 3 years ago Instructors_List.php 3 years ago Lesson.php 3 years ago Options_V2.php 3 years ago Post_types.php 3 years ago Private_Course_Access.php 3 years ago Q_and_A.php 3 years ago Question_Answers_List.php 3 years ago Quiz.php 3 years ago Quiz_Attempts_List.php 3 years ago RestAPI.php 3 years ago Reviews.php 3 years ago Rewrite_Rules.php 3 years ago Shortcode.php 3 years ago Student.php 3 years ago Students_List.php 3 years ago Taxonomies.php 3 years ago Template.php 3 years ago Theme_Compatibility.php 3 years ago Tools.php 3 years ago Tools_V2.php 3 years ago Tutor.php 3 years ago TutorEDD.php 3 years ago Tutor_Base.php 3 years ago Tutor_Setup.php 3 years ago Upgrader.php 3 years ago User.php 3 years ago Utils.php 3 years ago Video_Stream.php 3 years ago Withdraw.php 3 years ago Withdraw_Requests_List.php 3 years ago WooCommerce.php 3 years ago
Tutor_Setup.php
936 lines
1 <?php
2 /**
3 * Tutor setup class
4 *
5 * @package Tutor\Setup
6 * @author Themeum <support@themeum.com>
7 * @link https://themeum.com
8 * @since 1.0.0
9 */
10
11 namespace TUTOR;
12
13 if ( ! defined( 'ABSPATH' ) ) {
14 exit;
15 }
16
17 /**
18 * Manage setup functionalities
19 *
20 * @since 1.0.0
21 */
22 class Tutor_Setup {
23
24 /**
25 * Register hooks
26 *
27 * @since 1.0.0
28 */
29 public function __construct() {
30 add_action( 'admin_menu', array( $this, 'admin_menus' ) );
31 add_action( 'admin_init', array( $this, 'setup_wizard' ) );
32 add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
33 add_action( 'wp_ajax_setup_action', array( $this, 'tutor_setup_action' ) );
34 add_filter( 'tutor_wizard_attributes', array( $this, 'tutor_setup_attributes_callback' ) );
35 }
36
37 /**
38 * Tutor setup attr callback
39 *
40 * @since 1.0.0
41 *
42 * @param mixed $attr attr.
43 *
44 * @return array
45 */
46 public function tutor_setup_attributes_callback( $attr ) {
47 $options = (array) maybe_unserialize( get_option( 'tutor_option' ) );
48 $final_arr = array();
49 $data_arr = $this->tutor_setup_attributes();
50 foreach ( $data_arr as $key => $section ) {
51 foreach ( $section['attr'] as $k => $val ) {
52 $final_arr[ $k ] = isset( $options[ $k ] ) ? $options[ $k ] : '';
53 }
54 }
55 return $final_arr;
56 }
57
58 /**
59 * Setup action
60 *
61 * @since 1.0.0
62 *
63 * @return void send wp_json response
64 */
65 public function tutor_setup_action() {
66 tutor_utils()->checking_nonce();
67
68 $options = (array) maybe_unserialize( get_option( 'tutor_option' ) );
69 $action = Input::post( 'action', '' );
70 if ( 'setup_action' !== $action || ! current_user_can( 'manage_options' ) ) {
71 return;
72 }
73
74 // General Settings.
75 $change_data = apply_filters( 'tutor_wizard_attributes', array() );
76 foreach ( $change_data as $key => $value ) {
77 $post_key = Input::post( $key, '' );
78 if ( Input::has( $key ) ) {
79 if ( $post_key != $change_data[ $key ] ) {
80 if ( '' === $post_key ) {
81 unset( $options[ $key ] );
82 } else {
83 $options[ $key ] = $post_key;
84 }
85 }
86 $options_preset[ $key ] = $post_key;
87 } else {
88 unset( $options[ $key ] );
89 }
90 }
91
92 update_option( 'tutor_default_option', $options_preset );
93 update_option( 'tutor_option', $options );
94
95 // Payment Settings.
96 $payments = (array) maybe_unserialize( get_option( 'tutor_withdraw_options' ) );
97 $payments_data = array( 'bank_transfer_withdraw', 'echeck_withdraw', 'paypal_withdraw' );
98 foreach ( $payments_data as $key ) {
99 $post_key = Input::post( $key, '' );
100 if ( Input::has( $key ) ) {
101 $payments[ $key ]['enabled'] = 1;
102 } else {
103 if ( 'bank_transfer_withdraw' === $key ) {
104 unset( $payments[ $key ]['enabled'] );
105 } else {
106 unset( $payments[ $key ] );
107 }
108 }
109 }
110 update_option( 'tutor_withdraw_options', $payments );
111
112 // Add wizard flag.
113 wp_send_json_success( array( 'status' => 'success' ) );
114 }
115
116 /**
117 * Add dashboard page without title
118 *
119 * @since 1.0.0
120 *
121 * @return void
122 */
123 public function admin_menus() {
124 add_dashboard_page( '', '', 'manage_options', 'tutor-setup', '' );
125 }
126
127 /**
128 * Setup wizard
129 *
130 * @since 1.0.0
131 *
132 * @return void
133 */
134 public function setup_wizard() {
135 $setup_page = Input::get( 'page', '' );
136 if ( 'tutor-setup' === $setup_page ) {
137 $this->tutor_setup_wizard_header();
138 $this->tutor_setup_wizard_boarding();
139 $this->tutor_setup_wizard_type();
140 $this->tutor_setup_wizard_settings();
141 $this->tutor_setup_wizard_footer();
142 exit;
143 }
144 }
145
146 /**
147 * Undocumented function
148 *
149 * @return void
150 */
151 public function tutor_setup_generator() {
152 $i = 1;
153 $html = '';
154 $options = (array) maybe_unserialize( get_option( 'tutor_option' ) );
155 $payments = (array) maybe_unserialize( get_option( 'tutor_withdraw_options' ) );
156 $field_arr = $this->tutor_setup_attributes();
157
158 $down_desc_fields = array( 'rows', 'slider', 'text', 'radio', 'dropdown', 'range', 'payments' );
159 $full_width_fields = array( 'rows', 'slider', 'radio', 'range', 'payments', 'dropdown' );
160
161 foreach ( $field_arr as $key_parent => $field_parent ) {
162 $html .= '<li class="' . ( $i == 1 ? 'active' : '' ) . '">';
163 $html .= '<div class="tutor-setup-content-heading heading">';
164 $html .= '<div class="setup-section-title tutor-fs-6 tutor-fw-medium tutor-color-black">' . $field_parent['lable'] . '</div>';
165 $html .= '<div class="step-info">';
166 $html .= '<span class="tutor-fs-7 tutor-color-muted">' . __( 'Step', 'tutor' ) . ':</span> <strong class="tutor-color-black">' . $i . '/' . count( $field_arr ) . ' </strong>';
167 $html .= '</div>';
168 $html .= '<div class="tutor-reset-section tutor-text-btn-small tutor-color-secondary tutor-d-flex tutor-align-center">' . __( 'Reset Default', 'tutor' ) . '</div>';
169 $html .= '</div>';
170 $html .= '<div class="tutor-setup-content-heading body">';
171
172 foreach ( $field_parent['attr'] as $key => $field ) {
173 if ( ! isset( $field['lable'] ) ) {
174 continue; }
175
176 // Generate data attributes if necessary
177 $data_attr = '';
178 if ( isset( $field['data'] ) && is_array( $field['data'] ) ) {
179 foreach ( $field['data'] as $data_key => $data_value ) {
180 $data_attr .= ' data-' . $data_key . '="' . $data_value . '" ';
181 }
182 }
183
184 $html .= '<div class="tutor-setting' . ( in_array( $field['type'], $full_width_fields ) ? ' course-setting-wrapper' : '' ) . ' ' . ( isset( $field['class'] ) ? $field['class'] : '' ) . '">';
185 $html .= isset( $field['lable'] ) ? '<div class="tutor-fs-6 tutor-color-black ______">' . $field['lable'] : '';
186
187 $html .= isset( $field['tooltip'] ) ? '<span class="tooltip-wrap tooltip-icon"><span class="tooltip-txt tooltip-right">' . $field['tooltip'] . '</span></span>' : '';
188 $html .= isset( $field['lable'] ) ? '</div>' : '';
189
190 if ( ! in_array( $field['type'], $down_desc_fields ) ) {
191 $html .= isset( $field['desc'] ) ? '<div class="content tutor-fs-7 tutor-color-secondary">' . $field['desc'] . '</div>' : '';
192 }
193
194 $html .= '<div class="settings">';
195
196 switch ( $field['type'] ) {
197
198 case 'switch':
199 $html .= '<label for="' . $key . '" class="switch-label input-switch-label">';
200 $html .= '<span class="label-off">' . __( 'OFF', 'tutor' ) . '</span>';
201 $html .= '<div class="switchbox-wrapper">';
202 $html .= '<input ' . $data_attr . ' id="' . $key . '" class="input-switchbox" type="checkbox" name="' . $key . '" value="on" ' . ( isset( $options[ $key ] ) && $options[ $key ] ? 'checked' : '' ) . '/>';
203 $html .= '<span class="switchbox-icon"></span>';
204 $html .= '</div>';
205 $html .= '<span class="label-on">' . __( 'ON', 'tutor' ) . '</span>';
206 $html .= '</label>';
207 break;
208
209 case 'text':
210 $html .= '<input type="text" name="' . $key . '" class="lesson-permalink" value="' . ( isset( $options[ $key ] ) ? $options[ $key ] : '' ) . '" />';
211 break;
212
213 case 'rows':
214 $html .= '<div class="content">';
215 $html .= '<div class="course-per-row">';
216 $html .= '<div class="wrapper">';
217 $html .= '<label for="' . $key . '1">';
218 $html .= '<input type="radio" value="1" name="' . $key . '" class="course" id="' . $key . '1" ' . ( isset( $options[ $key ] ) && $options[ $key ] == 1 ? 'checked' : '' ) . '>';
219 $html .= '<span class="span"><span>1</span></span>';
220 $html .= '</label>';
221 $html .= '</div>';
222 $html .= '<div class="wrapper">';
223 $html .= '<label for="' . $key . '2">';
224 $html .= '<input type="radio" value="2" name="' . $key . '" class="course" id="' . $key . '2" ' . ( isset( $options[ $key ] ) && $options[ $key ] == 2 ? 'checked' : '' ) . '>';
225 $html .= '<span class="span"><span>2</span><span>2</span></span>';
226 $html .= '</label>';
227 $html .= '</div>';
228 $html .= '<div class="wrapper">';
229 $html .= '<label for="' . $key . '3">';
230 $html .= '<input type="radio" value="3" name="' . $key . '" class="course" id="' . $key . '3" ' . ( isset( $options[ $key ] ) && $options[ $key ] == 3 ? 'checked' : '' ) . '>';
231 $html .= '<span class="span"><span>3</span><span>3</span><span>3</span></span>';
232 $html .= '</label>';
233 $html .= '</div>';
234 $html .= '<div class="wrapper">';
235 $html .= '<label for="' . $key . '4">';
236 $html .= '<input type="radio" value="4" name="' . $key . '" class="course" id="' . $key . '4" ' . ( isset( $options[ $key ] ) && $options[ $key ] == 4 ? 'checked' : '' ) . '>';
237 $html .= '<span class="span"><span>4</span><span>4</span><span>4</span><span>4</span></span>';
238 $html .= '</label>';
239 $html .= '</div>';
240 $html .= '</div>';
241 $html .= '</div>';
242 break;
243
244 case 'radio':
245 if ( isset( $field['options'] ) ) {
246 foreach ( $field['options'] as $k => $val ) {
247 $html .= '<label for="' . $key . $k . '" class="time-expires"><input type="radio" id="' . $key . $k . '" name="' . $key . '" value="' . $k . '" ' . ( isset( $options[ $key ] ) && $options[ $key ] == $k ? 'checked' : '' ) . ' /> ' . '<span class="radio-icon"></span>';
248 $html .= $val . '</label>';
249 }
250 }
251 break;
252
253 case 'slider':
254 $available_times = array(
255 'seconds' => __( 'seconds', 'tutor' ),
256 'minutes' => __( 'minutes', 'tutor' ),
257 'hours' => __( 'hours', 'tutor' ),
258 'days' => __( 'days', 'tutor' ),
259 'weeks' => __( 'weeks', 'tutor' ),
260 );
261 $html .= '<div class="limit-slider">';
262 if ( isset( $field['time'] ) ) {
263 $html .= '<input type="range" name="' . $key . '[value]" min="' . ( isset( $field['min'] ) ? $field['min'] : 0 ) . '" max="' . ( isset( $field['max'] ) ? $field['max'] : 60 ) . '" step="1" value="' . ( isset( $options[ $key ]['value'] ) ? $options[ $key ]['value'] : '' ) . '" class="range-input"/>';
264 $html .= '<input type="hidden" name="' . $key . '[time]" value="' . ( isset( $options[ $key ]['time'] ) ? $options[ $key ]['time'] : __( 'minutes', 'tutor' ) ) . '" class="range-input"/>';
265 $html .= '<span class=""><span class="range-value">' . ( isset( $options[ $key ]['value'] ) ? $options[ $key ]['value'] : '' ) . '</span>';
266 $html .= isset( $options[ $key ]['time'] ) ? $available_times[ $options[ $key ]['time'] ] : '';
267 $html .= '</span>';
268 } else {
269 $html .= '<input type="range" name="' . $key . '" min="' . ( isset( $field['min'] ) ? $field['min'] : '' ) . '" max="' . ( isset( $field['max'] ) ? $field['max'] : 30 ) . '" step="1" value="' . ( isset( $options[ $key ] ) ? $options[ $key ] : '' ) . '" class="range-input"/>';
270 $html .= ' <strong class="range-value">' . ( isset( $options[ $key ] ) ? $options[ $key ] : '' ) . '</strong>';
271 }
272 $html .= '</div>';
273 break;
274
275 case 'dropdown':
276 $html .= '<div class="grade-calculation"><div class="select-box"><div class="options-container">';
277 $selected_data = '';
278 if ( isset( $field['options'] ) ) {
279 foreach ( $field['options'] as $val ) {
280 $html .= '<div class="option">';
281 $html .= '<input type="radio" class="radio" id="' . $val['value'] . '" name="' . $key . '" value="' . $val['value'] . '" ' . ( isset( $options[ $key ] ) && $options[ $key ] == $val['value'] ? 'checked' : '' ) . ' />';
282 $html .= '<label for="' . $val['value'] . '">';
283 $html .= '<h3>' . $val['title'] . '</h3>';
284 $html .= '<h5>' . $val['desc'] . '</h5>';
285 $html .= '</label>';
286 $html .= '</div>';
287
288 if ( isset( $options[ $key ] ) && $options[ $key ] == $val['value'] ) {
289 $selected_data .= '<div class="selected">';
290 $selected_data .= '<h3>' . $val['title'] . '</h3>';
291 $selected_data .= '<h5>' . $val['desc'] . '</h5>';
292 $selected_data .= '</div>';
293 }
294 }
295 }
296 $html .= '</div>';
297 $html .= $selected_data ? $selected_data : '<div class="selected"><h3>' . $field['options'][0]['title'] . '</h3><h5>' . $field['options'][0]['desc'] . '</h5></div>';
298 $html .= '</div></div>';
299 break;
300
301 case 'payments':
302 $html .= '<div class="checkbox-wrapper column-3">';
303 $available_withdraw_methods = get_tutor_all_withdrawal_methods();
304 if ( ! empty( $available_withdraw_methods ) ) {
305 foreach ( $available_withdraw_methods as $key => $value ) {
306 $html .= '<div class="payment-setting">';
307 $html .= '<label for="' . $key . '" class="label">';
308 $html .= '<div>';
309 $html .= '<input type="checkbox" name="' . $key . '" id="' . $key . '" class="checkbox payment" ' . ( isset( $payments[ $key ]['enabled'] ) && $payments[ $key ]['enabled'] ? 'checked' : '' ) . ' />';
310 $html .= '<span class="check-icon round"></span>';
311 $html .= '</div>';
312 $html .= '<div>';
313 $html .= '<img src="' . $value['image'] . '" alt="' . $value['method_name'] . '">';
314 $html .= '<h4>' . $value['method_name'] . '</h4>';
315 $html .= '</div>';
316 $html .= '</label>';
317 $html .= '</div>';
318 }
319 }
320 $html .= '</div>';
321 break;
322
323 case 'range':
324 $earning_instructor = isset( $options['earning_instructor_commission'] ) ? $options['earning_instructor_commission'] : 80;
325 $earning_admin = isset( $options['earning_admin_commission'] ) ? $options['earning_admin_commission'] : 20;
326 $html .= '<div class="limit-slider column-1">';
327 $html .= '<div class="limit-slider-has-parent">';
328 $html .= '<input type="range" min="0" max="100" step="1" value="' . $earning_instructor . '" class="range-input double-range-slider" name=""/>';
329 $html .= '</div>';
330 $html .= '<div class="commision-data">';
331 $html .= '<div class="data">';
332 $html .= '<h4 class="range-value-1">' . $earning_instructor . '%</h4>';
333 $html .= '<h5>' . __( 'Instructor', 'tutor' ) . '</h5>';
334 $html .= '<input type="hidden" min="0" max="100" step="1" value="' . $earning_instructor . '" class="range-value-data-1 range-input" name="earning_instructor_commission"/>';
335 $html .= '</div>';
336 $html .= '<div class="data">';
337 $html .= '<h4 class="range-value-2">' . $earning_admin . '%</h4>';
338 $html .= '<h5>' . __( 'Admin / Owner', 'tutor' ) . '</h5>';
339 $html .= '<input type="hidden" min="0" max="100" step="1" value="' . $earning_admin . '" class="range-value-data-2 range-input" name="earning_admin_commission"/>';
340 $html .= '</div>';
341 $html .= '</div>';
342 $html .= '</div> ';
343 break;
344
345 case 'checkbox':
346 $html .= '<div class="checkbox-wrapper column-2">';
347 if ( isset( $field['options'] ) ) {
348 foreach ( $field['options'] as $k => $val ) {
349 $html .= '<div class="email-notification">';
350 $html .= '<label for="' . $key . $k . '" class="label">';
351 $html .= '<div>';
352 $html .= '<input type="checkbox" value="' . $k . '" ' . ( isset( $options[ $key ] ) && $options[ $key ] == $k ? 'checked' : '' ) . ' name="' . $key . '" id="' . $key . $k . '" class="checkbox" />';
353 $html .= '<span class="check-icon square"></span>';
354 $html .= '</div>';
355 $html .= '<div>';
356 $html .= '<h4>' . $val . '</h4>';
357 $html .= '</div>';
358 $html .= '</label>';
359 $html .= '</div>';
360 }
361 }
362 $html .= '</div>';
363 break;
364
365 case 'attempt':
366 $html .= '<div class="tutor-setting course-setting-wrapper">';
367
368 $html .= '<input type="hidden" name="quiz_attempts_allowed" value="' . ( isset( $options[ $key ] ) ? $options[ $key ] : 'off' ) . '">';
369
370 $html .= '<div class="content">';
371 $html .= '<div class="course-per-page attempts-allowed">';
372 $html .= '<div class="wrapper">';
373 $html .= '<label for="attempts-allowed-1">';
374 $html .= '<input type="radio" value="single" name="attempts-allowed" class="course-p" id="attempts-allowed-1" ' . ( isset( $options[ $key ] ) && $options[ $key ] ? 'checked' : '' ) . '>';
375 $html .= '<span class="radio-icon"></span>';
376 $html .= '<span class="label-text label-text-2">';
377 $html .= '<input type="number" value="' . $options[ $key ] . '" name="attempts-allowed-number" class="attempts tutor-form-number-verify" id="attempts-allowed-1" min="' . ( isset( $field['min'] ) ? $field['min'] : 0 ) . '" max="' . ( isset( $field['max'] ) ? $field['max'] : 30 ) . '">';
378 $html .= '</span>';
379 $html .= '</label>';
380 $html .= '</div>';
381 $html .= '<div class="wrapper tutor-unlimited-value">';
382 $html .= '<label for="attempts-allowed-2">';
383 $html .= '<input type="radio" name="attempts-allowed" value="unlimited" class="course-p" id="attempts-allowed-2" ' . ( ( ! isset( $options[ $key ] ) ) || $options[ $key ] == 0 ? 'checked' : '' ) . '>';
384 $html .= '<span class="radio-icon"></span>';
385 $html .= '<span class="label-text">' . __( 'Unlimited', 'tutor' ) . '</span>';
386 $html .= '</label>';
387 $html .= '</div>';
388 $html .= '</div>';
389 $html .= '</div>';
390 $html .= '</div>';
391 break;
392
393 default:
394 // code...
395 break;
396 }
397
398 if ( in_array( $field['type'], $down_desc_fields ) ) {
399 $html .= isset( $field['desc'] ) ? '<div class="content">' . $field['desc'] . '</div>' : '';
400 }
401 $html .= '</div>';
402 $html .= '</div>';
403
404 }
405 $html .= '</div>';
406 if ( 'payments' !== $field['type'] ) {
407 $html .= $this->tutor_setup_wizard_action();
408 } else {
409 $html .= $this->tutor_setup_wizard_action_final();
410 }
411 $html .= '</li>';
412 $i++;
413 }
414
415 echo tutor_kses_html( $html );
416 }
417
418 /**
419 * Setup attrs
420 *
421 * @since 1.0.0
422 *
423 * @return array
424 */
425 public function tutor_setup_attributes() {
426 $general_fields = array(
427
428 'general' => array(
429 'lable' => __( 'General Settings', 'tutor' ),
430 'attr' => array(
431 'enable_course_marketplace' => array(
432 'type' => 'marketplace',
433 ),
434 'public_profile_layout' => array(
435 'type' => 'switch',
436 'data' => array(
437 'off' => 'private',
438 'on' => 'pp-rectangle',
439 ),
440 'lable' => __( 'Instructor Profile', 'tutor' ),
441 'desc' => __( 'Allow users to have a instructor profile to showcase awards and completed courses.', 'tutor' ),
442 ),
443 'student_public_profile_layout' => array(
444 'type' => 'switch',
445 'data' => array(
446 'off' => 'private',
447 'on' => 'pp-rectangle',
448 ),
449 'lable' => __( 'Student Profile', 'tutor' ),
450 'desc' => __( 'Allow users to have a student profile to showcase awards and completed courses.', 'tutor' ),
451 ),
452 'lesson_permalink_base' => array(
453 'type' => 'text',
454 'max' => 50,
455 'lable' => __( 'Lesson permalink', 'tutor' ),
456 'desc' => sprintf( __( 'Example: %s', 'tutor' ), get_home_url() . '/' . tutor()->course_post_type . '/sample-course/<strong>' . ( tutor_utils()->get_option( 'lesson_permalink_base', 'lessons' ) ) . '</strong>/sample-lesson/' ),
457 ),
458 ),
459 ),
460
461 'course' => array(
462 'lable' => __( 'Course Settings', 'tutor' ),
463 'attr' => array(
464 'display_course_instructors' => array(
465 'type' => 'switch',
466 'lable' => __( 'Show Instructor Bio', 'tutor' ),
467 'desc' => __( 'Let the students know the instructor(s). Display their credentials, professional experience, and more.', 'tutor' ),
468 ),
469 'enable_q_and_a_on_course' => array(
470 'type' => 'switch',
471 'lable' => __( 'Question and Anwser', 'tutor' ),
472 'desc' => __( 'Allows a Q&A forum on each course.', 'tutor' ),
473 ),
474 'courses_col_per_row' => array(
475 'type' => 'rows',
476 'lable' => __( 'Courses Per Row', 'tutor' ),
477 'tooltip' => __( 'How many courses per row on the archive pages.', 'tutor' ),
478 ),
479 'courses_per_page' => array(
480 'type' => 'slider',
481 'lable' => __( 'Courses Per Page', 'tutor' ),
482 'tooltip' => __( 'How many courses per page on the archive pages.', 'tutor' ),
483 ),
484 ),
485 ),
486
487 'instructor' => array(
488 'lable' => __( 'Instructor Settings', 'tutor' ),
489 'attr' => array(
490 'enable_become_instructor_btn' => array(
491 'type' => 'switch',
492 'lable' => __( 'New Signup', 'tutor' ),
493 'desc' => __( 'Choose between open and closed instructor signup. If you’re creating a course marketplace, instructor signup should be open.', 'tutor' ),
494 ),
495 'instructor_can_publish_course' => array(
496 'type' => 'switch',
497 'lable' => __( 'Earning', 'tutor' ),
498 'desc' => __( 'Enable earning for instructors?', 'tutor' ),
499 ),
500 ),
501 ),
502
503 'payment' => array(
504 'lable' => __( 'Payment Settings ', 'tutor' ),
505 'attr' => array(
506 'enable_guest_course_cart' => array(
507 'type' => 'switch',
508 'lable' => __( 'Guest Checkout', 'tutor' ),
509 'desc' => __( 'Allow users to buy and consume content without logging in.', 'tutor' ),
510 ),
511 'commission_split' => array(
512 'type' => 'range',
513 'lable' => __( 'Commission Rate', 'tutor' ),
514 'tooltip' => __( 'Control revenue sharing between admin and instructor.', 'tutor' ),
515 ),
516 'earning_instructor_commission' => array(
517 'type' => 'commission',
518 ),
519 'earning_admin_commission' => array(
520 'type' => 'commission',
521 ),
522 'withdraw_split' => array(
523 'type' => 'payments',
524 'lable' => __( 'Payment Withdrawal Method', 'tutor' ),
525 'desc' => __( 'Choose your preferred withdrawal method from the options.', 'tutor' ),
526 ),
527
528 ),
529 ),
530
531 );
532
533 return $general_fields;
534 }
535
536 /**
537 * Wizard settings
538 *
539 * @since 1.0.0
540 *
541 * @return void
542 */
543 public function tutor_setup_wizard_settings() {
544 $options = (array) maybe_unserialize( get_option( 'tutor_option' ) );
545 ?>
546 <div class="tutor-wizard-container">
547 <div class="tutor-wrapper-boarding tutor-setup-wizard-settings">
548 <div class="tutor-setup-wrapper">
549 <ul class="tutor-setup-title">
550 <li data-url="general" class="general active current">
551 <?php esc_html_e( 'General', 'tutor' ); ?>
552 </li>
553 <li data-url="course" class="course">
554 <?php esc_html_e( 'Course', 'tutor' ); ?>
555 </li>
556 <li data-url="instructor" class="instructor">
557 <?php esc_html_e( 'Instructor', 'tutor' ); ?>
558 </li>
559 <li data-url="payment" class="payment">
560 <?php esc_html_e( 'Payment', 'tutor' ); ?>
561 </li>
562 <li data-url="finish" style="display:none" class="finish">
563 <?php esc_html_e( 'Finish', 'tutor' ); ?>
564 </li>
565 </ul>
566
567
568 <form id="tutor-setup-form" method="post">
569 <?php wp_nonce_field( tutor()->nonce_action, tutor()->nonce ); ?>
570 <input type="hidden" name="action" value="setup_action">
571
572 <?php $course_marketplace = tutor_utils()->get_option( 'enable_course_marketplace' ); ?>
573 <input type="hidden" name="enable_course_marketplace" class="enable_course_marketplace_data" value="<?php echo ( $course_marketplace ? 'on' : 'off' ); ?>">
574
575 <ul class="tutor-setup-content">
576 <?php $this->tutor_setup_generator(); ?>
577 <li>
578 <div class="tutor-setup-content-heading greetings">
579 <div class="header">
580 <img src="<?php echo esc_url( tutor()->url ) . 'assets/images/greeting-img.png'; ?>" alt="greeting">
581 </div>
582 <div class="content">
583 <h2>
584 <?php esc_html_e( 'Congratulations, you’re all set!', 'tutor' ); ?>
585 </h2>
586 <p>
587 <?php esc_html_x( 'Tutor LMS is up and running on your website! If you really want to become a Tutor LMS genius, read our ', 'tutor setup content', 'tutor' ); ?>
588 <a target="_blank" href="https://docs.themeum.com/tutor-lms/">
589 <?php esc_html_x( 'documentation', 'tutor setup content', 'tutor' ); ?>
590 </a>
591 <?php esc_html_x( 'that covers everything!', 'tutor setup content', 'tutor' ); ?>
592 </p>
593 <p>
594 <?php esc_html_x( 'If you need further assistance, please don’t hesitate to contact us via our ', 'tutor-setup-assistance', 'tutor' ); ?>
595 <a target="_blank" href="https://www.themeum.com/contact-us/">
596 <?php esc_html_x( 'contact form.', 'tutor-setup-assistance', 'tutor' ); ?>
597 </a>
598 </p>
599 </div>
600 <div class="tutor-setup-content-footer footer">
601 <?php
602 $welcome_url = admin_url( 'admin.php?page=tutor&welcome=1' );
603 $addons_url = admin_url( 'admin.php?page=tutor-addons' );
604 $course_url = admin_url( 'admin.php?page=tutor' );
605 ?>
606 <a class="tutor-btn tutor-btn-primary" href="<?php echo esc_url( ! self::is_welcome_page_visited() ? $welcome_url : $course_url ); ?>">
607 <?php esc_html_e( 'Create a New Course', 'tutor' ); ?>
608 </a>
609 <a class="tutor-btn tutor-btn-outline-primary" href="<?php echo esc_url( ! self::is_welcome_page_visited() ? $welcome_url : $addons_url ); ?>">
610 <?php esc_html_e( 'Explore Addons', 'tutor' ); ?>
611 </a>
612 </div>
613 </div>
614 </li>
615 </ul>
616 </form>
617 </div>
618 </div>
619 </div>
620 <?php
621 }
622
623 /**
624 * Setup wizard action
625 *
626 * @since 1.0.0
627 *
628 * @return string
629 */
630 public function tutor_setup_wizard_action() {
631 $html = '<div class="tutor-setup-content-footer footer">';
632 $html .= '<div class="tutor-setup-btn-wrapper">';
633 $html .= '<button class="tutor-btn tutor-btn-outline-primary tutor-btn-md tutor-setup-previous">';
634 $html .= '<span>&#8592;</span>&nbsp;<span>' . __( 'Previous', 'tutor' ) . '</span>';
635 $html .= '</button>';
636 $html .= '</div>';
637 $html .= '<div class="tutor-setup-btn-wrapper">';
638 $html .= '<button class="tutor-setup-skip tutor-btn tutor-btn-ghost">' . __( 'Skip this step', 'tutor' ) . '</button>';
639 $html .= '</div>';
640 $html .= '<div class="tutor-setup-btn-wrapper">';
641 $html .= '<button class="tutor-btn tutor-btn-primary tutor-btn-md tutor-setup-next">';
642 $html .= '<span>' . __( 'Next', 'tutor' ) . '</span>&nbsp;<span>&#8594;</span>';
643 $html .= '</button>';
644 $html .= '</div>';
645 $html .= '</div>';
646
647 return $html;
648 }
649
650 /**
651 * Setup wizard action final
652 *
653 * @since 1.0.0
654 *
655 * @return string
656 */
657 public function tutor_setup_wizard_action_final() {
658 $welcome_url = admin_url( 'admin.php?page=tutor&welcome=1' );
659
660 $html = '<div class="tutor-setup-content-footer footer">';
661 $html .= '<div class="tutor-setup-btn-wrapper">';
662 $html .= '<button class="tutor-btn tutor-btn-outline-primary tutor-btn-md tutor-setup-previous">';
663 $html .= '<span>&#8592;</span>&nbsp;<span>' . __( 'Previous', 'tutor' ) . '</span>';
664 $html .= '</button>';
665 $html .= '</div>';
666 $html .= '<div class="tutor-setup-btn-wrapper">';
667 $html .= '<a href="' . esc_url( $welcome_url ) . '" class="tutor-btn tutor-btn-ghost">' . __( 'Skip this step', 'tutor' ) . '</a>';
668 $html .= '</div>';
669 $html .= '<div class="tutor-setup-btn-wrapper">';
670 $html .= '<a href="' . esc_url( $welcome_url ) . '" class="tutor-btn tutor-btn-primary tutor-btn-md">' . __( 'Finish Setup', 'tutor' ) . '</a>';
671 $html .= '</div>';
672 $html .= '</div>';
673
674 return $html;
675 }
676
677 /**
678 * Setup wizard boarding
679 *
680 * @since 1.0.0
681 *
682 * @return void
683 */
684 public function tutor_setup_wizard_boarding() {
685 global $current_user;
686 ?>
687 <div class="tutor-wizard-container">
688 <div class="tutor-wrapper-boarding tutor-setup-wizard-boarding active">
689 <div class="wizard-boarding-header">
690 <div>
691 <img src="<?php echo esc_url( tutor()->url ) . 'assets/images/tutor-logo.svg'; ?>" />
692 </div>
693 <div>
694 <div class="wizard-boarding-header-sub tutor-fs-5 tutor-color-black">
695 <?php
696 $greeting = _x( 'Hello ', 'tutor-wizard-greeting', 'tutor' );
697 $greeting .= tutor_utils()->display_name( $current_user->ID );
698 $greeting .= _x( ' welcome to Tutor LMS!', 'tutor-wizard-greeting', 'tutor' );
699 echo esc_html( $greeting );
700 ?>
701 </div>
702 <div class="wizard-boarding-header-main tutor-fs-3 tutor-fw-medium tutor-color-black tutor-mt-10">
703 <?php esc_html_e( 'Thank You for Choosing Us', 'tutor' ); ?>
704 </div>
705 </div>
706 </div>
707 <div class="wizard-boarding-body tutor-mt-60">
708 <ul class="slider tutor-boarding">
709 <li>
710 <div class="slide-thumb">
711 <img src="<?php echo esc_url( tutor()->url ) . 'assets/images/scalable_lms_solution.jpg'; ?>" alt="<?php esc_html_e( 'A Powerful, Smart, and Scalable LMS Solution', 'tutor' ); ?>"/>
712 </div>
713 <div class="slide-title tutor-fs-5 tutor-fw-medium tutor-color-black"><?php esc_html_e( 'A Powerful, Smart, and Scalable LMS Solution', 'tutor' ); ?></div>
714 <div class="slide-subtitle tutor-fs-6 tutor-color-secondary tutor-mt-16">
715 <?php esc_html_e( 'From individual instructors to vast eLearning platforms, Tutor LMS grows with you to create your ideal vision of an LMS website.', 'tutor' ); ?>
716 </div>
717 </li>
718 <li>
719 <div class="slide-thumb">
720 <img src="<?php echo esc_url( tutor()->url ) . 'assets/images/extensive_course_builder.jpg'; ?>" alt="<?php esc_html_e( 'Extensive Course Builder', 'tutor' ); ?>"/>
721 </div>
722 <div class="slide-title tutor-fs-5 tutor-fw-medium tutor-color-black"><?php esc_html_e( 'Extensive Course Builder', 'tutor' ); ?></div>
723 <div class="slide-subtitle tutor-fs-6 tutor-color-secondary tutor-mt-16">
724 <?php esc_html_e( 'Tutor LMS comes with a state-of-the-art frontend course builder. Construct rich and resourceful courses with ease.', 'tutor' ); ?>
725 </div>
726 </li>
727 <li>
728 <div class="slide-thumb">
729 <img src="<?php echo esc_url( tutor()->url ) . 'assets/images/advanced_quiz_creator.jpg'; ?>" alt="<?php esc_html_e( 'Advanced Quiz Creator', 'tutor' ); ?>"/>
730 </div>
731 <div class="slide-title tutor-fs-5 tutor-fw-medium tutor-color-black"><?php esc_html_e( 'Advanced Quiz Creator', 'tutor' ); ?></div>
732 <div class="slide-subtitle tutor-fs-6 tutor-color-secondary tutor-mt-16">
733 <?php esc_html_e( 'Build interactive quizzes with the vast selection of question types and verify the learning of your students.', 'tutor' ); ?>
734 </div>
735 </li>
736 <li>
737 <div class="slide-thumb">
738 <img src="<?php echo esc_url( tutor()->url ) . 'assets/images/freedom_with_ecommerce.jpg'; ?>" alt="<?php esc_html_e( 'Freedom With eCommerce', 'tutor' ); ?>"/>
739 </div>
740 <div class="slide-title tutor-fs-5 tutor-fw-medium tutor-color-black"><?php esc_html_e( 'Freedom With eCommerce', 'tutor' ); ?></div>
741 <div class="slide-subtitle tutor-fs-6 tutor-color-secondary tutor-mt-16">
742 <?php esc_html_e( 'Select an eCommerce plugin and sell courses any way you like and use any payment gateway you want!', 'tutor' ); ?>
743 </div>
744 </li>
745 <li>
746 <div class="slide-thumb">
747 <img src="<?php echo esc_url( tutor()->url ) . 'assets/images/reports_and_analytics.jpg'; ?>" alt="<?php esc_html_e( 'Reports and Analytics', 'tutor' ); ?>"/>
748 </div>
749 <div class="slide-title tutor-fs-5 tutor-fw-medium tutor-color-black"><?php esc_html_e( 'Reports and Analytics', 'tutor' ); ?></div>
750 <div class="slide-subtitle tutor-fs-6 tutor-color-secondary tutor-mt-16">
751 <?php esc_html_e( 'Track what type of courses sell the most! Gain insights on user purchases, manage reviews and track quiz attempts.', 'tutor' ); ?>
752 </div>
753 </li>
754 </ul>
755 </div>
756 <div class="wizard-boarding-footer">
757 <div class="">
758 <button class="tutor-btn tutor-btn-primary tutor-btn-md tutor-boarding-next">
759 <?php esc_html_e( 'Let’s Start', 'tutor' ); ?>
760 </button>
761 </div>
762 <div>
763 <a href="<?php echo esc_url( admin_url( 'admin.php?page=tutor' ) ); ?>" class="tutor-text-btn-medium">
764 <?php esc_html_e( 'I already know, skip it!', 'tutor' ); ?>
765 </a>
766 </div>
767 </div>
768 </div>
769 </div>
770 <?php
771 }
772
773 /**
774 * Setup wizard type
775 *
776 * @since 1.0.0
777 *
778 * @return void
779 */
780 public function tutor_setup_wizard_type() {
781 $course_marketplace = tutor_utils()->get_option( 'enable_course_marketplace' );
782 $course_marketplace = 1 === $course_marketplace ? 'on' : 'off';
783 ?>
784 <div class="tutor-wizard-container">
785 <div class="tutor-wrapper-type tutor-setup-wizard-type">
786 <div class="wizard-type-header">
787 <div class="logo"><img src="<?php echo esc_url( tutor()->url . 'assets/images/tutor-logo.svg' ); ?>" /></div>
788 <div class="title"><?php esc_html_e( 'Let’s get the platform up and running', 'tutor' ); ?></div>
789 <div class="subtitle"><?php esc_html_e( 'Pick a category for your LMS platform. You can always update this later.', 'tutor' ); ?></div>
790 </div>
791 <div class="wizard-type-body">
792 <div class="wizard-type-item">
793 <input id="enable_course_marketplace-0" type="radio" name="enable_course_marketplace" value="off"
794 <?php
795 if ( ! $course_marketplace ) {
796 echo 'checked'; }
797 ?>
798 />
799 <span class="icon"></span>
800 <label for="enable_course_marketplace-0">
801 <img src="<?php echo esc_url( tutor()->url . 'assets/images/single-marketplace.svg' ); ?>" />
802 <div class="title"><?php esc_html_e( 'Individual', 'tutor' ); ?></div>
803 <div class="subtitle"><?php esc_html_e( 'Share solo journey as an educator and spread knowledge', 'tutor' ); ?></div>
804 <div class="action">
805 <button class="tutor-btn tutor-btn-primary tutor-btn-md tutor-type-next">
806 <?php esc_html_e( 'Next', 'tutor' ); ?>
807 </button>
808 </div>
809 </label>
810 </div>
811
812 <div class="wizard-type-item">
813 <input id="enable_course_marketplace-1" type="radio" name="enable_course_marketplace" value="on"
814 <?php
815 if ( $course_marketplace ) {
816 echo 'checked'; }
817 ?>
818 />
819 <span class="icon"></span>
820 <label for="enable_course_marketplace-1">
821 <img src="<?php echo esc_url( tutor()->url . 'assets/images/multiple-marketplace.svg' ); ?>" />
822 <div class="title"><?php esc_html_e( 'Marketplace', 'tutor' ); ?></div>
823 <div class="subtitle"><?php esc_html_e( 'Create an eLearning platform to let anyone earn by teaching online', 'tutor' ); ?></div>
824 <div class="action">
825 <button class="tutor-btn tutor-btn-primary tutor-btn-md tutor-type-next">
826 <?php esc_html_e( 'Next', 'tutor' ); ?>
827 </button>
828 </div>
829 </label>
830 </div>
831 </div>
832
833 <div class="wizard-type-footer">
834 <div class="tutor-fs-7">
835 <span><?php esc_html_e( 'Not sure?', 'tutor' ); ?></span>&nbsp;
836 <a href="#" class="tutor-type-skip" class="">
837 <?php esc_html_e( 'Let’s go to the next step.', 'tutor' ); ?>
838 </a>
839 </div>
840 </div>
841 </div>
842 </div>
843 <?php
844 }
845
846 /**
847 * Setup wizard header
848 *
849 * @since 1.0.0
850 *
851 * @return void
852 */
853 public function tutor_setup_wizard_header() {
854 set_current_screen();
855 ?>
856 <!DOCTYPE html>
857 <html <?php language_attributes(); ?>>
858 <head>
859 <meta name="viewport" content="width=device-width" />
860 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
861 <title><?php esc_html_e( 'Tutor &rsaquo; Setup Wizard', 'tutor' ); ?></title>
862 <?php
863 try {
864 do_action( 'admin_enqueue_scripts' );
865 } catch ( \Throwable $th ) { //phpcs:ignore
866 }
867 ?>
868 <?php wp_print_scripts( 'tutor-plyr' ); ?>
869 <?php wp_print_scripts( 'tutor-slick' ); ?>
870 <?php wp_print_scripts( 'tutor-setup' ); ?>
871 <?php do_action( 'admin_print_styles' ); ?>
872 <?php do_action( 'admin_head' ); ?>
873 </head>
874 <body class="tutor-setup wp-core-ui">
875 <?php
876 }
877
878 /**
879 * Setup wizard footer
880 *
881 * @since 1.0.0
882 *
883 * @return void
884 */
885 public function tutor_setup_wizard_footer() {
886 ?>
887 </body>
888 </html>
889 <?php
890 }
891
892 /**
893 * Enqueue scripts
894 *
895 * @since 1.0.0
896 *
897 * @return void
898 */
899 public function enqueue_scripts() {
900 $page = Input::get( 'page', '' );
901 if ( 'tutor-setup' === $page ) {
902 wp_enqueue_style( 'tutor-setup', tutor()->url . 'assets/css/tutor-setup.min.css', array(), TUTOR_VERSION );
903 wp_enqueue_style( 'tutor-slick', tutor()->url . 'assets/packages/slick/slick.css', array(), TUTOR_VERSION );
904 wp_enqueue_style( 'tutor-slick-theme', tutor()->url . 'assets/packages/slick/slick-theme.css', array(), TUTOR_VERSION );
905 wp_register_script( 'tutor-slick', tutor()->url . 'assets/packages/slick/slick.min.js', array( 'jquery' ), TUTOR_VERSION, true );
906 wp_register_script( 'tutor-setup-v2', tutor()->url . 'assets/js/tutor.min.js', array( 'jquery', 'wp-i18n' ), TUTOR_VERSION, true );
907 wp_register_script( 'tutor-setup', tutor()->url . 'assets/js/tutor-setup.min.js', array( 'jquery', 'tutor-slick', 'wp-i18n' ), TUTOR_VERSION, true );
908 wp_localize_script( 'tutor-setup', '_tutorobject', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) );
909 }
910 }
911
912
913 /**
914 * Check if welcome page already visited
915 *
916 * @since 1.0.0
917 *
918 * @return bool
919 */
920 public static function is_welcome_page_visited(): bool {
921 return false;
922 }
923
924 /**
925 * Mark as welcome page visited
926 *
927 * @since 1.0.0
928 *
929 * @return void
930 */
931 public static function mark_as_visited() {
932 update_option( 'tutor_welcome_page_visited', true );
933 }
934 }
935
936