Last active
December 25, 2015 23:29
-
-
Save GaryJones/7057100 to your computer and use it in GitHub Desktop.
WordPress: Allow anchor target attribute in user biography field.
This file contains 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
<?php | |
// Don't include the above | |
add_filter( 'wp_kses_allowed_html', 'georgef_allow_anchor_target_attribute_in_biography', 20, 2 ); | |
/** | |
* Allow links to have a target attribute in user biographical information. | |
* | |
* @author Gary Jones | |
* @link http://www.studiopress.com/forums/topic/about-the-author-box-can-open-links-in-new-window/ | |
* | |
* @param array $tags Multi-dimensional array of allowed elements and their attributes. | |
* @param string $context Context under which wp_kses is operating. | |
* | |
* @return array Amended allowed elements and attributes. | |
*/ | |
function prefix_allow_anchor_target_attribute_in_biography( $tags, $context ) { | |
if ( ! in_array( $context, array( 'pre_user_description', 'user_description' ) ) ) | |
return $tags; | |
$tags['a']['target'] = true; | |
return $tags; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment