• Resolved daveagp

    (@daveagp)


    I am not getting a correct translation when I call

    pll_home_url()

    when building the toolbar (specifically within an action hooked to “wp_before_admin_bar_render”) when viewing the dashboard or profile (any is_admin page). Investigating the problem and the source code of pll_home_url(), the issue seems to be that

    class_exists(‘Polylang_Core’)

    returns false. Is this the expected behaviour or not? Thanks!

    https://www.ads-software.com/extend/plugins/polylang/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Chouby

    (@chouby)

    Could you explain what you want to achieve? pll_home_url() returns the home url in the current language. This has a meaning only on frontend, not on admin side.

    Thread Starter daveagp

    (@daveagp)

    Thanks! I didn’t think about it enough to notice that the viewer language is not defined on admin pages in the same way that it is on the main site. However, there is a user_meta variable called user_lang on the Profile page which I think is what I want to use.

    I also looked a bit more at my problem and I see that pll_get_post() suffices for my purposes in lieu of pll_home_url() since I know the home page ID. So I am now doing

    pll_get_post($id, substr(get_user_meta( wp_get_current_user()->ID, “user_lang”, true), 0, 2))

    which seems to be just as good. Thanks very much!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘API problem on admin page (profile, dashboard)’ is closed to new replies.