PluginProbe
Optimole – Optimize Images | Convert WebP & AVIF | CDN & Lazy Load | Image Optimization / trunk
Optimole – Optimize Images | Convert WebP & AVIF | CDN & Lazy Load | Image Optimization vtrunk
4.2.14 4.2.13 4.2.12 4.2.11 4.2.10 4.2.9 4.2.8 4.2.7 4.2.6 4.2.5 2.5.5 2.5.6 2.5.7 3.0.0 3.0.1 3.1.0 3.1.1 3.1.2 3.1.3 3.10.0 3.11.0 3.11.1 3.11.2 3.11.3 3.12.0 All 135 releases
← All changes | vendor/codeinwp/themeisle-sdk/load.php +167 -15 3.11.3 → trunk View file →
@@ -13,9 +13,9 @@
13 13 if ( ! defined( 'ABSPATH' ) ) {
14 14 return;
15 15 }
16 16 // Current SDK version and path.
17 -$themeisle_sdk_version = '3.3.7';
17 +$themeisle_sdk_version = '3.3.62';
18 18 $themeisle_sdk_path = dirname( __FILE__ );
19 19
20 20 global $themeisle_sdk_max_version;
21 21 global $themeisle_sdk_max_path;
@@ -71,8 +71,87 @@
71 71 }
72 72 endif;
73 73 add_action( 'init', 'themeisle_sdk_load_latest' );
74 74
75 +if ( ! function_exists( 'themeisle_sdk_crash_sentinel' ) ) :
76 + /**
77 + * Early crash sentinel: minimal shutdown-time capture of fatal errors
78 + * originating from a registered ThemeIsle product directory.
79 + *
80 + * Runs only when the full crash reporter module never registered (e.g. the
81 + * fatal happened during plugin bootstrap, before the SDK loaded on init).
82 + * Stores one raw record locally; the module sanitizes and adopts it on the
83 + * next normal load. Never outputs, never exits, fails silently.
84 + *
85 + * Must stay parseable on PHP 5.4, like the rest of this file.
86 + */
87 + function themeisle_sdk_crash_sentinel() {
88 + if ( defined( 'THEMEISLE_SDK_CRASH_HANDLER' ) ) {
89 + return;
90 + }
91 + if ( defined( 'WP_SANDBOX_SCRAPING' ) && WP_SANDBOX_SCRAPING ) {
92 + return;
93 + }
94 + if ( ! function_exists( 'apply_filters' ) || ! function_exists( 'get_option' ) || ! function_exists( 'update_option' ) || ! function_exists( 'add_option' ) ) {
95 + return;
96 + }
97 + $error = error_get_last();
98 + if ( empty( $error ) || ! isset( $error['type'] ) || ! in_array( (int) $error['type'], array( E_ERROR, E_PARSE, E_CORE_ERROR, E_COMPILE_ERROR ), true ) ) {
99 + return;
100 + }
101 + $error_file = isset( $error['file'] ) ? str_replace( '\\', '/', (string) $error['file'] ) : '';
102 + if ( '' === $error_file ) {
103 + return;
104 + }
105 + $products = apply_filters( 'themeisle_sdk_products', array() );
106 + if ( empty( $products ) || ! is_array( $products ) ) {
107 + return;
108 + }
109 + foreach ( $products as $basefile ) {
110 + $product_dir = rtrim( str_replace( '\\', '/', dirname( (string) $basefile ) ), '/' ) . '/';
111 + if ( '/' === $product_dir || 0 !== strpos( $error_file, $product_dir ) ) {
112 + continue;
113 + }
114 + $key = str_replace( '-', '_', strtolower( trim( basename( $product_dir ) ) ) );
115 + $option = $key . '_crash_data';
116 + $data = get_option( $option, array() );
117 + if ( ! is_array( $data ) ) {
118 + $data = array();
119 + }
120 + if ( ! isset( $data['raw'] ) || ! is_array( $data['raw'] ) ) {
121 + $data['raw'] = array();
122 + }
123 + if ( count( $data['raw'] ) >= 3 ) {
124 + return;
125 + }
126 + foreach ( $data['raw'] as $record ) {
127 + if ( isset( $record['file'] ) && isset( $record['line'] ) && $record['file'] === $error_file && (int) $record['line'] === (int) $error['line'] ) {
128 + return;
129 + }
130 + }
131 + $data['raw'][] = array(
132 + 'type' => (int) $error['type'],
133 + 'message' => substr( isset( $error['message'] ) ? (string) $error['message'] : '', 0, 2000 ),
134 + 'file' => $error_file,
135 + 'line' => isset( $error['line'] ) ? (int) $error['line'] : 0,
136 + 'time' => time(),
137 + );
138 + if ( false === get_option( $option, false ) ) {
139 + add_option( $option, $data, '', 'no' );
140 + } else {
141 + update_option( $option, $data );
142 + }
143 +
144 + return;
145 + }
146 + }
147 +endif;
148 +
149 +if ( empty( $GLOBALS['themeisle_sdk_crash_sentinel'] ) ) {
150 + $GLOBALS['themeisle_sdk_crash_sentinel'] = true;
151 + register_shutdown_function( 'themeisle_sdk_crash_sentinel' );
152 +}
153 +
75 154 if ( ! function_exists( 'tsdk_utmify' ) ) {
76 155 /**
77 156 * Utmify a link.
78 157 *
@@ -89,10 +168,11 @@
89 168 $screen = function_exists( 'get_current_screen' ) ? get_current_screen() : $pagenow;
90 169 $current_page = isset( $screen->id ) ? $screen->id : ( ( $screen === null ) ? 'non-admin' : $screen );
91 170 $current_page = sanitize_key( str_replace( '.php', '', $current_page ) );
92 171 }
93 - $location = $location === null ? $current_page : $location;
94 - $content = sanitize_key(
172 + $location = $location === null ? $current_page : $location;
173 + $is_upgrade_url = strpos( $url, '/upgrade' ) !== false;
174 + $content = sanitize_key(
95 175 trim(
96 176 str_replace(
97 177 [
98 178 'https://',
@@ -101,24 +181,49 @@
101 181 '/plugins/',
102 182 '/upgrade',
103 183 ],
104 184 '',
105 - $url
185 + $url
106 186 ),
107 - '/'
108 - )
187 + '/'
188 + )
109 189 );
110 - return esc_url_raw(
190 + $filter_key = sanitize_key( $content );
191 + $url_args = [
192 + 'utm_source' => 'wpadmin',
193 + 'utm_medium' => $location,
194 + 'utm_campaign' => $area,
195 + 'utm_content' => $content,
196 + ];
197 + $query_arguments = apply_filters( 'tsdk_utmify_' . $filter_key, $url_args, $url );
198 + $utmify_url = esc_url_raw(
111 199 add_query_arg(
112 - [
113 - 'utm_source' => 'wpadmin',
114 - 'utm_medium' => $location,
115 - 'utm_campaign' => $area,
116 - 'utm_content' => $content,
117 - ],
118 - $url
119 - )
200 + $query_arguments,
201 + $url
202 + )
120 203 );
204 +
205 + /**
206 + * Check if there is an affiliate URL for this upgrade link, if so use it.
207 + */
208 + if ( $is_upgrade_url ) {
209 + $option_content_key = str_replace( '-', '_', $filter_key );
210 + $theme_upgrade_option_name = 'themeisle_af_' . $option_content_key . '_themes_upgrade';
211 + $plugin_upgrade_option_name = 'themeisle_af_' . $option_content_key . '_plugins_upgrade';
212 +
213 + $theme_option_url = get_option( $theme_upgrade_option_name, false );
214 + if ( ! empty( $theme_option_url ) ) {
215 + $utmify_url = esc_url_raw( $theme_option_url );
216 + }
217 + $plugin_option_url = get_option( $plugin_upgrade_option_name, false );
218 + if ( ! empty( $plugin_option_url ) ) {
219 + $utmify_url = esc_url_raw( $plugin_option_url );
220 + }
221 + }
222 +
223 +
224 +
225 + return apply_filters( 'tsdk_utmify_url_' . $filter_key, $utmify_url, $url );
121 226 }
122 227
123 228 add_filter( 'tsdk_utmify', 'tsdk_utmify', 10, 3 );
124 229 }
@@ -170,8 +275,55 @@
170 275 * @return string Key.
171 276 */
172 277 function tsdk_lkey( $file ) {
173 278 return \ThemeisleSDK\Modules\Licenser::key( $file );
279 + }
280 +}
281 +
282 +if ( ! function_exists( 'tsdk_translate_link' ) ) {
283 +
284 + /**
285 + * Function to translate a link based on the current language.
286 + *
287 + * @param string $url URL to translate.
288 + * @param string{'path'|'query'|'domain'} $type Type of localization. Supports path, query and domain.
289 + * @param array $available_languages Available language to choose from.
290 + *
291 + * @return string
292 + */
293 + function tsdk_translate_link(
294 + $url, $type = 'path', $available_languages = [
295 + 'de_DE' => 'de',
296 + 'de_DE_formal' => 'de',
297 + 'es_ES' => 'es',
298 + 'fr_FR' => 'fr',
299 + 'it_IT' => 'it',
300 + 'ja' => 'ja',
301 + 'nl_NL' => 'nl',
302 + 'nl_NL_formal' => 'nl',
303 + 'ro_RO' => 'ro',
304 + ]
305 + ) {
306 + $language = get_user_locale();
307 + if ( ! isset( $available_languages[ $language ] ) ) {
308 + return $url;
309 + }
310 + $code = $available_languages[ $language ];
311 + // We asume that false is based on query and add the code via query arg.
312 + if ( $type === 'query' ) {
313 + return add_query_arg( 'lang', $code, $url );
314 + }
315 +
316 + $parsed_url = wp_parse_url( $url );
317 + // we replace the domain here based on the localized one.
318 + if ( $type === 'domain' ) {
319 + return $parsed_url['scheme'] . '://' . $code . ( isset( $parsed_url['path'] ) ? $parsed_url['path'] : '' ) . ( isset( $parsed_url['query'] ) ? '?' . $parsed_url['query'] : '' ) . ( isset( $parsed_url['fragment'] ) ? '#' . $parsed_url['fragment'] : '' );
320 + }
321 + // default is the path based approach.
322 + $new_path = isset( $parsed_url['path'] ) ? "/$code" . $parsed_url['path'] : "/$code";
323 +
324 + return $parsed_url['scheme'] . '://' . $parsed_url['host'] . $new_path . ( isset( $parsed_url['query'] ) ? '?' . $parsed_url['query'] : '' ) . ( isset( $parsed_url['fragment'] ) ? '#' . $parsed_url['fragment'] : '' );
325 +
174 326 }
175 327 }
176 328 if ( ! function_exists( 'tsdk_support_link' ) ) {
177 329