[WordPress] 外掛分享: Hatch

首頁外掛目錄 › Hatch
⚠ 此外掛已下架 — 不再更新維護,建議勿安裝。
全新外掛
安裝啟用
尚無評分
1438 天前
最後更新
問題解決
WordPress 4.7+ PHP 7.0+ v1.1.0 上架:2021-02-09

內容簡介

Hatch 是一個協助開發人員建立網站的輔助程式庫,可以讓使用 Timber、Advanced Custom Fields Pro 及其他常用外掛更加愉悅。

這是什麼東西?

Hatch 是一個協助開發人員建立網站的輔助程式庫,可以讓使用 Timber、Advanced Custom Fields Pro 及其他常用外掛更加愉悅。

需求

Timber(最新版本)

更好的使用 Timber

使用 Timber,我們可以使用 Twig 模板來建立網站,而非使用 PHP。

通常我們會像這樣設定 Timber context:

$context = Timber::get_context();

$context['post'] = Timber::get_post();

function website_get_related_posts() {
// 在這裡實現想法

return [];
}

$context['related_posts'] = website_get_related_posts();

Timber::render( 'post.twig', $context );

這樣是可以的,但當我們有許多變數的複雜頁面模板時,這樣寫就會變得有點混亂。

Hatch 提供了更整潔的 Timber 和其他常用程式庫上下文設定方式:

// 'post' 預設已添加

Hatch::add_context( 'related_posts', function() {
// 在此實現想法
return [];
} );

Hatch::render( 'post.twig' ); // 無需傳遞 $context

更多和更好的文件即將推出!請查看 abe-hatch.php 以獲取更多資訊。

授權

版權所有 2020 A Big Egg(David Hewitson Ltd)

特此無償授權任何取得本軟體和相關說明文件(以下簡稱「軟體」)的人,以不受限制的方式處理本軟體,包括但不限於使用、複製、修改、合併、出版、發行、授權或販售軟體的副本,以及允許軟體使用者進行同等操作,但需遵守以下條件:

在軟體的所有副本或重要部分中都必須包含上述版權聲明和本許可聲明。

本軟體不附帶任何保證,包括但不限於適銷性和適用於特定用途的保證。無論任何情況,作者或版權持有人都不對任何主張、損害或其他責任承擔任何責任,無論是在合同行為、侵權行為或其他行為中從、與軟體或使用軟體的其他交易中產生,甚至在已告知可能發生此類損害的情況下。

外掛標籤

開發者團隊

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

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

原文外掛簡介

Hatch is a helper library for developers which makes it more pleasant to build websites using Timber, Advanced Custom Fields Pro and other common plugins.
What is this thing?
Hatch is a helper library for developers which makes it more pleasant to build websites using Timber, Advanced Custom Fields Pro and other common plugins.
Requirements
Timber (latest version.)
A better way to use Timber
Using Timber we can use Twig templates to build our sites rather than PHP.
Typically we set up a Timber context like this:
$context = Timber::get_context();

$context['post'] = Timber::get_post();

function website_get_related_posts() {
// do something fancy here

return [];
}

$context['related_posts'] = website_get_related_posts();

Timber::render( 'post.twig', $context );

This is fine but it can get a bit mucky – especially if we have complicated page templates with lots of variables.
Hatch provides a tidier way of setting up contexts for Timber and other popular libraries:
// 'post' is already added by default

Hatch::add_context( 'related_posts', function() {
// do something fancy
return [];
} );

Hatch::render( 'post.twig' ); // no need to pass $context in

More & better documentation to come! Look in abe-hatch.php for more info
License
Copyright 2020 A Big Egg (David Hewitson Ltd)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.%

延伸相關外掛

文章
Filter
Apply Filters
Mastodon