{"id":58,"date":"2014-05-28T17:29:43","date_gmt":"2014-05-28T17:29:43","guid":{"rendered":"http:\/\/localhost\/__sites\/3d_blog\/?p=58"},"modified":"2014-05-29T09:07:48","modified_gmt":"2014-05-29T09:07:48","slug":"wordpress-soft-exit","status":"publish","type":"post","link":"https:\/\/blog.silverterra.net\/?p=58","title":{"rendered":"wordpress soft exit"},"content":{"rendered":"<blockquote><p><em>Goal: after the exit link click keep the focus on blog page with a simple refresh.<\/em><\/p><\/blockquote>\n<p>The exit link is generated by <code data-enlighter-language=\"php\" class=\"EnlighterJSRAW\">wp_loginout();<\/code>. Put the generated link into an identified container like this.<\/p>\n<pre data-enlighter-language=\"php\" class=\"EnlighterJSRAW\">\r\n&lt;li class=&quot;wpexit&quot;&gt;&lt;?php wp_loginout(); ?&gt;&lt;\/li&gt;\r\n<\/pre>\n<p>Catch the link object and override the click action (but only the logout action):<\/p>\n<pre data-enlighter-language=\"js\" class=\"EnlighterJSRAW\">\r\n\/\/ exit link\r\n$j('.wpexit a').on('click',function(){\r\n  var h = ($j(this).attr('href'));\r\n  if(h.Contains('action=logout')){\r\n    callAjax(h, function(d){ location.reload(true); });\r\n    return false;\r\n  }\r\n});\r\n\r\ncallAjax = function(_url, _callback){\r\n  $j.ajax({\r\n    url : _url,\r\n    type : 'GET',\r\n    success : function(data) {},\r\n    error: function() {},\r\n    complete: function(){ _callback &amp;&amp; _callback();}\r\n  });\r\n};\r\n<\/pre>\n<p>So the result is: when you click on the <strong><em>Log out<\/em><\/strong> link the process happening in the background and you can keep the current page after a simple refresh.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Goal: after the exit link click keep the focus on blog page with a simple refresh. The exit link is generated by . Put the generated link into an identified container like this. Catch the link object and override the click action (but only the logout action): So the result is: when you click on [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-58","post","type-post","status-publish","format-standard","hentry","category-wordpress"],"_links":{"self":[{"href":"https:\/\/blog.silverterra.net\/index.php?rest_route=\/wp\/v2\/posts\/58","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.silverterra.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.silverterra.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.silverterra.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.silverterra.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=58"}],"version-history":[{"count":9,"href":"https:\/\/blog.silverterra.net\/index.php?rest_route=\/wp\/v2\/posts\/58\/revisions"}],"predecessor-version":[{"id":85,"href":"https:\/\/blog.silverterra.net\/index.php?rest_route=\/wp\/v2\/posts\/58\/revisions\/85"}],"wp:attachment":[{"href":"https:\/\/blog.silverterra.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=58"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.silverterra.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=58"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.silverterra.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=58"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}