Skip to content

Instantly share code, notes, and snippets.

@wplit
Created June 13, 2024 08:57
Show Gist options
  • Save wplit/e439d37d5750cbb8428ad6c88ddaa8f1 to your computer and use it in GitHub Desktop.
Save wplit/e439d37d5750cbb8428ad6c88ddaa8f1 to your computer and use it in GitHub Desktop.
remove 'target' attribute from social share element links (https://academy.bricksbuilder.io/article/filter-bricks-element-render_attributes/)
<?php
add_filter( 'bricks/element/render_attributes', function( $attributes, $key, $element ) {
$element_name = "xsocialshare";
if ( $element_name === $element->name && strpos( $key, "link-") === 0 ) {
foreach($attributes as $attr=>$row){
unset($attributes[$attr]['target']);
}
}
return $attributes;
}, 10, 4 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment