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.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 / Tools_V2.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
Tools_V2.php
583 lines
1 <?php
2
3 /**
4 * Options for TutorLMS
5 *
6 * @package Tutor\Tools
7 * @author Themeum <support@themeum.com>
8 * @link https://themeum.com
9 * @since 2.0.0
10 */
11
12 namespace Tutor;
13
14 use TUTOR\Admin;
15
16 if ( ! defined( 'ABSPATH' ) ) {
17 exit;
18 }
19
20 /**
21 * Tools class
22 *
23 * @since 2.0.0
24 */
25 class Tools_V2 {
26
27 /**
28 * Environment status
29 *
30 * @since 2.0.0
31 *
32 * @var string
33 */
34 private $environment_status;
35
36 /**
37 * Tools filed
38 *
39 * @since 2.0.0
40 *
41 * @var mixed
42 */
43 private $tools_fields;
44
45 /**
46 * Apply settings
47 *
48 * @since 2.0.0
49 *
50 * @return void send wp_json response
51 */
52 public function tutor_apply_settings() {
53 $tutor_settings_log = get_option( 'tutor_settings_log' );
54 $apply_id = $this->get_request_data( 'apply_id' );
55
56 update_option( 'tutor_option', $tutor_settings_log[ $apply_id ]['dataset'] );
57
58 wp_send_json_success( $tutor_settings_log[ $apply_id ] );
59 }
60
61 /**
62 * Get request data
63 *
64 * @since 2.0.0
65 *
66 * @param mixed $var var.
67 *
68 * @return mixed
69 */
70 public function get_request_data( $var ) {
71 return Input::sanitize_request_data( $var, null );
72 }
73
74 /**
75 * Tools page
76 *
77 * @since 2.0.0
78 *
79 * @return void including template
80 */
81 public function load_tools_page() {
82 $tools_fields = $this->get_tools_fields();
83 $tutor_setup = array( 'tutor-setup' => $tools_fields['tutor-setup'] );
84 unset( $tools_fields['tutor-setup'] );
85 $tools_fields = array_merge( $tools_fields, $tutor_setup );
86
87 $active_tab = Input::get( 'sub_page', 'status' );
88 include tutor()->path . '/views/options/tools.php';
89 }
90
91 /**
92 * Function options_tools
93 *
94 * @since 2.0.0
95 *
96 * @return array
97 */
98 private function get_tools_fields() {
99 global $wpdb;
100
101 if ( $this->tools_fields ) {
102 // Return fields if already prepared.
103 return $this->tools_fields;
104 }
105
106 $attr_tools = array(
107 'status' => array(
108 'label' => __( 'Status', 'tutor' ),
109 'slug' => 'status',
110 'desc' => __( 'Status Settings', 'tutor' ),
111 'template' => 'status',
112 'view_path' => tutor()->path . 'views/options/template/',
113 'icon' => 'tutor-icon-chart-pie',
114 'blocks' => array(
115 'wordpress_environment' => array(
116 'label' => __( 'WordPress environment', 'tutor' ),
117 'slug' => 'wordpress_environment',
118 'classes' => 'wordpress_environment',
119 'block_type' => 'column',
120 'fieldset' => array(
121 array(
122 array(
123 'key' => 'home_url',
124 'type' => 'info_row',
125 'label' => __( 'Home URL', 'tutor' ),
126 'status' => 'default',
127 'default' => $this->status( 'home_url' ),
128 ),
129 ),
130 array(
131 array(
132 'key' => 'wordpress_version',
133 'type' => 'info_col',
134 'label' => __( 'WordPress version', 'tutor' ),
135 'status' => 'default',
136 'default' => $this->status( 'wordpress_version' ),
137
138 ),
139 array(
140 'key' => 'wordpress_multisite',
141 'type' => 'info_col',
142 'label' => __( 'WordPress multisite', 'tutor' ),
143 'status' => 'default',
144 'default' => $this->status( 'wordpress_multisite' ),
145
146 ),
147 array(
148 'key' => 'wordpress_debug_mode',
149 'type' => 'info_col',
150 'label' => __( 'WordPress debug mode', 'tutor' ),
151 'status' => ( defined( 'WP_DEBUG' ) && true === WP_DEBUG ) ? 'success' : 'default',
152 'default' => $this->status( 'wordpress_debug_mode' ),
153
154 ),
155 array(
156 'key' => 'language',
157 'type' => 'info_col',
158 'label' => __( 'Language', 'tutor' ),
159 'status' => 'default',
160 'default' => $this->status( 'language' ),
161
162 ),
163 ),
164 array(
165 array(
166 'key' => 'site_url',
167 'type' => 'info_row',
168 'label' => __( 'Site URL', 'tutor' ),
169 'status' => 'default',
170 'default' => $this->status( 'site_url' ),
171
172 ),
173 ),
174 array(
175 array(
176 'key' => 'tutor_version',
177 'type' => 'info_col',
178 'label' => __( 'Tutor version', 'tutor' ),
179 'status' => 'success',
180 'default' => $this->status( 'tutor_version' ),
181
182 ),
183 array(
184 'key' => 'wordpress_memory_limit',
185 'type' => 'info_col',
186 'label' => __( 'WordPress memory limit', 'tutor' ),
187 'status' => 'success',
188 'default' => $this->status( 'wordpress_memory_limit' ),
189
190 ),
191 array(
192 'key' => 'wordpress_cron',
193 'type' => 'info_col',
194 'label' => __( 'WordPress Cron', 'tutor' ),
195 'status' => ! empty( _get_cron_array() ) ? 'success' : 'default',
196 'default' => $this->status( 'wordpress_cron' ),
197
198 ),
199 array(
200 'key' => 'external_object_cache',
201 'type' => 'info_col',
202 'label' => __( 'External object cache', 'tutor' ),
203 'status' => 'default',
204 'default' => $this->status( 'external_object_cache' ),
205
206 ),
207 ),
208 ),
209 ),
210 'server_environment' => array(
211 'label' => __( 'Server environment', 'tutor' ),
212 'slug' => 'server_environment',
213 'block_type' => 'column',
214 'fieldset' => array(
215 array(
216 array(
217 'key' => 'server_info',
218 'type' => 'info_col',
219 'label' => __( 'Server info', 'tutor' ),
220 'status' => 'default',
221 'default' => $this->status( 'server_info' ),
222
223 ),
224 array(
225 'key' => 'php_version',
226 'type' => 'info_col',
227 'label' => __( 'PHP version', 'tutor' ),
228 'status' => 'default',
229 'default' => $this->status( 'php_version' ),
230
231 ),
232 array(
233 'key' => 'php_post_max_size',
234 'type' => 'info_col',
235 'label' => __( 'PHP post max size', 'tutor' ),
236 'status' => 'default',
237 'default' => $this->status( 'php_post_max_size' ),
238
239 ),
240 array(
241 'key' => 'php_time_limit',
242 'type' => 'info_col',
243 'label' => __( 'PHP time limit', 'tutor' ),
244 'status' => 'default',
245 'default' => $this->status( 'php_time_limit' ),
246
247 ),
248 array(
249 'key' => 'curl_version',
250 'type' => 'info_col',
251 'label' => __( 'cURL version', 'tutor' ),
252 'status' => 'default',
253 'default' => $this->status( 'curl_version' ),
254
255 ),
256 array(
257 'key' => 'language',
258 'type' => 'info_col',
259 'label' => __( 'Language', 'tutor' ),
260 'status' => 'default',
261 'default' => $this->status( 'language' ),
262
263 ),
264 ),
265 array(
266 array(
267 'key' => 'tutor_version',
268 'type' => 'info_col',
269 'label' => __( 'MySQL version', 'tutor' ),
270 'status' => 'default',
271 'default' => sprintf( 'Server: %s, Client: %s', $wpdb->dbh->server_info, $wpdb->dbh->client_info ),
272 ),
273 array(
274 'key' => 'wordpress_memory_limit',
275 'type' => 'info_col',
276 'label' => __( 'Default timezone is UTC', 'tutor' ),
277 'status' => 'default',
278 'default' => $this->status( 'default_timezone_is_utc' ),
279 ),
280 array(
281 'key' => 'wordpress_cron',
282 'type' => 'info_col',
283 'label' => __( 'fsockopen/cURL', 'tutor' ),
284 'status' => 'default',
285 'default' => $this->status( 'fsockopen_curl' ),
286 ),
287 array(
288 'key' => 'external_object_cache',
289 'type' => 'info_col',
290 'label' => __( 'DOMDocument', 'tutor' ),
291 'status' => 'default',
292 'default' => $this->status( 'dom_document' ),
293 ),
294 array(
295 'key' => 'external_object_cache',
296 'type' => 'info_col',
297 'label' => __( 'GZip', 'tutor' ),
298 'status' => 'default',
299 'default' => $this->status( 'gzip' ),
300 ),
301 array(
302 'key' => 'external_object_cache',
303 'type' => 'info_col',
304 'label' => __( 'Multibyte string', 'tutor' ),
305 'status' => 'default',
306 'default' => $this->status( 'multibyte_string' ),
307 ),
308 ),
309 ),
310 ),
311 ),
312 ),
313 'import_export' => array(
314 'label' => __( 'Import/Export', 'tutor' ),
315 'slug' => 'import_export',
316 'desc' => __( 'Import/Export Settings', 'tutor' ),
317 'template' => 'import_export',
318 'view_path' => tutor()->path . 'views/options/template/',
319 'icon' => 'tutor-icon-import-export',
320 'blocks' => array(),
321 ),
322 'tutor_pages' => array(
323 'label' => __( 'Tutor Pages', 'tutor' ),
324 'slug' => 'tutor_pages',
325
326 'desc' => __( 'Tutor Pages Settings', 'tutor' ),
327 'template' => 'tutor_pages',
328 'view_path' => tutor()->path . 'views/options/template/',
329 'icon' => 'tutor-icon-page-review',
330 'blocks' => array(
331 'block' => array(),
332 ),
333 ),
334 'tutor-setup' => array(
335 'label' => __( 'Setup Wizard', 'tutor' ),
336 'slug' => 'tutor-setup',
337 'desc' => __( 'Setup Wizard Settings', 'tutor' ),
338 'icon' => 'tutor-icon-earth',
339 'blocks' => array(
340 'block' => array(),
341 ),
342 ),
343 );
344
345 $attr_tools = apply_filters( 'tutor/tools/extend/attr', apply_filters( 'tutor/tools/attr', apply_filters( 'tutor_tool_pages', $attr_tools ) ) );
346
347 $this->tools_fields = $attr_tools;
348
349 return $this->tools_fields;
350 }
351
352 /**
353 * Get environment info
354 *
355 * @since 2.0.0
356 *
357 * @return array
358 */
359 private function get_environment_info() {
360
361 if ( $this->environment_status ) {
362 // Use runtime cache for repetitive call.
363 return $this->environment_status;
364 }
365
366 // Figure out cURL version, if installed.
367 $curl_version = '';
368 if ( function_exists( 'curl_version' ) ) {
369 $curl_version = curl_version();
370 $curl_version = $curl_version['version'] . ', ' . $curl_version['ssl_version'];
371 }
372
373 // WP memory limit.
374 $wp_memory_limit = tutor_utils()->let_to_num( WP_MEMORY_LIMIT );
375 if ( function_exists( 'memory_get_usage' ) ) {
376 $wp_memory_limit = max( $wp_memory_limit, tutor_utils()->let_to_num( @ini_get( 'memory_limit' ) ) );
377 }
378
379 $database_version = tutor_utils()->get_db_version();
380
381 $this->environment_status = array(
382 'home_url' => get_option( 'home' ),
383 'site_url' => get_option( 'siteurl' ),
384 'version' => TUTOR_VERSION,
385 'wp_version' => get_bloginfo( 'version' ),
386 'wp_multisite' => is_multisite(),
387 'wp_memory_limit' => $wp_memory_limit,
388 'wp_debug_mode' => ( defined( 'WP_DEBUG' ) && WP_DEBUG ),
389 'wp_cron' => ! ( defined( 'DISABLE_WP_CRON' ) && DISABLE_WP_CRON ),
390 'language' => get_locale(),
391 'external_object_cache' => wp_using_ext_object_cache(),
392 'server_info' => isset( $_SERVER['SERVER_SOFTWARE'] ) ? sanitize_text_field( wp_unslash( $_SERVER['SERVER_SOFTWARE'] ) ) : '',
393 'php_version' => phpversion(),
394 'php_post_max_size' => tutor_utils()->let_to_num( ini_get( 'post_max_size' ) ),
395 'php_max_execution_time' => ini_get( 'max_execution_time' ),
396 'php_max_input_vars' => ini_get( 'max_input_vars' ),
397 'curl_version' => $curl_version,
398 'suhosin_installed' => extension_loaded( 'suhosin' ),
399 'max_upload_size' => wp_max_upload_size(),
400 'mysql_version' => $database_version['number'],
401 'mysql_version_string' => $database_version['string'],
402 'default_timezone' => date_default_timezone_get(),
403 'fsockopen_or_curl_enabled' => ( function_exists( 'fsockopen' ) || function_exists( 'curl_init' ) ),
404 'soapclient_enabled' => class_exists( 'SoapClient' ),
405 'domdocument_enabled' => class_exists( 'DOMDocument' ),
406 'gzip_enabled' => is_callable( 'gzopen' ),
407 'mbstring_enabled' => extension_loaded( 'mbstring' ),
408 );
409
410 return $this->environment_status;
411 }
412
413 /**
414 * Status
415 *
416 * @since 2.0.0
417 *
418 * @param string $type type.
419 *
420 * @return mixed
421 */
422 public function status( $type = '' ) {
423
424 $data = array();
425 $data[ null ] = 'null';
426
427 $environment = $this->get_environment_info();
428
429 $data['home_url'] = $environment['home_url'] ?? null;
430 $data['site_url'] = $environment['site_url'] ?? null;
431
432 $latest_version = get_transient( 'tutor_system_status_wp_version_check' );
433
434 // WordPress already has efficient update notification mechanism.
435 // We don't need to slow down the page for no reason.
436 // phpcs:disable WordPress.WP.I18n.MissingTranslatorsComment
437 $data['wordpress_version'] = esc_html( $environment['wp_version'] );
438
439 $data['tutor_version'] = esc_html( $environment['version'] );
440
441 $data['wordpress_multisite'] = $environment['wp_multisite'] ? '' : '-';
442
443 $data['wordpress_debug_mode'] = $environment['wp_debug_mode'] ? '' : '-';
444
445 $data['language'] = esc_html( $environment['language'] );
446
447 $data['wordpress_memory_limit'] = ( $environment['wp_memory_limit'] < 67108864 )
448 ? sprintf( esc_html__( '%1$s - We recommend setting memory to at least 64MB. See: %2$s', 'tutor' ), esc_html( size_format( $environment['wp_memory_limit'] ) ), '<a href="https://codex.wordpress.org/Editing_wp-config.php#Increasing_memory_allocated_to_PHP" target="_blank">' . esc_html__( 'Increasing memory allocated to PHP', 'tutor' ) . '</a>' )
449 : esc_html( size_format( $environment['wp_memory_limit'] ) );
450
451 $data['wordpress_cron'] = $environment['wp_cron'] ? '' : '-';
452
453 $data['external_object_cache'] = $environment['external_object_cache'] ? '' : '-';
454
455 $data['server_info'] = $environment['server_info'] ?? null;
456
457 $data['php_version'] = ( version_compare( $environment['php_version'], '7.2', '>=' ) )
458 ? esc_html( $environment['php_version'] )
459 : ( ( version_compare( $environment['php_version'], '5.6', '<' ) )
460 ? __( 'Tutor will run under this version of PHP, however, it has reached end of life. We recommend using PHP version 7.2 or above for greater performance and security.', 'tutor' )
461 : __( 'We recommend using PHP version 7.2 or above for greater performance and security.', 'tutor' ) );
462
463 $data['php_post_max_size'] = esc_html( size_format( $environment['php_post_max_size'] ) ) ?? null;
464
465 $data['php_time_limit'] = esc_html( $environment['php_max_execution_time'] ) ?? null;
466
467 $data['php_max_input_vars'] = esc_html( $environment['php_max_input_vars'] ) ?? null;
468
469 $data['curl_version'] = esc_html( $environment['curl_version'] ) ?? null;
470
471 $data['suhosin_installed'] = $environment['suhosin_installed'] ? '' : '-';
472
473 $data['max_upload_size'] = esc_html( size_format( $environment['max_upload_size'] ) ) ?? null;
474
475 $data['mysql_version'] = ( version_compare( $environment['mysql_version'], '5.6', '<' ) && ! strstr( $environment['mysql_version_string'], 'MariaDB' ) )
476 ? sprintf( esc_html__( '%1$s - We recommend a minimum MySQL version of 5.6. See: %2$s', 'tutor' ), esc_html( $environment['mysql_version_string'] ), '<a href="https://wordpress.org/about/requirements/" target="_blank">' . esc_html__( 'WordPress requirements', 'tutor' ) . '</a>' )
477 : esc_html( $environment['mysql_version_string'] );
478
479 $data['default_timezone_is_utc'] = ( 'UTC' !== $environment['default_timezone'] )
480 ? sprintf( esc_html__( 'Default timezone is %s - it should be UTC', 'tutor' ), esc_html( $environment['default_timezone'] ) )
481 : '';
482
483 $data['fsockopen_curl'] = $environment['fsockopen_or_curl_enabled']
484 ? ''
485 : esc_html__( 'Your server does not have fsockopen or cURL enabled - PayPal IPN and other scripts which communicate with other servers will not work. Contact your hosting provider.', 'tutor' );
486
487 $data['dom_document'] = $environment['domdocument_enabled']
488 ? ''
489 : sprintf( esc_html__( 'Your server does not have the %s class enabled - HTML/Multipart emails, and also some extensions, will not work without DOMDocument.', 'tutor' ), '<a href="https://php.net/manual/en/class.domdocument.php">DOMDocument</a>' );
490
491 $data['gzip'] = ( $environment['gzip_enabled'] )
492 ? ''
493 : sprintf( esc_html__( 'Your server does not support the %s function - this is required to use the GeoIP database from MaxMind.', 'tutor' ), '<a href="https://php.net/manual/en/zlib.installation.php">gzopen</a>' );
494
495 $data['multibyte_string'] = ( $environment['mbstring_enabled'] )
496 ? ''
497 : sprintf( esc_html__( 'Your server does not support the %s functions - this is required for better character encoding. Some fallbacks will be used instead for it.', 'tutor' ), '<a href="https://php.net/manual/en/mbstring.installation.php">mbstring</a>' );
498
499 if ( ! null == $type ) {
500 return $data[ $type ];
501 }
502
503 return $data[ null ];
504 }
505
506 /**
507 * Generate Option Field
508 *
509 * @since 2.0.0
510 *
511 * @param array $field fields.
512 *
513 * @return string
514 */
515 public function generate_field( $field = array() ) {
516 ob_start();
517 include tutor()->path . "views/options/field-types/{$field['type']}.php";
518
519 return ob_get_clean();
520 }
521
522 /**
523 * Get field type template
524 *
525 * @since 2.0.0
526 *
527 * @param array $field field.
528 *
529 * @return string
530 */
531 public function field_type( $field = array() ) {
532 ob_start();
533 include tutor()->path . "views/options/field-types/{$field['type']}.php";
534 return ob_get_clean();
535 }
536
537 /**
538 * Blocks template content
539 *
540 * @since 2.0.0
541 *
542 * @param array $blocks field.
543 *
544 * @return string
545 */
546 public function blocks( $blocks = array() ) {
547 ob_start();
548 include tutor()->path . 'views/options/option_blocks.php';
549 return ob_get_clean();
550 }
551
552 /**
553 * Template content
554 *
555 * @since 2.0.0
556 *
557 * @param array $section field.
558 *
559 * @return string
560 */
561 public function template( $section = array() ) {
562 ob_start();
563 include $section['view_path'] . $section['template'] . '.php';
564 return ob_get_clean();
565 }
566
567 /**
568 * Load template inside template directory
569 *
570 * @since 2.0.0
571 *
572 * @param string $template_slug template slug.
573 * @param array $section sections array.
574 *
575 * @return string
576 */
577 public function view_template( $template_slug, $section = array() ) {
578 ob_start();
579 require tutor()->path . "views/options/template/{$template_slug}";
580 return ob_get_clean();
581 }
582 }
583