Skip to content

Instantly share code, notes, and snippets.

@damiencarbery
Created March 3, 2017 13:30
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 damiencarbery/d0bd59e34520aa37b87924a04a87847e to your computer and use it in GitHub Desktop.
Save damiencarbery/d0bd59e34520aa37b87924a04a87847e to your computer and use it in GitHub Desktop.
<?php
add_filter( 'nav_menu_link_attributes', function ( $atts, $item, $args ) {
$prefix = 'target';
$target_items = preg_grep( "/^${prefix}-/", $classes );
if ( $target_items ) {
foreach( $target_items as $target_item ) {
$value = substr( $target_item, strlen( $prefix.'-' ) );
$atts[$prefix] = $value;
}
}
return $atts;
}, 10, 3 );
@mayishaciyevgithub
Copy link

good

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment