'All Tests', 'section508' => 'Section 508', 'wcag1a' => 'WCAG 1.0 A', 'wcag1aa' => 'WCAG 1.0 AA', 'wcag1aaa' => 'WCAG 1.0 AAA', 'wcag2a' => 'WCAG 2.0 A', 'wcag2aa' => 'WCAG 2.0 AA', 'wcag2aaa' => 'WCAG 2.0 AAA', ); } /** * Accessibility admin options page. This is where the admin sets the guideline * to use for the site, as well as the severity levels to cover during testing. */ function accessible_helper_options() { if ( $_GET['test'] ) { include( 'test_settings.php' ); return null; } if ( function_exists('current_user_can') && !current_user_can( 'manage_options' ) ) { wp_die( __( 'You do not have sufficient permissions to access this page.' ) ); } if ( isset($_POST['submit']) ) { update_option( 'accessibility_guideline', $_POST['guideline'] ); update_option( 'accessibility_severity', $_POST['severity'] ); } $severity = get_option( 'accessibility_severity' ); ?>

setOption( 'cms_mode', true ); $quail->runCheck(); $results = $quail->getReport(); $errors = accessible_helper_cleanup_results( $results ); foreach ( $errors as $level => $total ) { add_post_meta( $post->ID, '_accessibility_'. $level, $total['total'], true ); } return $data; } /** * Because QUAIL just dumps all tests on you, this cleans up tests that had * no errors, as well as tests which had a severity level different than those * enabled by the site admin. */ function accessible_helper_cleanup_results($results) { $severity = get_option( 'accessibility_severity' ); $errors = array(); foreach($results as $testname => $result) { if ( $severity[$result['severity']] && ($result['problems']['pass'] === false || count( $result['problems'] ) > 0) ) { if ( $result['problems']['pass'] === false ) { $errors[$result['severity']]['total']++; } else { $errors[$result['severity']]['total'] += count( $result['problems'] ) - 1; } $errors[$result['severity']][$testname] = $result; } } return $errors; } /** * Returns the human-readable version of a given numeric severity level. */ function accessible_helper_get_severity($level = null) { $severity = array(1 => __( 'Severe Errors', 'accessible_helper' ), 2 => __( 'Moderate Errors', 'accessible_helper' ), 3 => __( 'Suggestions', 'accessible_helper' ), ); if ( $level ) { return $severity[$level]; } return $severity; } /** * The overview widget for the admin interface. */ function accessible_helper_overview( $post ) { if ( !$post->post_content ) { echo '

Accessibility information will be available once this post is saved.

'; return null; } foreach( accessible_helper_get_severity() as $severity => $label ) { $total = get_post_meta( $post->ID, '_accessibility_'. $severity, true ); if ( $total ) { echo '

'. $label .': '. $total .'

'; } } echo '

View More Information | '; echo 'View Highlighted Info

'; } /** * Includes the QUAIL library */ function accessible_helper_include_library() { return include_once(ABSPATH .'wp-content/plugins/accessible-helper/quail/quail/quail.php'); } /** * The overview page that helps users see accessibility problems with a given page or post. * We switch between includes based on the 'type' URL parameter. */ function accessible_helper_overview_page() { accessible_helper_include_library(); switch( $_GET['type'] ) { case 'overview': include('overview.php'); break; case 'highlight': include('highlight.php'); break; case 'test': include('test.php'); break; default; include('overview.php'); } } /** * Retrieves the translated or user-prepared error codes about a test. * @param string The test class name from QUAIL */ function accessible_helper_get_test( $test ) { if ( !$test_info = get_option('accessibility_test_'. $test) ) { $translations = fopen(ABSPATH .'wp-content/plugins/accessible-helper/quail/quail/guidelines/translations/en.txt', 'r'); if ($translations ) { while ( $translation = fgetcsv($translations) ) { if ( count($translation) == 4 && $translation[0] == $test ) { $test_info['title'] = $translation[1]; $test_info['body'] = $translation[2]; return $test_info; } } } } return $test_info; }