[WordPress] 外掛分享: Menu Item Visibility Control

首頁外掛目錄 › Menu Item Visibility Control
⚠ 此外掛已下架 — 不再更新維護,建議勿安裝。
10,000+
安裝啟用
★★★★
4.5/5 分(69 則評價)
1595 天前
最後更新
0%
問題解決
WordPress 5.4+ v0.5 上架:2011-08-02

內容簡介

透過這個外掛,你可以使用 WordPress 的條件標籤來在前台啟用或停用選單項目。它的作用類似於「Widget Logic」,但是適用於選單項目。

請注意:這些條件是 PHP 程式碼,使用 PHP 的「eval」函數進行評估,這意味著有權訪問 WordPress 選單管理員的任何人都可以執行任何程式碼。請注意管理好有權訪問選單管理員的人員。

使用方法

你必須在選單項目選項表單的「可見性」框中插入條件標籤。你可以使用任何 PHP 或 WordPress 函数來構建選單項目的複雜條件和邏輯。例如,要在首頁隱藏選單項目,可以將可見性設為:

! is_home()

僅向已登錄的用戶顯示菜單:

is_user_logged_in()

僅向訪客訪問者顯示菜單:

! is_user_logged_in()

基於用戶權限顯示菜單項目:

current_user_can( 'manage_options' )

外掛標籤

開發者團隊

⬇ 下載最新版 (v0.5) 或搜尋安裝

① 下載 ZIP → 後台「外掛 › 安裝外掛 › 上傳外掛」
② 後台搜尋「Menu Item Visibility Control」→ 直接安裝(推薦)

原文外掛簡介

Using this plugin you can use WordPress Conditional Tags to enable or disable menu items on the front-end. It works like ‘Widget Logic’ but for menu items.
PLEASE NOTE The conditions are PHP codes that are evaluated using PHP’s “eval” function, meaning anyone who has access to the Menu manager in WordPress can execute any code. Be mindful of who has access to the Menu manager.
Usage
You must insert conditional tags in the “Visibility” box in the menu item options form. You can use any PHP or WordPress functions to build crazy conditions and logics for menu items. For example, to hide the menu item on homepage you can set the visibility to:
! is_home()

Show the menu only to logged-in users:
is_user_logged_in()

Show the menu only to guest visitors:
! is_user_logged_in()

To show the menu item based on user capability:
current_user_can( 'manage_options' )

延伸相關外掛

文章
Filter
Apply Filters
Mastodon