Skip to content

Instantly share code, notes, and snippets.

@GaryJones
Last active December 25, 2015 23:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GaryJones/7057100 to your computer and use it in GitHub Desktop.
Save GaryJones/7057100 to your computer and use it in GitHub Desktop.
WordPress: Allow anchor target attribute in user biography field.
<?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