PluginProbe
AccessiYes Accessibility Widget for ADA, EAA & WCAG Readiness / 1.2
AccessiYes Accessibility Widget for ADA, EAA & WCAG Readiness v1.2
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
accessibility-widget / accessibilitywidget.php

accessibilitywidget.php in AccessiYes Accessibility Widget for ADA, EAA & WCAG Readiness 1.2, at accessibilitywidget.php

97 lines 4.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 Plugin Name: Accessibility Widget
4 Plugin URI: http://webgrrrl.net/archives/accessibility-widget-revived.htm
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
8 Author URI: http://webgrrrl.net
9 */
10 class widget_accesstxt extends WP_Widget {
11 /** constructor */
12 function widget_accesstxt() {
13 parent::WP_Widget(false, $name = 'Accessibility Widget');
14 }
15 /** @see WP_Widget::widget */
16 function widget($args, $instance) {
17 extract( $args );
18 $title = apply_filters('widget_title', $instance['title']);
19 $tags = str_replace(" ", "", $instance['tags']); // remove whitespaces
20 $fontsize = str_replace(" ", "", $instance['fontsize']); // remove whitespaces
21 $afontsize = explode(",", $fontsize); // transform into arrays
22 $controls = explode(",", str_replace(" ", "", $instance['controls'])); // remove whitespaces then transform into arrays
23
24 echo $before_widget;
25 if ( $title ) echo $before_title . $title . $after_title;
26 ?>
27 <script type="text/javascript">
28 //Specify affected tags. Add or remove from list
29 var tgs = new Array(<?php echo "'" . str_replace(",", "','", $tags) . "'"; ?>);
30 //Specify spectrum of different font sizes
31 var szs = new Array(<?php echo "'" . str_replace(",", "','", $fontsize) . "'"; ?>);
32 var startSz = 2;
33 function ts( trgt,inc ) {
34 if (!document.getElementById) return
35 var d = document,cEl = null,sz = startSz,i,j,cTags;
36 sz = inc;
37 if ( sz < 0 ) sz = 0;
38 if ( sz > 6 ) sz = 6;
39 startSz = sz;
40 if ( !( cEl = d.getElementById( trgt ) ) ) cEl = d.getElementsByTagName( trgt )[ 0 ];
41 cEl.style.fontSize = szs[ sz ];
42 for ( i = 0 ; i < tgs.length ; i++ ) {
43 cTags = cEl.getElementsByTagName( tgs[ i ] );
44 for ( j = 0 ; j < cTags.length ; j++ ) cTags[ j ].style.fontSize = szs[ sz ];
45 }
46 }
47 </script>
48 <ul>
49 <li><?php
50 foreach ($afontsize as $key => $value) {
51 echo "<a href=\"javascript:ts('body'," . $key . ")\" style=\"font-size:" . $value . "\">" . $controls[$key] . "</a>&nbsp;&nbsp;";
52 }
53 ?></li>
54 </ul>
55 <?php echo $after_widget; ?>
56 <?php
57 }
58 /** @see WP_Widget::update -- do not rename this */
59 function update($new_instance, $old_instance) {
60 $instance = $old_instance;
61 $instance['title'] = strip_tags($new_instance['title']);
62 $instance['tags'] = strip_tags($new_instance['tags']);
63 $instance['fontsize'] = strip_tags($new_instance['fontsize']);
64 $instance['controls'] = strip_tags($new_instance['controls']);
65 return $instance;
66 }
67 /** @see WP_Widget::form -- do not rename this */
68 function form($instance) {
69 $title = esc_attr($instance['title']);
70 $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']));
73 ?>
74 <p>
75 <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
76 <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; ?>" />
77 </p>
78 <p>
79 <label for="<?php echo $this->get_field_id('tags'); ?>"><?php _e('Resize the following HTML/CSS tags:'); ?></label>
80 <input class="widefat" id="<?php echo $this->get_field_id('tags'); ?>" name="<?php echo $this->get_field_name('tags'); ?>" type="text" value="<?php echo $tags; ?>" /><br />
81 Separate each tag with a comma (,)
82 </p>
83 <p>
84 <label for="<?php echo $this->get_field_id('fontsize'); ?>"><?php _e('Set to these sizes:'); ?></label>
85 <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 />
86 Separate each size with a comma (,)
87 </p>
88 <p>
89 <label for="<?php echo $this->get_field_id('controls'); ?>"><?php _e('Set controller text:'); ?></label>
90 <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 Separate each controller text with a comma (,)
92 </p>
93 <?php
94 }
95 } // end class widget_accesstxt
96 add_action('widgets_init', create_function('', 'return register_widget("widget_accesstxt");'));
97 ?>