【问题标题】:SSL Google fonts errorSSL Google 字体错误
【发布时间】:2014-05-05 17:07:32
【问题描述】:

我收到一个错误,该网站无缘无故在 chrome 中被阻止。

因为它是一个小型网站,所以我将所有页面都强制使用 SSL。并收到此错误:

[阻止] 'https://www.splitapartments.co/' 处的页面通过 HTTPS 加载,但运行来自 'http://fonts.googleapis.com/css?family=Open+Sans:400,800,300,700' 的不安全内容:此内容也应通过 HTTPS 加载。

WordPress 主题排队 google 字体安全模式:

function dt_get_google_fonts( $font = '', $effect = '' ) {
    if ( ! $font ) {
        return;
    }

    if ( array_key_exists( $effect, dt_get_web_fonts_effects() ) ) {
        $effect = '&effect=' . esc_attr( $effect ); 
    } else {
        $effect = '';
    }

    $protocol = "http";
    if ( isset( $_SERVER['HTTPS'] ) && $_SERVER['HTTPS'] == 'on' ) {
        $protocol = "https";
    }
    ?>
    <link rel="stylesheet" type="text/css" href="<?php echo $protocol; ?>://fonts.googleapis.com/css?family=<?php echo str_replace( ' ', '+', $font ) . $effect; ?>">
    <?php
}

function dt_make_web_font_uri( $font, $effect = '' ) {
    if ( !$font ) {
        return false;
    }

    // add web font effect
    if ( function_exists('dt_get_web_fonts_effects') ) {

        if ( array_key_exists( $effect, dt_get_web_fonts_effects() ) ) {
            $effect = '&effect=' . esc_attr( $effect ); 
        } else {
            $effect = '';
        }

    } else {
        $effect = '';
    }

    $protocol = is_ssl() ? "https" : "http";

    $uri = $protocol . '://fonts.googleapis.com/css?family=' . str_replace( ' ', '+', $font ) . $effect;
    return $uri;
}

我完全不明白为什么会这样。我尝试了所有我能找到的解决方案,但没有任何效果。

【问题讨论】:

    标签: wordpress ssl google-webfonts


    【解决方案1】:

    这个问题有一段时间了,但终于解决了。我安装了一个 wordpress 插件,它硬编码了“http://fonts.google... etc”这一行。

    一旦我禁用了插件,一切都很好! (我想我可以编辑它,但我不再需要它了)。

    导致我这个问题的插件是:WP Construction Mode

    【讨论】:

    • 请添加错误消息,以便人们可以帮助您。如果您进入您的 wp-config 文件并将 WP DEBUG 模式启用为 true,它将给您错误消息。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-01-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多