| @@ -32,21 +32,48 @@ | ||
| 32 | 32 | * @package UserAccessManager\Controller |
| 33 | 33 | */ |
| 34 | 34 | class FrontendController extends Controller |
| 35 | 35 | { |
| 36 | - public const HANDLE_STYLE_LOGIN_FORM = 'UserAccessManagerLoginForm'; | |
| 36 | + const HANDLE_STYLE_LOGIN_FORM = 'UserAccessManagerLoginForm'; | |
| 37 | 37 | |
| 38 | + /** | |
| 39 | + * @var MainConfig | |
| 40 | + */ | |
| 41 | + private $mainConfig; | |
| 42 | + | |
| 43 | + /** | |
| 44 | + * @var AccessHandler | |
| 45 | + */ | |
| 46 | + private $accessHandler; | |
| 47 | + | |
| 48 | + /** | |
| 49 | + * FrontendController constructor. | |
| 50 | + * @param Php $php | |
| 51 | + * @param Wordpress $wordpress | |
| 52 | + * @param WordpressConfig $wordpressConfig | |
| 53 | + * @param MainConfig $mainConfig | |
| 54 | + * @param AccessHandler $userHandler | |
| 55 | + */ | |
| 38 | 56 | public function __construct( |
| 39 | 57 | Php $php, |
| 40 | 58 | Wordpress $wordpress, |
| 41 | 59 | WordpressConfig $wordpressConfig, |
| 42 | - private MainConfig $mainConfig, | |
| 43 | - private AccessHandler $accessHandler | |
| 60 | + MainConfig $mainConfig, | |
| 61 | + AccessHandler $userHandler | |
| 44 | 62 | ) { |
| 45 | 63 | parent::__construct($php, $wordpress, $wordpressConfig); |
| 64 | + $this->mainConfig = $mainConfig; | |
| 65 | + $this->accessHandler = $userHandler; | |
| 46 | 66 | } |
| 47 | 67 | |
| 48 | - private function registerStylesAndScripts(): void | |
| 68 | + /** | |
| 69 | + * Functions for other content. | |
| 70 | + */ | |
| 71 | + | |
| 72 | + /** | |
| 73 | + * Register all other styles. | |
| 74 | + */ | |
| 75 | + private function registerStylesAndScripts() | |
| 49 | 76 | { |
| 50 | 77 | $urlPath = $this->wordpressConfig->getUrlPath(); |
| 51 | 78 | |
| 52 | 79 | $this->wordpress->registerStyle( |
| @@ -57,9 +84,12 @@ | ||
| 57 | 84 | 'screen' |
| 58 | 85 | ); |
| 59 | 86 | } |
| 60 | 87 | |
| 61 | - public function enqueueStylesAndScripts(): void | |
| 88 | + /** | |
| 89 | + * The function for the wp_enqueue_scripts action. | |
| 90 | + */ | |
| 91 | + public function enqueueStylesAndScripts() | |
| 62 | 92 | { |
| 63 | 93 | $this->registerStylesAndScripts(); |
| 64 | 94 | $this->wordpress->enqueueStyle(self::HANDLE_STYLE_LOGIN_FORM); |
| 65 | 95 | } |
| @@ -64,11 +94,16 @@ | ||
| 64 | 94 | $this->wordpress->enqueueStyle(self::HANDLE_STYLE_LOGIN_FORM); |
| 65 | 95 | } |
| 66 | 96 | |
| 67 | 97 | /** |
| 98 | + * The function for the get_ancestors filter. | |
| 99 | + * @param array $ancestors | |
| 100 | + * @param int|string $objectId | |
| 101 | + * @param string $objectType | |
| 102 | + * @return array | |
| 68 | 103 | * @throws UserGroupTypeException |
| 69 | 104 | */ |
| 70 | - public function showAncestors(array $ancestors, int|string|null $objectId, string $objectType): array | |
| 105 | + public function showAncestors(array $ancestors, $objectId, string $objectType): array | |
| 71 | 106 | { |
| 72 | 107 | if ($this->mainConfig->lockRecursive() === true |
| 73 | 108 | && $this->accessHandler->checkObjectAccess($objectType, $objectId) === false |
| 74 | 109 | ) { |
| @@ -89,30 +124,17 @@ | ||
| 89 | 124 | * Functions for the redirection and files. |
| 90 | 125 | */ |
| 91 | 126 | |
| 92 | 127 | /** |
| 128 | + * Filter for Yoast SEO Plugin | |
| 129 | + * Hides the url from the site map if the user has no access | |
| 130 | + * @param string $url The url to check | |
| 131 | + * @param string $type The object type | |
| 132 | + * @param object $object The object | |
| 133 | + * @return false|string | |
| 93 | 134 | * @throws UserGroupTypeException |
| 94 | 135 | */ |
| 95 | - public function getWpSeoUrl(array|string $url, string $type, object $object): bool|array|string | |
| 136 | + public function getWpSeoUrl(string $url, string $type, object $object) | |
| 96 | 137 | { |
| 97 | 138 | return ($this->accessHandler->checkObjectAccess($type, $object->ID) === true) ? $url : false; |
| 98 | - } | |
| 99 | - | |
| 100 | - /* | |
| 101 | - * Elementor | |
| 102 | - */ | |
| 103 | - | |
| 104 | - /** | |
| 105 | - * @throws UserGroupTypeException | |
| 106 | - */ | |
| 107 | - public function getElementorContent($content): mixed | |
| 108 | - { | |
| 109 | - $this->wordpress->removeAction('elementor/frontend/the_content', [$this, 'getElementorContent']); | |
| 110 | - $post = $this->wordpress->getCurrentPost(); | |
| 111 | - | |
| 112 | - if ($this->accessHandler->checkObjectAccess($post->post_type, $post->ID) === false) { | |
| 113 | - $content = htmlspecialchars_decode($this->mainConfig->getPostTypeContent($post->post_type)); | |
| 114 | - } | |
| 115 | - | |
| 116 | - return $content; | |
| 117 | 139 | } |
| 118 | 140 | } |