Skip to content

Commit

Permalink
#1199 added a filter to remove all targets from content
Browse files Browse the repository at this point in the history
  • Loading branch information
FitoreGashi committed May 25, 2023
1 parent 0ae386e commit 4c638d3
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions functions/filters.php
Expand Up @@ -393,3 +393,17 @@ function fau_remove_image_size_options($sizes) {
return $sizes;
}
add_filter('image_size_names_choose', 'fau_remove_image_size_options');


/*-----------------------------------------------------------------------------------*/
/* Remove the target in all links in content
/*-----------------------------------------------------------------------------------*/

function fau_change_link_targets($content) {
$pattern = '/<a(.*?)href=[\'"](.*?)[\'"](.*?)(target=[\'"](.*?)[\'"])?(.*?)>/i';
$replacement = '<a$1href="$2"$3$6>';
$content = preg_replace($pattern, $replacement, $content);
return $content;
}
add_filter('the_content', 'fau_change_link_targets');

0 comments on commit 4c638d3

Please sign in to comment.