wordpress; } public function getLoginFormHtml(): string { $loginForm = $this->wordpress->isUserLoggedIn() === false ? $this->getIncludeContents('LoginForm.php') : ''; return $this->wordpress->applyFilters('uam_login_form', $loginForm); } public function loginFormShortCode(): string { return $this->getLoginFormHtml(); } public function publicShortCode(mixed $attributes, string $content = ''): string { return ($this->wordpress->isUserLoggedIn() === false) ? $this->wordpress->doShortCode($content) : ''; } private function getUserGroupsMapFromAttributes(array $attributes): array { $userGroups = (isset($attributes['group']) === true) ? explode(',', $attributes['group']) : []; return array_flip(array_map('trim', $userGroups)); } /** * @throws UserGroupTypeException */ public function privateShortCode(array $attributes, string $content = ''): string { if ($this->wordpress->isUserLoggedIn() === true) { $userGroupMap = $this->getUserGroupsMapFromAttributes($attributes); if ($userGroupMap === []) { return $this->wordpress->doShortCode($content); } $userUserGroups = $this->userGroupHandler->getUserGroupsForUser(); foreach ($userUserGroups as $userGroup) { if (isset($userGroupMap[$userGroup->getId()]) || isset($userGroupMap[$userGroup->getName()]) ) { return $this->wordpress->doShortCode($content); } } } return ''; } }