$path = new RecursiveDirectoryIterator(trailingslashit($path)); $recIterator = new RecursiveIteratorIterator($path); $regex = new RegexIterator($recIterator, '/\\/' . $file . '$/i'); foreach ($regex as $item) { require_once $item->getPathname(); } } else { foreach (glob(trailingslashit($path) . '*/' . $file) as $item) { require_once $item; } } } static function get_post_type() { global $post, $typenow, $current_screen; //we have a post so we can just get the post type from that if ($post && $post->post_type) { return $post->post_type; } elseif ($typenow) { return $typenow; } elseif ($current_screen && $current_screen->post_type) { return $current_screen->post_type; } elseif (isset($_REQUEST['post_type'])) { return sanitize_key($_REQUEST['post_type']); } //we do not know the post type! return null; } } AlfathAdmin::init(); }