srikat

Untitled

Aug 19th, 2016
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.16 KB | None | 0 0
  1. remove_action ( 'genesis_before_header', 'genesis_skip_links', 5 );
  2. add_action ( 'genesis_before_header', 'sk_skip_links', 5 );
  3. /**
  4. * Add skiplinks for screen readers and keyboard navigation
  5. *
  6. * @since 2.2.0
  7. */
  8. function sk_skip_links() {
  9.  
  10. if ( ! genesis_a11y( 'skip-links' ) ) {
  11. return;
  12. }
  13.  
  14. // Call function to add IDs to the markup
  15. genesis_skiplinks_markup();
  16.  
  17. // Determine which skip links are needed
  18. $links = array();
  19.  
  20. if ( genesis_nav_menu_supported( 'primary' ) && has_nav_menu( 'primary' ) ) {
  21. $links['genesis-nav-primary'] = __( 'Skip to primary navigation', 'genesis' );
  22. }
  23.  
  24. $links['genesis-content'] = __( 'Skip to content', 'genesis' );
  25.  
  26. if ( 'full-width-content' != genesis_site_layout() ) {
  27. $links['genesis-sidebar-primary'] = __( 'Skip to primary sidebar', 'genesis' );
  28. }
  29.  
  30. if ( in_array( genesis_site_layout(), array( 'sidebar-sidebar-content', 'sidebar-content-sidebar', 'content-sidebar-sidebar' ) ) ) {
  31. $links['genesis-sidebar-secondary'] = __( 'Skip to secondary sidebar', 'genesis' );
  32. }
  33.  
  34. if ( current_theme_supports( 'genesis-footer-widgets' ) ) {
  35. $footer_widgets = get_theme_support( 'genesis-footer-widgets' );
  36. if ( isset( $footer_widgets[0] ) && is_numeric( $footer_widgets[0] ) ) {
  37. if ( is_active_sidebar( 'footer-1' ) ) {
  38. $links['genesis-footer-widgets'] = __( 'Skip to footer', 'genesis' );
  39. }
  40. }
  41. }
  42.  
  43. /**
  44. * Filter the skip links.
  45. *
  46. * @since 2.2.0
  47. *
  48. * @param array $links {
  49. * Default skiplinks.
  50. *
  51. * @type string HTML ID attribute value to link to.
  52. * @type string Anchor text.
  53. * }
  54. */
  55. $links = apply_filters( 'genesis_skip_links_output', $links );
  56.  
  57. // write HTML, skiplinks in a list with a heading
  58. $skiplinks = '<section>';
  59. $skiplinks .= '<h3 class="screen-reader-text">'. __( 'Skip links', 'genesis' ) .'</h3>';
  60. $skiplinks .= '<ul class="genesis-skip-link">';
  61.  
  62. // Add markup for each skiplink
  63. foreach ($links as $key => $value) {
  64. $skiplinks .= '<li><a href="' . esc_url( '#' . $key ) . '" class="screen-reader-shortcut"> ' . $value . '</a></li>';
  65. }
  66.  
  67. $skiplinks .= '</ul>';
  68. $skiplinks .= '</section>' . "\n";
  69.  
  70. echo $skiplinks;
  71. }
Advertisement
Add Comment
Please, Sign In to add comment