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