Matt Gibson
Forum Replies Created
-
Forum: Plugins
In reply to: [Polylang] Best way to pragmatically add a post in a language?Hi Chouby,
Fabulous, that’s working perfectly.
Thanks,
Matt
Forum: Plugins
In reply to: [Polylang] Issues with Polylang 1.2.xCool, thanks for the confirmation. Confused the hell out of me before I spotted the missing brackets (“But it’s *uninitialised*! How can it be an array?!”) ??
Forum: Plugins
In reply to: [Polylang] Issues with Polylang 1.2.xYup, I’m getting the same thing with with the stock Twenty Ten theme, just seems to be some missing braces:
public function nav_menu_locations($menus) { if (is_array($menus)) $theme = get_option('stylesheet'); foreach ($menus as $loc => $menu) { if (!empty($this->options['nav_menus'][$theme][$loc][$this->curlang->slug])) $menus[$loc] = $this->options['nav_menus'][$theme][$loc][$this->curlang->slug]; } return $menus; }
…the indentation suggests that there should be braces with the is_array() conditional so that the foreach is inside it to me?
Forum: Plugins
In reply to: [Polylang] Using get_terms() in admin interface from a plugin?Excellent; thanks for all the help.
Forum: Plugins
In reply to: [Polylang] Using get_terms() in admin interface from a plugin?Fab, thanks, that seems to do the trick:
// Use Polylang's selected language if set. Otherwise we can default to pretty much // anything and get the same result, so I'll just choose 'en'. $admin_lang = defined('ICL_LANGUAGE_CODE') ? ICL_LANGUAGE_CODE : 'en'; $terms = get_terms($key, array( 'hide_empty'=>false, 'lang' => $admin_lang, 'cache_domain' => $admin_lang) );
Forum: Plugins
In reply to: [Polylang] Using get_terms() in admin interface from a plugin?Ah… except that if I try to figure out what the current language is using pll_current_language(), it looks for $polylang->curlang, which doesn’t exist. Any hints as to a workaround? Guessing this isn’t available in this way in PLL_Admin?
Thanks,
Matt
Forum: Plugins
In reply to: [Polylang] Using get_terms() in admin interface from a plugin?Hi,
Aha! Yes, your suspicions are right. I just stepped through the code in xdebug, and get_terms() hits the cache on my call, because earlier on, during taxonomy set-up, I check to see if any terms exist using the same query (so I can pre-populate them with some helpful values if none exist.)
Hah! Ironically, now that I can see what’s going on, the first Google hit I came across was someone fixing the same issue with WPML ?? https://wpml.org/forums/topic/get_terms-and-caching-bug/
I’ll see if I can fix my issue in a similar way. (Presumably I can use pll_current_language() to grab the right language from the admin bar drop-down, then use that to shove appropriate things in both ‘lang’ and ‘domain’..?)
Thanks for the pointers!
Matt
PS:
Forum: Plugins
In reply to: [Polylang] Using get_terms() in admin interface from a plugin?Thanks for getting back to me so quickly.
My custom taxonomies are all ticked under the “Custom taxonomies” setting of the Polylang settings page — is that all it should need?
And yes, sorry, it’s the name I’m using. (I just tend to think of it as a slug because it looks like one — I’m definitely passing the same value that I passed as the first parameter to register_taxonomy when I set it up.)
Forum: Plugins
In reply to: [Polylang] Feature: Adding Taxonomy Terms ProgrammaticallyThanks! It’s become a lot clearer now I’ve experimented with how terms are translated in polylang.
Forum: Plugins
In reply to: [Polylang] Feature: Adding Taxonomy Terms ProgrammaticallyHi,
Thanks for your answer.
I’m trying to do exactly the same thing, but not having much success, possibly because I’m not understanding what I should put in the last parameter to save_translations, which you say is an array with language slugs and term ids?
Is there any chance you could give a simple example, say of adding a single term and its translation?
Thanks,
Matt