Updated all the contrib modules to their latest versions.
[yaffs-website] / web / modules / contrib / metatag / metatag_open_graph / metatag_open_graph.module
1 <?php
2
3 /**
4  * @file
5  * Contains metatag_open_graph.module.
6  */
7
8 /**
9  * Implements template_preprocess_html().
10  */
11 function metatag_open_graph_preprocess_html(&$variables) {
12   if (!metatag_is_current_route_supported()) {
13     return;
14   }
15
16   // Add XML namespaces if the RDF module is not enabled as it adds these two
17   // automatically.
18   if (!isset($variables['html_attributes'])) {
19     $variables['html_attributes'] = [];
20   }
21   $namespaces = [];
22   if (!\Drupal::moduleHandler()->moduleExists('rdf')) {
23     $namespaces = [
24       'prefix' => 'og: http://ogp.me/ns#',
25     ];
26   }
27
28   // Namespaces for Google+.
29   if (isset($variables['itemtype'])) {
30     $namespaces['itemscope'] = '';
31     $namespaces['itemtype'] = "http://schema.org/{$variables['itemtype']}";
32   }
33
34   // Append each namespace.
35   foreach ($namespaces as $namespace => $uri) {
36     $variables['html_attributes'][$namespace] = $uri;
37   }
38 }