Created
September 25, 2012 09:52
-
-
Save rianrietveld/3780961 to your computer and use it in GitHub Desktop.
WordPress Genesis Accessible skip links
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* WordPress Genesis Accessible skip links for screen readers and keyboard users | |
* Rian Rietveld - rrwd.nl | |
* Add this to style.css in the child theme for the Genesis Framework by StudioPress. | |
* The skip links are dependent on the selected page layout | |
*/ | |
a.skip-link { | |
background-color: #f2f9ff; | |
border: 2px solid #12405C; | |
display: block; | |
font-size: 1em; | |
left: -1000em; | |
padding: 0.8em; | |
position: absolute; | |
z-index: 10; | |
} | |
a.skip-link:focus, a.skip-link:active { | |
top:1em; | |
left:1em; | |
z-index:1000; | |
color: #1E6891; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* WordPress Genesis Accessible skip links for screen readers and keyboard users | |
* Rian Rietveld - rrwd.nl | |
* Add this to functions.php in the child theme for the Genesis Framework by StudioPress. | |
* The skip links are dependent on the selected page layout | |
*/ | |
function wpacc_skip_links() { | |
// add link to primary navigation? | |
$nav = false; | |
if ( genesis_get_option( 'nav' ) == '1' ) { | |
$nav = true; | |
} | |
// Add links to sidebars? | |
$site_layout = genesis_site_layout(); | |
$sidebar = false; | |
$sidebar_alt = false; | |
// | |
if ( $site_layout == 'sidebar-sidebar-content' || $site_layout == 'content-sidebar-sidebar' || $site_layout == 'sidebar-content-sidebar') { | |
$sidebar = true; | |
$sidebar_alt = true; | |
} | |
if ( $site_layout == 'sidebar-content' || $site_layout == 'content-sidebar' ) { | |
$sidebar = true; | |
} | |
// add link to footer? | |
$footer = false; | |
if ( current_theme_supports( 'genesis-footer-widgets' ) == '1' ) { | |
$footer = true; | |
} | |
// write HTML | |
?> | |
<!-- skiplinks --> | |
<br class="skip-link" /> | |
<?php | |
if ($nav) echo '<a href="#nav" class="skip-link">'. __( 'Jump to main navigation', 'wpacc-genesis' ) .'</a><br class="skip-link" />' . "\n"; | |
echo '<a href="#content" class="skip-link">'. __( 'Jump to content', 'wpacc-genesis' ) .'</a><br class="skip-link" /> ' . "\n"; | |
if ($sidebar) echo '<a href="#sidebar" class="skip-link">'. __( 'Jump to primary sidebar', 'wpacc-genesis' ) .'</a><br class="skip-link" />' . "\n"; | |
if ($sidebar_alt) echo '<a href="#sidebar-alt" class="skip-link">'. __( 'Jump to secondary sidebar', 'wpacc-genesis' ) .'</a><br class="skip-link" />' . "\n"; | |
if ($footer) echo '<a href="#footer-widgets" class="skip-link">'. __( 'Jump to footer', 'wpacc-genesis' ) .'</a><br class="skip-link" />' . "\n"; | |
} | |
add_action ( 'genesis_header', 'wpacc_skip_links'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment