[WordPress] 外掛分享: Simple Gutenberg Google Fonts

首頁外掛目錄 › Simple Gutenberg Google Fonts
WordPress 外掛 Simple Gutenberg Google Fonts 的封面圖片
20+
安裝啟用
尚無評分
2714 天前
最後更新
問題解決
WordPress 4.9.8+ PHP 5.4+ v1.0.2 上架:2018-10-04

內容簡介

Simple Google Fonts可以在WordPress的新版本v5.0編輯器(代號Gutenberg)內部更改默認字體為Google字體。您需要安裝和啟用Gutenberg才能使用此外掛

它會做什麼?

Simple Google Fonts可以在WordPress的新版本v5.0編輯器(代號Gutenberg)內部更改默認字體為Google字體。您需要安裝和啟用Gutenberg才能使用此外掛

需要知道的事情:

閱讀“啟用後”部分以獲取使用信息。
支持的文章類型:文章和頁面
您可以為個別文章和頁面或全局位置設置Google字體
全局位置意味著從選定文章的樣式將應用於整個網站。它還會在編輯器中應用樣式,對於新的或舊的文章(它們沒有應用任何樣式)。
發布文章後,您需要啟用它的全局模式才能全局使用。
如果您沒有網路連接,Google字體將不會顯示(除非您已經在系統中安裝了它們)。

待完成事項:

為body和headings都添加word-spacing支援
如果字體支援這些變體,請自動添加700和700i權重

GDPR注意事項

使用此插件(請求來自Google字體服務器的數據)即表示您同意Google檢索您的IP地址並且可能向第三方發送它,同時,根據您的隱私政策和條款和條件,負責通知並獲取您網站用戶的同意。

請閱讀Google的隱私政策,如果您同意,可以開始使用此外掛。

主題開發人員

您可以使用sgf_defaults過濾器更改插件的默認值,例如:

add_filter('sgf_defaults',function($defaults){
    // since v1.0.1
    $check = function_exists('sgf_get_font_id');

    // Headings font family
    $hff =!$check?0:sgf_get_font_id('Josefin Sans');

    // Body font family
    $bff =!$check?0:sgf_get_font_id('Muli');

    // Headings
    $defaults ['headings'] ['ff'] = $hff; // int |字體家族

    // Bodybr / >
    $defaults ['body'] ['ff'] = $bff; // int |字體家族
    $defaults ['body'] ['wt'] ='400'; //字符串|字體重量
    $defaults ['body'] ['lh'] = 1.8; // 浮點數 | 行高
    $defaults ['body'] ['ls'] = 0; //浮點數|字符間距
    $defaults ['body'] ['ws'] = 0; //浮點數|單詞間距

    //返回新的默認值
    return $defaults;
},15);

對於標題,您可以使用sgf_headings_defaults,例如:

add_filter('sgf_headings_defaults',function($defaults,$headings){
    // $ headings = [ 'h1', ...'h6' ]。

    $defaults ['h1'] ['wt'] ='400'; // 字符串| H1字體重量,斜體自動添加。
    $defaults ['h1'] ['tt'] ='none'; //字符串| H1文本轉換
    $defaults ['h1'] ['lh'] = 1.8; // 浮點數 | 行高度
    $defaults ['h1'] ['ls'] = 0; // 浮點數|字符間距
    $defaults ['h1'] ['ws'] = 0; // 浮點數|詞間距

    //返回新的默認值
    return $defaults;
},15);

外掛標籤

開發者團隊

⬇ 下載最新版 (v1.0.2) 或搜尋安裝

① 下載 ZIP → 後台「外掛 › 安裝外掛 › 上傳外掛」
② 後台搜尋「Simple Gutenberg Google Fonts」→ 直接安裝(推薦)
📦 歷史版本下載

原文外掛簡介

Simple Google Fonts adds the posibility to change default fonts to Google fonts from within the new WordPress v5.0 editor, codename Gutenberg. You’ll need Gutenberg installed and activated in order to use this plugin.
What it does?
Simple Google Fonts adds the posibility to change default fonts to Google fonts from within the new WordPress v5.0 editor, codename Gutenberg. You’ll need Gutenberg installed and activated in order to use this plugin.
Things to know:

Read the After activation section for some info on how to use it.
Supported post types: posts and pages
You can set Google fonts for individual posts and pages or globally.
Globally means that the styles from a selected post will apply to the entire website. It will also apply the styles in the Editor, for new or old posts (that don’t have any styles applied to them).
The post needs to be published for you to be able to use its styles globally. If for some reason you change that post to draft mode and the global mode is enabled on it, the option will reset and you’ll need to enable it again after you publish the post.
It’s safe to say that if you don’t have an Internet connection, Google fonts will not display (unless you have them installed on your system).

To do list:

Add support for word-spacing for both body and headings
Auto add 700 and 700i weights if the font supports those variants.

GDPR Notice
By using this plugin (which requests data from Google Fonts servers) you consent that Google will retrieve your IP address and that it might send it to third parties. Also, it’s your responsability to notify and obtain consent from your website’s users (by updating your Privacy Policy and Terms and Conditions).
Please read Google’s Privacy Policy and if you agree with it, you can start using this plugin.
Theme developers
You can use the sgf_defaults filter to change the plugin defaults, example:
add_filter( 'sgf_defaults', function( $defaults ) {
// since v1.0.1
$check = function_exists( 'sgf_get_font_id' );

// Headings font family
$hff = ! $check ? 0 : sgf_get_font_id( 'Josefin Sans' );

// Body font family
$bff = ! $check ? 0 : sgf_get_font_id( 'Muli' );

// Headings
$defaults[ 'headings' ][ 'ff' ] = $hff; // int | Font Family

// Body
$defaults[ 'body' ][ 'ff' ] = $bff; // int | Font Family
$defaults[ 'body' ][ 'wt' ] = '400'; // string | Font Weight
$defaults[ 'body' ][ 'lh' ] = 1.8; // float | Line Height
$defaults[ 'body' ][ 'ls' ] = 0; // float | Letter spacing
$defaults[ 'body' ][ 'ws' ] = 0; // float | Word spacing

// Returns new defaults
return $defaults;
}, 15 );

For headings you can use the sgf_headings_defaults, example:
add_filter( 'sgf_headings_defaults', function( $defaults, $headings ) {
// $headings = [ 'h1', ... 'h6' ];

$defaults[ 'h1' ][ 'wt' ] = '400'; // string | H1 font weight, italic is added automatically.
$defaults[ 'h1' ][ 'tt' ] = 'none'; // string | H1 text transform
$defaults[ 'h1' ][ 'lh' ] = 1.8; // float | Line height
$defaults[ 'h1' ][ 'ls' ] = 0; // float | Letter spacing
$defaults[ 'h1' ][ 'ws' ] = 0; // float | Words spacing

// if a propriety is left out, it will use the plugin default.
// you can use this for headings from h1 to h6

return $defaults;
}, 10, 2 );

For text logos you can use the sgf_styles_frontend_txt_logo filter to make sure it always takes on the Headings font family, example:
add_filter( 'sgf_styles_frontend_txt_logo', function() { return '.logo-wrap'; }, 15 );

You can add these in your functions.php file. If you want to support old PHP versions, replace the anonymous functions with normal functions.

延伸相關外掛

文章
Filter
Apply Filters
Mastodon