https://github.com/cmatosbc/oopress-menus
Retrieve WP menus as pure data, as array or JSON.
https://github.com/cmatosbc/oopress-menus
Last synced: 7 months ago
JSON representation
Retrieve WP menus as pure data, as array or JSON.
- Host: GitHub
- URL: https://github.com/cmatosbc/oopress-menus
- Owner: cmatosbc
- License: gpl-3.0
- Created: 2024-11-11T02:41:52.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-11-12T09:47:42.000Z (11 months ago)
- Last Synced: 2025-01-20T19:12:22.093Z (9 months ago)
- Language: PHP
- Size: 37.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Oopress Menus
Retrieve WP menus as pure data, as array or JSON. Also allows the data to be passed to a particular template in Wordpress.

## Usage
Usage is pretty simple. You need to instantiate the class with the menu ID or slug, then use the method fetch() to access the data. Further, the method getItems() may return the structured menu data as array or JSON (using true). Finally, the method render() passes the menu data through a template part, rendering it (in the template, the menu data can be accessed from $args['data']).
```php
// Create the instance for "menu-1" menu
$menuData = (new \Oopress\Menus\Fetcher('testing'))
->fetch()
->getItems(true); // Fetches menu data and returns the data in JSON (or array if not TRUE)
```