public static function is_allowed($pod_name, $cap, &$debug = null) { if (core_utilities::isAdministrator(wp_get_current_user())) { if ($debug != NULL) { $debug .= "<pre>isAdministrator</pre>"; } return TRUE; } //sys_admin $user = wp_get_current_user(); if ($debug != NULL) { $debug .= "<pre>" . var_export($user, TRUE) . "</pre>"; } if (!empty($user->roles) && is_array($user->roles)) { if (in_array("sys_admin", $user->roles)) { return TRUE; } } if ($debug != NULL) { $debug .= "<h4>CAP</h4><pre>" . var_export($cap, TRUE) . "</pre>"; } if (is_array($cap)) { foreach ($cap as $c) { if (current_user_can("pods_{$c}" . "_{$pod_name}")) { if ($debug != NULL) { $debug .= "<pre>" . var_export($c, TRUE) . "</pre>"; } return TRUE; } } } elseif (current_user_can("pods_{$cap}" . "_{$pod_name}")) { return TRUE; } return FALSE; }
function block_wp_admin_init() { header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); header('Cache-Control: no-store, no-cache, must-revalidate'); header('Cache-Control: post-check=0, pre-check=0', FALSE); header('Pragma: no-cache'); if (!core_utilities::isAdministrator(wp_get_current_user())) { show_admin_bar(false); } if (strpos(strtolower($_SERVER['REQUEST_URI']), '/wp-admin/') !== false) { if (is_user_logged_in()) { if (!core_utilities::isAdministrator(wp_get_current_user())) { wp_redirect(get_option('siteurl'), 302); exit; } } else { wp_redirect(get_option('siteurl'), 302); exit; } } }