rankmath / seo-by-rank-math

Rank Math is a revolutionary WordPress SEO Plugin that combines the features of many SEO tools and lets you multiply your traffic in the easiest way possible :bulb: :chart_with_upwards_trend: →
https://rankmath.com
107 stars 52 forks source link

Hidden WPML languages shown in sitemaps #78

Closed radex02 closed 3 years ago

radex02 commented 3 years ago

Describe the bug Posts of an hidden language are shown in the sitemap

To Reproduce Steps to reproduce the behavior:

  1. Install WPML
  2. Hide a language
  3. Create a post with that language
  4. See sitemap

Expected behavior Hidden languages shouldn't be shown in sitemaps

Additional context Weirdly enough, translated terms seem to already be hidden. I currently use this snippet to go around this issue

add_filter( 'rank_math/sitemap/entry', function( $url, $type, $object ){
    if ($type !== 'post') return $url;
    $post_lang = apply_filters( 'wpml_post_language_details', NULL, $object->ID )['language_code'];
    $hidden_langs = apply_filters( 'wpml_setting', array(), 'hidden_languages' );
    if (in_array( $post_lang, $hidden_langs, true ) || $post_lang == '') return false;
    return $url;
}, 10, 3 );
surajv commented 3 years ago

Fixed in v1.0.67