An open API service indexing awesome lists of open source software.

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.

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.

![OOPress](https://raw.githubusercontent.com/cmatosbc/oopress-cache/refs/heads/main/img/one.jpg)

## 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)
```