javascript - 在 WordPress 主题中添加 Google 字体的函数出错

标签 javascript php jquery wordpress

我的 WordPress 主题函数文件中有以下函数,它应该将 google 字体添加到主题中。问题是我收到以下错误。

Parse error: syntax error, unexpected '=', expecting ')' in /home/***/wp-content/themes/sienna/functions.php on line 382

有人知道我该如何解决这个问题吗?

函数如下

// Add Google Fonts
    function sienna_fonts_url() {
        $fonts_url = '';
        $font_families = array();
        $font_families[] = 'Questrial';
        $font_families[] = 'Open Sans:400,600,700';
        $font_families[] = 'Playfair Display:400,700';

        $query_args = array(
        'family' => urlencode( implode( '|', $font_families ) ),
        'subset' => urlencode( 'latin,latin-ext' ),
        );

        $fonts_url = add_query_arg( $query_args, 'https://fonts.googleapis.com/css' );
        }

        return esc_url_raw( $fonts_url );
    }

非常感谢,

斯科特。

最佳答案

给你:

function sienna_fonts_url() {
$fonts_url = '';
$font_families = array();
$font_families[] = 'Questrial';
$font_families[] = 'Open Sans:400,600,700';
$font_families[] = 'Playfair Display:400,700';
$query_args = array(
    'family' => urlencode( implode( '|', $font_families ) ),
    'subset' => urlencode( 'latin,latin-ext' ),
);
$fonts_url = add_query_arg( $query_args, 'https://fonts.googleapis.com/css' );
return esc_url_raw( $fonts_url );

}

关于javascript - 在 WordPress 主题中添加 Google 字体的函数出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38328810/

相关文章:

javascript - 谷歌搜索中的网站截图

php - Laravel 5 中 RouteCollection.php 中的 MethodNotAllowedHttpException

php - 在 WooCommerce 快速订单预览中显示自定义字段

jquery - 无法将文本粘贴到 Redactor 所见即所得编辑器中。 jQuery : $. parseHTML 不是函数

jQuery 验证插件 : How to validate empty fields?

javascript - 为网格创建二维数组

javascript - 错误: Uncaught TypeError: Cannot read property 'value' of undefined

php - Mysql LIKE 或最接近的匹配

javascript - 如何将数据传递到jsp并从servlet在新窗口中打开它

Javascript正则表达式或疑问