mehrshaddarzi / wp-trait

Fast and standard development of WordPress plugins
MIT License
14 stars 5 forks source link

Menu Collection #20

Open mehrshaddarzi opened 2 years ago

mehrshaddarzi commented 2 years ago

https://github.com/thebatclaudio/wp-rest-api-v2-menus

iniznet commented 1 year ago

I'm assuming array as expected returned value? something like,

[
    'active' => true,
    'activeAncestor' => false,
    'activeParent' => false,
    'classes' => 'classes',
    'description' => 'description',
    'id' => 1,
    'label' => 'Sample Page',
    'objectId' => 2 // postId
    'parent' => false, // parent menu item id
    'slug' => 'sample-page',
    'target' => false,
    'title' => false, // title attribute
    'url' => 'https://foo.bar/sample-page',
]

With that, we can loop it over in a template.

mehrshaddarzi commented 1 year ago

@iniznet please see this file: https://github.com/thebatclaudio/wp-rest-api-v2-menus/blob/master/wp-rest-api-v2-menus.php

We want to Create a Menu Collection With three Methods: 1) Get all list Menu With Custom Meta Term 2) Get all List Locations Menu 3) Get Menu List item By ID or Name

Your proposed array is missing three points: 1- Every Menu Item List is a Post in WordPress Database, We must add Meta Parameter. 2- WordPress Menu is a Nested System, we Must add children Parameter. 3- We Prefer All Methods return Object in This Package.