maximeschoeni / sublanguage

Multilanguage plugin for wordpress
42 stars 13 forks source link

Custom language var #15

Open luileito opened 7 years ago

luileito commented 7 years ago

This PR makes the language_query_var property name configurable. This way e.g. if my blog is already using lng=fr to translate contents, now I can indicate Sublanguage to use the lng as well (instead of the default language name).

See https://wordpress.org/support/topic/customize-query-var-name/

maximeschoeni commented 7 years ago

Hello, I think most users won't need to change this and adding an option for this make things look more complex... What about solving this issue by a simple hook, like this:

add_action('sublanguage_admin_init', function($sublanguage) {
  $sublanguage->language_query_var = 'lng'; // or whatever
});

... And by adding this hook in the admin.php file in init():

do_action('sublanguage_admin_init', $this);

Anyway, I think I hard-coded the language query vars in some places, so even if we make changes it won't work correctly, I need to check the code...

luileito commented 7 years ago

Hey, thanks for looking into this. I didn't know of the hook-based approach, maybe it's worth trying though with this PR the plugin is now behaving exactly as I wanted to.