wordpress - SSL 谷歌字体错误

标签 wordpress ssl google-webfonts

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

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

[blocked] The page at 'https://www.splitapartments.co/' was loaded over HTTPS, but ran insecure content from 'http://fonts.googleapis.com/css?family=Open+Sans:400,800,300,700': this content should also be loaded over HTTPS.

WordPress 主题 enqueue google fonts 安全模式:

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 插件,它硬编码了“http://fonts.google ... 等”这一行。

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

导致我出现问题的插件是:WP Construction Mode

关于wordpress - SSL 谷歌字体错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22675538/

相关文章:

wordpress - 如何使用自定义元信息将 1500 个产品导入 WP eCommerce?

php - wordpress查询所有以数字开头的帖子

python - 使用 SSL 使用 Daphne + NGINX 部署 Django Channels

node.js - phantomjs + 网络字体 + 字体加载器

css - 如何使用谷歌图标网络字体?

css - Google webfont Lato 100 和移动版 Safari

css - 侧边栏在个别帖子中推送到内容下方(WordPress)

php - 使用 $wpdb 表示法允许搜索并可能回显某些类别的帖子的查询是什么?

nginx - 如何通过 nginx 通过 HTTPS 连接到安全的 WebSocket SurrealDB 实例?

c - 使用客户端问候消息进行 TLS 协议(protocol)检测