PluginProbe ʕ •ᴥ•ʔ
Element Pack – Widgets, Templates & Addons for Elementor / 5.10.21
Element Pack – Widgets, Templates & Addons for Elementor v5.10.21
8.7.5 8.7.4 8.7.3 8.7.2 8.7.1 8.7.0 8.6.3 8.6.2 8.6.1 trunk 1.0 1.0.1 1.0.3 1.1.0 1.2.0 1.8.0 2.1.0 2.7.0 2.9.2 3.7.3 4.10.0 4.10.1 4.10.2 4.10.3 4.11.0 4.11.1 4.11.2 4.3.0 4.5.0 4.8.2 5.0.0 5.0.1 5.1.0 5.1.1 5.1.2 5.1.3 5.10.0 5.10.1 5.10.10 5.10.11 5.10.12 5.10.13 5.10.14 5.10.15 5.10.16 5.10.17 5.10.18 5.10.19 5.10.2 5.10.20 5.10.21 5.10.22 5.10.23 5.10.24 5.10.25 5.10.26 5.10.27 5.10.28 5.10.29 5.10.3 5.10.30 5.10.4 5.10.5 5.10.6 5.10.7 5.10.8 5.10.9 5.11.0 5.11.1 5.11.2 5.11.3 5.2.2 5.2.3 5.3.0 5.3.1 5.4.0 5.4.1 5.4.10 5.4.11 5.4.13 5.4.14 5.4.2 5.4.3 5.4.4 5.4.5 5.4.6 5.4.7 5.4.8 5.4.9 5.5.0 5.5.2 5.5.6 5.6.0 5.6.10 5.6.11 5.6.12 5.6.13 5.6.14 5.6.2 5.6.3 5.6.4 5.6.5 5.6.6 5.6.7 5.6.8 5.6.9 5.7.0 5.7.1 5.7.2 5.7.3 5.7.4 5.7.5 5.7.6 5.7.7 5.7.8 5.8.0 5.8.1 5.8.2 5.8.3 5.8.4 5.8.5 5.9.0 8.0.0 8.1.0 8.1.1 8.1.10 8.1.2 8.1.3 8.1.4 8.1.5 8.1.6 8.1.7 8.1.8 8.1.9 8.2.0 8.2.1 8.2.2 8.2.3 8.2.4 8.2.5 8.2.6 8.3.0 8.3.1 8.3.10 8.3.11 8.3.12 8.3.13 8.3.14 8.3.15 8.3.16 8.3.17 8.3.18 8.3.19 8.3.2 8.3.3 8.3.4 8.3.5 8.3.6 8.3.7 8.3.8 8.3.9 8.4.0 8.4.1 8.4.2 8.5.0 8.5.1 8.5.2 8.6.0
bdthemes-element-pack-lite / includes / utils.php
bdthemes-element-pack-lite / includes Last commit date
compatiblity 1 year ago controls 1 year ago feedback-hub 1 year ago live-copy 1 year ago template-library 1 year ago twitteroauth 1 year ago widgets 1 year ago class-duplicator.php 1 year ago class-elements-wpml-compatibility.php 1 year ago class-fb-access-token-generator-control.php 1 year ago class-google-recaptcha.php 1 year ago class-json-file-upload-control.php 1 year ago class-parsedown.php 1 year ago class-pro-widget-map.php 1 year ago class-rooten-theme-compatibility.php 1 year ago class-svg-support.php 1 year ago controls.php 1 year ago element-pack-filters.php 1 year ago helper.php 1 year ago modules-manager.php 1 year ago utils.php 1 year ago
utils.php
179 lines
1 <?php
2 namespace ElementPack;
3
4 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
5
6 class Utils {
7
8 /**
9 * A list of safe tage for `get_valid_html_tag` method.
10 */
11 const ALLOWED_HTML_WRAPPER_TAGS = [
12 'article',
13 'aside',
14 'div',
15 'footer',
16 'h1',
17 'h2',
18 'h3',
19 'h4',
20 'h5',
21 'h6',
22 'header',
23 'main',
24 'nav',
25 'p',
26 'section',
27 'span',
28 ];
29
30 public static function get_client_ip() {
31 $server_ip_keys = [
32 'HTTP_CLIENT_IP',
33 'HTTP_X_FORWARDED_FOR',
34 'HTTP_X_FORWARDED',
35 'HTTP_X_CLUSTER_CLIENT_IP',
36 'HTTP_FORWARDED_FOR',
37 'HTTP_FORWARDED',
38 'REMOTE_ADDR',
39 ];
40
41 foreach ( $server_ip_keys as $key ) {
42 if ( isset( $_SERVER[ $key ] ) && filter_var( $_SERVER[ $key ], FILTER_VALIDATE_IP ) ) {
43 return $_SERVER[ $key ];
44 }
45 }
46
47 // Fallback local ip.
48 return '127.0.0.1';
49 }
50
51 public static function get_site_domain() {
52 return str_ireplace( 'www.', '', parse_url( home_url(), PHP_URL_HOST ) );
53 }
54
55 public static function readable_num( $size ) {
56 $l = substr( $size, -1 );
57 $ret = substr( $size, 0, -1 );
58
59 switch ( strtoupper( $l ) ) {
60 case 'P':
61 $ret *= 1024;
62 break;
63 case 'T':
64 $ret *= 1024;
65 break;
66 case 'G':
67 $ret *= 1024;
68 break;
69 case 'M':
70 $ret *= 1024;
71 break;
72 case 'K':
73 $ret *= 1024;
74 }
75 return $ret;
76 }
77
78 /**
79 * Validate an HTML tag against a safe allowed list.
80 * @param string $tag
81 * @return string
82 */
83 public static function get_valid_html_tag( $tag ) {
84 return in_array( strtolower( $tag ), self::ALLOWED_HTML_WRAPPER_TAGS ) ? $tag : 'div';
85 }
86
87 /**
88 * Get placeholder image source.
89 * Retrieve the source of the placeholder image.
90 * @since 5.7.6
91 * @access public
92 * @static
93 * @return string The source of the default placeholder image used by Elementor.
94 */
95 public static function get_placeholder_image_src() {
96 $placeholder_image = ELEMENTOR_ASSETS_URL . 'images/placeholder.png';
97
98 return $placeholder_image;
99 }
100
101 /**
102 * For get wp environment for element pack
103 * @return [type] [description]
104 */
105 public static function get_environment_info(){
106
107 // Figure out cURL version, if installed.
108 $curl_version = '';
109 if ( function_exists( 'curl_version' ) ) {
110 $curl_version = curl_version();
111 $curl_version = $curl_version['version'] . ', ' . $curl_version['ssl_version'];
112 }
113
114
115 // WP memory limit.
116 $wp_memory_limit = self::readable_num(WP_MEMORY_LIMIT);
117 if ( function_exists( 'memory_get_usage' ) ) {
118 $wp_memory_limit = max( $wp_memory_limit, self::readable_num( @ini_get( 'memory_limit' ) ) );
119 }
120
121
122 return array(
123 'home_url' => get_option( 'home' ),
124 'site_url' => get_option( 'siteurl' ),
125 'version' => BDTEP_VER,
126 'wp_version' => get_bloginfo( 'version' ),
127 'wp_multisite' => is_multisite(),
128 'wp_memory_limit' => $wp_memory_limit,
129 'wp_debug_mode' => ( defined( 'WP_DEBUG' ) && WP_DEBUG ),
130 'wp_cron' => ! ( defined( 'DISABLE_WP_CRON' ) && DISABLE_WP_CRON ),
131 'language' => get_locale(),
132 'external_object_cache' => wp_using_ext_object_cache(),
133 'server_info' => isset( $_SERVER['SERVER_SOFTWARE'] ) ? wp_unslash( $_SERVER['SERVER_SOFTWARE'] ) : '',
134 'php_version' => phpversion(),
135 'php_post_max_size' => self::readable_num( ini_get( 'post_max_size' ) ),
136 'php_max_execution_time' => ini_get( 'max_execution_time' ),
137 'php_max_input_vars' => ini_get( 'max_input_vars' ),
138 'curl_version' => $curl_version,
139 'suhosin_installed' => extension_loaded( 'suhosin' ),
140 'max_upload_size' => wp_max_upload_size(),
141 'default_timezone' => date_default_timezone_get(),
142 'fsockopen_or_curl_enabled' => ( function_exists( 'fsockopen' ) || function_exists( 'curl_init' ) ),
143 'soapclient_enabled' => class_exists( 'SoapClient' ),
144 'domdocument_enabled' => class_exists( 'DOMDocument' ),
145 'gzip_enabled' => is_callable( 'gzopen' ),
146 'mbstring_enabled' => extension_loaded( 'mbstring' ),
147 );
148
149 }
150
151 /**
152 * Get timezone string.
153 *
154 * Retrieve timezone string from the WordPress database.
155 *
156 * @since 1.0.0
157 * @access public
158 * @static
159 *
160 * @return string Timezone string.
161 */
162 public static function get_timezone_string() {
163 $current_offset = (float) get_option( 'gmt_offset' );
164 $timezone_string = get_option( 'timezone_string' );
165
166 // Create a UTC+- zone if no timezone string exists.
167 if ( empty( $timezone_string ) ) {
168 if ( $current_offset < 0 ) {
169 $timezone_string = 'UTC' . $current_offset;
170 } else {
171 $timezone_string = 'UTC+' . $current_offset;
172 }
173 }
174
175 return $timezone_string;
176 }
177
178 }
179