PluginProbe
AccessiYes Accessibility Widget for ADA, EAA & WCAG Readiness / 2
AccessiYes Accessibility Widget for ADA, EAA & WCAG Readiness v2
3.2.6 3.2.5 3.2.4 3.2.3 3.2.2 3.2.1 trunk 1.0 1.1 1.1.1 1.2 1.2.1 2 2.0.1 2.1 2.2 2.2.1 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 All 33 releases
← All changes | accessibilitywidget.php +36 -18 1.12 View file →
@@ -2,28 +2,31 @@
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.1
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']);
20 - $fontsize = str_replace(" ", "", $instance['fontsize']);
21 - $afontsize = explode(",", $fontsize);
20 + $tags = str_replace(" ", "", $instance['tags']); // remove whitespaces
21 + $fontsize = str_replace(" ", "", $instance['fontsize']); // remove whitespaces
22 + $afontsize = explode(",", $fontsize); // transform into arrays
23 + $controls = explode(",", str_replace(" ", "", $instance['controls'])); // remove whitespaces then transform into arrays
24 + $tips = explode(",", $instance['tips']); // transform into arrays
25 +
26 + echo $before_widget;
27 + if ( $title ) echo $before_title . $title . $after_title;
22 28 ?>
23 - <?php echo $before_widget; ?>
24 - <?php if ( $title ) echo $before_title . $title . $after_title;
25 - ?>
26 29 <script type="text/javascript">
27 30 //Specify affected tags. Add or remove from list
28 31 var tgs = new Array(<?php echo "'" . str_replace(",", "','", $tags) . "'"; ?>);
29 32 //Specify spectrum of different font sizes
@@ -36,11 +39,9 @@
36 39 if ( sz < 0 ) sz = 0;
37 40 if ( sz > 6 ) sz = 6;
38 41 startSz = sz;
39 42 if ( !( cEl = d.getElementById( trgt ) ) ) cEl = d.getElementsByTagName( trgt )[ 0 ];
40 -
41 43 cEl.style.fontSize = szs[ sz ];
42 -
43 44 for ( i = 0 ; i < tgs.length ; i++ ) {
44 45 cTags = cEl.getElementsByTagName( tgs[ i ] );
45 46 for ( j = 0 ; j < cTags.length ; j++ ) cTags[ j ].style.fontSize = szs[ sz ];
46 47 }
@@ -47,9 +48,13 @@
47 48 }
48 49 </script>
49 50 <ul>
50 51 <li><?php
51 - foreach ($afontsize as $key => $value) { echo "<a href=\"javascript:ts('body'," . $key . ")\" style=\"font-size:" . $value . "\">A</a>&nbsp;&nbsp;"; }
52 + $controlscount = count($controls);
53 + foreach ($afontsize as $key => $value) {
54 + $icontrols = ($controlscount > 1 ? $key : 0);
55 + echo "<a href=\"javascript:ts('body'," . $key . ")\" style=\"font-size:" . $value . "\" title=\"" . $tips[$icontrols] . "\">" . $controls[$icontrols] . "</a>&nbsp;&nbsp;";
56 + }
52 57 ?></li>
53 58 </ul>
54 59 <?php echo $after_widget; ?>
55 60 <?php
@@ -54,20 +59,25 @@
54 59 <?php echo $after_widget; ?>
55 60 <?php
56 61 }
57 62 /** @see WP_Widget::update -- do not rename this */
58 - function update($new_instance, $old_instance) {
63 + function update($new_instance, $old_instance) {
59 64 $instance = $old_instance;
60 65 $instance['title'] = strip_tags($new_instance['title']);
61 66 $instance['tags'] = strip_tags($new_instance['tags']);
62 67 $instance['fontsize'] = strip_tags($new_instance['fontsize']);
68 + $instance['controls'] = strip_tags($new_instance['controls']);
69 + $instance['tips'] = strip_tags($new_instance['tips']);
63 70 return $instance;
64 71 }
65 72 /** @see WP_Widget::form -- do not rename this */
66 73 function form($instance) {
74 + $str_default = "90%, 100%, 110%, 120%";
67 75 $title = esc_attr($instance['title']);
68 - $tags = ($instance['tags'] == "" ? "body" : esc_attr($instance['tags']));
69 - $fontsize = ($instance['fontsize'] == "" ? "90%, 100%, 110%, 120%" : esc_attr($instance['fontsize']));
76 + $tags = ($instance['tags'] == "" ? "body,p,li,td" : esc_attr($instance['tags']));
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']));
70 80 ?>
71 81 <p>
72 82 <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
73 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; ?>" />
@@ -80,11 +90,19 @@
80 90 <p>
81 91 <label for="<?php echo $this->get_field_id('fontsize'); ?>"><?php _e('Set to these sizes:'); ?></label>
82 92 <input class="widefat" id="<?php echo $this->get_field_id('fontsize'); ?>" name="<?php echo $this->get_field_name('fontsize'); ?>" type="text" value="<?php echo $fontsize; ?>" /><br />
83 93 Separate each size with a comma (,)
84 -<?php echo count($fontsize); ?>
85 94 </p>
95 + <p>
96 + <label for="<?php echo $this->get_field_id('controls'); ?>"><?php _e('Set controller text:'); ?></label>
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 />
98 + Separate each controller text with a comma (,)
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>
86 105 <?php
87 106 }
88 -} // end class example_widget
107 +} // end class widget_accesstxt
89 108 add_action('widgets_init', create_function('', 'return register_widget("widget_accesstxt");'));
90 -?>