Hello Uggur,
Thank you for this review. I’ll try to reply point by point.
1. This is a great idea. I am going to implement this in the next release.
2. Unfortunately for now the admin interface wp-admin/options-general.php
don’t allow to plug in to add custom fields, and I don’t want to hack into with jQuery injection, because it is buggy and hard to maintain. So this is the solution I’d recommend:
First add this into your function.php
:
if (!is_admin()) {
add_filter('option_blogdescription', 'my_translate_option_field');
add_filter('option_blogname', 'my_translate_option_field');
}
function my_translate_option_field($value) {
return apply_filters('sublanguage_custom_translate', $value, 'my_custom_language_parser');
}
function my_custom_language_parser($original, $language) {
if (preg_match('/\[:'.$language->post_name.'\]([^[]*)/', $original, $matches)) {
return $matches[1];
}
return $original;
}
And in the wordpress general settings page (wp-admin/options-general.php
), into “Site Title” and “description” field, write something like this: [:en]My Wonderfull Site[:fr]Mon super site[:es]Mi súper Sitio
.
Now for the yoast SEO plugin, here is a walkthrough to make it translatable, based on the same idea:
Add this into function.php
:
if (!is_admin()) {
add_filter('option_wpseo', 'my_wpseo_option');
add_filter('option_wpseo_titles', 'my_wpseo_option');
add_filter('option_wpseo_social', 'my_wpseo_option');
}
function my_wpseo_option($value) {
foreach ($value as $key => $val) {
$value[$key] = apply_filters('sublanguage_custom_translate', $val, 'my_custom_language_parser');
}
return $value;
}
function my_custom_language_parser($original, $language) {
if (preg_match('/\[:'.$language->post_name.'\]([^[]*)/', $original, $matches)) {
return $matches[1];
}
return $original;
}
And use the same way as before to translate fields. For example: Meta description template: [:en]English text[:fr]Texte fran?ais[:es]texto espa?ol
3. Can you precise this question, I am not sure to understand this point…
4. Sorry, I’m not going to add country flags into plugin. It’s too much work to update and actually it’s easy enough to do this through CSS.