PluginProbe ʕ •ᴥ•ʔ
Translate WordPress – Google Language Translator / 4.0.1
Translate WordPress – Google Language Translator v4.0.1
trunk 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 4.0 4.0.1 4.0.2 4.0.3 4.0.4 4.0.5 4.0.7 4.0.8 4.0.9 5.0 5.0.0 5.0.01 5.0.02 5.0.03 5.0.04 5.0.05 5.0.06 5.0.07 5.0.08 5.0.09 5.0.10 5.0.11 5.0.12 5.0.13 5.0.14 5.0.15 5.0.16 5.0.17 5.0.18 5.0.19 5.0.20 5.0.21 5.0.22 5.0.23 5.0.24 5.0.25 5.0.26 5.0.27 5.0.28 5.0.29 5.0.30 5.0.31 5.0.32 5.0.33 5.0.34 5.0.35 5.0.36 5.0.37 5.0.38 5.0.39 5.0.40 5.0.41 5.0.42 5.0.43 5.0.44 5.0.45 5.0.46 5.0.47 5.0.48 5.0.49 6.0.0 6.0.1 6.0.10 6.0.11 6.0.12 6.0.13 6.0.14 6.0.15 6.0.16 6.0.19 6.0.2 6.0.20 6.0.3 6.0.4 6.0.5 6.0.6 6.0.7 6.0.8 6.0.9
google-language-translator / widget.php
google-language-translator Last commit date
css 11 years ago images 11 years ago js 11 years ago google-language-translator.php 11 years ago readme.txt 11 years ago widget.php 11 years ago
widget.php
51 lines
1 <?php
2
3 class glt_widget extends WP_Widget {
4
5 function __construct() {
6 parent::__construct(
7 'glt_widget', // Base ID
8 __('Google Language Translator', 'text_domain'), // Name
9 array( 'description' => __( 'Add the Google Language Translator website tool.', 'text_domain' ), )
10 );
11 }
12
13 public function widget( $args, $instance ) {
14 $title = apply_filters( 'widget_title', $instance['title'] );
15 echo $args['before_widget'];
16 if ( ! empty( $title ) )
17 echo $args['before_title'] . $title . $args['after_title'];
18 $google_language_translator_class = new google_language_translator();
19 $glt_shortcode = $google_language_translator_class->google_translator_shortcode();
20 echo $glt_shortcode;
21 echo $args['after_widget'];
22 }
23
24 public function form( $instance ) {
25 if ( isset( $instance[ 'title' ] ) ) {
26 $title = $instance[ 'title' ];
27 }
28 else {
29 $title = __( 'Translate:', 'text_domain' );
30 }
31 ?>
32 <p>
33 <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label>
34 <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 ); ?>">
35 </p>
36 <?php
37 }
38
39 public function update( $new_instance, $old_instance ) {
40 $instance = array();
41 $instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : '';
42
43 return $instance;
44 }
45
46 } // class glt_widget
47
48 function register_foo_widget() {
49 register_widget( 'glt_widget' );
50 }
51 add_action( 'widgets_init', 'register_foo_widget' );