| @@ -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.20'; | |
| 17 | +$themeisle_sdk_version = '3.3.61'; | |
| 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 | * |
| @@ -90,8 +169,9 @@ | ||
| 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 | 172 | $location = $location === null ? $current_page : $location; |
| 173 | + $is_upgrade_url = strpos( $url, '/upgrade' ) !== false; | |
| 94 | 174 | $content = sanitize_key( |
| 95 | 175 | trim( |
| 96 | 176 | str_replace( |
| 97 | 177 | [ |
| @@ -121,8 +201,28 @@ | ||
| 121 | 201 | $url |
| 122 | 202 | ) |
| 123 | 203 | ); |
| 124 | 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 | + | |
| 125 | 225 | return apply_filters( 'tsdk_utmify_url_' . $filter_key, $utmify_url, $url ); |
| 126 | 226 | } |
| 127 | 227 | |
| 128 | 228 | add_filter( 'tsdk_utmify', 'tsdk_utmify', 10, 3 ); |
| @@ -193,8 +293,15 @@ | ||
| 193 | 293 | function tsdk_translate_link( |
| 194 | 294 | $url, $type = 'path', $available_languages = [ |
| 195 | 295 | 'de_DE' => 'de', |
| 196 | 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', | |
| 197 | 304 | ] |
| 198 | 305 | ) { |
| 199 | 306 | $language = get_user_locale(); |
| 200 | 307 | if ( ! isset( $available_languages[ $language ] ) ) { |