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

accessibility-widget.php in AccessiYes Accessibility Widget for ADA, EAA & WCAG Readiness 2.2, at accessibility-widget.php

112 lines 5.3 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: Enlarge text on your WP site with this widget. Revived plugin from tripcastradio.com.
6 * Author: Lorna Timbah (webgrrrl)
7 * Version: 2.2
8 * Author URI: https://webgrrrl.net
9 */
10 class widget_accesstxt extends WP_Widget {
11 /** constructor */
12 function __construct() {
13 parent::__construct(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 $tips = explode(",", $instance['tips']); // transform into arrays
24
25 echo $before_widget;
26 if ( $title ) echo $before_title . $title . $after_title;
27 ?>
28 <script type="text/javascript">
29 //Specify affected tags. Add or remove from list
30 var tgs = new Array(<?php echo "'" . str_replace(",", "','", $tags) . "'"; ?>);
31 //Specify spectrum of different font sizes
32 var szs = new Array(<?php echo "'" . str_replace(",", "','", $fontsize) . "'"; ?>);
33 var startSz = 2;
34 function ts( trgt,inc ) {
35 if (!document.getElementById) return
36 var d = document,cEl = null,sz = startSz,i,j,cTags;
37 sz = inc;
38 if ( sz < 0 ) sz = 0;
39 if ( sz > 6 ) sz = 6;
40 startSz = sz;
41 if ( !( cEl = d.getElementById( trgt ) ) ) cEl = d.getElementsByTagName( trgt )[ 0 ];
42 cEl.style.fontSize = szs[ sz ];
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 $controlscount = count($controls);
52 foreach ($afontsize as $key => $value) {
53 $icontrols = ($controlscount > 1 ? $key : 0);
54 echo "<a href=\"javascript:ts('body'," . $key . ")\" style=\"font-size:" . $value . "\" title=\"" . $tips[$icontrols] . "\">" . $controls[$icontrols] . "</a>&nbsp;&nbsp;";
55 }
56 ?></li>
57 </ul>
58 <?php echo $after_widget; ?>
59 <?php
60 }
61 /** @see WP_Widget::update -- do not rename this */
62 function update($new_instance, $old_instance) {
63 $instance = $old_instance;
64 $instance['title'] = strip_tags($new_instance['title']);
65 $instance['tags'] = strip_tags($new_instance['tags']);
66 $instance['fontsize'] = strip_tags($new_instance['fontsize']);
67 $instance['controls'] = strip_tags($new_instance['controls']);
68 $instance['tips'] = strip_tags($new_instance['tips']);
69 return $instance;
70 }
71 /** @see WP_Widget::form -- do not rename this */
72 function form($instance) {
73 $str_default = "90%, 100%, 110%, 120%";
74 $title = esc_attr($instance['title']);
75 $tags = ($instance['tags'] == "" ? "body,p,li,td" : esc_attr($instance['tags']));
76 $fontsize = ($instance['fontsize'] == "" ? $str_default : esc_attr($instance['fontsize']));
77 $controls = ($instance['controls'] == "" ? $str_default : esc_attr($instance['controls']));
78 $tips = ($instance['tips'] == "" ? $str_default : esc_attr($instance['tips']));
79 ?>
80 <p>
81 <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:', 'accessibility-widget'); ?></label>
82 <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; ?>" />
83 </p>
84 <p>
85 <label for="<?php echo $this->get_field_id('tags'); ?>"><?php _e('Resize the following HTML/CSS tags (separate with a comma (,)):', 'accessibility-widget'); ?></label>
86 <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 />
87 </p>
88 <p>
89 <label for="<?php echo $this->get_field_id('fontsize'); ?>"><?php _e('Set to these sizes (separate with a comma (,)):', 'accessibility-widget'); ?></label>
90 <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 />
91 </p>
92 <p>
93 <label for="<?php echo $this->get_field_id('controls'); ?>"><?php _e('Set controller text (separate with a comma (,)):', 'accessibility-widget'); ?></label>
94 <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 />
95 </p>
96 <p>
97 <label for="<?php echo $this->get_field_id('tips'); ?>"><?php _e('Set tooltip text on mouse hover (separate with a comma (,)):', 'accessibility-widget'); ?></label>
98 <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 />
99 </p>
100 <?php
101 }
102 } // end class widget_accesstxt
103
104 if ( ! version_compare( PHP_VERSION, '5.3.0', '>=' ) ) {
105 $initValue = create_function('', 'return register_widget("widget_accesstxt");');
106 } else {
107 $initValue = function() {
108 return register_widget( 'widget_accesstxt' );
109 };
110 }
111 add_action( 'widgets_init', $initValue );
112