[WordPress] 外掛分享: Sectors – Conditional Templates & Hooks

首頁外掛目錄 › Sectors – Conditional Templates & Hooks
WordPress 外掛 Sectors – Conditional Templates & Hooks 的封面圖片
10+
安裝啟用
尚無評分
599 天前
最後更新
問題解決
WordPress 4.8+ PHP 5.6+ v1.2 上架:2018-02-04

內容簡介

Sectors 是 WordPress 中獨一無二的外掛,可建立任何內容上下文的主題樣板。確保僅在滿足某些條件時添加選定的動作或過濾器。

上下文

當您在網站中添加新的區塊時,會選擇其所涵蓋的內容。這可能是:

選定類別中的所有文章
特定作者的頁面
具有自訂分類的自訂文章類型

以上任意組合

Sectors 還內建支援 BuddyPress、WPML、Polylang 等功能。

樣板

Sectors 會在您的佈景主題資料夾中尋找以下樣板:

/sectors/<sector-name>.php
/sector-<sector-name>.php

如果找到,它將自動載入給予上下文的樣板。

API

樣板標籤

檢查查詢是否是給定或任何區塊的一部分:

is_sector(string $sector):boolean

取得當前上下文的所有區塊:

get_current_sectors():array

鉤子

Sectors 透過添加範圍擴展所有 WordPress 動作和過濾器。這意味著您可以向動作添加回呼並確保它僅在特定上下文中執行:

add_sector_action(string $sector, string $tag, callable $function, int $priority = 10, int $accepted_args = 1 )

add_sector_filter(string $sector, string $tag, callable $function, int $priority = 10, int $accepted_args = 1 )

外掛標籤

開發者團隊

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

① 下載 ZIP → 後台「外掛 › 安裝外掛 › 上傳外掛」
② 後台搜尋「Sectors – Conditional Templates & Hooks」→ 直接安裝(推薦)

原文外掛簡介

Sectors is a first of its kind plugin for WordPress. Create theme templates for any context on your site. Make sure select Actions or Filters are only added when certain conditions are met.
Contexts
When you add a new sector to your site, you select the content it covers. This could be:

All posts in a select category
Pages by an author
Custom Post Types with a Custom Taxonomy

Any combination of above

Sectors also comes with built in support for BuddyPress, WPML, Polylang, and more.
Templates
Sectors will look in your theme folder for the following templates:

/sectors/.php
/sector-.php

If found, it will be automatically loaded for the context.
API
Template Tags
Check if a query is part of a given or any sector:
is_sector(string $sector):boolean

Get all sectors for current context:
get_current_sectors():array

Hooks
Sectors extends all WordPress Actions and Filters by adding a scope. This means you can add a callback to an action and make sure it’s only executed in a given context:
add_sector_action(string $sector, string $tag, callable $function, int $priority = 10, int $accepted_args = 1 )

add_sector_filter(string $sector, string $tag, callable $function, int $priority = 10, int $accepted_args = 1 )

延伸相關外掛

文章
Filter
Apply Filters
Mastodon