Diff: STRATO-apps/wordpress_03/app/wp-content/plugins/bdthemes-element-pack-lite/includes/utils.php

Keine Baseline-Datei – Diff nur gegen leer.
Zur Liste
1 -
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 +