PluginProbe
Ultimate Store Kit – Addon For WooCommerce, EDD and Elementor / trunk
Ultimate Store Kit – Addon For WooCommerce, EDD and Elementor vtrunk
3.0.7 3.0.5 3.0.4 3.0.3 3.0.2 trunk 1.5.0 1.5.1 1.5.2 1.6.1 1.6.2 1.6.3 1.6.4 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.1.0 2.1.1 2.1.10 2.1.2 2.1.3 All 87 releases
ultimate-store-kit / includes / utils.php

utils.php in Ultimate Store Kit – Addon For WooCommerce, EDD and Elementor trunk, at includes/utils.php

119 lines 2.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace UltimateStoreKit\Classes;
4
5 if (!defined('ABSPATH'))
6 exit; // Exit if accessed directly
7
8 class Utils
9 {
10
11
12 public static function get_site_domain()
13 {
14 return str_ireplace('www.', '', wp_parse_url(home_url(), PHP_URL_HOST));
15 }
16
17 public static function readable_num($size)
18 {
19 $l = substr($size, -1);
20 $ret = substr($size, 0, -1);
21 $byte = 1024;
22
23 switch (strtoupper($l)) {
24 case 'P':
25 $ret *= 1024;
26 case 'T':
27 $ret *= 1024;
28 case 'G':
29 $ret *= 1024;
30 case 'M':
31 $ret *= 1024;
32 case 'K':
33 $ret *= 1024;
34 }
35 return $ret;
36 }
37
38 /**
39 * For get wp environment for ultimate store kit
40 * @return [type] [description]
41 */
42 public static function get_environment_info()
43 {
44
45 // Figure out cURL version, if installed.
46 $curl_version = '';
47 if (function_exists('curl_version')) {
48 $curl_version = curl_version();
49 $curl_version = $curl_version['version'] . ', ' . $curl_version['ssl_version'];
50 }
51
52
53 // WP memory limit.
54 $wp_memory_limit = self::readable_num(WP_MEMORY_LIMIT);
55 if (function_exists('memory_get_usage')) {
56 $wp_memory_limit = max($wp_memory_limit, self::readable_num(@ini_get('memory_limit')));
57 }
58
59
60 return array(
61 'home_url' => get_option('home'),
62 'site_url' => get_option('siteurl'),
63 'version' => BDTUSK_VER,
64 'wp_version' => get_bloginfo('version'),
65 'wp_multisite' => is_multisite(),
66 'wp_memory_limit' => $wp_memory_limit,
67 'wp_debug_mode' => (defined('WP_DEBUG') && WP_DEBUG),
68 'wp_cron' => !(defined('DISABLE_WP_CRON') && DISABLE_WP_CRON),
69 'language' => get_locale(),
70 'external_object_cache' => wp_using_ext_object_cache(),
71 'php_version' => phpversion(),
72 'php_post_max_size' => self::readable_num(ini_get('post_max_size')),
73 'php_max_execution_time' => ini_get('max_execution_time'),
74 'php_max_input_vars' => ini_get('max_input_vars'),
75 'curl_version' => $curl_version,
76 'suhosin_installed' => extension_loaded('suhosin'),
77 'max_upload_size' => wp_max_upload_size(),
78 'default_timezone' => date_default_timezone_get(),
79 'fsockopen_or_curl_enabled' => (function_exists('fsockopen') || function_exists('curl_init')),
80 'soapclient_enabled' => class_exists('SoapClient'),
81 'domdocument_enabled' => class_exists('DOMDocument'),
82 'gzip_enabled' => is_callable('gzopen'),
83 'mbstring_enabled' => extension_loaded('mbstring'),
84 );
85 }
86
87 /**
88 * A list of safe tage for `get_valid_html_tag` method.
89 */
90 const ALLOWED_HTML_WRAPPER_TAGS = [
91 'article',
92 'aside',
93 'div',
94 'footer',
95 'h1',
96 'h2',
97 'h3',
98 'h4',
99 'h5',
100 'h6',
101 'header',
102 'main',
103 'nav',
104 'p',
105 'section',
106 'span',
107 ];
108
109 /**
110 * Validate an HTML tag against a safe allowed list.
111 * @param string $tag
112 * @return string
113 */
114 public static function get_valid_html_tag($tag)
115 {
116 return in_array(strtolower($tag), self::ALLOWED_HTML_WRAPPER_TAGS) ? $tag : 'div';
117 }
118 }
119