Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WPML language switcher not showing up in menu #18

Closed
huubl opened this issue Jul 20, 2020 · 3 comments · Fixed by #33
Closed

WPML language switcher not showing up in menu #18

huubl opened this issue Jul 20, 2020 · 3 comments · Fixed by #33
Labels
enhancement New feature or request

Comments

@huubl
Copy link

huubl commented Jul 20, 2020

Hi,

I'm using WPML to make my website multilingual, but the language switcher is not showing with Navi. The switcher is present when using wp_get_nav_menu_items().

[...]
35:
ID: "wpml-ls-2-en"
attr_title: ""
classes: (8) ["menu-item", "wpml-ls-slot-2", "wpml-ls-item", "wpml-ls-item-en", "wpml-ls-current-language", "wpml-ls-menu-item", "wpml-ls-first-item", "wpml-ls-last-item"]
db_id: "wpml-ls-2-en"
description: null
menu_item_parent: 0
menu_order: 36
object: "wpml_ls_menu_item"
object_id: "wpml-ls-2-en"
post_parent: null
post_title: "<img class="wpml-ls-flag" src="http://localhost:3002/app/plugins/sitepress-multilingual-cms/res/flags/en.png" alt="English">"
post_type: "nav_menu_item"
target: null
title: "<img class="wpml-ls-flag" src="http://localhost:3002/app/plugins/sitepress-multilingual-cms/res/flags/en.png" alt="English">"
type: "wpml_ls_menu_item"
type_label: null
url: "http://localhost:3002"
xfn: null
_invalid: false
[...]

When changing:

navi/src/Builder.php

Lines 81 to 83 in 5e1e3dd

$menu = collect($menu)->filter(function ($item) {
return $item instanceof \WP_Post;
})->all();

To:

$menu = collect($menu)->filter(function ($item) {
    return $item;
})->all();

Are there possible side effects of removing: instanceof \WP_Post ?

@Log1x
Copy link
Owner

Log1x commented Jul 21, 2020

Any idea what the item is returning as if it isn't a WP_Post?

@Log1x Log1x added the question Further information is requested label Jul 21, 2020
@huubl
Copy link
Author

huubl commented Jul 21, 2020

Yes, it's returning a WPML_LS_Menu_Item as object

@Log1x
Copy link
Owner

Log1x commented Jul 21, 2020

Yes, it's returning a WPML_LS_Menu_Item as object

oof that's a little frusterating. okay, let me think on it.

@Log1x Log1x added bug Something isn't working enhancement New feature or request and removed bug Something isn't working question Further information is requested labels Jul 21, 2020
@Log1x Log1x closed this as completed in #33 Feb 14, 2021
Log1x added a commit that referenced this issue Feb 14, 2021
* chore(docs): Update license
* chore(docs): Update README
* chore(docs): Update README links
* enhance(docs): Add instructions for installing as a plugin
* enhance(docs): Add usage example for vanilla themes
* enhance(docs): Improve documentation custom field examples (Supersedes #27)
* enhance(docs): Move theme usage into `examples/` folder
* feat(ci): Add GitHub action to package Navi as a plugin
* feat(ci): Switch to GitHub actions
* feat(navi): Add support for WPML (Fixes #18)
* feat(navi): Allow Navi to be used as a plugin
* feat(navi): Lower minimum PHP version to 7.0
* feat(navi): Remove dependency on Roots Sage
* feat(navi): Remove Illuminate dependencies (Supersedes #20)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants