/*
Plugin Name: Multilingue
Plugin URI: http://www.deeweb.fr/plugin-wordpress-multilingue/
Description: Le plugin vous donne accès à un widget qui permet aux visiteurs de traduire la page courante en un seul clic. Détection automatique de la langue d'origine du site. Traduction par Google Traduction.
Version: 0.4
Author: Bastien Canas
Author URI: http://www.deeweb.fr/
*/
class myWidget {
function myWidget() {
add_action('widgets_init', array(& $this, 'init_widget'));
}
function init_widget() {
if ( !function_exists('register_sidebar_widget') || !function_exists('register_widget_control') )
return;
register_sidebar_widget(array('Multilingue','widgets'),array(& $this, 'widget'));
register_widget_control(array('Multilingue', 'widgets'), array(& $this, 'widget_options'));
}
function widget($args) {
global $wpdb;
$WidgetTitle=get_option('mywidget_options');
extract($args);
echo $before_widget.$before_title.$WidgetTitle.$after_title;
$Langue = explode(',',$_SERVER['HTTP_ACCEPT_LANGUAGE']);
$Langue = strtolower(substr(chop($Langue[0]),0,2));
?>
echo $after_widget;
}
function widget_options() {
if ($_POST['mywidget_options']) {
$option=$_POST['mywidget_options'];
update_option('mywidget_options',$option);
}
$option=get_option('mywidget_options');
echo '';
}
}
$myWidgetVariable= new myWidget ();
?>