[WordPress] 外掛分享: Theme YAML – Use YAML instead JSON for your theme.json settings and styles

首頁外掛目錄 › Theme YAML – Use YAML instead JSON for your theme.json settings and styles
WordPress 外掛 Theme YAML – Use YAML instead JSON for your theme.json settings and styles 的封面圖片
10+
安裝啟用
★★★★
4.5/5 分(2 則評價)
908 天前
最後更新
問題解決
WordPress 5.8+ PHP 7.4+ v1.3.0 上架:2022-03-16

內容簡介

Theme Yaml 可以將您的 theme.yaml 檔案轉換為 theme.json,以便使用 YAML 配置您的主題。相較於 JSON,這樣的方式可以加注釋並且更簡潔明瞭。預設生成的 theme.json 是一行的,這樣可以讓您看到它是如何生成的,不過這個設置可以透過「theme_yaml_json_pretty_print」過濾器進行更改。

當加載頁面時,插件會自動查找活動主題根目錄中的 theme.yaml 文件。如果找到,它會檢查其最後修改時間並將其存儲在數據庫中。如果有新的修改,插件將解析 theme.yaml,將其轉換為 JSON,並將其寫入 theme.json 文件中。

如果當前使用的主題是子主題,它還會自動為其父主題運行此過程。

配置

在主題根目錄中添加一個包含主題設置的 theme.yaml 文件。如果您已經有現有的 theme.json 文件,您可以使用在線工具將其轉換為 YAML 格式。我個人使用 https://www.json2yaml.com/。然後,插件將把 theme.yaml 文件轉換為 JSON 並將其保存到 theme.json 文件中。

外掛標籤

開發者團隊

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

① 下載 ZIP → 後台「外掛 › 安裝外掛 › 上傳外掛」
② 後台搜尋「Theme YAML – Use YAML instead JSON for your theme.json settings and styles」→ 直接安裝(推薦)
📦 歷史版本下載

原文外掛簡介

Theme Yaml converts your theme.yaml file into theme.json so that you can configure your theme with YAML. It has the benefit of being able to add comments and is more concise than JSON. The generated theme.json is left as a one liner by default, so that you can see it is generated. This however can be changed through the ‘theme_yaml_json_pretty_print’ filter.
The plugin automatically looks for a theme.yaml file in the active theme’s root folder when a page is loaded. If found, it will check its last modified time and store the value in the database. If there are new modifications, the plugin parses theme.yaml, converts it to JSON, and writes it to the theme.json file.
If the active theme is a child, it will also automatically run through this process for its parent.
Configuration
Add a theme.yaml file with your theme settings in your theme’s root directory. If you already have an existing theme.json file, you can convert it to the YAML format using an online tool. I personally use https://www.json2yaml.com/. The plugin will then convert the theme.yaml file into JSON and save it to the theme.json file.

延伸相關外掛

文章
Filter
Apply Filters
Mastodon