From 1b0b11b593a6ad6fcc51559ff24c73347dbbf33b Mon Sep 17 00:00:00 2001 From: Ian Stewart Date: Fri, 7 Nov 2014 16:46:21 +0000 Subject: [PATCH] Twenty Fifteen: use antispambot to obfuscate email adresses in the social links menu. Props tywayne, fixes #30214. Built from https://develop.svn.wordpress.org/trunk@30270 git-svn-id: http://core.svn.wordpress.org/trunk@30270 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-content/themes/twentyfifteen/functions.php | 21 +++++++++++++++++++ wp-includes/version.php | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/wp-content/themes/twentyfifteen/functions.php b/wp-content/themes/twentyfifteen/functions.php index a5545d833f..691e4e93a8 100644 --- a/wp-content/themes/twentyfifteen/functions.php +++ b/wp-content/themes/twentyfifteen/functions.php @@ -301,6 +301,27 @@ function twentyfifteen_nav_description( $item_output, $item, $depth, $args ) { } add_filter( 'walker_nav_menu_start_el', 'twentyfifteen_nav_description', 10, 4 ); +/** +* Encode email address of mailto: links in social navigation +* +* @since Twenty Fifteen 1.0 +* +* @param array $atts HTML attributes in an associative array +* @param WP_Post $item Menu item object +* @param array $args Array containing config with desired markup of nav +* +* @return array HTML attributes for Menu item +*/ +function twentyfifteen_nav_encode_email( $atts, $item, $args ) { + if ( 'social' == $args->theme_location ) { + if ( preg_match( '/^mailto:(.+)/', $atts['href'], $match ) ) { + $atts['href'] = 'mailto:' . antispambot( $match[1] ); + } + } + return $atts; +} +add_filter( 'nav_menu_link_attributes', 'twentyfifteen_nav_encode_email', 10, 3 ); + /** * Add a `screen-reader-text` class to the search form's submit button. * diff --git a/wp-includes/version.php b/wp-includes/version.php index 32a2e1b3cc..ca01fdd02e 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.1-alpha-30269'; +$wp_version = '4.1-alpha-30270'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.