Commit 32758e7e authored by Jim Birch's avatar Jim Birch Committed by Damien McKenna
Browse files

Issue #3077780 by thejimbirch, volkswagenchick, DamienMcKenna: Add new meta...

Issue #3077780 by thejimbirch, volkswagenchick, DamienMcKenna: Add new meta tag: Google's new "handheld" link alternate URL (D8)
parent 0e5c8131
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -8,6 +8,8 @@ Metatag 8.x-1.x-dev, xxxx-xx-xx
  ROBOTS selector.
#3052628 by Neslee Canil Pinto, cindytwilliams, DamienMcKenna: Capitalize the
  name of the favicons submodule.
#3077780 by thejimbirch, volkswagenchick, DamienMcKenna: Add new meta tag:
  Google's new "handheld" link alternate URL.


Metatag 8.x-1.10, 2019-08-29
+3 −0
Original line number Diff line number Diff line
@@ -2,6 +2,9 @@
# could get longer, especially ones which use a textarea field instead of a
# textfield.

metatag.metatag_tag.alternate_handheld:
  type: label
  label: 'Handheld URL'
metatag.metatag_tag.android_app_link_alternative:
  type: label
  label: 'Android Mobile: Android App Link Alternative'
+29 −0
Original line number Diff line number Diff line
<?php

namespace Drupal\metatag_mobile\Plugin\metatag\Tag;

/**
 * The alternate_handheld meta tag.
 *
 * @MetatagTag(
 *   id = "alternate_handheld",
 *   label = @Translation("Handheld URL"),
 *   description = @Translation("Provides an absolute URL to a specially formatted version of the current page designed for 'feature phones', mobile phones that do not support modern browser standards. See the <a href='https://developers.google.com/webmasters/mobile-sites/mobile-seo/other-devices?hl=en#feature_phones'>official Google Mobile SEO Guide</a> for details on how the page should be formatted."),
 *   name = "alternate",
 *   group = "mobile",
 *   weight = 8,
 *   type = "uri",
 *   secure = FALSE,
 *   multiple = FALSE
 * )
 */
class alternateHandheld extends LinkMediaBase {

  /**
   * {@inheritdoc}
   */
  protected function media() {
    return 'handheld';
  }

}
+39 −0
Original line number Diff line number Diff line
<?php

namespace Drupal\metatag_mobile\Plugin\metatag\Tag;

use Drupal\metatag\Plugin\metatag\Tag\LinkRelBase;

/**
 * This base plugin allows "link rel" tags with a "media" attribute.
 */
abstract class LinkMediaBase extends LinkRelBase {

  /**
   * {@inheritdoc}
   */
  public function output() {
    $element = parent::output();

    if ($element) {
      $element['#attributes'] = [
        'rel' => $this->name(),
        'media' => $this->media(),
        'href' => $element['#attributes']['href'],
      ];
    }

    return $element;
  }

  /**
   * The dimensions supported by this icon.
   *
   * @return string
   *   A string for the desired media type.
   */
  protected function media() {
    return '';
  }

}
+1 −0
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@ class MetatagMobileTagsTest extends MetatagTagsTestBase {
   * {@inheritdoc}
   */
  private $tags = [
    'alternate_handheld',
    'android_app_link_alternative',
    'android_manifest',
    'apple_itunes_app',
Loading