Admin Toolbox','manage_options','admin-toolbox','atb_admin',1); } add_action('admin_menu','atb_adminMenu'); function atb_admin() { global $wpdb; global $atb_version; include_once('atb_admin.php'); wp_enqueue_style('atb_style',plugins_url('assets/atb_min.css?v=0'.$atb_version,__FILE__)); } add_shortcode('atb_admin','atb_admin'); function atb_upgrade_db() { $ug=get_option('atb_upgrade'); if(!empty($ug)) return; global $atb_version; $old_config=atb_r("SHOW TABLES LIKE 'wp_atb_options';"); if($old_config) { atb_r("INSERT INTO wp_options(option_name,option_value) SELECT CONCAT('atb_',option_name),option_value FROM wp_atb_options; "); atb_r("DROP TABLE IF EXISTS wp_atb_options;"); update_option('atb_setup',$atb_version); } update_option('atb_upgrade',$atb_version); } add_action('init','atb_upgrade_db'); function atb_activate($upgrade) { global $wpdb,$atb_version; require_once(ABSPATH.basename(get_admin_url()).'/includes/upgrade.php'); update_option('atb_db_version',$atb_version,'no'); $sql=" CREATE TABLE {$wpdb->prefix}atb_pagehits (hit_id INT NOT NULL AUTO_INCREMENT ,date TIMESTAMP DEFAULT CURRENT_TIMESTAMP ,ip VARCHAR(191) NULL ,userid INT ,url VARCHAR(500) ,referrer VARCHAR(500) ,subsq INT DEFAULT NULL ,PRIMARY KEY (hit_id) ,KEY date (date) ,KEY ip (ip)) ENGINE=InnoDB;"; dbDelta($sql); if(function_exists('atb_pro_ping'))atb_pro_ping(); } register_activation_hook(__FILE__,'atb_activate'); function atb_admin_notice() { if(!atb_is_path('cron,ajax,page=admin-toolbox')){ require_once(ABSPATH.WPINC.'/pluggable.php'); if(current_user_can('manage_options')) { $settings_url=get_admin_url(null,'admin.php?page=admin-toolbox');?>

Admin Toolbox plugin is active, but is not yet configured. Visit the configuration page to complete setup.",'Admin Toolbox');?>

0) if(!$get_config) return false; else return true; if(!$get_config && atb_is_path('plugins.php,index.php')) add_action('admin_notices','atb_admin_notice'); } add_action('admin_init','atb_checkConfig'); function atb_add_action_links($links) { $settings_url=get_admin_url(null,'admin.php?page=admin-toolbox'); $support_url='https://richardlerma.com/plugins/'; $links[]='Support'; array_push($links,'Settings'); return $links; } add_filter('plugin_action_links_'.plugin_basename(__FILE__),'atb_add_action_links'); function atb_uninstall() { $keep=get_option('atb_page_hit_keep'); if($keep>0) return; else { atb_r("DROP TABLE IF EXISTS wp_atb_options;"); atb_r("DROP TABLE IF EXISTS wp_atb_pagehits;"); atb_r("DELETE FROM wp_options WHERE option_name LIKE 'atb_%';"); delete_option('atb_db_version'); } } register_uninstall_hook(__FILE__,'atb_uninstall'); function atb_impact() { if(empty(get_option('atb_setup'))) return; if(get_option('atb_redirect_db')>0) atb_redirect_db(); if(get_option('atb_redirect_hp')>0) atb_redirect_hp(); function atb_admin_impact() {global $wpdb;include_once('atb_admin_impact.php');} add_action('admin_init','atb_admin_impact'); function atb_login_impact() {global $wpdb;include_once('atb_login_impact.php');} add_action('login_enqueue_scripts','atb_login_impact'); function atb_frontend_impact() {global $wpdb;include_once('atb_frontend_impact.php');} if(!is_admin()) atb_frontend_impact(); } add_action('init','atb_impact'); if(!function_exists('atb_ip')){ function atb_ip(){ static $ip=null;if($ip!==null)return $ip; if(isset($_SERVER['HTTP_CF_CONNECTING_IP']))return $ip=sanitize_text_field(wp_unslash($_SERVER['HTTP_CF_CONNECTING_IP'])); if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])){list($ip)=explode(',',sanitize_text_field(wp_unslash($_SERVER['HTTP_X_FORWARDED_FOR'])));return trim($ip);} if(isset($_SERVER['HTTP_X_REAL_IP']))return $ip=sanitize_text_field(wp_unslash($_SERVER['HTTP_X_REAL_IP'])); if(isset($_SERVER['REMOTE_ADDR']))return $ip=sanitize_text_field(wp_unslash($_SERVER['REMOTE_ADDR'])); return $ip='0.0.0.0'; } } function atb_cui($userid=0) { global $current_user; require_once(ABSPATH.WPINC.'/pluggable.php'); // If prior to pluggable loaded natively if(current_user_can('manage_options') && $userid>0) return $userid; $current_user=wp_get_current_user(); $userid=$current_user->ID; return $userid; } function atb_cur($user_id=0) { $user_role=''; require_once(ABSPATH."wp-includes/pluggable.php"); // If prior to pluggable loaded natively if(is_user_logged_in()) { if(is_multisite() && current_user_can('setup_network')) return array('super_admin'); $user_id=atb_cui($user_id); $user_info=get_userdata($user_id); $user_role=$user_info->roles; } return $user_role; } function atb_r($q,$t=NULL) { global $wp_version; if(function_exists('r')) return r($q,$t); require_once(ABSPATH."wp-includes/pluggable.php"); // If prior to pluggable loaded natively if(version_compare('6.1',$wp_version)>0) require_once(ABSPATH.'wp-includes/wp-db.php'); else require_once(ABSPATH.'wp-includes/class-wpdb.php'); global $wpdb; if(!$wpdb) $wpdb=new wpdb(DB_USER,DB_PASSWORD,DB_NAME,DB_HOST); $prf=$wpdb->prefix; $s=str_replace(' wp_',' '.$prf,$q); $s=str_replace($prf.str_replace('wp_','',$prf),$prf,$s); if(is_multisite()) { $bprf=$wpdb->base_prefix; $s=str_replace(" {$prf}user"," {$bprf}user",$s); } $r=$wpdb->get_results($s,OBJECT); if($r) return $r; } function atb_is_path($pages) { $page_array=explode(',',$pages); $current_page=strtolower($_SERVER['REQUEST_URI']); foreach($page_array as $page) { if(strpos($current_page,strtolower($page))!==false) return true; } return false; } // PageHit Action function atb_hit_page() { if(atb_is_path('toolbox&phv=1')!==false) return; global $current_user; $userid=0; $ip=atb_ip(); if(function_exists('atb_check_abuse')) { $abuse_score=get_transient("abu_$ip"); if($abuse_score>5) {header("HTTP/1.1 403 Forbidden");exit();} } $url=sanitize_text_field(substr($_SERVER['REQUEST_URI'],0,250)); if(!get_transient("atb_flag_".atb_cui())) if(is_user_logged_in()) $userid=atb_cui(); $page=get_transient("atb_page_$ip:$userid"); if($url!=$page) { $exclude_pages=atb_r("SELECT option_name,option_value FROM wp_options WHERE option_name LIKE 'atb_page_hit_page%';"); if($exclude_pages) { foreach($exclude_pages as $row): if($row->option_name=='atb_page_hit_page_exclude') $page_hit_page_exclude=$row->option_value; if($row->option_name=='atb_page_hit_page_frag') $page_hit_page_frag=preg_split("/[\r\n,]+/",$row->option_value); endforeach; if(isset($page_hit_page_exclude)) if($page_hit_page_exclude>0 && !empty($page_hit_page_frag)) { $current_page=strtolower($_SERVER['REQUEST_URI']); foreach($page_hit_page_frag as $frag) if(!empty($frag)) {if(strpos($current_page,strtolower($frag))!==false) return;} } } if(isset($_SERVER['HTTP_REFERER'])) $referrer=sanitize_text_field(substr($_SERVER['HTTP_REFERER'],0,250)); else $referrer=''; set_transient("atb_page_$ip:$userid",$url,3600); atb_r("INSERT INTO wp_atb_pagehits(ip,userid,url,referrer) VALUES ('$ip','$userid','$url','$referrer');"); } else atb_r("UPDATE wp_atb_pagehits SET subsq=IFNULL(subsq,0)+1 WHERE ip='$ip' AND userid='$userid' AND url='$url' ORDER BY hit_id DESC LIMIT 1;"); } // Admin Post Search Meta function atb_admin_post_search_meta($query) { if(!is_admin()) return; if(!isset($_GET['search_meta']) || !isset($_GET['s'])) return; if(empty($_GET['search_meta']) || empty($_GET['s'])) return; if(isset($_GET['post_type'])) $post_type=sanitize_text_field($_GET['post_type']); else return; if(isset($query->query_vars['s'])) $term=$query->query_vars['s']; else return; $meta_keys=r(" SELECT DISTINCT meta_key,MAX(LENGTH(meta_value))val_len FROM wp_postmeta pm JOIN (SELECT * FROM wp_posts WHERE post_type='$post_type' AND post_status!='trash' ORDER BY ID DESC LIMIT 100)p ON p.ID=pm.post_id WHERE meta_value NOT LIKE 'field_%' AND meta_key NOT LIKE '%_edit_%' GROUP BY meta_key HAVING val_len>2"); $meta[]=''; if($meta_keys) foreach($meta_keys as $m) array_push($meta,$m->meta_key); else return; $query->query_vars['s']=''; $meta_query=array('relation'=>'OR'); foreach($meta as $m) {array_push($meta_query, array('key'=>$m,'value'=>$term,'compare'=>'LIKE'));} $query->set("meta_query",$meta_query); } // Max Image Size Err Msg function atb_media_size_msg() { ?> 0) return true; if(atb_is_path(basename(get_admin_url())) && !atb_is_path(basename(get_admin_url()).'/plugins.php')) { $user_roles=atb_cur(); if(empty($user_roles)) $user_roles=array(); $get_limit=atb_r("SELECT option_name,option_value FROM wp_options WHERE option_name LIKE 'atb_limit_img_size%';"); if(!$get_limit) return; $limit_img_size=0; $limit_img_size_kb=0; if($get_limit): foreach($get_limit as $row): if($row->option_name=='atb_limit_img_size') $limit_img_size=$row->option_value; if($row->option_name=='atb_limit_img_size_role') $limit_img_size_role=explode(",",$row->option_value); if($row->option_name=='atb_limit_img_size_role_exclude') $limit_img_size_role_exclude=$row->option_value; if($row->option_name=='atb_limit_img_size_kb') $limit_img_size_kb=$row->option_value; endforeach; endif; if($limit_img_size==1 && $limit_img_size_kb>0) { if(($limit_img_size_role_exclude==0 && (count(array_intersect($limit_img_size_role,$user_roles))>0 || in_array('*All',$limit_img_size_role,true))) || ($limit_img_size_role_exclude==1 && (count(array_intersect($limit_img_size_role,$user_roles))==0 || in_array('*All',$limit_img_size_role,true)))) { set_transient('limit_img_size_kb_'.atb_cui(),$limit_img_size_kb,1100); return true; } } } return false; } function atb_media_limit($size) { if(atb_is_path('/wp-json')) return $size; if(!atb_check_media_limit()) return $size; add_action('admin_head','atb_media_size_msg'); $kb=get_transient('limit_img_size_kb_'.atb_cui())*1000; return $kb; } add_filter('upload_size_limit','atb_media_limit'); // Remove other plugins' login features if logged in //if(!atb_is_path('/wp-json')) if(atb_cui()>0) remove_all_actions('login_init'); // Configure Login Page function atb_login_init() { if(atb_is_path('action=logout')) return; if(atb_is_path('action=lostpassword') || atb_is_path('2fa=1')) { if(is_user_logged_in()) { remove_all_actions('login_init'); // Remove other plugins' features add_action('login_init','atb_prompt_token'); } } else add_action('login_init','atb_login_redirect'); } add_action('wp_loaded','atb_login_init',0); // Renamed Login Page (AIOWPS) add_action('wp_loaded','atb_login_init',999); // Standard wp-login.php // Add Token on Login function atb_create_token($login='') { $newcode=uniqid(); if(!empty($login)) {$user=get_user_by('login',$login); $userid=$user->ID;} else $userid=atb_cui(); set_transient('atb_token_'.$userid,strtoupper(substr($newcode,8,5)),300); $ip=atb_ip(); set_transient("atb_flag_".$userid,1,0); } add_action('wp_login','atb_create_token'); // Email Functions function atb_mail_content_type() {return 'text/html';} function atb_mail_from($email) {return get_bloginfo('admin_email');} function atb_mail_name($name) {return get_bloginfo('name');} function atb_html_mail($to,$subject,$message) { add_filter('wp_mail_content_type','atb_mail_content_type'); add_filter('wp_mail_from','atb_mail_from'); add_filter('wp_mail_from_name','atb_mail_name'); if(empty($to)) $to=get_bloginfo('admin_email'); wp_mail($to,$subject,$message); remove_filter('wp_mail_content_type','atb_mail_content_type'); } function atb_email_token($target) { $ip=atb_ip(); $user_info=get_userdata(atb_cui()); $title=get_bloginfo('name'); $to=$user_info->user_email; if(!get_transient('atb_target_'.atb_cui())) set_transient('atb_target_'.atb_cui(),$target,3600); if(atb_is_path('rsd=2')) atb_create_token(); // regen token if(atb_is_path('rsd=1')) set_transient("atb_flag_".atb_cui(),1,0); // resend token if(get_transient("atb_flag_".atb_cui())==1) { // if token not yet sent if(strpos($to,'@')!==false) { // check for valid email if(!get_transient('atb_token_'.atb_cui())) atb_create_token(); require_once(ABSPATH.WPINC.'/pluggable.php'); $message=get_transient('atb_token_'.atb_cui())." is your $title verification code."; if(function_exists('atb_text')) $sent=atb_text($user_info->ID,$message); if(!$sent) { $subject=$title.' Verification Code'; $name=$user_info->first_name; $intro="Dear ".$name."

 "; atb_html_mail($to,$subject,$intro.$message); $to=substr($to,0,3)."81818".substr($to,-6); set_transient('atb_prompt_mobile_'.atb_cui(),1,3600); } else $to=substr($sent,0,3)." 010 10".substr($sent,-2); set_transient("atb_flag_".atb_cui(),2,0); set_transient('atb_sent_to_'.atb_cui(),$to,3600); } else delete_transient("atb_flag_".atb_cui()); } wp_redirect(wp_login_url()."?action=lostpassword&2fa=1#token"); exit; } function atb_dual_auth($ip_exclude) { if(strlen(trim(atb_ip())>6)) $ip=trim(atb_ip()); else $ip='na'; if(get_transient("atb_flag_".atb_cui())!==false && atb_is_path(basename(get_admin_url()))) { if(function_exists('atb_check_abuse')) { $abuse_score=0; $abuse_score=atb_check_abuse($ip); if($abuse_score>5) { atb_report_abuse($ip,'15','Attempt to use stolen credentials to access CMS.'); wp_redirect(wp_login_url()."?action=lostpassword&2fa=1#token"); exit; } } $prev_ip=atb_r("SELECT group_concat(DISTINCT ip) as ip FROM wp_atb_pagehits WHERE userid=".atb_cui()." AND date>NOW()-INTERVAL 30 DAY;"); if($prev_ip[0]->ip??false)$ip_exclude.=($ip_exclude?',':'').$prev_ip[0]->ip; if(isset($_POST['redirect_to'])) $uri=$_POST['redirect_to']; elseif(atb_is_path('ajax')) $uri=$_SERVER['HTTP_HOST'].'/'.basename(get_admin_url()).'/'; else $uri=$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; if(!empty($ip_exclude) && strpos($ip_exclude,$ip)!==false) {delete_transient("atb_flag_".atb_cui());return;} atb_email_token($uri); } } // Show Token Entry Form function atb_prompt_token() { if(atb_is_path('2fa=1')) { if(!empty($_POST['token'])) $usr_token=strtolower(sanitize_text_field($_POST['token'])); else $usr_token=''; $ip=atb_ip(); if(!get_transient("atb_flag_".atb_cui())) atb_login_redirect(); $atb_token=strtolower(get_transient('atb_token_'.atb_cui())); $error_msg=''; if(strlen($atb_token)<1) $error_msg="
Code expired. Generate a new code.
"; elseif(strlen($usr_token)>0 && $atb_token!=$usr_token) $error_msg="
Invalid Code
"; if(strlen($error_msg)<1 && strlen($usr_token)>0 && $atb_token==$usr_token) { $target=get_transient('atb_target_'.atb_cui()); if(get_transient('atb_prompt_mobile_'.atb_cui())!==false) if(strpos($target,'?')===false) $target.="?atb_mob=1"; else $target.="&atb_mob=1"; delete_transient('atb_prompt_mobile_'.atb_cui()); delete_transient('atb_target_'.atb_cui()); delete_transient("atb_flag_".atb_cui()); delete_transient('atb_token_'.atb_cui()); delete_transient('atb_sent_to_'.atb_cui()); atb_hit_page(); wp_redirect(atb_login_redirect($target)); exit; } else { $sent_to=get_transient('atb_sent_to_'.atb_cui()); if(function_exists('atb_sms_origin') && is_numeric(substr($sent_to,0,3)) && is_numeric(substr($sent_to,-2))) { $origin=atb_sms_origin(); $check="If you previously opted out, you must first opt-in by texting RESUME to $origin."; } else $check="Check your spam folder for recent emails."; sleep(3); // Slow down brute force attempts ?> Two Factor Authentication

Two Factor Authentication

Please enter the code sent to

resend code
generate new code
"; for($x=$max_days;$x>=30;) { $y=$x+10; $r=atb_r("DELETE pg FROM wp_atb_pagehits pg JOIN ( SELECT MAX(hit_id) as hit_id FROM wp_atb_pagehits WHERE userid<1 AND date =DATE_FORMAT(NOW(),'%Y-%m-%d')-INTERVAL $y DAY GROUP BY LEFT(date,13),ip,userid,url,referrer HAVING COUNT(ip)>1 ORDER BY hit_id ASC LIMIT 2000 )mx ON mx.hit_id=pg.hit_id;"); $ct=$ct+intval($r); if($x>30 && !get_transient('atb_compress_timeout')) { if($max_days>30) set_transient('atb_compress_max_days',$max_days-20); return $status."Range:$x-$max_days days".number_format($ct)." hits compressed"; } sleep(1); $x=$x-10; } if(function_exists('atb_delete_transients')) $status.=atb_delete_transients(); delete_transient('atb_compress_max_days'); if(!get_transient('atb_compress_optimized')) { set_transient('atb_compress_optimized',1,259000); //every 3 days atb_r("OPTIMIZE TABLE wp_atb_pagehits;"); return $status."Fully optimized.".number_format($ct)." hits compressed"; } else return $status."Max compression achieved.".number_format($ct)." hits compressed"; } // PageHit Summary function atb_view_summary($atb_version_type) { $k='atb_view_summary_init'; if(get_transient($k))return; set_transient($k,1,5*MINUTE_IN_SECONDS); if(get_transient('limit_img_size_kb_'.atb_cui())!==false) delete_transient('limit_img_size_kb_'.atb_cui()); $current_mth=current_time('Y-m-01'); $last_gen_mth=get_option('atb_mt_max'); if(!$last_gen_mth) $last_gen_mth=get_transient('atb_mt_max'); if(!$last_gen_mth) $last_gen_mth=$current_mth; $mth=get_option('atb_mt'); if(!$mth) $mth=get_transient('atb_mt'); // Find Historical Month Stats function atb_month_stat($params) { if(function_exists('atb_pro_ping')) $blocked_ips='AND ip NOT IN (SELECT blocked_ip FROM wp_aiowps_permanent_block)'; else $blocked_ips=''; $query=" SELECT DATE_FORMAT(CONCAT(month,'-01'),'%b %y') as month ,month as month_id,visitors ,ROUND(visitors/CASE WHEN month=DATE_FORMAT(NOW(),'%Y-%m') THEN DAY(NOW()) ELSE 30 END,0) as day_avg FROM ( SELECT LEFT(date,7) as month,COUNT(DISTINCT ip) as visitors FROM wp_atb_pagehits WHERE date>NOW()-INTERVAL 400 DAY $params $blocked_ips AND url NOT LIKE '/wp-%' GROUP BY LEFT(date,7) )a ORDER BY DATE_FORMAT(CONCAT(month,'-01'),'%y-%m');"; $mth=atb_r($query); return $mth; } // Create Historical Month Stats if(!$mth) { $mth=atb_month_stat("AND date<'$current_mth'"); update_option('atb_mt',$mth,false); update_option('atb_mt_max',$current_mth,false); } // Get Month Stats between last Gen Date and Month Begin if(!$mth || $current_mth>$last_gen_mth) { $mth_new=atb_month_stat("AND date>='$last_gen_mth' AND date<'$current_mth'"); if($mth && $mth_new) { $mth=array_merge($mth,$mth_new); // Append Historical with Current update_option('atb_mt',$mth,false); update_option('atb_mt_max',$current_mth,false); delete_transient('atb_mt'); delete_transient('atb_mt_max'); } } // Get Month Stats greater than Month Begin $mth_new=atb_month_stat("AND date>='$current_mth'"); if(!$mth)$mth=$mth_new; elseif($mth_new)$mth=array_merge($mth,$mth_new); // Append Historical with Today $current_day=current_time('Y-m-d'); $last_gen_day=get_option('atb_dy_max'); if(!$last_gen_day) $last_gen_day=get_transient('atb_dy_max'); if(!$last_gen_day) $last_gen_day=$current_day; $day=get_option('atb_dy'); if(!$day) $day=get_transient('atb_dy'); // Find Historical Day Stats function atb_day_stat($params) { if(function_exists('atb_pro_ping')) $blocked_ips='AND ip NOT IN (SELECT blocked_ip FROM wp_aiowps_permanent_block)'; else $blocked_ips=''; $query=" SELECT DATE_FORMAT(date,'%a
%D') as day ,date as date_id ,DATE_FORMAT(CONCAT(date,'-01'),'%b %y') as month,visitors ,visitors FROM ( SELECT LEFT(date,10) as date,COUNT(DISTINCT ip) as visitors FROM wp_atb_pagehits WHERE date>NOW()-INTERVAL 400 DAY $params $blocked_ips AND url NOT LIKE '/wp-%' GROUP BY LEFT(date,10) )a ORDER BY date;"; $day=atb_r($query); return $day; } // Create Historical Day Stats if(!$day) { $day=atb_day_stat("AND date<'$current_day'"); update_option('atb_dy',$day,false); update_option('atb_dy_max',$current_day,false); } // Get Day Stats between last Gen Date and Today if(!$day || $current_day>$last_gen_day) { $day_new=atb_day_stat("AND date>='$last_gen_day' AND date<'$current_day' "); if($day && $day_new){ // Append Historical with Current $day=array_merge($day,$day_new); update_option('atb_dy',$day,false); update_option('atb_dy_max',$current_day,false); delete_transient('atb_dy'); delete_transient('atb_dy_max'); } } // Get Day Stats Today $day_new=atb_day_stat("AND date>='$current_day'"); if(!$day) $day=$day_new; elseif($day_new)$day=array_merge($day,$day_new); // Append Historical with Today $max_visit_avg=0; $max_visit_tot=0; if($mth) foreach($mth as $mth_item) if($mth_item->day_avg>$max_visit_avg) {$max_visit_avg=$mth_item->day_avg; $max_visit_tot=$mth_item->visitors;} ?>
Traffic Summary   
'>
month;?>
visitors);?>
month==$mth_item->month && $day_item->visitors>$max_day_visit_tot) $max_day_visit_tot=$day_item->visitors;?>
month==$mth_item->month){ if($max_day_visit_tot==0) $max_day_visit_tot=.1; ?>
onclick="atb_loading(); window.location.href='&phv=1&date=date_id;?>';">
day;?>
$hide_items{display:none!important}"; } function atb_hide_item_all() { $hide_items=get_option('atb_hide_item_all'); echo ""; } function atb_redirect_hp() { $redirect_hp=get_option('atb_redirect_hp'); $redirect_hp_role=get_option('atb_redirect_hp_role'); $redirect_hp_role=explode(",",$redirect_hp_role); $redirect_hp_role_exclude=get_option('atb_redirect_hp_role_exclude'); $redirect_hp_page=trim(get_option('atb_redirect_hp_page')); $redirect_hp_page=preg_replace("/[\r\n,]+/",',',$redirect_hp_page); if($redirect_hp==1 && !empty($redirect_hp_page)) { $user_roles=atb_cur(); if(!is_array($user_roles)) $user_roles=array_filter(array($user_roles)); if(($redirect_hp_role_exclude==0 && (count(array_intersect($redirect_hp_role,$user_roles))>0 || in_array('*All',$redirect_hp_role,true))) || ($redirect_hp_role_exclude==1 && count(array_intersect($redirect_hp_role,$user_roles))==0 && !in_array('*All',$redirect_hp_role,true))) { if(atb_is_path($redirect_hp_page)) {header("Location: ".site_url()); exit();} } } } function atb_redirect_db() { $redirect_db=get_option('atb_redirect_db'); $redirect_db_role=get_option('atb_redirect_db_role'); $redirect_db_role=explode(",",$redirect_db_role); $redirect_db_role_exclude=get_option('atb_redirect_db_role_exclude'); $redirect_db_page=get_option('atb_redirect_db_page'); $redirect_db_page=preg_replace("/[\r\n,]+/",',',$redirect_db_page); if($redirect_db==1 && !empty($redirect_db_page)) { $user_roles=atb_cur(); if(!is_array($user_roles)) $user_roles=array_filter(array($user_roles)); if(($redirect_db_role_exclude==0 && (count(array_intersect($redirect_db_role,$user_roles))>0 || in_array('*All',$redirect_db_role,true))) || ($redirect_db_role_exclude==1 && count(array_intersect($redirect_db_role,$user_roles))==0 && !in_array('*All',$redirect_db_role,true))) { if(atb_is_path($redirect_db_page)) {header("Location: ".get_admin_url()); exit();} } } } function atb_admin_email_check() { $admin_email_check=get_option('atb_admin_email_check'); if(!empty($admin_email_check)) { add_filter('admin_email_check_interval',function($admin_email_check) { if($admin_email_check<0) return false; else return ($admin_email_check*MONTH_IN_SECONDS); }); } else return get_option('admin_email_lifespan'); } add_filter('admin_email_check_interval','atb_admin_email_check'); function atb_admin_email_rules(){ $on=get_option('atb_admin_email'); if($on!=1&&$on!='1')return; $types=get_option('atb_admin_email_type'); if(!$types)return; $list=preg_split("/[\r\n,]+/",$types); if(!$list||!is_array($list))return; $wc_map=['woocommerce_product_on_backorder_notification'=>'backorder','woocommerce_low_stock_notification'=>'low_stock','woocommerce_no_stock_notification'=>'no_stock']; foreach($list as $t){ $t=trim($t); if($t==='')continue; if(stripos($t,'woocommerce')===0){ if(isset($wc_map[$t])){ add_action('woocommerce_email',function($email)use($t,$wc_map){remove_action($t,[$email,$wc_map[$t]]);}); }else{ add_filter($t,'__return_false'); } }else add_filter($t,'__return_false'); } } add_action('init','atb_admin_email_rules');