On wordpress, does anyone know how to programatically change link from:
<a href="some_url">click</a>
to:
<a onclick="window.open('some_url','_blank', 'location=no')">click</a>
so that all links created in the wordpress visual editor be opened via inappbrowser in a cordova app.
After googling around, below is the closest that i can get, but still doesn't work, the '%link%'
variable doesn't change to the actual link url :
add_filter('the_content', 'changeToOnclick');
function changeToOnclick($content) {
return preg_replace('/<a [^>]*>/', "<a onclick=\"window.open('%link%', '_blank', 'location=no')\">", $content);
}
any help will be appreciated :)