PluginProbe
AccessiYes Accessibility Widget for ADA, EAA & WCAG Readiness / 1.1
AccessiYes Accessibility Widget for ADA, EAA & WCAG Readiness v1.1
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.1, at accessibilitywidget.php

90 lines 3.9 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.1
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']);
20 $fontsize = str_replace(" ", "", $instance['fontsize']);
21 $afontsize = explode(",", $fontsize);
22 ?>
23 <?php echo $before_widget; ?>
24 <?php if ( $title ) echo $before_title . $title . $after_title;
25 ?>
26 <script type="text/javascript">
27 //Specify affected tags. Add or remove from list
28 var tgs = new Array(<?php echo "'" . str_replace(",", "','", $tags) . "'"; ?>);
29 //Specify spectrum of different font sizes
30 var szs = new Array(<?php echo "'" . str_replace(",", "','", $fontsize) . "'"; ?>);
31 var startSz = 2;
32 function ts( trgt,inc ) {
33 if (!document.getElementById) return
34 var d = document,cEl = null,sz = startSz,i,j,cTags;
35 sz = inc;
36 if ( sz < 0 ) sz = 0;
37 if ( sz > 6 ) sz = 6;
38 startSz = sz;
39 if ( !( cEl = d.getElementById( trgt ) ) ) cEl = d.getElementsByTagName( trgt )[ 0 ];
40
41 cEl.style.fontSize = szs[ sz ];
42
43 for ( i = 0 ; i < tgs.length ; i++ ) {
44 cTags = cEl.getElementsByTagName( tgs[ i ] );
45 for ( j = 0 ; j < cTags.length ; j++ ) cTags[ j ].style.fontSize = szs[ sz ];
46 }
47 }
48 </script>
49 <ul>
50 <li><?php
51 foreach ($afontsize as $key => $value) { echo "<a href=\"javascript:ts('body'," . $key . ")\" style=\"font-size:" . $value . "\">A</a>&nbsp;&nbsp;"; }
52 ?></li>
53 </ul>
54 <?php echo $after_widget; ?>
55 <?php
56 }
57 /** @see WP_Widget::update -- do not rename this */
58 function update($new_instance, $old_instance) {
59 $instance = $old_instance;
60 $instance['title'] = strip_tags($new_instance['title']);
61 $instance['tags'] = strip_tags($new_instance['tags']);
62 $instance['fontsize'] = strip_tags($new_instance['fontsize']);
63 return $instance;
64 }
65 /** @see WP_Widget::form -- do not rename this */
66 function form($instance) {
67 $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']));
70 ?>
71 <p>
72 <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
73 <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; ?>" />
74 </p>
75 <p>
76 <label for="<?php echo $this->get_field_id('tags'); ?>"><?php _e('Resize the following HTML/CSS tags:'); ?></label>
77 <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 />
78 Separate each tag with a comma (,)
79 </p>
80 <p>
81 <label for="<?php echo $this->get_field_id('fontsize'); ?>"><?php _e('Set to these sizes:'); ?></label>
82 <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 Separate each size with a comma (,)
84 <?php echo count($fontsize); ?>
85 </p>
86 <?php
87 }
88 } // end class example_widget
89 add_action('widgets_init', create_function('', 'return register_widget("widget_accesstxt");'));
90 ?>