maximeschoeni / sublanguage

Multilanguage plugin for wordpress
42 stars 13 forks source link

Updating the slug of a tag/category behaves erratically. #8

Open filipecatraia opened 7 years ago

filipecatraia commented 7 years ago

Hey! The plugin was working great for me until this bit:

When I try to translate the slug of a tag or category, most times the translation doesn't work as expected. Example: I have the tag breakfast, and translate it to another language (i.e. pt_PT) as pequenoalmoco. After clicking save, the slug is now pequenoalmoco-breakfast instead of just pequenoalmoco.

Slugs in posts work fine, but in tags and categories this problem occurs almost all the time.

BTW, it's a new Wordpress install with no other plugins except WP Markdown Editor (turned off). Speaking of WPME, I think Sublanguage causes a bug in WPME.

Thanks a bunch :)

maximeschoeni commented 7 years ago

Hello, thank you for reporting this issue. I'll have a look.

filipecatraia commented 7 years ago

Let me know how if there's a way for me help.

maximeschoeni commented 7 years ago

Can you tell me which version of WP you have and also the "db_version" (for this, go to yoursite.com/wp-admin/options.php and find value of "db_version")?

maximeschoeni commented 7 years ago

About the issue with markdown editor plugin, I added a filter to deal with it. Now we can write a fix for this problem:

add_filter('sublanguage_insert_post_data', function($data, $sublanguage) {
  if ($sublanguage->is_sub()) {
    if (!empty($data["post_content_filtered"])) {
      $data["post_content"] = $data["post_content_filtered"];
    }
    foreach ($sublanguage->sublanguage_data as $lng_id => $sub_data) {
      $sublanguage->sublanguage_data[$lng_id]["post_content_filtered"] = $sub_data["post_content"];
    }
  }
  return $data;
}, 10, 2);

Please add this into your function.php file and tell me if it solve the problem. Of course you need to have sublanguage 1.5.4 for this to work.