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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 4 years ago Admin.php 4 years ago Ajax.php 4 years ago Announcements.php 4 years ago Assets.php 4 years ago Backend_Page_Trait.php 4 years ago Course.php 4 years ago Course_Filter.php 4 years ago Course_List.php 4 years ago Course_Settings_Tabs.php 4 years ago Course_Widget.php 4 years ago Custom_Validation.php 4 years ago Dashboard.php 4 years ago FormHandler.php 4 years ago Frontend.php 4 years ago Gutenberg.php 4 years ago Input.php 4 years ago Instructor.php 4 years ago Instructors_List.php 4 years ago Lesson.php 4 years ago Options_V2.php 4 years ago Post_types.php 4 years ago Private_Course_Access.php 4 years ago Q_and_A.php 4 years ago Question_Answers_List.php 4 years ago Quiz.php 4 years ago Quiz_Attempts_List.php 4 years ago RestAPI.php 4 years ago Reviews.php 4 years ago Rewrite_Rules.php 4 years ago Shortcode.php 4 years ago Student.php 4 years ago Students_List.php 4 years ago Taxonomies.php 4 years ago Template.php 4 years ago Theme_Compatibility.php 5 years ago Tools.php 4 years ago Tools_V2.php 4 years ago Tutor.php 4 years ago TutorEDD.php 4 years ago Tutor_Base.php 5 years ago Tutor_List_Table.php 4 years ago Tutor_Setup.php 4 years ago Upgrader.php 4 years ago User.php 4 years ago Utils.php 4 years ago Video_Stream.php 4 years ago Withdraw.php 4 years ago Withdraw_Requests_List.php 4 years ago WooCommerce.php 4 years ago
Tools_V2.php
530 lines
1 <?php
2
3 /**
4 * Options for TutorLMS
5 *
6 * @since v.2.0
7 *
8 * @author Themeum
9 * @url https://themeum.com
10 *
11 * @package TutorLMS/Certificate
12 * @version 2.0
13 */
14
15 namespace Tutor;
16
17 use TUTOR\Admin;
18
19 if ( ! defined( 'ABSPATH' ) ) {
20 exit;
21 }
22
23 class Tools_V2 {
24
25 private $environment_status;
26 private $tools_fields;
27
28 public function tutor_apply_settings() {
29 $tutor_settings_log = get_option( 'tutor_settings_log' );
30 $apply_id = $this->get_request_data( 'apply_id' );
31
32 update_option( 'tutor_option', $tutor_settings_log[ $apply_id ]['dataset'] );
33
34 wp_send_json_success( $tutor_settings_log[ $apply_id ] );
35 }
36
37 public function get_request_data( $var ) {
38 return isset( $_REQUEST[ $var ] ) ? $_REQUEST[ $var ] : null;
39 }
40
41 /**
42 * tutor_default_settings
43 *
44 * @return JSON
45 */
46 public function tutor_default_settings() {
47 $attr = $this->get_setting_fields();
48 foreach ( $attr as $sections ) {
49 foreach ( $sections['sections'] as $section ) {
50 foreach ( $section['blocks'] as $blocks ) {
51 foreach ( $blocks['fields'] as $field ) {
52 if ( isset( $field['default'] ) ) {
53 $attr_default[ $field['key'] ] = $field['default'];
54 }
55 }
56 }
57 }
58 }
59
60 update_option( 'tutor_option', $attr_default );
61
62 wp_send_json_success( $attr_default );
63 }
64
65 public function load_tools_page() {
66 $tools_fields = $this->get_tools_fields();
67 $tutor_setup = array( 'tutor-setup' => $tools_fields['tutor-setup'] );
68 unset( $tools_fields['tutor-setup'] );
69 $tools_fields = array_merge( $tools_fields, $tutor_setup );
70
71 $active_tab = tutor_utils()->array_get( 'sub_page', $_GET, 'status' );
72 include tutor()->path . '/views/options/tools.php';
73 }
74
75 /**
76 * Function options_tools
77 *
78 * @return void
79 */
80 private function get_tools_fields() {
81 global $wpdb;
82
83 if ( $this->tools_fields ) {
84 // Return fields if already prepared
85 return $this->tools_fields;
86 }
87
88 $attr_tools = array(
89 'status' => array(
90 'label' => __( 'Status', 'tutor' ),
91 'slug' => 'status',
92 'desc' => __( 'Status Settings', 'tutor' ),
93 'template' => 'status',
94 'view_path' => tutor()->path . 'views/options/template/',
95 'icon' => 'tutor-icon-chart-pie',
96 'blocks' => array(
97 'wordpress_environment' => array(
98 'label' => __( 'WordPress environment', 'tutor' ),
99 'slug' => 'wordpress_environment',
100 'classes' => 'wordpress_environment',
101 'block_type' => 'column',
102 'fieldset' => array(
103 array(
104 array(
105 'key' => 'home_url',
106 'type' => 'info_row',
107 'label' => __( 'Home URL', 'tutor' ),
108 'status' => 'default',
109 'default' => $this->status( 'home_url' ),
110 ),
111 ),
112 array(
113 array(
114 'key' => 'wordpress_version',
115 'type' => 'info_col',
116 'label' => __( 'WordPress version', 'tutor' ),
117 'status' => 'default',
118 'default' => $this->status( 'wordpress_version' ),
119
120 ),
121 array(
122 'key' => 'wordpress_multisite',
123 'type' => 'info_col',
124 'label' => __( 'WordPress multisite', 'tutor' ),
125 'status' => 'default',
126 'default' => $this->status( 'wordpress_multisite' ),
127
128 ),
129 array(
130 'key' => 'wordpress_debug_mode',
131 'type' => 'info_col',
132 'label' => __( 'WordPress debug mode', 'tutor' ),
133 'status' => ( defined( 'WP_DEBUG' ) && true === WP_DEBUG ) ? 'success' : 'default',
134 'default' => $this->status( 'wordpress_debug_mode' ),
135
136 ),
137 array(
138 'key' => 'language',
139 'type' => 'info_col',
140 'label' => __( 'Language', 'tutor' ),
141 'status' => 'default',
142 'default' => $this->status( 'language' ),
143
144 ),
145 ),
146 array(
147 array(
148 'key' => 'site_url',
149 'type' => 'info_row',
150 'label' => __( 'Site URL', 'tutor' ),
151 'status' => 'default',
152 'default' => $this->status( 'site_url' ),
153
154 ),
155 ),
156 array(
157 array(
158 'key' => 'tutor_version',
159 'type' => 'info_col',
160 'label' => __( 'Tutor version', 'tutor' ),
161 'status' => 'success',
162 'default' => $this->status( 'tutor_version' ),
163
164 ),
165 array(
166 'key' => 'wordpress_memory_limit',
167 'type' => 'info_col',
168 'label' => __( 'WordPress memory limit', 'tutor' ),
169 'status' => 'success',
170 'default' => $this->status( 'wordpress_memory_limit' ),
171
172 ),
173 array(
174 'key' => 'wordpress_cron',
175 'type' => 'info_col',
176 'label' => __( 'WordPress corn', 'tutor' ),
177 'status' => ! empty( _get_cron_array() ) ? 'success' : 'default',
178 'default' => $this->status( 'wordpress_cron' ),
179
180 ),
181 array(
182 'key' => 'external_object_cache',
183 'type' => 'info_col',
184 'label' => __( 'External object cache', 'tutor' ),
185 'status' => 'default',
186 'default' => $this->status( 'external_object_cache' ),
187
188 ),
189 ),
190 ),
191 ),
192 'server_environment' => array(
193 'label' => __( 'Server environment', 'tutor' ),
194 'slug' => 'server_environment',
195 'block_type' => 'column',
196 'fieldset' => array(
197 array(
198 array(
199 'key' => 'server_info',
200 'type' => 'info_col',
201 'label' => __( 'Server info', 'tutor' ),
202 'status' => 'default',
203 'default' => $this->status( 'server_info' ),
204
205 ),
206 array(
207 'key' => 'php_version',
208 'type' => 'info_col',
209 'label' => __( 'PHP version', 'tutor' ),
210 'status' => 'default',
211 'default' => $this->status( 'php_version' ),
212
213 ),
214 array(
215 'key' => 'php_post_max_size',
216 'type' => 'info_col',
217 'label' => __( 'PHP post max size', 'tutor' ),
218 'status' => 'default',
219 'default' => $this->status( 'php_post_max_size' ),
220
221 ),
222 array(
223 'key' => 'php_time_limit',
224 'type' => 'info_col',
225 'label' => __( 'PHP time limit', 'tutor' ),
226 'status' => 'default',
227 'default' => $this->status( 'php_time_limit' ),
228
229 ),
230 array(
231 'key' => 'curl_version',
232 'type' => 'info_col',
233 'label' => __( 'cURL version', 'tutor' ),
234 'status' => 'default',
235 'default' => $this->status( 'curl_version' ),
236
237 ),
238 array(
239 'key' => 'language',
240 'type' => 'info_col',
241 'label' => __( 'Language', 'tutor' ),
242 'status' => 'default',
243 'default' => $this->status( 'language' ),
244
245 ),
246 ),
247 array(
248 array(
249 'key' => 'tutor_version',
250 'type' => 'info_col',
251 'label' => __( 'MySQL version', 'tutor' ),
252 'status' => 'default',
253 'default' => sprintf( 'Server: %s, Client: %s', $wpdb->dbh->server_info, $wpdb->dbh->client_info ),
254 ),
255 array(
256 'key' => 'wordpress_memory_limit',
257 'type' => 'info_col',
258 'label' => __( 'Default timezone is UTC', 'tutor' ),
259 'status' => 'default',
260 'default' => $this->status( 'default_timezone_is_utc' ),
261 ),
262 array(
263 'key' => 'wordpress_cron',
264 'type' => 'info_col',
265 'label' => __( 'fsockopen/cURL', 'tutor' ),
266 'status' => 'default',
267 'default' => $this->status( 'fsockopen_curl' ),
268 ),
269 array(
270 'key' => 'external_object_cache',
271 'type' => 'info_col',
272 'label' => __( 'DOMDocument', 'tutor' ),
273 'status' => 'default',
274 'default' => $this->status( 'dom_document' ),
275 ),
276 array(
277 'key' => 'external_object_cache',
278 'type' => 'info_col',
279 'label' => __( 'GZip', 'tutor' ),
280 'status' => 'default',
281 'default' => $this->status( 'gzip' ),
282 ),
283 array(
284 'key' => 'external_object_cache',
285 'type' => 'info_col',
286 'label' => __( 'Multibyte string', 'tutor' ),
287 'status' => 'default',
288 'default' => $this->status( 'multibyte_string' ),
289 ),
290 ),
291 ),
292 ),
293 ),
294 ),
295 'import_export' => array(
296 'label' => __( 'Import/Export', 'tutor' ),
297 'slug' => 'import_export',
298 'desc' => __( 'Import/Export Settings', 'tutor' ),
299 'template' => 'import_export',
300 'view_path' => tutor()->path . 'views/options/template/',
301 'icon' => 'tutor-icon-import-export',
302 'blocks' => array(),
303 ),
304 'tutor_pages' => array(
305 'label' => __( 'Tutor Pages', 'tutor' ),
306 'slug' => 'tutor_pages',
307
308 'desc' => __( 'Tutor Pages Settings', 'tutor' ),
309 'template' => 'tutor_pages',
310 'view_path' => tutor()->path . 'views/options/template/',
311 'icon' => 'tutor-icon-page-review',
312 'blocks' => array(
313 'block' => array(),
314 ),
315 ),
316 'tutor-setup' => array(
317 'label' => __( 'Setup Wizard', 'tutor' ),
318 'slug' => 'tutor-setup',
319 'desc' => __( 'Setup Wizard Settings', 'tutor' ),
320 'icon' => 'tutor-icon-earth',
321 'blocks' => array(
322 'block' => array(),
323 ),
324 ),
325 );
326
327 $attr_tools = apply_filters( 'tutor/tools/extend/attr', apply_filters( 'tutor/tools/attr', apply_filters( 'tutor_tool_pages', $attr_tools ) ) );
328
329 $this->tools_fields = $attr_tools;
330
331 return $this->tools_fields;
332 }
333
334 private function get_environment_info() {
335
336 if ( $this->environment_status ) {
337 // Use runtime cache for repetitve call
338 return $this->environment_status;
339 }
340
341 // Figure out cURL version, if installed.
342 $curl_version = '';
343 if ( function_exists( 'curl_version' ) ) {
344 $curl_version = curl_version();
345 $curl_version = $curl_version['version'] . ', ' . $curl_version['ssl_version'];
346 }
347
348 // WP memory limit.
349 $wp_memory_limit = tutor_utils()->let_to_num( WP_MEMORY_LIMIT );
350 if ( function_exists( 'memory_get_usage' ) ) {
351 $wp_memory_limit = max( $wp_memory_limit, tutor_utils()->let_to_num( @ini_get( 'memory_limit' ) ) );
352 }
353
354 $database_version = tutor_utils()->get_db_version();
355
356 $this->environment_status = array(
357 'home_url' => get_option( 'home' ),
358 'site_url' => get_option( 'siteurl' ),
359 'version' => TUTOR_VERSION,
360 'wp_version' => get_bloginfo( 'version' ),
361 'wp_multisite' => is_multisite(),
362 'wp_memory_limit' => $wp_memory_limit,
363 'wp_debug_mode' => ( defined( 'WP_DEBUG' ) && WP_DEBUG ),
364 'wp_cron' => ! ( defined( 'DISABLE_WP_CRON' ) && DISABLE_WP_CRON ),
365 'language' => get_locale(),
366 'external_object_cache' => wp_using_ext_object_cache(),
367 'server_info' => isset( $_SERVER['SERVER_SOFTWARE'] ) ? wp_unslash( $_SERVER['SERVER_SOFTWARE'] ) : '',
368 'php_version' => phpversion(),
369 'php_post_max_size' => tutor_utils()->let_to_num( ini_get( 'post_max_size' ) ),
370 'php_max_execution_time' => ini_get( 'max_execution_time' ),
371 'php_max_input_vars' => ini_get( 'max_input_vars' ),
372 'curl_version' => $curl_version,
373 'suhosin_installed' => extension_loaded( 'suhosin' ),
374 'max_upload_size' => wp_max_upload_size(),
375 'mysql_version' => $database_version['number'],
376 'mysql_version_string' => $database_version['string'],
377 'default_timezone' => date_default_timezone_get(),
378 'fsockopen_or_curl_enabled' => ( function_exists( 'fsockopen' ) || function_exists( 'curl_init' ) ),
379 'soapclient_enabled' => class_exists( 'SoapClient' ),
380 'domdocument_enabled' => class_exists( 'DOMDocument' ),
381 'gzip_enabled' => is_callable( 'gzopen' ),
382 'mbstring_enabled' => extension_loaded( 'mbstring' ),
383 );
384
385 return $this->environment_status;
386 }
387
388 public function status( $type = '' ) {
389
390 $data = array();
391 $data[ null ] = 'null';
392
393 $environment = $this->get_environment_info();
394
395 $data['home_url'] = $environment['home_url'] ?? null;
396 $data['site_url'] = $environment['site_url'] ?? null;
397
398 $latest_version = get_transient( 'tutor_system_status_wp_version_check' );
399
400 // WordPress already has efficient update notification mechanism.
401 // We don't need to slow down the page for no reason.
402 /*
403 if ( false === $latest_version ) {
404 $version_check = wp_remote_get( 'https://api.wordpress.org/core/version-check/1.7/' );
405 $api_response = json_decode( wp_remote_retrieve_body( $version_check ), true );
406
407 $latest_version = ( $api_response && isset( $api_response['offers'], $api_response['offers'][0], $api_response['offers'][0]['version'] ) )
408 ? $api_response['offers'][0]['version']
409 : $environment['wp_version'];
410 set_transient( 'tutor_system_status_wp_version_check', $latest_version, DAY_IN_SECONDS );
411 }
412
413 $data['wordpress_version'] = ( version_compare( $environment['wp_version'], $latest_version, '<' ) )
414 ? sprintf( esc_html__( '%1$s - There is a newer version of WordPress available (%2$s)', 'tutor' ), esc_html( $environment['wp_version'] ), esc_html( $latest_version ) )
415 : esc_html( $environment['wp_version'] ); */
416
417 $data['wordpress_version'] = esc_html( $environment['wp_version'] );
418
419 $data['tutor_version'] = esc_html( $environment['version'] );
420
421 $data['wordpress_multisite'] = $environment['wp_multisite'] ? '' : '-';
422
423 $data['wordpress_debug_mode'] = $environment['wp_debug_mode'] ? '' : '-';
424
425 $data['language'] = esc_html( $environment['language'] );
426
427 $data['wordpress_memory_limit'] = ( $environment['wp_memory_limit'] < 67108864 )
428 ? 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>' )
429 : esc_html( size_format( $environment['wp_memory_limit'] ) );
430
431 $data['wordpress_cron'] = $environment['wp_cron'] ? '' : '-';
432
433 $data['external_object_cache'] = $environment['external_object_cache'] ? '' : '-';
434
435 $data['server_info'] = $environment['server_info'] ?? null;
436
437 $data['php_version'] = ( version_compare( $environment['php_version'], '7.2', '>=' ) )
438 ? esc_html( $environment['php_version'] )
439 : ( ( version_compare( $environment['php_version'], '5.6', '<' ) )
440 ? __( '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' )
441 : __( 'We recommend using PHP version 7.2 or above for greater performance and security.', 'tutor' ) );
442
443 $data['php_post_max_size'] = esc_html( size_format( $environment['php_post_max_size'] ) ) ?? null;
444
445 $data['php_time_limit'] = esc_html( $environment['php_max_execution_time'] ) ?? null;
446
447 $data['php_max_input_vars'] = esc_html( $environment['php_max_input_vars'] ) ?? null;
448
449 $data['curl_version'] = esc_html( $environment['curl_version'] ) ?? null;
450
451 $data['suhosin_installed'] = $environment['suhosin_installed'] ? '' : '-';
452
453 $data['max_upload_size'] = esc_html( size_format( $environment['max_upload_size'] ) ) ?? null;
454
455 $data['mysql_version'] = ( version_compare( $environment['mysql_version'], '5.6', '<' ) && ! strstr( $environment['mysql_version_string'], 'MariaDB' ) )
456 ? 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>' )
457 : esc_html( $environment['mysql_version_string'] );
458
459 $data['default_timezone_is_utc'] = ( 'UTC' !== $environment['default_timezone'] )
460 ? sprintf( esc_html__( 'Default timezone is %s - it should be UTC', 'tutor' ), esc_html( $environment['default_timezone'] ) )
461 : '';
462
463 $data['fsockopen_curl'] = $environment['fsockopen_or_curl_enabled']
464 ? ''
465 : 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' );
466
467 $data['dom_document'] = $environment['domdocument_enabled']
468 ? ''
469 : 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>' );
470
471 $data['gzip'] = ( $environment['gzip_enabled'] )
472 ? ''
473 : 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>' );
474
475 $data['multibyte_string'] = ( $environment['mbstring_enabled'] )
476 ? ''
477 : 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>' );
478
479 if ( ! null == $type ) {
480 return $data[ $type ];
481 }
482
483 return $data[ null ];
484 }
485
486 /**
487 * @param array $field
488 *
489 * @return string
490 *
491 * Generate Option Field
492 */
493 public function generate_field( $field = array() ) {
494 ob_start();
495 include tutor()->path . "views/options/field-types/{$field['type']}.php";
496
497 return ob_get_clean();
498 }
499
500 public function field_type( $field = array() ) {
501 ob_start();
502 include tutor()->path . "views/options/field-types/{$field['type']}.php";
503 return ob_get_clean();
504 }
505
506 public function blocks( $blocks = array() ) {
507 ob_start();
508 include tutor()->path . 'views/options/option_blocks.php';
509 return ob_get_clean();
510 }
511
512 public function template( $section = array() ) {
513 ob_start();
514 include $section['view_path'] . $section['template'] . '.php';
515 return ob_get_clean();
516 }
517 /**
518 * Load template inside template dirctory
519 *
520 * @param mixed $template_slug
521 * @param mixed $section
522 * @return void
523 */
524 public function view_template( $template_slug, $section = array() ) {
525 ob_start();
526 require tutor()->path . "views/options/template/{$template_slug}";
527 return ob_get_clean();
528 }
529 }
530