| Total Complexity | 6 |
| Total Lines | 38 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 8 | class LinkManager extends Module |
||
| 9 | { |
||
| 10 | use TargetsInitHook; |
||
| 11 | |||
| 12 | public function hook(): void |
||
| 13 | { |
||
| 14 | $this->targetInitHook(); |
||
| 15 | } |
||
| 16 | |||
| 17 | protected function doInitAction(): void |
||
| 18 | { |
||
| 19 | $enabled = $this->enabledTags(); |
||
| 20 | |||
| 21 | foreach ($this->links() as $tag => $args) { |
||
| 22 | if (!in_array($tag, $enabled)) { |
||
| 23 | $callback = $args[0]; |
||
| 24 | $priority = $args[1] ?? HOOK_DEFAULT_PRIORITY; |
||
| 25 | |||
| 26 | remove_action('wp_head', $callback, $priority); |
||
| 27 | } |
||
| 28 | } |
||
| 29 | } |
||
| 30 | |||
| 31 | protected function links(): array |
||
| 32 | { |
||
| 33 | return [ |
||
| 34 | 'adjacent_posts' => ['adjacent_posts_rel_link_wp_head'], |
||
| 35 | 'canonical' => ['rel_canonical'], |
||
| 36 | 'generator' => ['wp_generator'], |
||
| 37 | 'rsd' => ['rsd_link'], |
||
| 38 | 'shortlink' => ['wp_shortlink_wp_head'], |
||
| 39 | 'wlwmanifest' => ['wlwmanifest_link'], |
||
| 40 | ]; |
||
| 41 | } |
||
| 42 | |||
| 43 | protected function enabledTags(): array |
||
| 46 | } |
||
| 47 | } |
||
| 48 |