[WordPress] 外掛分享: Editor for Timber

首頁外掛目錄 › Editor for Timber
WordPress 外掛 Editor for Timber 的封面圖片
50+
安裝啟用
尚無評分
1919 天前
最後更新
問題解決
WordPress 5.5+ PHP 7.4+ v1.0.2 上架:2020-10-28

內容簡介

功能特色

為可配置的文章類型添加元框,以建立並編輯 Twig 模板
為 WP 主題和外掛程式編輯器添加 Twig 支援

甚至可以自訂 CodeMirror 主題

外掛相依性

Timber

Classic Editor

如何使用元框功能

本外掛使用在 Timber::$locations 中定義的路徑作為模板路徑,如果沒有提供,則回退到上傳資料夾。

請使用以下方式調整您的 Timber::render('page.twig', $context) 函式:

$filenames = [TimberEditor::getTemplateFilename(), 'page.twig'];
Timber::render($filenames, $context);

或是使用以下方式:

TimberEditor::render('page.twig', $context);
# 如果當前文章的模板不存在,則 'page.twig' 作為回退

或是使用以下方式:

TimberEditor::renderPost('page.twig', $context);
# renderPost() 自動將 ['post' => new Timber\Post()] 加入 $context

外掛標籤

開發者團隊

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

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

原文外掛簡介

Features

adds a metabox to configurable Post-Types to create and edit Twig templates
adds Twig support to the WP Theme & Plugin editors

you can even customize the CodeMirror theme

Plugin Dependencies

Timber

Classic Editor

How to use the MetaBox Feature
The plugin uses the path defined in Timber::$locations as the templates path or falls back to the uploads folder if none is provided.
Either adjust your Timber::render('page.twig', $context)-functions like this:
$filenames = [TimberEditor::getTemplateFilename(), 'page.twig'];
Timber::render($filenames, $context);

like this
TimberEditor::render('page.twig', $context);
# 'page.twig' serves as a fallback if the current posts's template doesn't exist

or like this
TimberEditor::renderPost('page.twig', $context);
# renderPost() automatically adds ['post' => new Timber\Post()] to the $context

延伸相關外掛

文章
Filter
Mastodon