fazarcon

add aria label

Jul 29th, 2022
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. add_filter( 'render_block', function( $block_content, $block ) {
  2. if ( !is_admin() && ! empty( $block['attrs']['className'] ) && 'add-title-aria' === $block['attrs']['className'] ) {
  3. $block_content = str_replace( '<a ', '<a aria-label="' . get_the_title() . '" ', $block_content );
  4. }
  5.  
  6. return $block_content;
  7. }, 10, 2 );
Advertisement
Add Comment
Please, Sign In to add comment