| 开发者 | teamstaccato |
|---|---|
| 更新时间 | 2026年9月25日 15:14 |
| PHP版本: | 8.1 及以上 |
| WordPress版本: | 7.1 |
| 版权: | GPL-2.0-or-later |
| 版权网址: | 版权信息 |
wp_get_current_user() to evaluate role-based conditions.
Important: this is display control, not access control
Shed Menu hides menu items, blocks, and shortcode content from output. It does not restrict access to the underlying page, post, or URL. A visitor who knows or guesses the direct URL can still open it even if the menu link to it is hidden. Do not rely on Shed Menu to protect private or paid content — use post visibility settings (Private / Password protected) or a membership plugin for that.
Three ways to use
shedmenu_visible() in your header.php or other template files.[shedmenu_visible login="in" start="2026-04-01" end="2026-04-30" roles="administrator"] This content is only visible to administrators between April 1 and April 30. [/shedmenu_visible]
日本語の説明
WordPress 標準ナビゲーションメニューに、メニュー項目単位の表示条件を追加します。
wp_nav_menu() を使わず HTML 直書きしている場合は shedmenu_visible() ヘルパー関数を使ってください。Gutenberg では「Shed Menu — Conditional」ブロックで任意のブロック群を条件表示にできます。
重要: これは「表示の制御」であり「アクセス制限」ではありません。 Shed Menu はメニュー項目・ブロック・ショートコードの内容を出力しないようにするだけで、リンク先のページや投稿・ URL 自体へのアクセスを制限するものではありません。メニューを非表示にしても、URL を直接知っている(または推測できる)訪問者はそのページを開けます。非公開にしたい・有料会員限定にしたいコンテンツの保護には、投稿の公開状態(非公開・パスワード保護)や会員制プラグインを使ってください。
shed-menu folder to the /wp-content/plugins/ directory, or install via the Plugins screen in WordPress.Login-based visibility is evaluated per request. If you use a page caching plugin, make sure it serves separate cached pages for logged-in vs logged-out users. Most caching plugins support this by default.
Shed Menu uses the standard wp_nav_menu_objects filter and does not override menu rendering. It works alongside most menu plugins.
The Navigation block uses its own internal item structure that does not expose per-item post meta in a stable way. Use the "Shed Menu — Conditional" block to wrap navigation links instead.
Uninstalling removes all visibility settings stored on menu items and plugin options. Deactivating without uninstalling preserves all settings.
Yes. The Roles field in the menu item editor lists all roles registered in your WordPress installation, including custom roles added by other plugins.
No. Shed Menu only controls whether a menu item, block, or shortcode content is rendered in the output. It does not restrict access to the linked page, post, or URL itself — a visitor who has the direct link can still open it. To actually restrict access to content, use WordPress's built-in post visibility settings (Private / Password protected) or a membership plugin.
shed/conditional to shed-menu/conditional for WordPress.org compliance.shed_menu_visible() to shedmenu_visible() for prefix consistency.[shed_menu_visible] to [shedmenu_visible] for prefix consistency.Shedmenu_PATH renamed to SHEDMENU_PATH to follow WordPress naming conventions (uppercase).phpcs:disable/enable blocks with per-line phpcs:ignore in menu item save handler. Added English comment explaining core nonce pre-verification.