Improving polylang compatibility with other plugins
-
Hello,
I am trying to get Polylang to work with CPT-onomies and in the process I have stumbled upon something that I need some help/clarification with.
Some introductory info follows:
——————————————-//start context info
My wordpress setup is as follows:I have polylang installed to display 2 different languages.
I have 2 custom post types , say Brands and Products.
Both are set as translateable and I have the polylang translations working fine.
Now, for reasons that are not important to the problem, I need to also use the Brand custom post type as a taxonomy that can be assigned to a Product (yes, there are other ways of doing this semantic connection but as I said , it needs to be done like that for other reasons).
To this end, I have installed CPT-Onomies which allows you to do exactly that (register a custom post type as a taxonomy).
Obviously that plugin is unaware of the the existence of Polylang so when I’m editing a product it displays the UN-filtered list of taxonomy terms (in this case custom posts of the Brand type).
When that plugin obtains the list of terms to display I could use a conditional like :
if (pll_is_translated_taxonomy($taxonomy)) {to add the ‘lang’ argument to obtain a filtered list.
However that obviously would break that plugin in any other wordpress install without polylang.
Digging a little deeper I found out that the parse_query filter of Polylang is called at that point but the query vars of that get_posts call remain unchanged (without a ‘lang’ argument being added)
———————————– //end context infoSo the question is this.
If a get_posts call is made requesting posts of a custom type that IS declared as traslateable in Polylang but the query_vars do NOT have a ‘lang’ arg set (because the calling plugin is unaware of this), shouldn’t the parse_query filter add this argument? Wouldn’t that improve general compatibility? Obviously that would need a different way of obtaining all the translations of a certain post type etc. (for example when displaying the list of posts in the admin) but surely there is a better way of bypassing translation filtering.
Any thoughts?
The topic ‘Improving polylang compatibility with other plugins’ is closed to new replies.