• I have this functions…

    First is for encoding URL:

    function urle( $atts, $content = null ) {
    $cnt = base64_encode($content);
    		return '<a href="/external?link='.$cnt.'">Visit Link</a>';
    }
    
    add_shortcode( 'urle', 'urle' );

    Second is for decoding URL:

    function urls( $atts, $content = null ) {
    $content = $_GET['link'];
    $cnt = base64_decode($content);
    		return '<a href="'.$cnt.'">Visit Link</a>';
    }

    Problem is in first, if I use [urle]https://www.ads-software.com[/urle]
    Link is /external?link=
    It is empty. Where is the catch?

    • This topic was modified 7 years, 11 months ago by pinokio.
    • This topic was modified 7 years, 11 months ago by pinokio.
    • This topic was modified 7 years, 11 months ago by pinokio.
Viewing 1 replies (of 1 total)
  • My only thought is that the base64_encode() function itself is failing for some reason and returning false.

    If you try this modified function, what is output?

    function urle( $atts, $content = null ) {
    	
    	$cnt = base64_encode($content);
    	
    	if ( $cnt ){
    		return '<a href="/external?link=' . $cnt . '">Visit Link</a>';
    	} else {
    		return 'Could not convert to base64';
    	}
    
    }
Viewing 1 replies (of 1 total)
  • The topic ‘Encode and Decode with base64 in shortcode?’ is closed to new replies.