thebatclaudio / wp-rest-api-v2-menus

Adding menus endpoints on WP REST API v2
47 stars 22 forks source link

wpml lang query #29

Open cannap opened 4 years ago

cannap commented 4 years ago

Hi when i add the WPML ?lang=query

http://masks.local/wp-json/menus/v1/locations/header?lang=**de**

this works because its the DEFAULT one

now when i add a other language

http://masks.local/wp-json/menus/v1/locations/header?lang=**en**

then i get the right menu but i get the slug as slug: lang=en

Example: check the slug response Response with lang=de WPML Default lang

{
    "term_id": 12,
    "name": "Menu Deutsch",
    "slug": "menu-deutsch",
    "term_group": 0,
    "term_taxonomy_id": 12,
    "taxonomy": "nav_menu",
    "description": "",
    "parent": 0,
    "count": 3,
    "filter": "raw",
    "items": [
        {
            "ID": 71,
            "post_author": "1",
            "post_date": "2020-04-21 14:44:43",
            "post_date_gmt": "2020-04-21 14:44:43",
            "post_content": " ",
            "post_title": "",
            "post_excerpt": "",
            "post_status": "publish",
            "comment_status": "closed",
            "ping_status": "closed",
            "post_password": "",
            "post_name": "71",
            "to_ping": "",
            "pinged": "",
            "post_modified": "2020-04-21 14:45:05",
            "post_modified_gmt": "2020-04-21 14:45:05",
            "post_content_filtered": "",
            "post_parent": 0,
            "guid": "http://masks.local/?p=71",
            "menu_order": 1,
            "post_type": "nav_menu_item",
            "post_mime_type": "",
            "comment_count": "0",
            "filter": "raw",
            "db_id": 71,
            "menu_item_parent": "0",
            "object_id": "47",
            "object": "page",
            "type": "post_type",
            "type_label": "Seite",
            "url": "http://masks.local/startseite/",
            "title": "Startseite",
            "target": "",
            "attr_title": "",
            "description": "",
            "classes": [
                ""
            ],
            "xfn": "",
            "slug": "startseite"
        },
        {
            "ID": 70,
            "post_author": "1",
            "post_date": "2020-04-21 12:23:08",
            "post_date_gmt": "2020-04-21 12:23:08",
            "post_content": " ",
            "post_title": "",
            "post_excerpt": "",
            "post_status": "publish",
            "comment_status": "closed",
            "ping_status": "closed",
            "post_password": "",
            "post_name": "70",
            "to_ping": "",
            "pinged": "",
            "post_modified": "2020-04-21 14:45:05",
            "post_modified_gmt": "2020-04-21 14:45:05",
            "post_content_filtered": "",
            "post_parent": 0,
            "guid": "http://masks.local/?p=70",
            "menu_order": 2,
            "post_type": "nav_menu_item",
            "post_mime_type": "",
            "comment_count": "0",
            "filter": "raw",
            "db_id": 70,
            "menu_item_parent": "0",
            "object_id": "63",
            "object": "page",
            "type": "post_type",
            "type_label": "Seite",
            "url": "http://masks.local/xxx-german/",
            "title": "xxx German",
            "target": "",
            "attr_title": "",
            "description": "",
            "classes": [
                ""
            ],
            "xfn": "",
            "slug": "xxx-german"
        },
        {
            "ID": 69,
            "post_author": "1",
            "post_date": "2020-04-21 12:23:08",
            "post_date_gmt": "2020-04-21 12:23:08",
            "post_content": " ",
            "post_title": "",
            "post_excerpt": "",
            "post_status": "publish",
            "comment_status": "closed",
            "ping_status": "closed",
            "post_password": "",
            "post_name": "69",
            "to_ping": "",
            "pinged": "",
            "post_modified": "2020-04-21 14:45:05",
            "post_modified_gmt": "2020-04-21 14:45:05",
            "post_content_filtered": "",
            "post_parent": 0,
            "guid": "http://masks.local/?p=69",
            "menu_order": 3,
            "post_type": "nav_menu_item",
            "post_mime_type": "",
            "comment_count": "0",
            "filter": "raw",
            "db_id": 69,
            "menu_item_parent": "0",
            "object_id": "65",
            "object": "page",
            "type": "post_type",
            "type_label": "Seite",
            "url": "http://masks.local/privacy-policy-deutsch/",
            "title": "Privacy Policy Deutsch",
            "target": "",
            "attr_title": "",
            "description": "",
            "classes": [
                ""
            ],
            "xfn": "",
            "slug": "privacy-policy-deutsch"
        }
    ]
}

now with a non default query

lang=en

{
    "term_id": 2,
    "name": "Menu Header",
    "slug": "menu-header",
    "term_group": 0,
    "term_taxonomy_id": 2,
    "taxonomy": "nav_menu",
    "description": "",
    "parent": 0,
    "count": 3,
    "filter": "raw",
    "items": [
        {
            "ID": 60,
            "post_author": "1",
            "post_date": "2020-04-20 13:34:39",
            "post_date_gmt": "2020-04-20 13:34:39",
            "post_content": " ",
            "post_title": "",
            "post_excerpt": "",
            "post_status": "publish",
            "comment_status": "closed",
            "ping_status": "closed",
            "post_password": "",
            "post_name": "60",
            "to_ping": "",
            "pinged": "",
            "post_modified": "2020-04-20 13:34:39",
            "post_modified_gmt": "2020-04-20 13:34:39",
            "post_content_filtered": "",
            "post_parent": 0,
            "guid": "http://masks.local/?p=60",
            "menu_order": 1,
            "post_type": "nav_menu_item",
            "post_mime_type": "",
            "comment_count": "0",
            "filter": "raw",
            "db_id": 60,
            "menu_item_parent": "0",
            "object_id": "45",
            "object": "page",
            "type": "post_type",
            "type_label": "Page",
            "url": "http://masks.local/home/?lang=en",
            "title": "Home",
            "target": "",
            "attr_title": "",
            "description": "",
            "classes": [
                ""
            ],
            "xfn": "",
            "slug": "?lang=en"
        },
        {
            "ID": 59,
            "post_author": "1",
            "post_date": "2020-04-20 13:34:39",
            "post_date_gmt": "2020-04-20 13:34:39",
            "post_content": " ",
            "post_title": "",
            "post_excerpt": "",
            "post_status": "publish",
            "comment_status": "closed",
            "ping_status": "closed",
            "post_password": "",
            "post_name": "59",
            "to_ping": "",
            "pinged": "",
            "post_modified": "2020-04-20 13:34:39",
            "post_modified_gmt": "2020-04-20 13:34:39",
            "post_content_filtered": "",
            "post_parent": 0,
            "guid": "http://masks.local/?p=59",
            "menu_order": 2,
            "post_type": "nav_menu_item",
            "post_mime_type": "",
            "comment_count": "0",
            "filter": "raw",
            "db_id": 59,
            "menu_item_parent": "0",
            "object_id": "57",
            "object": "page",
            "type": "post_type",
            "type_label": "Page",
            "url": "http://masks.local/kn95/?lang=en",
            "title": "KN95",
            "target": "",
            "attr_title": "",
            "description": "",
            "classes": [
                ""
            ],
            "xfn": "",
            "slug": "?lang=en"
        },
        {
            "ID": 72,
            "post_author": "1",
            "post_date": "2020-04-21 14:45:13",
            "post_date_gmt": "2020-04-21 14:45:13",
            "post_content": " ",
            "post_title": "",
            "post_excerpt": "",
            "post_status": "publish",
            "comment_status": "closed",
            "ping_status": "closed",
            "post_password": "",
            "post_name": "72",
            "to_ping": "",
            "pinged": "",
            "post_modified": "2020-04-21 14:45:13",
            "post_modified_gmt": "2020-04-21 14:45:13",
            "post_content_filtered": "",
            "post_parent": 0,
            "guid": "http://masks.local/72/",
            "menu_order": 3,
            "post_type": "nav_menu_item",
            "post_mime_type": "",
            "comment_count": "0",
            "filter": "raw",
            "db_id": 72,
            "menu_item_parent": null,
            "object_id": "61",
            "object": "page",
            "type": "post_type",
            "type_label": "Page",
            "url": "http://masks.local/privacy-policy/?lang=en",
            "title": "Privacy Policy",
            "target": "",
            "attr_title": "",
            "description": "",
            "classes": [
                ""
            ],
            "xfn": "",
            "slug": "?lang=en"
        }
    ]
}

the items are correct but the slug is just ?lang=en

thebatclaudio commented 4 years ago

Hello, this plugin doesn't support WPML and in this time I don't have enough free time to implement this functionality. If you want you can implement this functionality by yourself and send me a pull request. I will add you to the contributors of this plugin

cannap commented 4 years ago

hi thanks for you answer wpml also gave much more problems i stoped using wordpress for my current project

birksy89 commented 1 year ago

Is this still the case in 2022?

We have a WPML setup, and are trying to pull Menu nodes in various languages over the REST API.

Any help, suggestions etc would be greatly appreciated

thebatclaudio commented 1 year ago

Hello @birksy89, I'm sorry but the plugin doesn't support WPML and in this time I'm too busy to implement this. If you want, you can try to implement this and send a PR that I will review (and I will add you to contributors).

I'm reopening the issue, so that if anyone else wants to contribute they can.