<?php

class AiniaWidget extends WP_Widget
{
  function AiniaWidget()
  {
    $widget_ops = array('classname' => 'AiniaWidget', 'description' => 'Panel de usuario de iWatch' );
    $this->WP_Widget('AiniaWidget', 'Usuario iWatch', $widget_ops);
  }
 /*
  function form($instance)
  {
	return;
    $instance = wp_parse_args( (array) $instance, array( 'title' => '' ) );
    $title = $instance['title'];
	?>
	  <p><label for="<?php echo $this->get_field_id('title'); ?>">Title: <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo attribute_escape($title); ?>" /></label></p>
	<?php
  }*/
 
  function update($new_instance, $old_instance)
  {
    $instance = $old_instance;
    $instance['title'] = $new_instance['title'];
    return $instance;
  }
 
  function widget($args, $instance)
  {
    extract($args, EXTR_SKIP);
 	
	$current_user = wp_get_current_user();
	
    //$title = empty($instance['title']) ? 'Usuario' : apply_filters('widget_title', $instance['title']);
	$title = $current_user ->display_name;
 
    if (!empty($title))	 
      echo $before_title . $title . $after_title;;

	//cuerpo del widget
	echo "<ul>";
	if(current_user_can('edit_posts'))
	echo '<li><a href="'.get_admin_url().'" title="Admin Panel">'.__('Administration Board','ainia').'</a></li>';
	
	echo '<li><a href="'.wp_lostpassword_url().'" title="Logout">'.__('Change Password','ainia').'</a></li>';	
	echo '<li><a href="'.wp_logout_url().'" title="Lost Password">'.__('Disconnect','ainia').'</a></li>';	
	//echo '<li><a href="http://translate.google.com/translate?sl=es&tl=en&u='.$_SERVER["SERVER_NAME"].$_SERVER['REQUEST_URI'] . '">'.__('Translate','ainia').'</a></li>';
	echo "</ul>";
 
    if(!is_front_page())echo $after_widget;
  }
 
}

add_action( 'widgets_init', create_function('', 'return register_widget("AiniaWidget");') );

