WPLib::get_module_dir PHP Method

get_module_dir() static public method

static public get_module_dir ( WPLib_Item_Base | string | boolean $item_class = false ) : string | null
$item_class WPLib_Item_Base | string | boolean
return string | null
    static function get_module_dir($item_class = false)
    {
        if (!$item_class) {
            $item_class = get_called_class();
        } else {
            if (is_object($item_class)) {
                $item_class = get_class($item_class);
            }
        }
        $reflector = new ReflectionClass($item_class);
        $filepath = self::maybe_make_abspath_relative($reflector->getFileName());
        $app_class = self::app_class();
        $module_dir = null;
        foreach (self::get_module_classes($app_class) as $module_class => $module_filepath) {
            if (0 === strpos($filepath, $module_filepath)) {
                $module_dir = self::maybe_make_absolute_path($module_filepath, ABSPATH);
                break;
            }
        }
        return $module_dir;
    }