| 1 |
var automatorwp_redirect_in_progress=!1;function automatorwp_check_for_redirect(){var $=jQuery;var user_id=parseInt(automatorwp_redirect.user_id);if(user_id===0||isNaN(user_id)){return} |
| 2 |
if(automatorwp_redirect_in_progress){return} |
| 3 |
automatorwp_redirect_in_progress=!0;$.ajax({url:automatorwp_redirect.ajaxurl,method:'POST',data:{action:'automatorwp_check_for_redirect',nonce:automatorwp_redirect.nonce,user_id:automatorwp_redirect.user_id,},success:function(response){if(!automatorwp_is_response_valid_for_redirect(response)){automatorwp_redirect_in_progress=!1;return} |
| 4 |
if(!automatorwp_redirect_to_url(response.data.redirect_url)){automatorwp_redirect_in_progress=!1}},error:function(response){if(!automatorwp_is_response_valid_for_redirect(response)){automatorwp_redirect_in_progress=!1;return} |
| 5 |
if(!automatorwp_redirect_to_url(response.data.redirect_url)){automatorwp_redirect_in_progress=!1}}})} |
| 6 |
function automatorwp_is_response_valid_for_redirect(response){if(response===undefined){return!1} |
| 7 |
if(response.data===undefined){return!1} |
| 8 |
if(response.data.redirect_url===undefined){return!1} |
| 9 |
return!0} |
| 10 |
function automatorwp_redirect_to_url(url){if(url===undefined){url=''} |
| 11 |
if(!url.length){return!1} |
| 12 |
document.location.href=url;return!0} |
| 13 |
function automatorwp_redirect_is_url_excluded(url,data){if(url===undefined){url=''} |
| 14 |
if(data===undefined){data=url} |
| 15 |
if(typeof data!=='string'){data=url} |
| 16 |
var excluded_url=!1;automatorwp_redirect.excluded_urls.forEach(function(to_match){if(url!==undefined&&url.includes(to_match)||url===to_match){excluded_url=!0}});if(excluded_url){return!0} |
| 17 |
var excluded_data=!1;automatorwp_redirect.excluded_data.forEach(function(to_match){if(data!==undefined&&data.includes(to_match)){excluded_data=!0}});if(excluded_data){return!0} |
| 18 |
if(url!==undefined&&url.includes('admin-ajax.php')){var excluded_action=!1;automatorwp_redirect.excluded_ajax_actions.forEach(function(to_match){if(data!==undefined&&data.includes('action='+to_match)){excluded_action=!0} |
| 19 |
if(url!==undefined&&url.includes('action='+to_match)){excluded_action=!0}});if(excluded_action){return!0}} |
| 20 |
return!1}(function($){$(document).ajaxSuccess(function(event,request,settings){if(automatorwp_redirect_is_url_excluded(settings.url,settings.data)){return} |
| 21 |
var status=parseInt(request.status);if(status===200){automatorwp_check_for_redirect()}})})(jQuery) |