[WordPress] 外掛分享: ACF: Google Font Selector

WordPress 外掛 ACF: Google Font Selector 的封面圖片。

前言介紹

  • 這款 WordPress 外掛「ACF: Google Font Selector」是 2014-02-03 上架。
  • 目前有 3000 個安裝啟用數。
  • 上一次更新是 2015-04-28,距離現在已有 3660 天。超過一年沒更新,安裝要確認版本是否可用。以及後續維護問題!
  • 外掛最低要求 WordPress 3.5 以上版本才可以安裝。
  • 有 6 人給過評分。
  • 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。

外掛協作開發者

danielpataki |

外掛標籤

acf | fonts | google |

內容簡介

這個外掛可以讓你創建一個 Google 字體選擇欄位,並提供不同的選項。此外,外掛還會在主題標頭中創建字體請求,以自動加載字體。你可以分別選擇字體變體和字符集,以使字體加載更加靈活和優化。

將字體選項添加到任何選項頁面都會被自動載入。將字體添加到文章頁面中將僅在顯示該特定文章時自動載入。

Google API 金鑰

為了從 Google 獲取字體列表,你需要 API 金鑰。這是免費且易於操作的,可以參考這份指南來獲取 API 金鑰。

ACF 相容性

此 ACF 欄位類型與 ACF 4 和 ACF 5 均相容。

感謝

感謝Advanced Custom Fields提供的優秀基礎插件。
感謝Iconjam提供的 T 標誌。

使用方法

安裝完成後,Google 字體列表將從插件中包含的靜態文件中檢索。如果你想從 Google API 中提取列表,你需要在管理員中定義你的 API 金鑰。你可以在「設置」 > 「Google 字體選擇器」中進行設置。

針對開發人員

你可以設置一些更高級的控件,以使插件更符合你的需求。如果你想硬編碼 API 金鑰,並禁用用戶查看提示和設置面板,你可以定義ACFGFS_API_KEY常量。

define( 'ACFGFS_API_KEY', 'your_google_api_key' );

ACFGFS_REFRESH 常量可以控制插件檢查 Google API 更新的頻率。值以秒為單位,86400 表示一天。預設值為 7 天。

define( 'ACFGFS_REFRESH', 259200 );

如果你想禁用字體的自動加載,你可以使用 ACFGFS_NOENQUEUE 常量。當未定義此常量時,字體會自動加載。定義常量可以禁用加載。

define( 'ACFGFS_NOENQUEUE', true );

如果你想要修改頁面上載入的字體,你可以使用 acfgfs/enqueued_fonts 過濾器。這應返回一個陣列,其中包含所需的字體變體和子集,例如:

array(
'font' => 'Open Sans',
'variants' => array( 'regular', '700' ),
'subsets' => array( 'latin' )
)

3.0.1 中新增了控制下拉列表中顯示字體的功能。如果你只想讓用戶訪問 Google 字體的一小部分,你可以使用 acfgfs/font_dropdown_array 過濾器來修改用於生成下拉列表的陣列。請返回一個鍵和值都是字體名稱的陣列。

add_filter( 'acfgfs/font_dropdown_array', 'my_font_list' );
function my_font_list( $fonts ) {
$fonts = array(
'Raleway' => 'Raleway',
'Lato' => 'Lato'
);
return $fonts;
}

原文外掛簡介

This plugin allows you to create a Google font selector field with different options. The plugin also creates the font request in the theme header to autoload the fonts if you’d like. Font variants and charsets can be selected separately to make font loading more flexible and optimized.
Font options added to any options page will always be enqueued. Any fonts added to post pages will only be enqueued when that specific post is displayed.
Google API Key
To grab the font list from Google you’ll need an API key. This is free and easy to do, take a look at this guide to get an API key.
ACF Compatibility
This ACF field type is compatible with both ACF 4 and ACF 5.
Thanks

Advanced Custom Fields for the awesome base plugin.
Iconjam for the T icon.

Usage
Once installed the list of Google Fonts will be retrieved from a static file included in the plugin. If you would like the list to be pulled from the Google API you will need to define your API key. You can do this in Settings->Google Font Selector in the admin.
For Developers
There are a few more advanced controls you can set to make the plugin do your bidding. If you would like to hard-code the API key and disable users from seeing the nag screen and setting panel you can define the ACFGFS_API_KEY constant.
define( 'ACFGFS_API_KEY', 'your_google_api_key' );

The ACFGFS_REFRESH constant can controls how frequently the plugin checks the Google API for updates. The value is in seconds, 86400 would be a day. The default is set to 7 days.
define( 'ACFGFS_REFRESH', 259200 );

If you would like to disable the automatic enqueueing of fonts you can use the ACFGFS_NOENQUEUE constant. The fonts are only enqueued automatically when this constant is not defined. Define the constant to disable enqueueing.
define( 'ACFGFS_NOENQUEUE', true );

If you want to modify the fonts that are loaded on a page you can use the acfgfs/enqueued_fonts filter. This should return an array of fonts with variants and subsets needed, something like this:
array(
'font' => 'Open Sans',
'variants' => array( 'regular', '700' ),
'subsets' => array( 'latin' )
)

New in 3.0.1 is the ability to control the fonts displayed in the dropdown. If you only want to give your users access to a smaller portion of Google fonts you can use the acfgfs/font_dropdown_array filter to modify the array that is used to generate the dropdown. Please return an array where the key and the value are both the names of the font.
add_filter( 'acfgfs/font_dropdown_array', 'my_font_list' );
function my_font_list( $fonts ) {
$fonts = array(
'Raleway' => 'Raleway',
'Lato' => 'Lato'
);
return $fonts;
}

各版本下載點

  • 方法一:點下方版本號的連結下載 ZIP 檔案後,登入網站後台左側選單「外掛」的「安裝外掛」,然後選擇上方的「上傳外掛」,把下載回去的 ZIP 外掛打包檔案上傳上去安裝與啟用。
  • 方法二:透過「安裝外掛」的畫面右方搜尋功能,搜尋外掛名稱「ACF: Google Font Selector」來進行安裝。

(建議使用方法二,確保安裝的版本符合當前運作的 WordPress 環境。


1.0 | 2.2 |

延伸相關外掛(你可能也想知道)

  • OMGF | GDPR/DSGVO Compliant, Faster Google Fonts. Easy. 》, 使用 Google 的字型服務,怎麼可能與 GDPR 不符呢?事實上,當使用者的瀏覽器要求字型時,他們的 IP 會被 Google 記錄並用於分析。, — Lifehacker, , OMG...。
  • Custom Fonts – Host Your Fonts Locally 》此外掛能協助您輕鬆地在 WordPress 網站中嵌入自定義字型檔案 (woff2、woff、ttf、svg、eot、otf)。, 目前能與以下主題和外掛一起使用:, , Astra 主題, Beav...。
  • TypeSquare Webfonts for エックスサーバー 》這是一個 WordPress 外掛,可在由 XServer Co., Ltd. 提供的租用伺服器服務中使用由株式会社モリサワ提供的 TypeSquare 網頁字型服務。, 透過使用字型主題功...。
  • Local Google Fonts 》將使用的 Google 字體儲存在您的伺服器上,讓您的網站更符合 GDPR 條例 💯。, 約有 5,000 萬*個網站使用 Google Fonts,而在 2022 年一家德國法院裁定使...。
  • WP Google Fonts 》查看網站的最新WordPress優惠。, Google的免費字體目錄是網頁排版中最令人興奮的發展之一。這個新字體資源的驚人崛起使得這個外掛成為WordPress中最受歡迎的...。
  • Adobe Fonts (formerly Typekit) for WordPress 》使用這個 WordPress 外掛,您可以在不必編輯主題的情況下,嵌入並使用Typekit 字體。, Typekit 提供的服務可讓您從數百種高品質字體中為 WordPress 網站選擇...。
  • TypeSquare Webfonts for お名前.com 》這是一個可以在お名前.com共用伺服器上使用株式會社モリサワ提供的Web字型服務「TypeSquare」的外掛程式。, 透過使用字型主題功能,您可以輕鬆地設定適合您網...。
  • TypeSquare Webfonts for ConoHa 》這是一款插件,可讓您在ConoHa WING上使用由株式會社モリサワ提供的Web字型服務「TypeSquare」。, 透過使用字型主題功能,您可以輕鬆設定符合網站氛圍的Web字...。
  • Swap Google Fonts Display: Improve Font Rendering & Performance 》確保在網頁字型載入期間文本仍可顯示, 功能, , 插入 display=swap 至 Google 字型, , 支援, , 官方支援論壇, Facebook 群組, , 我們的高級產品, , FlyingPres...。
  • Japanese font for WordPress(Previously: Japanese Font for TinyMCE) 》將日語字體新增到Gutenberg和TinyMCE Advanced外掛的字體家族選擇中。, 現在支援Gutenberg為選項。請啟用Gutenberg選項以使用它。, 將要新增的字體包括;, ふ...。
  • Fonts 》這個外掛會在編輯器中新增兩個下拉選單,提供額外的字型大小和字型選項:, , 樣式按鈕, 字型大小按鈕, , 新增:您也可以透過購買進階版,將您自己選擇的 Goog...。
  • Customify – Intuitive Website Styling 》Customify 可讓開發者輕鬆在 WordPress 客製化設定中創建進階的主題特定選項。使用這些選項,使用者可以進行呈現上的更改,而不必了解或編輯主題代碼。, 這個...。
  • Arabic Webfonts 》, 使用 WordPress Customizer,在不編寫程式碼的情況下,輕鬆地將阿拉伯字型添加到任何佈景主題上的簡單方法。, , , Arabic Webfonts Site | Jozoor Plugins ...。
  • Pojo Custom Fonts 》請注意:這個外掛只適用於Pojo Framework使用者。, 使用 Pojo Custom Fonts 可以讓您在您的 Pojo 主題中添加無限數量的自定義字體,並與您的自定義樣式內的字...。
  • Google Typography 》Google Typography 外掛可以讓你在現有網站上使用任何 Google 字型,而不需要寫任何程式碼。在「外觀 > 字體排版」設定頁面中,只需添加和自定義多種字型,然...。

文章
Filter
Apply Filters
Mastodon