PluginProbe ʕ •ᴥ•ʔ
Tutor LMS – eLearning and online course solution / 3.6.3
Tutor LMS – eLearning and online course solution v3.6.3
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 1 year ago Admin.php 1 year ago Ajax.php 1 year ago Announcements.php 1 year ago Assets.php 1 year ago Backend_Page_Trait.php 1 year ago BaseController.php 1 year ago Course.php 1 year ago Course_Embed.php 3 years ago Course_Filter.php 1 year ago Course_List.php 1 year ago Course_Settings_Tabs.php 1 year ago Course_Widget.php 1 year ago Custom_Validation.php 3 years ago Dashboard.php 1 year ago Earnings.php 1 year ago FormHandler.php 2 years ago Frontend.php 1 year ago Gutenberg.php 1 year ago Input.php 1 year ago Instructor.php 1 year ago Instructors_List.php 1 year ago Lesson.php 1 year ago Options_V2.php 1 year ago Permalink.php 2 years ago Post_types.php 1 year ago Private_Course_Access.php 1 year ago Q_And_A.php 1 year ago Question_Answers_List.php 3 years ago Quiz.php 1 year ago QuizBuilder.php 1 year ago Quiz_Attempts_List.php 1 year ago RestAPI.php 2 years ago Reviews.php 3 years ago Rewrite_Rules.php 2 years ago Shortcode.php 1 year ago Singleton.php 1 year ago Student.php 1 year ago Students_List.php 1 year ago Taxonomies.php 1 year ago Template.php 1 year ago Theme_Compatibility.php 3 years ago Tools.php 1 year ago Tools_V2.php 1 year ago Tutor.php 1 year ago TutorEDD.php 1 year ago Tutor_Base.php 2 years ago Tutor_Setup.php 1 year ago Upgrader.php 1 year ago User.php 1 year ago Utils.php 1 year ago Video_Stream.php 3 years ago WhatsNew.php 2 years ago Withdraw.php 1 year ago Withdraw_Requests_List.php 1 year ago WooCommerce.php 11 months ago
Tutor_Setup.php
871 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 use Tutor\Ecommerce\Settings;
14
15 if ( ! defined( 'ABSPATH' ) ) {
16 exit;
17 }
18
19 /**
20 * Manage setup functionalities
21 *
22 * @since 1.0.0
23 */
24 class Tutor_Setup {
25
26 /**
27 * Register hooks
28 *
29 * @since 1.0.0
30 */
31 public function __construct() {
32 add_action( 'admin_menu', array( $this, 'admin_menus' ) );
33 add_action( 'admin_init', array( $this, 'setup_wizard' ) );
34 add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
35 add_action( 'wp_ajax_setup_action', array( $this, 'tutor_setup_action' ) );
36 add_filter( 'tutor_wizard_attributes', array( $this, 'tutor_setup_attributes_callback' ) );
37 }
38
39 /**
40 * Tutor setup attr callback
41 *
42 * @since 1.0.0
43 *
44 * @param mixed $attr attr.
45 *
46 * @return array
47 */
48 public function tutor_setup_attributes_callback( $attr ) {
49 $options = (array) maybe_unserialize( get_option( 'tutor_option' ) );
50 $final_arr = array();
51 $data_arr = $this->tutor_setup_attributes();
52
53 foreach ( $data_arr as $key => $section ) {
54 foreach ( $section['attr'] as $k => $val ) {
55 $final_arr[ $k ] = isset( $options[ $k ] ) ? $options[ $k ] : '';
56 }
57 }
58
59 return $final_arr;
60 }
61
62 /**
63 * Setup action
64 *
65 * @since 1.0.0
66 *
67 * @return void send wp_json response
68 */
69 public function tutor_setup_action() {
70 tutor_utils()->checking_nonce();
71 if ( 'setup_action' !== Input::post( 'action', '' ) || ! current_user_can( 'manage_options' ) ) {
72 wp_send_json_error( tutor_utils()->error_message() );
73 return;
74 }
75
76 // General Settings.
77 $options = (array) maybe_unserialize( get_option( 'tutor_option' ) );
78 $change_data = apply_filters( 'tutor_wizard_attributes', array() );
79 foreach ( $change_data as $key => $value ) {
80 $post_key = Input::post( $key, '' );
81 if ( Input::has( $key ) ) {
82 if ( $post_key != $change_data[ $key ] ) {
83 if ( '' === $post_key ) {
84 unset( $options[ $key ] );
85 } else {
86 $options[ $key ] = $post_key;
87 }
88 }
89 $options_preset[ $key ] = $post_key;
90 } else {
91 unset( $options[ $key ] );
92 }
93 }
94
95 // Payment Settings.
96 $withdrawal_payments_methods = array( 'bank_transfer_withdraw', 'echeck_withdraw', 'paypal_withdraw' );
97 $options['tutor_withdrawal_methods'] = array();
98
99 foreach ( $withdrawal_payments_methods as $key ) {
100 if ( 'on' === Input::post( $key ) ) {
101 $options['tutor_withdrawal_methods'][ $key ] = $key;
102 }
103 }
104
105 update_option( 'tutor_default_option', $options_preset );
106 update_option( 'tutor_option', $options );
107
108 do_action( 'tutor_setup_finished' );
109
110 wp_send_json_success( __( 'Success', 'tutor' ) );
111 }
112
113 /**
114 * Add dashboard page without title
115 *
116 * @since 1.0.0
117 *
118 * @return void
119 */
120 public function admin_menus() {
121 add_dashboard_page( '', '', 'manage_options', 'tutor-setup', '' );
122 }
123
124 /**
125 * Setup wizard
126 *
127 * @since 1.0.0
128 *
129 * @return void
130 */
131 public function setup_wizard() {
132 $setup_page = Input::get( 'page', '' );
133 if ( 'tutor-setup' === $setup_page ) {
134 $this->tutor_setup_wizard_header();
135 $this->tutor_setup_wizard_boarding();
136 $this->tutor_setup_wizard_type();
137 $this->tutor_setup_wizard_settings();
138 $this->tutor_setup_wizard_footer();
139 exit;
140 }
141 }
142
143 /**
144 * Undocumented function
145 *
146 * @return void
147 */
148 public function tutor_setup_generator() {
149 $i = 1;
150 $html = '';
151 $options = (array) maybe_unserialize( get_option( 'tutor_option' ) );
152 $payments = (array) maybe_unserialize( get_option( 'tutor_withdraw_options' ) );
153 $field_arr = $this->tutor_setup_attributes();
154
155 $down_desc_fields = array( 'rows', 'slider', 'text', 'radio', 'dropdown', 'select', 'range', 'payments' );
156 $full_width_fields = array( 'rows', 'slider', 'radio', 'range', 'payments', 'dropdown', 'select' );
157
158 foreach ( $field_arr as $key_parent => $field_parent ) {
159 $html .= '<li class="' . ( 1 == $i ? 'active' : '' ) . '">';
160 $html .= '<div class="tutor-setup-content-heading heading">';
161 $html .= '<div class="setup-section-title tutor-fs-6 tutor-fw-medium tutor-color-black">' . $field_parent['lable'] . '</div>';
162 $html .= '</div>';
163 $html .= '<div class="tutor-setup-content-heading body">';
164
165 foreach ( $field_parent['attr'] as $key => $field ) {
166 if ( ! isset( $field['lable'] ) ) {
167 continue; }
168
169 // Generate data attributes if necessary.
170 $data_attr = '';
171 if ( isset( $field['data'] ) && is_array( $field['data'] ) ) {
172 foreach ( $field['data'] as $data_key => $data_value ) {
173 $data_attr .= ' data-' . $data_key . '="' . $data_value . '" ';
174 }
175 }
176
177 $html .= '<div class="tutor-setting' . ( in_array( $field['type'], $full_width_fields ) ? ' course-setting-wrapper' : '' ) . ' ' . ( isset( $field['class'] ) ? $field['class'] : '' ) . '">';
178 $html .= isset( $field['lable'] ) ? '<div class="tutor-fs-6 tutor-color-black ______">' . $field['lable'] : '';
179
180 $html .= isset( $field['lable'] ) ? '</div>' : '';
181
182 if ( ! in_array( $field['type'], $down_desc_fields ) ) {
183 $html .= isset( $field['desc'] ) ? '<div class="content tutor-fs-7 tutor-color-secondary">' . $field['desc'] . '</div>' : '';
184 }
185
186 $html .= '<div class="settings">';
187
188 switch ( $field['type'] ) {
189
190 case 'switch':
191 $html .= '<label for="' . $key . '" class="switch-label input-switch-label">';
192 $html .= '<span class="label-off">' . __( 'OFF', 'tutor' ) . '</span>';
193 $html .= '<div class="switchbox-wrapper">';
194 $html .= '<input ' . $data_attr . ' id="' . $key . '" class="input-switchbox" type="checkbox" name="' . $key . '" value="on" ' . ( isset( $options[ $key ] ) && $options[ $key ] ? 'checked' : '' ) . '/>';
195 $html .= '<span class="switchbox-icon"></span>';
196 $html .= '</div>';
197 $html .= '<span class="label-on">' . __( 'ON', 'tutor' ) . '</span>';
198 $html .= '</label>';
199 break;
200
201 case 'text':
202 $html .= '<input type="text" name="' . $key . '" class="lesson-permalink" value="' . ( isset( $options[ $key ] ) ? $options[ $key ] : '' ) . '" />';
203 break;
204
205 case 'rows':
206 $html .= '<div class="content">';
207 $html .= '<div class="course-per-row">';
208 $html .= '<div class="wrapper">';
209 $html .= '<label for="' . $key . '1">';
210 $html .= '<input type="radio" value="1" name="' . $key . '" class="course" id="' . $key . '1" ' . ( isset( $options[ $key ] ) && 1 == $options[ $key ] ? 'checked' : '' ) . '>';
211 $html .= '<span class="span"><span>1</span></span>';
212 $html .= '</label>';
213 $html .= '</div>';
214 $html .= '<div class="wrapper">';
215 $html .= '<label for="' . $key . '2">';
216 $html .= '<input type="radio" value="2" name="' . $key . '" class="course" id="' . $key . '2" ' . ( isset( $options[ $key ] ) && 2 == $options[ $key ] ? 'checked' : '' ) . '>';
217 $html .= '<span class="span"><span>2</span><span>2</span></span>';
218 $html .= '</label>';
219 $html .= '</div>';
220 $html .= '<div class="wrapper">';
221 $html .= '<label for="' . $key . '3">';
222 $html .= '<input type="radio" value="3" name="' . $key . '" class="course" id="' . $key . '3" ' . ( isset( $options[ $key ] ) && 3 == $options[ $key ] ? 'checked' : '' ) . '>';
223 $html .= '<span class="span"><span>3</span><span>3</span><span>3</span></span>';
224 $html .= '</label>';
225 $html .= '</div>';
226 $html .= '<div class="wrapper">';
227 $html .= '<label for="' . $key . '4">';
228 $html .= '<input type="radio" value="4" name="' . $key . '" class="course" id="' . $key . '4" ' . ( isset( $options[ $key ] ) && 4 == $options[ $key ] ? 'checked' : '' ) . '>';
229 $html .= '<span class="span"><span>4</span><span>4</span><span>4</span><span>4</span></span>';
230 $html .= '</label>';
231 $html .= '</div>';
232 $html .= '</div>';
233 $html .= '</div>';
234 break;
235
236 case 'radio':
237 if ( isset( $field['options'] ) ) {
238 foreach ( $field['options'] as $k => $val ) {
239 $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>';
240 $html .= $val . '</label>';
241 }
242 }
243 break;
244
245 case 'slider':
246 $available_times = array(
247 'seconds' => __( 'seconds', 'tutor' ),
248 'minutes' => __( 'minutes', 'tutor' ),
249 'hours' => __( 'hours', 'tutor' ),
250 'days' => __( 'days', 'tutor' ),
251 'weeks' => __( 'weeks', 'tutor' ),
252 );
253 $html .= '<div class="limit-slider">';
254 if ( isset( $field['time'] ) ) {
255 $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"/>';
256 $html .= '<input type="hidden" name="' . $key . '[time]" value="' . ( isset( $options[ $key ]['time'] ) ? $options[ $key ]['time'] : __( 'minutes', 'tutor' ) ) . '" class="range-input"/>';
257 $html .= '<span class=""><span class="range-value">' . ( isset( $options[ $key ]['value'] ) ? $options[ $key ]['value'] : '' ) . '</span>';
258 $html .= isset( $options[ $key ]['time'] ) ? $available_times[ $options[ $key ]['time'] ] : '';
259 $html .= '</span>';
260 } else {
261 $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"/>';
262 $html .= ' <strong class="range-value">' . ( isset( $options[ $key ] ) ? $options[ $key ] : '' ) . '</strong>';
263 }
264 $html .= '</div>';
265 break;
266
267 case 'dropdown':
268 $html .= '<div class="grade-calculation"><div class="select-box"><div class="options-container">';
269 $selected_data = '';
270 if ( isset( $field['options'] ) ) {
271 foreach ( $field['options'] as $value => $label ) {
272 $html .= '<div class="option">';
273 $html .= '<input type="radio" class="radio" id="' . esc_attr( $value ) . '" name="' . esc_attr( $key ) . '" value="' . esc_attr( $value ) . '" ' . ( isset( $options[ $key ] ) && $options[ $key ] === $value ? 'checked' : '' ) . ' />';
274 $html .= '<label for="' . esc_attr( $value ) . '">';
275 $html .= '<h3>' . esc_html( $label ) . '</h3>';
276 $html .= '</label>';
277 $html .= '</div>';
278
279 if ( isset( $options[ $key ] ) && $options[ $key ] === $value ) {
280 $selected_data .= '<div class="selected">';
281 $selected_data .= '<h3>' . esc_html( $label ) . '</h3>';
282 $selected_data .= '</div>';
283 }
284 }
285 }
286 $html .= '</div>';
287 $html .= $selected_data ? $selected_data : '<div class="selected"><h3>' . esc_html( $field['options'][0]['title'] ) . '</h3><h5>' . $field['options'][0]['desc'] . '</h5></div>';
288 $html .= '</div></div>';
289 break;
290
291 case 'select':
292 $html .= '<select name="' . esc_attr( $key ) . '" class="tutor-form-select"';
293 if ( isset( $field['searchable'] ) ) {
294 $html .= ' data-searchable>';
295 } else {
296 $html .= '>';
297 }
298 if ( isset( $field['options'] ) ) {
299 foreach ( $field['options'] as $value => $label ) {
300 $html .= '<option value="' . esc_attr( $value ) . '"' . ( isset( $options[ $key ] ) && $options[ $key ] === $value ? 'selected' : '' ) . '>' . esc_html( $label ) . '</option>';
301 }
302 }
303 $html .= '</select>';
304 break;
305
306 case 'payments':
307 $html .= '<div class="checkbox-wrapper column-3">';
308 $available_withdraw_methods = get_tutor_all_withdrawal_methods();
309 if ( ! empty( $available_withdraw_methods ) ) {
310 foreach ( $available_withdraw_methods as $key => $value ) {
311 $html .= '<div class="payment-setting">';
312 $html .= '<label for="' . $key . '" class="label">';
313 $html .= '<div>';
314 $html .= '<input type="checkbox" name="' . $key . '" id="' . $key . '" class="checkbox payment" ' . ( isset( $value['enabled'] ) && $value['enabled'] ? 'checked' : '' ) . ' />';
315 $html .= '<span class="check-icon round"></span>';
316 $html .= '</div>';
317 $html .= '<div>';
318 $html .= '<img src="' . $value['image'] . '" alt="' . $value['method_name'] . '">';
319 $html .= '<h4>' . $value['method_name'] . '</h4>';
320 $html .= '</div>';
321 $html .= '</label>';
322 $html .= '</div>';
323 }
324 }
325 $html .= '</div>';
326 break;
327
328 case 'range':
329 $earning_instructor = isset( $options['earning_instructor_commission'] ) ? $options['earning_instructor_commission'] : 80;
330 $earning_admin = isset( $options['earning_admin_commission'] ) ? $options['earning_admin_commission'] : 20;
331 $html .= '<div class="limit-slider column-1">';
332 $html .= '<div class="limit-slider-has-parent">';
333 $html .= '<input type="range" min="0" max="100" step="1" value="' . $earning_instructor . '" class="range-input double-range-slider" name=""/>';
334 $html .= '</div>';
335 $html .= '<div class="commision-data">';
336 $html .= '<div class="data">';
337 $html .= '<h4 class="range-value-1">' . $earning_instructor . '%</h4>';
338 $html .= '<h5>' . __( 'Instructor', 'tutor' ) . '</h5>';
339 $html .= '<input type="hidden" min="0" max="100" step="1" value="' . $earning_instructor . '" class="range-value-data-1 range-input" name="earning_instructor_commission"/>';
340 $html .= '</div>';
341 $html .= '<div class="data">';
342 $html .= '<h4 class="range-value-2">' . $earning_admin . '%</h4>';
343 $html .= '<h5>' . __( 'Admin / Owner', 'tutor' ) . '</h5>';
344 $html .= '<input type="hidden" min="0" max="100" step="1" value="' . $earning_admin . '" class="range-value-data-2 range-input" name="earning_admin_commission"/>';
345 $html .= '</div>';
346 $html .= '</div>';
347 $html .= '</div> ';
348 break;
349
350 case 'checkbox':
351 $html .= '<div class="checkbox-wrapper column-2">';
352 if ( isset( $field['options'] ) ) {
353 foreach ( $field['options'] as $k => $val ) {
354 $html .= '<div class="email-notification">';
355 $html .= '<label for="' . $key . $k . '" class="label">';
356 $html .= '<div>';
357 $html .= '<input type="checkbox" value="' . $k . '" ' . ( isset( $options[ $key ] ) && $options[ $key ] == $k ? 'checked' : '' ) . ' name="' . $key . '" id="' . $key . $k . '" class="checkbox" />';
358 $html .= '<span class="check-icon square"></span>';
359 $html .= '</div>';
360 $html .= '<div>';
361 $html .= '<h4>' . $val . '</h4>';
362 $html .= '</div>';
363 $html .= '</label>';
364 $html .= '</div>';
365 }
366 }
367 $html .= '</div>';
368 break;
369
370 case 'attempt':
371 $html .= '<div class="tutor-setting course-setting-wrapper">';
372
373 $html .= '<input type="hidden" name="quiz_attempts_allowed" value="' . ( isset( $options[ $key ] ) ? $options[ $key ] : 'off' ) . '">';
374
375 $html .= '<div class="content">';
376 $html .= '<div class="course-per-page attempts-allowed">';
377 $html .= '<div class="wrapper">';
378 $html .= '<label for="attempts-allowed-1">';
379 $html .= '<input type="radio" value="single" name="attempts-allowed" class="course-p" id="attempts-allowed-1" ' . ( isset( $options[ $key ] ) && $options[ $key ] ? 'checked' : '' ) . '>';
380 $html .= '<span class="radio-icon"></span>';
381 $html .= '<span class="label-text label-text-2">';
382 $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 ) . '">';
383 $html .= '</span>';
384 $html .= '</label>';
385 $html .= '</div>';
386 $html .= '<div class="wrapper tutor-unlimited-value">';
387 $html .= '<label for="attempts-allowed-2">';
388 $html .= '<input type="radio" name="attempts-allowed" value="unlimited" class="course-p" id="attempts-allowed-2" ' . ( ( ! isset( $options[ $key ] ) ) || $options[ $key ] == 0 ? 'checked' : '' ) . '>';//phpcs:ignore
389 $html .= '<span class="radio-icon"></span>';
390 $html .= '<span class="label-text">' . __( 'Unlimited', 'tutor' ) . '</span>';
391 $html .= '</label>';
392 $html .= '</div>';
393 $html .= '</div>';
394 $html .= '</div>';
395 $html .= '</div>';
396 break;
397
398 default:
399 // code...
400 break;
401 }
402
403 if ( in_array( $field['type'], $down_desc_fields ) ) {
404 $html .= isset( $field['desc'] ) ? '<div class="content">' . $field['desc'] . '</div>' : '';
405 }
406 $html .= '</div>';
407 $html .= '</div>';
408
409 }
410 $html .= '</div>';
411 if ( 'select' !== $field['type'] ) {
412 $html .= $this->tutor_setup_wizard_action();
413 } else {
414 $html .= $this->tutor_setup_wizard_action_final();
415 }
416 $html .= '</li>';
417 $i++;
418 }
419
420 echo tutor_kses_html( $html );//phpcs:ignore
421 }
422
423 /**
424 * Setup attrs
425 *
426 * @since 1.0.0
427 *
428 * @return array
429 */
430 public function tutor_setup_attributes() {
431 $currency_options = Settings::get_currency_options();
432 $currency_positions = Settings::get_currency_position_options();
433
434 $general_fields = array(
435 'course' => array(
436 'lable' => __( 'Course', 'tutor' ),
437 'attr' => array(
438 'course_permalink_base' => array(
439 'type' => 'text',
440 'max' => 50,
441 'lable' => __( 'Course permalink', 'tutor' ),
442 /* translators: %s: sample permalink */
443 'desc' => sprintf( __( 'Example: %s', 'tutor' ), get_home_url() . '/' . tutor()->course_post_type . '/sample-course/<strong>' . ( tutor_utils()->get_option( 'course_permalink_base', 'courses' ) ) . '</strong>/sample-lesson/' ),//phpcs:ignore
444 ),
445 'lesson_permalink_base' => array(
446 'type' => 'text',
447 'max' => 50,
448 'lable' => __( 'Lesson permalink', 'tutor' ),
449 /* translators: %s: sample permalink */
450 '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/' ),//phpcs:ignore
451 ),
452 'enable_q_and_a_on_course' => array(
453 'type' => 'switch',
454 'lable' => __( 'Question and Answer', 'tutor' ),
455 'desc' => __( 'Allows a Q&A forum on each course.', 'tutor' ),
456 ),
457 'courses_col_per_row' => array(
458 'type' => 'rows',
459 'lable' => __( 'Courses Per Row', 'tutor' ),
460 'tooltip' => __( 'How many courses per row on the archive pages.', 'tutor' ),
461 ),
462 'courses_per_page' => array(
463 'type' => 'slider',
464 'lable' => __( 'Courses Per Page', 'tutor' ),
465 'tooltip' => __( 'How many courses per page on the archive pages.', 'tutor' ),
466 ),
467 ),
468 ),
469
470 'instructor' => array(
471 'lable' => __( 'Instructor', 'tutor' ),
472 'attr' => array(
473 'enable_revenue_sharing' => array(
474 'type' => 'switch',
475 'lable' => __( 'Revenue Sharing', 'tutor' ),
476 'desc' => __( 'Allow revenue generated from selling courses to be shared with course creators.', 'tutor' ),
477 ),
478 'commission_split' => array(
479 'type' => 'range',
480 'lable' => __( 'Sharing Percentage', 'tutor' ),
481 'tooltip' => '',
482 ),
483 'earning_instructor_commission' => array(
484 'type' => 'commission',
485 ),
486 'earning_admin_commission' => array(
487 'type' => 'commission',
488 ),
489 'withdraw_split' => array(
490 'type' => 'payments',
491 'lable' => __( 'Payment Withdrawal Method', 'tutor' ),
492 // 'desc' => __( 'Choose your preferred withdrawal method from the options.', 'tutor' ),
493 ),
494 ),
495 ),
496
497 'payment' => array(
498 'lable' => __( 'Currency ', 'tutor' ),
499 'attr' => array(
500 'currency_code' => array(
501 'type' => 'select',
502 'options' => $currency_options,
503 'lable' => __( 'Currency Symbol', 'tutor' ),
504 'tooltip' => __( 'Choose the currency for transactions', 'tutor' ),
505 'searchable' => true,
506 ),
507 'currency_position' => array(
508 'type' => 'select',
509 'options' => $currency_positions,
510 'lable' => __( 'Currency Symbol Position', 'tutor' ),
511 'tooltip' => __( 'Set the position of the currency symbol', 'tutor' ),
512 ),
513
514 ),
515 ),
516
517 );
518
519 return $general_fields;
520 }
521
522 /**
523 * Wizard settings
524 *
525 * @since 1.0.0
526 *
527 * @return void
528 */
529 public function tutor_setup_wizard_settings() {
530 $options = (array) maybe_unserialize( get_option( 'tutor_option' ) );
531 ?>
532 <div class="tutor-wizard-container">
533 <div class="tutor-wrapper-boarding tutor-setup-wizard-settings">
534 <div class="tutor-setup-wrapper">
535 <ul class="tutor-setup-title">
536 <li data-url="course" class="course">
537 <span><?php esc_html_e( 'Course', 'tutor' ); ?></span>
538 </li>
539 <li data-url="instructor" class="instructor">
540 <span><?php esc_html_e( 'Instructor', 'tutor' ); ?></span>
541 </li>
542 <li data-url="payment" class="payment">
543 <span><?php esc_html_e( 'Currency', 'tutor' ); ?></span>
544 </li>
545 <li data-url="finish" style="display:none" class="finish">
546 <span><?php esc_html_e( 'Finish', 'tutor' ); ?></span>
547 </li>
548 </ul>
549
550
551 <form id="tutor-setup-form" method="post">
552 <?php wp_nonce_field( tutor()->nonce_action, tutor()->nonce ); ?>
553 <input type="hidden" name="action" value="setup_action">
554
555 <?php $course_marketplace = tutor_utils()->get_option( 'enable_course_marketplace' ); ?>
556 <input type="hidden" name="enable_course_marketplace" class="enable_course_marketplace_data" value="<?php echo ( $course_marketplace ? 'on' : 'off' ); ?>">
557
558 <ul class="tutor-setup-content">
559 <?php $this->tutor_setup_generator(); ?>
560 <li>
561 <div class="tutor-setup-content-heading greetings">
562 <div class="header">
563 <img src="<?php echo esc_url( tutor()->url ) . 'assets/images/greeting-img.png'; ?>" alt="greeting">
564 </div>
565 <div class="content">
566 <h2>
567 <?php esc_html_e( 'Congratulations, you’re all set!', 'tutor' ); ?>
568 </h2>
569 <p>
570 <?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' ); ?>
571 <a target="_blank" href="https://docs.themeum.com/tutor-lms/">
572 <?php esc_html_x( 'documentation', 'tutor setup content', 'tutor' ); ?>
573 </a>
574 <?php esc_html_x( 'that covers everything!', 'tutor setup content', 'tutor' ); ?>
575 </p>
576 <p>
577 <?php esc_html_x( 'If you need further assistance, please don’t hesitate to contact us via our ', 'tutor-setup-assistance', 'tutor' ); ?>
578 <a target="_blank" href="https://www.themeum.com/contact-us/">
579 <?php esc_html_x( 'contact form.', 'tutor-setup-assistance', 'tutor' ); ?>
580 </a>
581 </p>
582 </div>
583 <div class="tutor-setup-content-footer footer">
584 <?php
585 $welcome_url = admin_url( 'admin.php?page=tutor&welcome=1' );
586 $addons_url = admin_url( 'admin.php?page=tutor-addons' );
587 $course_url = admin_url( 'admin.php?page=tutor' );
588 ?>
589 <a class="tutor-btn tutor-btn-primary" href="<?php echo esc_url( ! self::is_welcome_page_visited() ? $welcome_url : $course_url ); ?>">
590 <?php esc_html_e( 'Create a New Course', 'tutor' ); ?>
591 </a>
592 <a class="tutor-btn tutor-btn-outline-primary" href="<?php echo esc_url( ! self::is_welcome_page_visited() ? $welcome_url : $addons_url ); ?>">
593 <?php esc_html_e( 'Explore Addons', 'tutor' ); ?>
594 </a>
595 </div>
596 </div>
597 </li>
598 </ul>
599 </form>
600 </div>
601 </div>
602 </div>
603 <?php
604 }
605
606 /**
607 * Setup wizard action
608 *
609 * @since 1.0.0
610 *
611 * @return string
612 */
613 public function tutor_setup_wizard_action() {
614 $html = '<div class="tutor-setup-content-footer footer">';
615 $html .= '<div class="tutor-setup-btn-wrapper">';
616 $html .= '<button class="tutor-btn tutor-btn-outline-primary tutor-btn-md tutor-setup-previous">';
617 $html .= '<span>&#8592;</span>&nbsp;<span>' . __( 'Previous', 'tutor' ) . '</span>';
618 $html .= '</button>';
619 $html .= '</div>';
620 $html .= '<div class="tutor-setup-btn-wrapper">';
621 $html .= '<button class="tutor-setup-skip tutor-btn tutor-btn-ghost">' . __( 'Skip this step', 'tutor' ) . '</button>';
622 $html .= '</div>';
623 $html .= '<div class="tutor-setup-btn-wrapper">';
624 $html .= '<button class="tutor-btn tutor-btn-primary tutor-btn-md tutor-setup-next">';
625 $html .= '<span>' . __( 'Next', 'tutor' ) . '</span>&nbsp;<span>&#8594;</span>';
626 $html .= '</button>';
627 $html .= '</div>';
628 $html .= '</div>';
629
630 return $html;
631 }
632
633 /**
634 * Setup wizard action final
635 *
636 * @since 1.0.0
637 *
638 * @return string
639 */
640 public function tutor_setup_wizard_action_final() {
641 $welcome_url = admin_url( 'admin.php?page=tutor&welcome=1' );
642
643 $html = '<div class="tutor-setup-content-footer footer">';
644 $html .= '<div class="tutor-setup-btn-wrapper">';
645 $html .= '<button class="tutor-btn tutor-btn-outline-primary tutor-btn-md tutor-setup-previous">';
646 $html .= '<span>&#8592;</span>&nbsp;<span>' . __( 'Previous', 'tutor' ) . '</span>';
647 $html .= '</button>';
648 $html .= '</div>';
649 $html .= '<div class="tutor-setup-btn-wrapper">';
650 $html .= '<a href="' . esc_url( $welcome_url ) . '" class="tutor-btn tutor-btn-ghost">' . __( 'Skip this step', 'tutor' ) . '</a>';
651 $html .= '</div>';
652 $html .= '<div class="tutor-setup-btn-wrapper">';
653 $html .= '<button class="tutor-btn tutor-btn-primary tutor-btn-md tutor-finish-setup" data-redirect-url="' . esc_url( $welcome_url ) . '">' . __( 'Finish Setup', 'tutor' ) . '</button>';
654 $html .= '</div>';
655 $html .= '</div>';
656
657 return $html;
658 }
659
660 /**
661 * Setup wizard boarding
662 *
663 * @since 1.0.0
664 *
665 * @return void
666 */
667 public function tutor_setup_wizard_boarding() {
668 global $current_user;
669 ?>
670 <div class="tutor-wizard-container">
671 <div class="tutor-wrapper-boarding tutor-setup-wizard-boarding active">
672 <div class="tutor-setup-wizard-boarding-inner">
673 <div class="wizard-boarding-header">
674 <div>
675 <img src="<?php echo esc_url( tutor()->url ) . 'assets/images/tutor-logo.svg'; ?>" />
676 </div>
677 <div>
678 <div class="wizard-boarding-header-sub tutor-fs-5 tutor-color-black">
679 <?php
680 $greeting = _x( 'Hello ', 'tutor-wizard-greeting', 'tutor' );
681 $greeting .= tutor_utils()->display_name( $current_user->ID );
682 $greeting .= '!';
683 echo esc_html( $greeting );
684 ?>
685 </div>
686 <div class="wizard-boarding-header-main tutor-fs-3 tutor-fw-medium tutor-color-black tutor-mt-10">
687 <?php esc_html_e( 'Welcome to Tutor LMS', 'tutor' ); ?>
688 </div>
689 </div>
690 </div>
691 <div class="wizard-boarding-body">
692 <img src="<?php echo esc_url( tutor()->url ) . 'assets/images/setup/welcome-to-tutor-lms.png'; ?>" />
693
694 <p class="description">
695 <?php esc_html_e( 'Get started with an all-in-one platform to create, manage, and sell your courses effortlessly—trusted by over 100,000 eLearning websites worldwide.', 'tutor' ); ?>
696 </p>
697 </div>
698 <div class="">
699 <button class="tutor-btn tutor-btn-primary tutor-btn-lg tutor-boarding-next">
700 <?php esc_html_e( 'Let’s Start', 'tutor' ); ?>
701 </button>
702 </div>
703 </div>
704 <div class="wizard-boarding-footer">
705 <div>
706 <a href="<?php echo esc_url( admin_url( 'admin.php?page=tutor' ) ); ?>" class="tutor-text-btn-medium">
707 <?php esc_html_e( 'I already know, skip it!', 'tutor' ); ?>
708 </a>
709 </div>
710 </div>
711 </div>
712 </div>
713 <?php
714 }
715
716 /**
717 * Setup wizard type
718 *
719 * @since 1.0.0
720 *
721 * @return void
722 */
723 public function tutor_setup_wizard_type() {
724 $course_marketplace = tutor_utils()->get_option( 'enable_course_marketplace' );
725 $course_marketplace = 1 === $course_marketplace ? 'on' : 'off';
726 ?>
727 <div class="tutor-wizard-container">
728 <div class="tutor-wrapper-type tutor-setup-wizard-type">
729 <div class="tutor-setup-wizard-type-inner">
730 <div class="wizard-type-header">
731 <div class="logo"><img src="<?php echo esc_url( tutor()->url . 'assets/images/tutor-logo.svg' ); ?>" /></div>
732 <div class="title"><?php esc_html_e( 'How do you want to set up?', 'tutor' ); ?></div>
733 <div class="subtitle"><?php esc_html_e( 'Select the option that best fits your needs. You can change this setting anytime.', 'tutor' ); ?></div>
734 </div>
735 <div class="wizard-type-body">
736 <div class="wizard-type-item">
737 <input id="enable_course_marketplace-0" type="radio" name="enable_course_marketplace" value="off"
738 <?php
739 if ( ! $course_marketplace ) {
740 echo 'checked'; }
741 ?>
742 />
743 <span class="icon"></span>
744 <label for="enable_course_marketplace-0">
745 <img src="<?php echo esc_url( tutor()->url . 'assets/images/setup/individual.svg' ); ?>" />
746 <div class="title"><?php esc_html_e( 'Individual', 'tutor' ); ?></div>
747 <div class="subtitle"><?php esc_html_e( 'Start as an independent educator and share your expertise.', 'tutor' ); ?></div>
748 </label>
749 </div>
750
751 <div class="wizard-type-item">
752 <input id="enable_course_marketplace-1" type="radio" name="enable_course_marketplace" value="on"
753 <?php
754 if ( $course_marketplace ) {
755 echo 'checked'; }
756 ?>
757 />
758 <span class="icon"></span>
759 <label for="enable_course_marketplace-1">
760 <img src="<?php echo esc_url( tutor()->url . 'assets/images/setup/marketplace.svg' ); ?>" />
761 <div class="title"><?php esc_html_e( 'Marketplace', 'tutor' ); ?></div>
762 <div class="subtitle"><?php esc_html_e( 'Build a marketplace that empowers others to sell courses online.', 'tutor' ); ?></div>
763 </label>
764 </div>
765 </div>
766
767 <div class="wizard-type-footer">
768 <div class="action">
769 <button class="tutor-btn tutor-btn-outline-primary tutor-btn-md tutor-type-previous">
770 <span></span>&nbsp;<span><?php esc_html_e( 'Previous ', 'tutor' ); ?></span>
771 </button>
772 </div>
773
774 <div class="action">
775 <button class="tutor-btn tutor-btn-primary tutor-btn-md tutor-type-next">
776 <span><?php esc_html_e( 'Next ', 'tutor' ); ?></span>&nbsp;<span></span>
777 </button>
778 </div>
779 </div>
780 </div>
781 </div>
782 </div>
783 <?php
784 }
785
786 /**
787 * Setup wizard header
788 *
789 * @since 1.0.0
790 *
791 * @return void
792 */
793 public function tutor_setup_wizard_header() {
794 set_current_screen();
795 ?>
796 <!DOCTYPE html>
797 <html <?php language_attributes(); ?>>
798 <head>
799 <meta name="viewport" content="width=device-width" />
800 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
801 <title><?php esc_html_e( 'Tutor &rsaquo; Setup Wizard', 'tutor' ); ?></title>
802 <?php
803 try {
804 do_action( 'admin_enqueue_scripts' );
805 } catch ( \Throwable $th ) { //phpcs:ignore
806 }
807 ?>
808 <?php wp_print_scripts( 'tutor-setup' ); ?>
809 <?php do_action( 'admin_print_styles' ); ?>
810 <?php do_action( 'admin_head' ); ?>
811 </head>
812 <body class="tutor-setup wp-core-ui">
813 <?php
814 }
815
816 /**
817 * Setup wizard footer
818 *
819 * @since 1.0.0
820 *
821 * @return void
822 */
823 public function tutor_setup_wizard_footer() {
824 ?>
825 </body>
826 </html>
827 <?php
828 }
829
830 /**
831 * Enqueue scripts
832 *
833 * @since 1.0.0
834 *
835 * @return void
836 */
837 public function enqueue_scripts() {
838 $page = Input::get( 'page', '' );
839 if ( 'tutor-setup' === $page ) {
840 wp_enqueue_style( 'tutor-setup', tutor()->url . 'assets/css/tutor-setup.min.css', array(), TUTOR_VERSION );
841 wp_register_script( 'tutor-setup', tutor()->url . 'assets/js/tutor-setup.js', array( 'jquery', 'wp-i18n' ), TUTOR_VERSION, true );
842 wp_localize_script( 'tutor-setup', '_tutorobject', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) );
843 wp_set_script_translations( 'tutor-setup', 'tutor', tutor()->path . 'languages/' );
844 }
845 }
846
847
848 /**
849 * Check if welcome page already visited
850 *
851 * @since 1.0.0
852 *
853 * @return bool
854 */
855 public static function is_welcome_page_visited(): bool {
856 return false;
857 }
858
859 /**
860 * Mark as welcome page visited
861 *
862 * @since 1.0.0
863 *
864 * @return void
865 */
866 public static function mark_as_visited() {
867 update_option( 'tutor_welcome_page_visited', true );
868 }
869 }
870
871