json_decode does not support comments or trailing commas.'; $template = '

JSON error

%s

Please check %s

'; // PHP 5.2 if ( !function_exists( 'json_last_error' ) ) { if ( null == $json_result ) { return sprintf( $template, $syntax_error, $url, $path ); } return false; } // PHP 5.3+ switch ( json_last_error() ) { case JSON_ERROR_NONE: return false; break; case JSON_ERROR_DEPTH: $error = 'Maximum stack depth exceeded.'; break; case JSON_ERROR_STATE_MISMATCH: $error = 'Underflow or the modes mismatch.'; break; case JSON_ERROR_CTRL_CHAR: $error = 'Unexpected control character.'; break; case JSON_ERROR_SYNTAX: $error = $syntax_error; break; case JSON_ERROR_UTF8: $error = 'Malformed UTF-8 characters, possibly incorrectly encoded.'; break; default: $error = 'Unknown JSON error.'; break; } return sprintf( $template, $error, $url, $path ); } public static function get_template() { if ( isset( self::$template ) ) { return self::$template; } global $wp_customize; if ( isset( $_GET['theme'] ) ) { self::$template = $_GET['theme']; }else if ( is_a( $wp_customize, 'WP_Customize_Manager' ) ) { self::$template = $wp_customize->theme()->template; }else { self::$template = get_template(); } return self::$template; } public static function get_option_key( $suffix = false ) { if ( $suffix ) { return 'storm-styles-' . self::get_template() . '-' . $suffix; }else { return 'storm-styles-' . self::get_template(); } } }