| @@ -2,26 +2,28 @@ | ||
| 2 | 2 | /* |
| 3 | 3 | Plugin Name: Accessibility Widget |
| 4 | 4 | Plugin URI: http://webgrrrl.net/archives/accessibility-widget-revived.htm |
| 5 | 5 | Description: Adds a sidebar widget to enlarge text size in your WP site. Originally created by Tane of Digital Spaghetti (http://www.tripcastradio.com/) and revived by Lorna of WebGrrrl.net. |
| 6 | -Author: Lorna Timbah | |
| 7 | -Version: 1.2 | |
| 6 | +Author: Lorna Timbah (webgrrrl) | |
| 7 | +Version: 2 | |
| 8 | 8 | Author URI: http://webgrrrl.net |
| 9 | +Text Domain: accessibility-widget | |
| 9 | 10 | */ |
| 10 | 11 | class widget_accesstxt extends WP_Widget { |
| 11 | 12 | /** constructor */ |
| 12 | 13 | function widget_accesstxt() { |
| 13 | - parent::WP_Widget(false, $name = 'Accessibility Widget'); | |
| 14 | + parent::WP_Widget(false, $name = 'Accessibility Widget'); | |
| 14 | 15 | } |
| 15 | 16 | /** @see WP_Widget::widget */ |
| 16 | 17 | function widget($args, $instance) { |
| 17 | 18 | extract( $args ); |
| 18 | 19 | $title = apply_filters('widget_title', $instance['title']); |
| 19 | - $tags = str_replace(" ", "", $instance['tags']); // remove whitespaces | |
| 20 | + $tags = str_replace(" ", "", $instance['tags']); // remove whitespaces | |
| 20 | 21 | $fontsize = str_replace(" ", "", $instance['fontsize']); // remove whitespaces |
| 21 | 22 | $afontsize = explode(",", $fontsize); // transform into arrays |
| 22 | 23 | $controls = explode(",", str_replace(" ", "", $instance['controls'])); // remove whitespaces then transform into arrays |
| 23 | - | |
| 24 | + $tips = explode(",", $instance['tips']); // transform into arrays | |
| 25 | + | |
| 24 | 26 | echo $before_widget; |
| 25 | 27 | if ( $title ) echo $before_title . $title . $after_title; |
| 26 | 28 | ?> |
| 27 | 29 | <script type="text/javascript"> |
| @@ -46,10 +48,12 @@ | ||
| 46 | 48 | } |
| 47 | 49 | </script> |
| 48 | 50 | <ul> |
| 49 | 51 | <li><?php |
| 52 | + $controlscount = count($controls); | |
| 50 | 53 | foreach ($afontsize as $key => $value) { |
| 51 | - echo "<a href=\"javascript:ts('body'," . $key . ")\" style=\"font-size:" . $value . "\">" . $controls[$key] . "</a> "; | |
| 54 | + $icontrols = ($controlscount > 1 ? $key : 0); | |
| 55 | + echo "<a href=\"javascript:ts('body'," . $key . ")\" style=\"font-size:" . $value . "\" title=\"" . $tips[$icontrols] . "\">" . $controls[$icontrols] . "</a> "; | |
| 52 | 56 | } |
| 53 | 57 | ?></li> |
| 54 | 58 | </ul> |
| 55 | 59 | <?php echo $after_widget; ?> |
| @@ -55,22 +59,25 @@ | ||
| 55 | 59 | <?php echo $after_widget; ?> |
| 56 | 60 | <?php |
| 57 | 61 | } |
| 58 | 62 | /** @see WP_Widget::update -- do not rename this */ |
| 59 | - function update($new_instance, $old_instance) { | |
| 63 | + function update($new_instance, $old_instance) { | |
| 60 | 64 | $instance = $old_instance; |
| 61 | 65 | $instance['title'] = strip_tags($new_instance['title']); |
| 62 | 66 | $instance['tags'] = strip_tags($new_instance['tags']); |
| 63 | - $instance['fontsize'] = strip_tags($new_instance['fontsize']); | |
| 67 | + $instance['fontsize'] = strip_tags($new_instance['fontsize']); | |
| 64 | 68 | $instance['controls'] = strip_tags($new_instance['controls']); |
| 69 | + $instance['tips'] = strip_tags($new_instance['tips']); | |
| 65 | 70 | return $instance; |
| 66 | 71 | } |
| 67 | 72 | /** @see WP_Widget::form -- do not rename this */ |
| 68 | 73 | function form($instance) { |
| 74 | + $str_default = "90%, 100%, 110%, 120%"; | |
| 69 | 75 | $title = esc_attr($instance['title']); |
| 70 | 76 | $tags = ($instance['tags'] == "" ? "body,p,li,td" : esc_attr($instance['tags'])); |
| 71 | - $fontsize = ($instance['fontsize'] == "" ? "90%, 100%, 110%, 120%" : esc_attr($instance['fontsize'])); | |
| 72 | - $controls = ($instance['controls'] == "" ? "T" : esc_attr($instance['controls'])); | |
| 77 | + $fontsize = ($instance['fontsize'] == "" ? $str_default : esc_attr($instance['fontsize'])); | |
| 78 | + $controls = ($instance['controls'] == "" ? $str_default : esc_attr($instance['controls'])); | |
| 79 | + $tips = ($instance['tips'] == "" ? $str_default : esc_attr($instance['tips'])); | |
| 73 | 80 | ?> |
| 74 | 81 | <p> |
| 75 | 82 | <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label> |
| 76 | 83 | <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" /> |
| @@ -89,9 +96,13 @@ | ||
| 89 | 96 | <label for="<?php echo $this->get_field_id('controls'); ?>"><?php _e('Set controller text:'); ?></label> |
| 90 | 97 | <input class="widefat" id="<?php echo $this->get_field_id('controls'); ?>" name="<?php echo $this->get_field_name('controls'); ?>" type="text" value="<?php echo $controls; ?>" /><br /> |
| 91 | 98 | Separate each controller text with a comma (,) |
| 92 | 99 | </p> |
| 100 | + <p> | |
| 101 | + <label for="<?php echo $this->get_field_id('tips'); ?>"><?php _e('Set tooltip text on mouse hover:'); ?></label> | |
| 102 | + <input class="widefat" id="<?php echo $this->get_field_id('tips'); ?>" name="<?php echo $this->get_field_name('tips'); ?>" type="text" value="<?php echo $tips; ?>" /><br /> | |
| 103 | + Separate each tooltip with a comma (,) | |
| 104 | + </p> | |
| 93 | 105 | <?php |
| 94 | 106 | } |
| 95 | 107 | } // end class widget_accesstxt |
| 96 | 108 | add_action('widgets_init', create_function('', 'return register_widget("widget_accesstxt");')); |
| 97 | -?> | |