Loading CHANGELOG.txt +2 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,8 @@ Metatag 8.x-1.x-dev, xxxx-xx-xx verification. #3101288 by chr.fritsch: Fix namespace and imports. #3090002 by DamienMcKenna: Rename migrate plugins to follow naming conventions. #3099168 by jedihe, DamienMcKenna, docans: Remove "title" meta tag, leave the regular title tag. Metatag 8.x-1.10, 2019-08-29 Loading metatag.module +17 −1 Original line number Diff line number Diff line Loading @@ -166,6 +166,18 @@ function metatag_page_attachments(array &$attachments) { ]; } } // Remove the erroneous "title" meta tag as the page title has already been // overridden. // @see metatag_preprocess_html() if (!empty($attachments['#attached']['html_head'])) { foreach ($attachments['#attached']['html_head'] as $ctr => $data) { if (!empty($data[1]) && $data[1] == 'title') { unset($attachments['#attached']['html_head'][$ctr]); break; } } } } /** Loading Loading @@ -414,7 +426,9 @@ function metatag_preprocess_html(&$variables) { return NULL; } // Load the page title. // Copy the "title" meta tag into the regular <title> tag. The redundant meta // tag will be removed elsewhere. // @see metatag_page_attachments() if (!empty($attachments['#attached']['html_head'])) { foreach ($attachments['#attached']['html_head'] as $attachment) { if (!empty($attachment[1]) && $attachment[1] == 'title') { Loading @@ -422,6 +436,8 @@ function metatag_preprocess_html(&$variables) { // the meta title. $variables['head_title'] = []; $variables['head_title']['title'] = html_entity_decode($attachment[0]['#attributes']['content'], ENT_QUOTES); // No need to do anything else after this. break; } } Loading tests/src/Functional/MetatagFrontpageTest.php +40 −8 Original line number Diff line number Diff line Loading @@ -71,8 +71,16 @@ class MetatagFrontpageTest extends BrowserTestBase { $this->drupalGet('<front>'); foreach ($edit as $metatag => $metatag_value) { $xpath = $this->xpath("//meta[@name='" . $metatag . "']"); if ($metatag == 'title') { $this->assertEqual(count($xpath), 0, 'Title meta tag not found.'); $xpath = $this->xpath("//title"); $this->assertEqual(count($xpath), 1, 'Head title tag found.'); $value = $xpath[0]->getText(); } else { $this->assertEqual(count($xpath), 1, 'Exactly one ' . $metatag . ' meta tag found.'); $value = $xpath[0]->getAttribute('content'); } $this->assertEqual($value, $metatag_value); } Loading @@ -81,8 +89,16 @@ class MetatagFrontpageTest extends BrowserTestBase { $this->drupalGet($node_path); foreach ($edit as $metatag => $metatag_value) { $xpath = $this->xpath("//meta[@name='" . $metatag . "']"); if ($metatag == 'title') { $this->assertEqual(count($xpath), 0, 'Title meta tag not found.'); $xpath = $this->xpath("//title"); $this->assertEqual(count($xpath), 1, 'Head title tag found.'); $value = $xpath[0]->getText(); } else { $this->assertEqual(count($xpath), 1, 'Exactly one ' . $metatag . ' meta tag found.'); $value = $xpath[0]->getAttribute('content'); } $this->assertEqual($value, $metatag_value); } Loading Loading @@ -130,8 +146,16 @@ class MetatagFrontpageTest extends BrowserTestBase { $this->drupalGet('<front>'); foreach ($edit as $metatag => $metatag_value) { $xpath = $this->xpath("//meta[@name='" . $metatag . "']"); if ($metatag == 'title') { $this->assertEqual(count($xpath), 0, 'Title meta tag not found.'); $xpath = $this->xpath("//title"); $this->assertEqual(count($xpath), 1, 'Head title tag found.'); $value = $xpath[0]->getText(); } else { $this->assertEqual(count($xpath), 1, 'Exactly one ' . $metatag . ' meta tag found.'); $value = $xpath[0]->getAttribute('content'); } $this->assertEqual($value, $metatag_value); } Loading Loading @@ -160,8 +184,16 @@ class MetatagFrontpageTest extends BrowserTestBase { $this->assertResponse(200); foreach ($edit as $metatag => $metatag_value) { $xpath = $this->xpath("//meta[@name='" . $metatag . "']"); if ($metatag == 'title') { $this->assertEqual(count($xpath), 0, 'Title meta tag not found.'); $xpath = $this->xpath("//title"); $this->assertEqual(count($xpath), 1, 'Head title tag found.'); $value = $xpath[0]->getText(); } else { $this->assertEqual(count($xpath), 1, 'Exactly one ' . $metatag . ' meta tag found.'); $value = $xpath[0]->getAttribute('content'); } $this->assertEqual($value, $metatag_value); } } Loading Loading
CHANGELOG.txt +2 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,8 @@ Metatag 8.x-1.x-dev, xxxx-xx-xx verification. #3101288 by chr.fritsch: Fix namespace and imports. #3090002 by DamienMcKenna: Rename migrate plugins to follow naming conventions. #3099168 by jedihe, DamienMcKenna, docans: Remove "title" meta tag, leave the regular title tag. Metatag 8.x-1.10, 2019-08-29 Loading
metatag.module +17 −1 Original line number Diff line number Diff line Loading @@ -166,6 +166,18 @@ function metatag_page_attachments(array &$attachments) { ]; } } // Remove the erroneous "title" meta tag as the page title has already been // overridden. // @see metatag_preprocess_html() if (!empty($attachments['#attached']['html_head'])) { foreach ($attachments['#attached']['html_head'] as $ctr => $data) { if (!empty($data[1]) && $data[1] == 'title') { unset($attachments['#attached']['html_head'][$ctr]); break; } } } } /** Loading Loading @@ -414,7 +426,9 @@ function metatag_preprocess_html(&$variables) { return NULL; } // Load the page title. // Copy the "title" meta tag into the regular <title> tag. The redundant meta // tag will be removed elsewhere. // @see metatag_page_attachments() if (!empty($attachments['#attached']['html_head'])) { foreach ($attachments['#attached']['html_head'] as $attachment) { if (!empty($attachment[1]) && $attachment[1] == 'title') { Loading @@ -422,6 +436,8 @@ function metatag_preprocess_html(&$variables) { // the meta title. $variables['head_title'] = []; $variables['head_title']['title'] = html_entity_decode($attachment[0]['#attributes']['content'], ENT_QUOTES); // No need to do anything else after this. break; } } Loading
tests/src/Functional/MetatagFrontpageTest.php +40 −8 Original line number Diff line number Diff line Loading @@ -71,8 +71,16 @@ class MetatagFrontpageTest extends BrowserTestBase { $this->drupalGet('<front>'); foreach ($edit as $metatag => $metatag_value) { $xpath = $this->xpath("//meta[@name='" . $metatag . "']"); if ($metatag == 'title') { $this->assertEqual(count($xpath), 0, 'Title meta tag not found.'); $xpath = $this->xpath("//title"); $this->assertEqual(count($xpath), 1, 'Head title tag found.'); $value = $xpath[0]->getText(); } else { $this->assertEqual(count($xpath), 1, 'Exactly one ' . $metatag . ' meta tag found.'); $value = $xpath[0]->getAttribute('content'); } $this->assertEqual($value, $metatag_value); } Loading @@ -81,8 +89,16 @@ class MetatagFrontpageTest extends BrowserTestBase { $this->drupalGet($node_path); foreach ($edit as $metatag => $metatag_value) { $xpath = $this->xpath("//meta[@name='" . $metatag . "']"); if ($metatag == 'title') { $this->assertEqual(count($xpath), 0, 'Title meta tag not found.'); $xpath = $this->xpath("//title"); $this->assertEqual(count($xpath), 1, 'Head title tag found.'); $value = $xpath[0]->getText(); } else { $this->assertEqual(count($xpath), 1, 'Exactly one ' . $metatag . ' meta tag found.'); $value = $xpath[0]->getAttribute('content'); } $this->assertEqual($value, $metatag_value); } Loading Loading @@ -130,8 +146,16 @@ class MetatagFrontpageTest extends BrowserTestBase { $this->drupalGet('<front>'); foreach ($edit as $metatag => $metatag_value) { $xpath = $this->xpath("//meta[@name='" . $metatag . "']"); if ($metatag == 'title') { $this->assertEqual(count($xpath), 0, 'Title meta tag not found.'); $xpath = $this->xpath("//title"); $this->assertEqual(count($xpath), 1, 'Head title tag found.'); $value = $xpath[0]->getText(); } else { $this->assertEqual(count($xpath), 1, 'Exactly one ' . $metatag . ' meta tag found.'); $value = $xpath[0]->getAttribute('content'); } $this->assertEqual($value, $metatag_value); } Loading Loading @@ -160,8 +184,16 @@ class MetatagFrontpageTest extends BrowserTestBase { $this->assertResponse(200); foreach ($edit as $metatag => $metatag_value) { $xpath = $this->xpath("//meta[@name='" . $metatag . "']"); if ($metatag == 'title') { $this->assertEqual(count($xpath), 0, 'Title meta tag not found.'); $xpath = $this->xpath("//title"); $this->assertEqual(count($xpath), 1, 'Head title tag found.'); $value = $xpath[0]->getText(); } else { $this->assertEqual(count($xpath), 1, 'Exactly one ' . $metatag . ' meta tag found.'); $value = $xpath[0]->getAttribute('content'); } $this->assertEqual($value, $metatag_value); } } Loading