Title: WP REST Menus
Author: skapator
Published: <strong>جولائی 4, 2018</strong>
Last modified: فروری 17, 2022

---

پلگ انز تلاش کریں

![](https://ps.w.org/wp-rest-menu/assets/banner-772x250.png?rev=2678035)

یہ پلگ ان **ورڈپریس کے تازہ ترین 3 ریلیزوں کے ساتھ ٹیسٹ نہیں کیا گیا ہے**۔ اب یہ
برقرار نہیں رکھا جا سکتا یا معاونت نہیں کی جا سکتی اور اس کو ورڈپریس کے تازہ ترین
ورژنز کے ساتھ استعمال کیے جانے پر مطابقت کے مسائل ہو سکتے ہیں۔

![](https://ps.w.org/wp-rest-menu/assets/icon-128x128.png?rev=2678036)

# WP REST Menus

 منجانب [skapator](https://profiles.wordpress.org/skapator/)

[ڈاؤن لوڈ کریں](https://downloads.wordpress.org/plugin/wp-rest-menu.1.0.4.zip)

 * [تفصیلات](https://ur.wordpress.org/plugins/wp-rest-menu/#description)
 * [جائزے](https://ur.wordpress.org/plugins/wp-rest-menu/#reviews)
 *  [انسٹالیشن](https://ur.wordpress.org/plugins/wp-rest-menu/#installation)
 * [ڈیولپمنٹ](https://ur.wordpress.org/plugins/wp-rest-menu/#developers)

 [معاونت](https://wordpress.org/support/plugin/wp-rest-menu/)

## تفصیل

This plugin adds new endpoints for WordPress registered menus.
 Usefull when building
SPAs with Vuejs, React or any front-end framework. Works with Advacned Custom Fields,
WPML, Polylang

The new endpoints available:

**Get all menus**

    ```
    GET /menus/v1/menus

    // Response sample
    {  
        term_id: 2,
        name: "Main Menu",
        slug: "main-menu",
        term_group: 0,
        term_taxonomy_id: 2,
        taxonomy: "nav_menu",
        description: "",
        parent: 0,
        count: 8,
        filter: "raw"
    },
    ...
    ```

**Get a menus items by id (term_id)**

    ```
    GET /menus/v1/menus/<id>

    // Response sample
    {  
        ID: 5,
        post_author: "1",
        post_date: "2018-07-03 06:42:18",
        post_date_gmt: "2018-07-03 06:42:18",
        filter: "raw",
        db_id:5,
        menu_item_parent: "0",
        object_id: "5",
        object: "custom",
        type: "custom",
        type_label: "Custom Link",
        title: "Home",
        url: "https:\/\/wp-rest-menu.local\/",
        target: "",
        attr_title: "",
        description: "",
        classes: [  
         ""
        ],
        xfn: "",
        meta: null
    },
    ...
    ```

**Get all menu locations**
 All menu locations assigned in /wp-admin/nav-menus.php?
action=locations

    ```
    GET /menus/v1/menus/locations is deprecated and will be removed in newer versions use:
    GET /menus/v1/locations

    // Response example
    {  
        slug: "top",
        description: "Top Menu"
    },
    {  
        slug: "social",
        description: "Social Links Menu"
    }
    ...
    ```

**Get all menu location items**
 All menu locations assigned in /wp-admin/nav-menus.
php?action=locations

    ```
    GET /menus/v1/menus/locations/<slug> is deprecated and will be removed in newer versions use:
    GET /menus/v1/locations/<slug>

    // Response samexampleple
    {  
        ID: 5,
        post_author: "1",
        post_date: "2018-07-03 06:42:18",
        post_date_gmt: "2018-07-03 06:42:18",
        filter: "raw",
        db_id:5,
        menu_item_parent: "0",
        object_id: "5",
        object: "custom",
        type: "custom",
        type_label: "Custom Link",
        title: "Home",
        url: "https:\/\/wp-rest-menu.local\/",
        target: "",
        attr_title: "",
        description: "",
        classes: [  
         ""
        ],
        xfn: "",
        meta: null
    },
    ...
    ```

There are two filters availiable:

**Fields Filter**

    ```
    // it will return only the fields specified
    GET /menus/v1/menus/<id>/?fields=ID,title,meta

    // Response sample
    // Response sample
    {  
        ID: 5,
        title: "Home",
        meta: null
    },
    ...
    ```

**Nested Items Filter**

    ```
    // it will return menu items parents and nested children in a 'children' field
    // Currently only one level deep is supported
    GET /menus/v1/menus/<id>/?nested=1

    // Response sample
    {  
      ID: 1716,
      menu_item_parent: "0",
      object_id: "174",
      object: "page",
      title: "Level 1",
      meta: {  
         vue_component: "LevelComponent",
         menu-item-field-01: "Field 1 value",
         menu-item-field-02: "Field 2 value"
      },
      children:[  
         {  
            ID: 1717,
            menu_item_parent: "1716",
            object_id: "744",
            object: "page",
            title: "Level 2b",
            meta : {  
               vue_component: null
            }
         },
         ...
      ]
    },
    ...
    ```

**WP filter hooks**

This plugin is quite configurable and provides lots of wp filter hooks from returned
data in responses for each endpoint to params validation and endpoint permissions.

    ```
    add_filter( 'wprm/get_menus/wp_get_nav_menus/args', 'my_wp_get_nav_menus', 10, 1 );
    (used in GET /menus/v1/menus)

    function my_wp_get_nav_menus( $args ) {
        // do something with wp_get_nav_menus $args array
        return $args;
    }



    add_filter( 'wprm/get_menus', 'my_get_menus', 10, 1 );
    (used in GET /menus/v1/menus)

    function my_get_menus( $menus ) {
        // do something with $menus array

        return $menus; // WP_Error|WP_HTTP_Response|WP_REST_Response|mixed
    }



    add_filter( 'wprm/get_menu_locations', 'my_get_menu_locations', 10, 1 );
    (used in GET /menus/v1/locations)

    function my_get_menu_locations( $locations ) {
        // You can modify the $locations array response (get_registered_nav_menus())

        return $locations; // WP_Error|WP_HTTP_Response|WP_REST_Response|mixed
    }



    add_filter( 'wprm/get_menu_items', 'my_get_menu_items', 10, 1 );
    (used in GET /menus/v1/menus/<id>)

    function my_rest_menu_item_fields( $menu ) {
        // You can modify the $menu items

        return $menu;
    }



    add_filter( 'wprm/get_location_menu_items', 'my_get_location_menu_items', 10, 1 );
    (used in GET /menus/v1/menus/<id>)

    function my_get_location_menu_items( $menu ) {
        // You can modify the locations $menu items

        return $menu;
    }



    add_filter( 'wprm/get_item_fields/filter_fields', 'my_filter_fields', 10, 1 );
    (used to filter return field -node edges-)

    function my_filter_fields( $fields ) {
        // You can modify the $fields array so
        // you can filter the return fields for all endpoints
        // without using the url param ?fields

        $fields = array( 'ID', 'title' );
        return $fields;
    }
    ```

More filters

    ```
    apply_filters('wprm/get_menus/permissions', '__return_true', $request );
    apply_filters('wprm/get_menu_locations/permissions', '__return_true', $request );
    apply_filters('wprm/get_menu_items/permissions', '__return_true', $request );
    apply_filters('wprm/get_menu_items/validate/args/id', is_numeric( $param ), $param, $request, $key );
    apply_filters('wprm/get_menu_items/validate/args/fields', is_string( $param ), $param, $request, $key );
    apply_filters('wprm/get_menu_items/validate/args/nested', absint( $param ), $param, $request, $key );
    apply_filters('wprm/get_location_menu_items/permissions', '__return_true', $request );
    apply_filters('wprm/get_location_menu_items/validate/args/slug', is_string( $param ), $param, $request, $key );
    apply_filters('wprm/get_location_menu_items/validate/args/fields', is_string( $param ), $param, $request, $key );
    apply_filters('wprm/get_location_menu_items/validate/args/nested', absint( $param ), $param, $request, $key );
    apply_filters('wprm/get_location_menu_items/permissions', '__return_true', $request );
    apply_filters('wprm/get_location_menu_items/validate/args/slug', is_string( $param ), $param, $request, $key );
    apply_filters('wprm/get_location_menu_items/validate/args/fields', is_string( $param ), $param, $request, $key );
    apply_filters('wprm/get_location_menu_items/validate/args/nested', absint( $param ), $param, $request, $key );
    ```

Supports custom fields and Advanced Custom Fields
 If ACF is installed the response
node edge is _acf_ else _meta_ In newer version these two edges will co exist and
the plugin will separate natively registered custom fields ad acf registered ones.

## انسٹالیشن

There are no requirements other than WordPress and one active menu. Installation
is simple:

 1. Upload the `wp-rest-menus` folder to the `/wp-content/plugins/` directory
 2. Activate the plugin through the ‘Plugins’ menu in WordPress

## عمومی سوالات

### How do I use this plugin?

It creates endpoints for wp nav menus to use in your front end.

### Can I contribute?

Yes, you can fork it on [github](https://github.com/kostasxyz/wp-rest-menus).

## جائزے

![](https://secure.gravatar.com/avatar/37bcaa4b105b6508e8ef8c46657c26ab36fb13a51d3501cb43849c8ade7c0dd5?
s=60&d=retro&r=g)

### 󠀁[Awesome plugin!](https://wordpress.org/support/topic/awesome-plugin-4955/)󠁿

 [Yiannis Christodoulou](https://profiles.wordpress.org/yiannistaos/) اپریل 12, 
2020

This plugin is what I was looking for! Very easy to add new endpoints in WP menus.
Thanks!

![](https://secure.gravatar.com/avatar/59b970a8a077a00b3420c01d7c5c54435c3621154be14b7ffd40eed375509335?
s=60&d=retro&r=g)

### 󠀁[Better than WP-REST-API V2 Menus](https://wordpress.org/support/topic/better-than-wp-rest-api-v2-menus/)󠁿

 [ITomSawyerI](https://profiles.wordpress.org/itomsawyeri/) اپریل 5, 2020

This plugin has a fields filter ability.

![](https://secure.gravatar.com/avatar/e455bfa29d9ef411c3406fa90f86d63543024adac0c15efefea6e186220e9b81?
s=60&d=retro&r=g)

### 󠀁[Awesome for building front end apps with wp-rest api for dynamic menus](https://wordpress.org/support/topic/awesome-for-building-front-end-apps-with-wp-rest-api-for-dynamic-menus/)󠁿

 [imaginena](https://profiles.wordpress.org/imaginena/) نومبر 26, 2018

Just saved some days on development, thrilled that ACF is supported. Thumbs up, 
good work.

![](https://secure.gravatar.com/avatar/72d107aaf08236cc9f8995145eeb62d5815253825c7a9978a38ed455bf410773?
s=60&d=retro&r=g)

### 󠀁[Does exactly what it’s supposed to do!!!](https://wordpress.org/support/topic/does-exactly-what-its-supposed-to-do-16/)󠁿

 [alexitsios](https://profiles.wordpress.org/alexitsios/) نومبر 9, 2018

I’ve been searching for something like that for some time now. Really grateful that
it supports Advanced Custom Fields and meta fields.

 [ تمام 3 جائزے پڑھیں ](https://wordpress.org/support/plugin/wp-rest-menu/reviews/)

## شراکت دار اور ڈیویلپرز

“WP REST Menus” اوپن سورس سافٹ ویئر ہے۔ مندرجہ ذیل لوگوں نے اس پلگ ان میں حصہ لیا:

شراکت دار

 *   [ skapator ](https://profiles.wordpress.org/skapator/)

[“WP REST Menus” کا اپنی زبان میں ترجمہ کریں۔](https://translate.wordpress.org/projects/wp-plugins/wp-rest-menu)

### ڈویلپمینٹ میں دلچسپی ہے؟

[کوڈ براؤز کریں](https://plugins.trac.wordpress.org/browser/wp-rest-menu/)، [ایس این وی ریپوزیٹری](https://plugins.svn.wordpress.org/wp-rest-menu/)
کو چیک کریں یا [ڈویلپمینٹ لاگ](https://plugins.trac.wordpress.org/log/wp-rest-menu/)
کو سبسکرائب کریں بذریعہ [آر ایس ایس](https://plugins.trac.wordpress.org/log/wp-rest-menu/?limit=100&mode=stop_on_copy&format=rss)۔

## میٹا

 *  Version **1.0.4**
 *  Last updated **4 سال پہلے**
 *  Active installations **100+**
 *  WordPress version ** 5.0 یا اس سے جدید **
 *  Tested up to **5.9.13**
 *  PHP version ** 5.6 یا اس سے جدید **
 *  Language
 * [English (US)](https://wordpress.org/plugins/wp-rest-menu/)
 * Tags
 * [api](https://ur.wordpress.org/plugins/tags/api/)[v2](https://ur.wordpress.org/plugins/tags/v2/)
   [wp-rest-api](https://ur.wordpress.org/plugins/tags/wp-rest-api/)
 *  [اعلی درجے کا منظر](https://ur.wordpress.org/plugins/wp-rest-menu/advanced/)

## درجہ بندیاں

 5 out of 5 stars.

 *  [  4 5-star reviews     ](https://wordpress.org/support/plugin/wp-rest-menu/reviews/?filter=5)
 *  [  0 4-star reviews     ](https://wordpress.org/support/plugin/wp-rest-menu/reviews/?filter=4)
 *  [  0 3-star reviews     ](https://wordpress.org/support/plugin/wp-rest-menu/reviews/?filter=3)
 *  [  0 2-star reviews     ](https://wordpress.org/support/plugin/wp-rest-menu/reviews/?filter=2)
 *  [  0 1-star reviews     ](https://wordpress.org/support/plugin/wp-rest-menu/reviews/?filter=1)

[Your review](https://wordpress.org/support/plugin/wp-rest-menu/reviews/#new-post)

[See all reviews](https://wordpress.org/support/plugin/wp-rest-menu/reviews/)

## شراکت دار

 *   [ skapator ](https://profiles.wordpress.org/skapator/)

## معاونت

کچھ کہنا ہے؟ مدد چاہیے؟

 [معاونتی فورم دیکھیں](https://wordpress.org/support/plugin/wp-rest-menu/)