| 1 |
<?php |
| 2 |
// no direct access! |
| 3 |
defined('ABSPATH') or die("No direct access"); |
| 4 |
|
| 5 |
class GSpeechWidget extends WP_Widget { |
| 6 |
|
| 7 |
function __construct() { |
| 8 |
|
| 9 |
parent::__construct('gspeech', esc_html__('GSpeech', 'gspeech'), array('description' => esc_html__('GSpeech - Text To Speech', 'gspeech'))); |
| 10 |
} |
| 11 |
|
| 12 |
public function widget($args, $instance) { |
| 13 |
|
| 14 |
echo $args['before_widget']; |
| 15 |
|
| 16 |
if(!empty($instance['title'])) { |
| 17 |
echo $args['before_title'] . apply_filters('widget_title', $instance['title']) . $args['after_title']; |
| 18 |
} |
| 19 |
|
| 20 |
echo GSpeech::get_widget_code(array('position' => 'inline', 'wrapper_selector' => '.gtranslate_wrapper')); |
| 21 |
|
| 22 |
echo $args['after_widget']; |
| 23 |
} |
| 24 |
|
| 25 |
public function form($instance) { |
| 26 |
|
| 27 |
$title = !empty($instance['title']) ? $instance['title'] : ''; |
| 28 |
?> |
| 29 |
<p> |
| 30 |
<label for="<?php echo esc_attr($this->get_field_id('title')); ?>"><?php esc_attr_e('Title:', 'gspeech'); ?></label> |
| 31 |
<input class="widefat" id="<?php echo esc_attr($this->get_field_id('title')); ?>" name="<?php echo esc_attr($this->get_field_name('title')); ?>" type="text" value="<?php echo esc_attr($title); ?>"> |
| 32 |
</p> |
| 33 |
<?php |
| 34 |
} |
| 35 |
|
| 36 |
public function update($new_instance, $old_instance) { |
| 37 |
|
| 38 |
$instance = array(); |
| 39 |
$instance['title'] = (!empty($new_instance['title'])) ? strip_tags($new_instance['title']) : ''; |
| 40 |
|
| 41 |
return $instance; |
| 42 |
} |
| 43 |
} |