cabrerahector / wordpress-popular-posts

WordPress Popular Posts - A highly customizable WordPress widget that displays your most popular posts.
https://wordpress.org/plugins/wordpress-popular-posts/
GNU General Public License v2.0
279 stars 83 forks source link

/wp-json/wordpress-popular-posts/v1/popular-posts/ endpoint doesn't translate posts #284

Closed cabrerahector closed 3 years ago

cabrerahector commented 3 years ago

Describe the bug

Unlike the /widget endpoint, /popular-posts doesn't detect the presence of WPML/Polylang and returns posts in the original language instead.

To Reproduce

Steps to reproduce the behavior:

  1. Install either WPML or Polylang and translate some posts.
  2. Load the /wp-json/wordpress-popular-posts/v1/popular-posts/ endpoint (either via AJAX or using a browser tab) and use the lang parameter to set the current locale (eg. ?lang=es).
  3. The endpoint ignores the parameter returning posts in their original language (eg. English) instead.

Expected behavior

Like the /widget endpoint, /popular-posts should be able to detect the current locale and act accordingly.

Environment: