[wp-trac] [WordPress Trac] #59682: Bug fix for rel attributes in social-link.php

WordPress Trac noreply at wordpress.org
Mon Oct 30 13:46:56 UTC 2023


#59682: Bug fix for rel attributes in social-link.php
--------------------------+------------------------------
 Reporter:  niallhotfoot  |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  General       |     Version:  6.3.2
 Severity:  normal        |  Resolution:
 Keywords:  needs-patch   |     Focuses:
--------------------------+------------------------------

Comment (by niallhotfoot):

 I've just been doing some follow up testing for you and I'm afraid I'm
 none the wiser! I've scoured the code for any references or hooks into
 WP_HTML_Tag_processor itself but I've not found anything.

 So I'll breifly go through the setup from the beginning!

 I've got a site which has widget areas, in that widget are it is using the
 Social Icons block.

 When rendered on the front end, it is going through wp-includes > blocks >
 social-link.php through the render_block_core_social_link function.

 In this function, there is a section about opening in a new tab.

 The line in question is this one:


 {{{
 $processor->set_attribute( 'rel', esc_attr( $rel ) . ' noopener nofollow'
 );
 }}}

 If I dump the $processor as it is, I cannot find the 'noopener nofollow'
 attributes. However, dumping $processor->getAttributes('rel') does get the
 attributes.

 If I repeat the process with my workaround, so:

 {{{
 $processor->set_attribute( 'rel', trim(esc_attr( $rel ) . ' noopener
 nofollow' ));
 }}}

 And then dump the $processor, I am then able to find the 'noopener
 nofollow'

 I'm really interested to see if it works fine for you using the Social
 Icons block in a widget!

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/59682#comment:7>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list