[WordPress] 外掛分享: Hatch

前言介紹

  • 這款 WordPress 外掛「Hatch」是 2021-02-09 上架。 目前已經下架不再更新,不建議安裝使用。
  • 目前尚無安裝啟用數,是個很新的外掛。如有要安裝使用,建議多測試確保功能沒問題!
  • 上一次更新是 2022-04-11,距離現在已有 1118 天。超過一年沒更新,安裝要確認版本是否可用。以及後續維護問題!
  • 外掛最低要求 WordPress 4.7 以上版本才可以安裝。
  • 外掛要求網站主機運作至少需要 PHP 版本 7.0 以上。
  • 尚未有人給過這款外掛評分。
  • 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。

外掛協作開發者

abigegg |

外掛標籤

Timber | developers | templating |

內容簡介

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)

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

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

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

原文外掛簡介

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.%

各版本下載點

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

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


0.2 | 0.3 | 0.4 | 0.4.1 | 0.4.2 | 0.4.3 | 0.4.4 | 0.5.5 | 0.6.0 | 0.6.1 | 0.6.2 | 1.0.0 | 1.1.0 | trunk |

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

  • Default Theme Pages 》此外掛旨在為模板開發人員提供便利, 版本 0.4 中的新功能, , 在每個 $default_theme_pages 項目中添加「物件」(頁面物件),以便快速存取。, 將所有預設頁面...。
  • Twigify 》這個外掛使用TWIG建立模板系統,您可以在WordPress管理介面中進行管理。不再需要為每個內容類型或上下文創建數十個模板文件。模板可以應用於每個頁面或文章,...。
  • Action Runner by The Rite Sites 》隨著區塊的日漸普及,開發人員和商店所有者發現一些模板功能缺失,通常透過 PHP 和 WordPress Hooks 可以獲得。 WordPress 社區正在努力將 PHP 中的可擴展性...。

文章
Filter
Apply Filters
Mastodon