wordpress soft exit [ 1167 views ]
Goal: after the exit link click keep the focus on blog page with a simple refresh.
The exit link is generated by wp_loginout();. Put the generated link into an identified container like this.
<li class="wpexit"><?php wp_loginout(); ?></li>
Catch the link object and override the click action (but only the logout action):
// exit link
$j('.wpexit a').on('click',function(){
var h = ($j(this).attr('href'));
if(h.Contains('action=logout')){
callAjax(h, function(d){ location.reload(true); });
return false;
}
});
callAjax = function(_url, _callback){
$j.ajax({
url : _url,
type : 'GET',
success : function(data) {},
error: function() {},
complete: function(){ _callback && _callback();}
});
};
So the result is: when you click on the Log out link the process happening in the background and you can keep the current page after a simple refresh.


