Encoding URL partially in Javascript and PHP (url tweak) -


that might strange when want encode url partially, caught in situation , seems got no other solution...

here code snippet

    $url = isset($_get['u']) ? esc_url($_get['u']) : '';         $image = isset($_get['i']) ? $_get['i'] : '';      maybeappend = '<a href="?ajax=photo_thickbox&amp;i=' + encodeuricomponent(img.src) +    '&amp;u=<?php echo urlencode($url); ?>&amp;height=400&amp;width=500" title=""      class="thickbox"><img src="' + img.src + '" ' + img_attr + '/></a>'; 

its taken wordpress /wp-admin/press-this.php issue is, cant post site via press this bookmarklet

i searched google, studied wordpress forums , found need tweek press this button in bookmark tool bar in broswer..

but me, not solution,,why? obviously, cant teach every visitor change in broswer..so have edit code residing on server...

how can edit encodeuricomponent(img.src) , <?php echo urlencode($url); ?> not encode http:// part of url,

say got url 'http://www.google.com want encoded www.google.com

any suggesion?

how can achieve goal? might regex ? (dont know regex :( )

what code adjustment this??

thanks help..

first remove http part using substr, apply urlencode , reattacht http part.

same method can applied in javascript using equivalent javascript functions.

$encoded = 'http://' . urlencode(substr($url, -7)); 

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -