Make WordPress Core

Changeset 30270


Ignore:
Timestamp:
11/07/2014 04:45:53 PM (10 years ago)
Author:
iandstewart
Message:

Twenty Fifteen: use antispambot to obfuscate email adresses in the social links menu.

Props tywayne, fixes #30214.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-content/themes/twentyfifteen/functions.php

    r30233 r30270  
    303303
    304304/**
     305* Encode email address of mailto: links in social navigation
     306*
     307* @since Twenty Fifteen 1.0
     308*
     309* @param array   $atts        HTML attributes in an associative array
     310* @param WP_Post $item        Menu item object
     311* @param array   $args        Array containing config with desired markup of nav
     312*
     313* @return array HTML attributes for Menu item
     314*/
     315function twentyfifteen_nav_encode_email( $atts, $item, $args ) {
     316    if ( 'social' == $args->theme_location ) {
     317        if ( preg_match( '/^mailto:(.+)/', $atts['href'], $match ) ) {
     318            $atts['href'] = 'mailto:' . antispambot( $match[1] );
     319        }
     320    }
     321    return $atts;
     322}
     323add_filter( 'nav_menu_link_attributes', 'twentyfifteen_nav_encode_email', 10, 3 );
     324
     325/**
    305326 * Add a `screen-reader-text` class to the search form's submit button.
    306327 *
Note: See TracChangeset for help on using the changeset viewer.