• Resolved glenderman

    (@glenderman)


    Hi

    I’ve been analysing my website using Google’s Lighthouse tool, and under the “Best Practices” tab it flags my social media icons that I use Hustle for.

    This recommends adding a rel=”noopener” or rel=”noreferrer” to these links.

    Here is the relevant reading from web.dev:

    https://web.dev/external-anchors-use-rel-noopener/?utm_source=lighthouse&utm_medium=devtools

    Could this possibly be added to any social share links as it would improve best practice score of most likely all websites who use Hustle.

    Thanks

    • This topic was modified 6 years ago by glenderman.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Imran – WPMU DEV Support

    (@wpmudev-support9)

    Hello @glenderman

    I trust you’re doing well!

    Would you please try the following solution. Add this code to a child’s theme functions.php file:

    add_filter( 'hustle_render_module_markup', function( $html, $renderer, $render_id, $sub_type, $post_id ){
    	if ( 'floating' !== $sub_type ) {
    		return $html;
    	}
    	$doc = new \DOMDocument('1.0', 'UTF-8');
    	libxml_use_internal_errors( true );
    	$doc->loadHTML( $html );
    	libxml_use_internal_errors( false );
    	$xpath = new DOMXPath( $doc );
    	$nodes = $xpath->query( "//*[contains(@class, 'hustle-share-icon')]" );
    	foreach ( $nodes as $key =>$node ) {
    		$node->setAttribute( 'rel', 'nofollow' );
    	}
    	return $doc->saveHTML();
    }, 20, 5 );

    In case there is no child theme, please create a mu-plugin. Create a file and name it hustle-render-module-markup.php. Add <?php to a first line and then the rest of the above code.

    Upload the file to /wp-content/mu-plugins/ directory. if the mu-plugins folder is not there, please feel free to create it.

    Have a good day!

    Cheers,
    Nastia

    Plugin Support Imran – WPMU DEV Support

    (@wpmudev-support9)

    Hello @glenderman

    I hope you are doing well!

    We haven’t heard back from you for a while now so we’ve marked this ticket as resolved. If you do have any followup questions or require further assistance feel free to reopen it and let us know here.

    Kind regards,
    Nastia

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Adding rel-noopener/noreferrer Link’ is closed to new replies.