這個外掛並未在最新的 3 個 WordPress 主要版本上進行測試。開發者可能不再對這個外掛進行維護或提供技術支援,並可能會與更新版本的 WordPress 產生使用上的相容性問題。

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.

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()

To hide the menu item to logged in users:
! is_user_logged_in()

To show the menu item only to users with “administrator” role:
in_array(‘administrator’, $GLOBALS[‘current_user’]->roles)

螢幕擷圖

  • Visibility Control

安裝方式

  1. Upload the menu-item-visibility directory to the /wp-content/plugins/ directory
  2. Activate the plugin through the ‘Plugins’ menu in WordPress
  3. Locate the ‘Menus’ item on the ‘Appearance’ menu
  4. While editing your menu item, you see another option: Visibility, input your logic and that’s it.

常見問題集

Installation Instructions
  1. Upload the menu-item-visibility directory to the /wp-content/plugins/ directory
  2. Activate the plugin through the ‘Plugins’ menu in WordPress
  3. Locate the ‘Menus’ item on the ‘Appearance’ menu
  4. While editing your menu item, you see another option: Visibility, input your logic and that’s it.

使用者評論

七月 1, 2018
I needed to hide a menu item on some pages. I only needed to set for this item: !in_array(get_the_id(),[29,30,31,32]) where 29..32 are the four id of posts. Thanks for this plugin!
九月 23, 2018
Works for me too! Easy to setup, and weirdly powerful once you wrap your head around the concept.
六月 7, 2018
I have a nice menu set up but linked to a bunch of unfinished pages. This plugin helped me disable the menu items easily. I just added "!1" to the visibility fields to hide them. Thanks Hassan Derakhshandeh!
五月 31, 2018
This plugin leaves it pretty much fully open to use any function and logic that you like - this means you can create complex conditional menus very easily. I could not ask for better. Thank you for your continued work!
閱讀全部 61 則使用者評論

參與者及開發者

Menu Item Visibility Control 外掛為開源軟體。以下人員為這個外掛做出了重大貢獻。

參與者

Menu Item Visibility Control 外掛目前已有 28 個本地化語言版本。 感謝全部譯者為這個外掛做出的貢獻。

將 Menu Item Visibility Control 外掛本地化為台灣繁體中文版

對開發相關資訊感興趣?

任何人均可瀏覽程式碼、查看 SVN 存放庫,或透過 RSS 訂閱開發記錄

變更記錄

0.3.7

  • Fix JS error on Menus manager

0.3.6

  • Revamp of how fields are added to WP UI, should prevent conflict with other plugins and themes.

0.3.5

  • Possible fatal error prevention

0.3.4

  • Fix compatibility with Menu Icons plugin

0.3.3

  • Fix menu item edit screen styles

0.3.2

  • Fix Customizer wiping out the Visibility value upon save

0.3.1

  • Got rid of PHP notices in the admin area
  • Updated Walker_Nav_Menu_Edit

0.3

  • Gantry 4.0 compatibility
  • implemented singleton pattern
  • added the remove_visibility_meta function which cleans up the meta datas for deleted menu items

0.2.1

  • Fixed a minor bug where unnecessary database rows in postmeta table would be created upon save
  • fixed a bug concerning using quotes in conditions

0.2

  • Compatibility with latest WordPress release
  • Fixed a minor bug where conditions would also execute on the admin area