glt_widget

The Google Language Translator glt widget class.

Defined (1)

The class is defined in the following location(s).

/widget.php  
  1. class glt_widget extends WP_Widget { 
  2. function __construct() { 
  3. parent::__construct( 
  4. 'glt_widget', __('Google Language Translator', 'text_domain'), array( 'description' => __( 'Add the Google Language Translator website tool.', 'text_domain' ), )  
  5. ); 
  6.  
  7. public function widget( $args, $instance ) { 
  8. $title = apply_filters( 'widget_title', $instance['title'] ); 
  9. echo $args['before_widget']; 
  10. if ( ! empty( $title ) ) 
  11. echo $args['before_title'] . $title . $args['after_title']; 
  12. echo do_shortcode('[google-translator]'); 
  13. echo $args['after_widget']; 
  14.  
  15. public function form( $instance ) { 
  16. if ( isset( $instance[ 'title' ] ) ) { 
  17. $title = $instance[ 'title' ]; 
  18. } else { 
  19. $title = __( 'Translate:', 'text_domain' ); 
  20. } ?> 
  21.  
  22. <p><label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label><input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>"></p> 
  23. <?php  
  24.  
  25. public function update( $new_instance, $old_instance ) { 
  26. $instance = array(); 
  27. $instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : ''; 
  28. return $instance; 
  29. } // class glt_widget