Or, embed this snippet using GenerateWP WordPress Plugin.

Download

Clone

Safe link

// Add Shortcode
function safe_link_shortcode( $atts ) {

	// Attributes
	$atts = shortcode_atts(
		array(
			'href' => '#link',
			'text' => 'Link',
			'target' => '',
		),
		$atts,
		'safe-link'
	);

	// Return only if has HREF attribute
	if ( isset( $atts['href'] ) ) {
	    $e_href = base64_encode($atts['href']);
	    $e_text = $atts['text'] !== '' ? base64_encode($atts['text']) : base64_encode($atts['href']);
	    wp_enqueue_script( 'rcom_main', get_stylesheet_directory_uri() . '/assets/rcom.main.js', array('jquery'), '', true );
	    return '<a href="' . $e_href . '" class="safe-link" rel="nofollow" ' . ($atts['target'] !== '' ? 'target="'. $atts['target'] .'"' : '') . ' >' . $e_text . '</a>';
	}
	// jQuery code in safe-link.jquery.js:
	/*
	(function(){
	   var $ = jQuery;
	   // safe links decode to human format
	   $('.safe-link').each(function(index){
	      var href = $(this).attr('href');
	      var txt = $(this).text();
	      $(this).text(window.atob(txt));
	      $(this).attr('href', window.atob(href));
	   });
	
	})();
	*/
	
	/* HOW TO USE:
	
	[safe-link href="some/url" text="Link text" target="_blank"] //target is optional

}
add_shortcode( 'safe-link', 'safe_link_shortcode' );