[WordPress] 外掛分享: Menu Rules

首頁外掛目錄 › Menu Rules
WordPress 外掛 Menu Rules 的封面圖片
10+
安裝啟用
尚無評分
4823 天前
最後更新
問題解決
WordPress 3.2+ v1.2.2 上架:2012-03-20

內容簡介

這個外掛已經被 Context Manager 取代

Context Manager 執行與 Menu Rules 相同的工作,不過卻擁有更多功能可節省時間並避免過度編碼。

Menu Rules 可與 Context Manager 並行,以便您遷移您的規則。若需要轉移幫忙,可透過Twitter與我聯繫。

關於 Menu Rules

在 WordPress 中,無法針對選單系統應用上下文。Menu Rules 正好解決了這個問題,並提供您一個框架來撰寫自己的選單擴展。

使用範例

您擁有一個名為「產品(products)」的自訂文章類別的電商網站。您在主選單中列出了一個顯示產品列表的頁面。當用戶訪問該頁面時,選單項目會變成「顯示中(active)」。當您點擊到產品頁面時,選單項目將失去其啟用狀態。這是如何使用選單規則解決此問題的:

安裝Menu Rules 外掛
新增一個菜單規則
在標題欄中輸入有意義的名稱,這僅供管理目的
在條件欄中輸入is_singular( 'product' )
選擇「模擬當前頁面作為子頁面,但不建立選單項目」作為菜單規則
在選單下拉清單中找到您的產品頁面
發布

擴充功能

建立一個繼承Menu_Rules_Handler且包含一個handler方法的類別
編寫您的自訂功能
使用add_action( 'plugins_loaded', create_function( '', 'Menu_Rules::register( "Your_Menu_Rule_Class" );' ) );註冊您的類別

內置規則位於 menu-rules/rules/。

支援

如果卡住了,可以在Twitter上尋求我的幫助。

外掛標籤

開發者團隊

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

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

原文外掛簡介

This plugin has been replaced by Context Manager
Context Manager does the same job as Menu Rules, but comes with many more features to save you time and unnecessary coding.
Menu Rules can run alongside Context Manager while you migrate your rules across. Speak to me on Twitter if you need any help with the transfer.
About Menu Rules
In WordPress there’s no way to apply context to the menu system. Menu Rules solves this problem and gives you a framework to write your own menu extensions.
Example usage
You have an e-commerce website that has a custom post type called ‘products’. You have a page that lists products which is listed in your main menu. A user visits the page and the menu item becomes ‘active’. You click through to a product and the menu item loses its active state. This is how to fix it with menu rules:

Install the Menu Rules plugin
Add a menu rule
Give it a meaningful name in the title field. This is just for administration purposes
In the conditions field enter is_singular( 'product' )
Choose Emulate current page as a child but do not create a menu item. as the menu rule
Find your products page in the menu dropdown
Hit publish

Extending Menu Rules

Create a class that extends Menu_Rules_Handler and includes a handler method.
Write your custom functionality
Register your class using add_action( 'plugins_loaded', create_function( '', 'Menu_Rules::register( "Your_Menu_Rule_Class" );' ) );

Built-in rules are found in menu-rules/rules/
Support
If you’re stuck, ask me for help on Twitter.

文章
Filter
Mastodon