Wpml support #2

Closed
wants to merge 2 commits into
from

Projects

None yet

2 participants

@hermes3por3

This has changes in includes/core.php and includes/sitemaps.php with WPML support.

hermes3por3 added some commits Apr 7, 2016
@hermes3por3 hermes3por3 Include WPML language specific sitemaps
Includes WPML language specific sitemaps if global $sitepress variable and function icl_get_languages() are defined. Language specific sitemaps are only generated from the default language. Otherwise W3 Total Cache (and maybe other plugins or web services) enter an infinite loop.
1c24126
@hermes3por3 hermes3por3 Add WPML support
Added WPML wherever there was already polylang.
8d2d642
@hermes3por3 hermes3por3 closed this Apr 7, 2016
@hermes3por3 hermes3por3 reopened this Apr 7, 2016
@hermes3por3

I am not familiar with the system. Should I leave it open or closed?

@RavanH
Owner
RavanH commented Apr 7, 2016

Hi Hermes, just leave it open. Thanks for your contribution! I'll review the code and if all is well, it should make it into the next release :)

If I've any questions (about WPML for example) I'll post them here, OK?

@RavanH
Owner
RavanH commented Apr 7, 2016

Can you share a link to a sitemap where WPML is active?

@hermes3por3

Thanks. You can see the plugin in action in an WPML site: http://www.slowbarcelona.es You can see sitemap in http://www.slowbarcelona.es/sitemap.xml. Default language is Spanish, the other is English. Right now it is using the branch WPMLcompat.
Sure, post any questions here!

Should future upgrades of WPML require additional changes, I would notify you as well.

@RavanH
Owner
RavanH commented Apr 10, 2016

Great!

I have two questions:

  1. Does WPML have an option to not include the language in the URL? I mean, could it have the english contact page http://www.slowbarcelona.es/en/home/contactus/ live on http://www.slowbarcelona.es/home/contactus/ for example? And if so, how would that scenario reflect on the sitemaps?
  2. Could you switch on the Google News Sitemaps option so I can take a look at the news sitemap?
@RavanH
Owner
RavanH commented Apr 11, 2016

Interesting case of WPML and empty sitemap reported here https://wordpress.org/support/topic/xml-sitemap-and-wpml-1 ... One language has no posts but the sitemap plugin cannot detect that in advance so it includes a post sitemap in the index. No idea how to address that. Is there any function in WPML that allows to detect the number of posts per language?

@hermes3por3

Hi, I have upgraded you plugin to the latest version and introduced the same changes for WPML that are present in your branch WPML_compat. I activated the google news feed and now they can be reached at http://www.slowbarcelona.es/sitemap-news.xml and http://www.slowbarcelona.es/en/sitemap-news.xml without problems.

I do not know how to merge within github the commits you made in your master branch since I forked your plugin. Should I open a new pull request reintroducing the changes in WPML_compat branch, or is there a way to do it within github?

@hermes3por3

Regarding the topic https://wordpress.org/support/topic/xml-sitemap-and-wpml-1 you can definitely check for posts (actually of each activated post_type) in any given language in WPML. Does your code check for the presence posts of a specific post_type before creating the sitemap for that specific post type?

@RavanH
Owner
RavanH commented Apr 20, 2016

Hi Hermes, no we can leave this pull request open for now. I'm currently trying to figure out a slightly different approach to see which one fits best with the current plugin setup. But whichever I decide, basic WPML support will come :)

Regarding the topic https://wordpress.org/support/topic/xml-sitemap-and-wpml-1 you can definitely
check for posts (actually of each activated post_type) in any given language in WPML.

Is there a specific WPML function for that? If so, is there any public documentation?

Does your code check for the presence posts of a specific post_type before creating the sitemap for > that specific post type?

Yes it does, but not "per language" only "per post type" or "per taxonomy term" as a whole because a sitemap is normally language neutral. This means that (for that example) if there are posts but they all are in one language, the check will tell my plugin that there are posts while on the front end, when WPML has filtered out all posts in a language that the visitor has not chosen, there can be none.

I suppose WPML filters posts on the front-end based on either the visitors browser language, URL (containing language information) or active choice from the language menu. This is similar to how Polylang does it, but the difference is that currently WPML also filters posts from the sitemap. The result is that the main posts sitemap will only contain posts from the default language. This makes it necessary to add secondary language sitemaps like /en/sitemap.xml for example.

@hermes3por3

Hi there was a problem with the new version (4.7.1) and WPML. While you were getting the posts in all languages using that remove_filter trick, the calls to get_permalink in your templates were outputting links in one language only (which means translated post urls were being displayed multiple times with the same url). I have resolved this and also another problem with taxonomies feeds, all minimal changes.

You can see it working well at http://www.slowbarcelona.es/sitemap.xml (taxonomies are not activated on my production server)

How can I fork your master branch again from github? Or how can I apply all your commits to my fork? I am not so familiar with github.

@RavanH
Owner
RavanH commented May 23, 2016

the calls to get_permalink in your templates were outputting links in one language only (which means translated post urls were being displayed multiple times with the same url). I have resolved this and also another problem with taxonomies feeds, all minimal changes.

That's great! Did you apply these changes to your WMPL-compat-2 branch? Can you create a merge request from that branch to my master branch?

@hermes3por3
hermes3por3 commented May 24, 2016 edited

That's great! Did you apply these changes to your WMPL-compat-2 branch?

Yes, I managed to commit all your updates to release 4.7.1 and then applied the changes I mentioned. I have created a pull request to your master branch. If I am not mistaken.

@RavanH RavanH closed this Jul 5, 2016
@hermes3por3

Hi, I will review your updates in my site shortly and will let you know!

@RavanH
Owner
RavanH commented Jul 12, 2016

Make sure you use the latest version 4.7.3 and let me know if you find any issues :)

@hermes3por3

Hi, almost there! Now it lists correctly all the slugs in their language specific variations, but it does not prepend the language in the url. For example, if a url not in the default language would be http://www.slowbarcelona.es/en/cocktail/atari/ it is listed as http://www.slowbarcelona.es/cocktail/atari/ instead. If you check http://www.slowbarcelona.es/sitemap.xml you will not find this problem because I am using an older and edited version of the plugin. The error I mentioned happens in my local installation with the latest plugin version (4.7.3). I haven't had time to go through the code to see where the problem is, though I would start in the filter_request method.

@RavanH
Owner
RavanH commented Jul 12, 2016

Hmmm... still something.

WPML is a nightmare (as I suspected) because every time I fix one thing another thing comes up or back. Another user reported that with version .3 the URLs where finally working correctly (with subdomains, I think it was) but apparently still not with subdirectories...

Thanks for the feedback!

@RavanH
Owner
RavanH commented Jul 12, 2016

@hermes3por3 there is a new version (.4) ready in master https://github.com/RavanH/xml-sitemap-feed could you dowload the zip and test it please? :)

@hermes3por3

Yeah, it works!

@RavanH
Owner
RavanH commented Jul 13, 2016

Will be releasing the upgrade then :) thanks again for the feedback !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment