Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/andreiigna/if-menu
If Menu - WordPress plugin
https://github.com/andreiigna/if-menu
menus wordpress
Last synced: 5 days ago
JSON representation
If Menu - WordPress plugin
- Host: GitHub
- URL: https://github.com/andreiigna/if-menu
- Owner: AndreiIgna
- License: gpl-3.0
- Created: 2019-06-05T13:41:39.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-09-08T15:49:27.000Z (2 months ago)
- Last Synced: 2024-09-08T17:50:07.437Z (2 months ago)
- Topics: menus, wordpress
- Language: PHP
- Homepage: https://layered.market/plugins/if-menu
- Size: 375 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
If Menu
=========**If Menu** is a WordPress plugin which adds extra functionality for menu items, making it easy to hide or display menu items based on user-defined rules. Example:
* Display a menu item only if current `User is logged in`
* Hide menu items if `visiting from mobile device`
* Display menu items just for `Admins and Editors`The plugin is easy to use, each menu item will have a “Change menu item visibility” option which will enable the selection of rules.
> This repo is used only for development, downloading & installing from here won't work as expected. Install from [WordPress.org plugin page](https://wordpress.org/plugins/if-menu/)
## Features
* Basic set of visibility rules
* User state `User is logged in`
* User roles `Admin` `Editor` `Author` etc
* Page type `Front page` `Single page` `Single post`
* Device `Is Mobile`
* Language `Is RTL`
* Multiple rules - mix multiple rules for a menu item visibility
* show if `User is logged in` AND `Device is mobile`
* show if `User is Admin` AND `Is front page`
* Support for adding your custom rules## Adding custom visibility rules in a plugin or theme
Custom visibility rules can be added easily by any plugin or theme.
Example of adding a new rule for displaying/hiding a menu item when current page is a custom-post-type.```
// theme's functions.php or plugin file
add_filter('if_menu_conditions', 'my_new_menu_conditions');function my_new_menu_conditions($conditions) {
$conditions[] = array(
'id' => 'single-my-custom-post-type', // unique ID for the condition
'name' => __('Single my-CPT', 'i18n-domain'), // name of the condition
'condition' => function($item) { // callback - must return Boolean
return is_singular('my-custom-post-type');
}
);return $conditions;
}
```## WordPress.org
Head over to [plugin's page on WordPress.org](https://wordpress.org/plugins/if-menu/) for more info, reviews and support