[WordPress] 外掛分享: Block Areas

首頁外掛目錄 › Block Areas
50+
安裝啟用
★★★★★
5/5 分(3 則評價)
2402 天前
最後更新
問題解決
WordPress 5.0+ PHP 7.0+ v0.2.0 上架:2019-07-03

內容簡介

這個外掛提供一個簡單的方式,讓你可以在文章內容以外的區域中使用區塊編輯器。

這是一個實驗性的外掛,試驗了如何在整個網站上使用古銅板區塊以外的基本功能。

長期來看,當 WordPress 核心和古銅板區塊完成下一階段並升級到網站層級時,這個外掛可能會被淘汰。但現在它作為一個基礎線來提供一個容易的方法,讓你可以立即試驗類似的功能。

使用方式

啟用外掛後,在「外觀」>「區塊區域」下可以創建和編輯區塊區域。有兩個預設的區塊區域: header 和 footer。

區塊區域可由其獨特的縮略名識別。由於預期 header 和 footer 存在,因此確保不要刪除它們。

要在主題中顯示特定的區塊區域,例如,使用 block_areas()->render( $slug )(例如 block_areas()->render( 'header' ))。

你還可以明確地添加主題支援,指定你的主題依賴的區塊區域縮略名(例如 add_theme_support( 'block-areas', 'header', 'footer' ))。

外掛標籤

開發者團隊

⬇ 下載最新版 (v0.2.0) 或搜尋安裝

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

原文外掛簡介

Introduces a simple method for defining block areas to use the block editor outside of the post content.
This is an experimental plugin that explores basic usage of Gutenberg blocks outside of the content bubble, on a sitewide level.
In the long term it will likely eliminate itself once WordPress core and Gutenberg will have completed the next phase of advancing to the sitewide level. The plugin exists as a baseline to have an easy way for experimenting with similar functionality already today.
Usage
After activating the plugin, you can create and edit block areas under Appearance > Block Areas. There should be two block areas already, header and footer.
Block areas are identified by their unique slug. Since header and footer are expected to exist, make sure not to delete them.
In order to print a specific block area, for example in your theme, use block_areas()->render( $slug ) (e.g. block_areas()->render( 'header' )).
You can also explicitly add theme support, specifying which block area slugs your theme relies on (e.g. add_theme_support( 'block-areas', 'header', 'footer' )).

延伸相關外掛

文章
Filter
Mastodon