Updated all the contrib modules to their latest versions.
[yaffs-website] / web / modules / contrib / metatag / metatag_favicons / metatag_favicons.module
1 <?php
2
3 /**
4  * @file
5  * Custom hook implementations for Metatag Favicons.
6  */
7
8 use Drupal\Core\Routing\RouteMatchInterface;
9
10 /**
11  * Implements hook_help().
12  */
13 function metatag_favicons_help($route_name, RouteMatchInterface $route_match) {
14   switch ($route_name) {
15     // Main module help for the metatag_favicons module.
16     case 'help.page.metatag_favicons':
17       $output = '';
18       $output .= '<h3>' . t('About') . '</h3>';
19       $output .= '<p>' . t('Provides support for many different favicons.') . '</p>';
20       return $output;
21
22     default:
23   }
24 }
25
26 /**
27  * Implements hook_page_attachments_alter().
28  */
29 function metatag_favicons_page_attachments_alter(array &$attachments) {
30   // Check html_head_link on attached tags in head.
31   if (!isset($attachments['#attached']['html_head_link'])) {
32     return;
33   }
34
35   // Remove the default shortcut icon if one was set by Metatag.
36   foreach ($attachments['#attached']['html_head'] as $element) {
37     if (isset($element[1]) && $element[1] == 'shortcut_icon') {
38       foreach ($attachments['#attached']['html_head_link'] as $key => $value) {
39         if (isset($value[0]['rel']) && $value[0]['rel'] == 'shortcut icon') {
40           unset($attachments['#attached']['html_head_link'][$key]);
41         }
42       }
43     }
44   }
45 }