You are here

metatag_mobile.module in Metatag 7

Same filename and directory in other branches
  1. 8 metatag_mobile/metatag_mobile.module

Primary hook implementations for Metatag:Mobile.

File

metatag_mobile/metatag_mobile.module
View source
<?php

/**
 * @file
 * Primary hook implementations for Metatag:Mobile.
 */

/**
 * Implements hook_ctools_plugin_api().
 */
function metatag_mobile_ctools_plugin_api($owner, $api) {
  if ($owner == 'metatag' && $api == 'metatag') {
    return array(
      'version' => 1,
    );
  }
}

/**
 * Implements hook_theme().
 */
function metatag_mobile_theme() {
  $info['metatag_mobile_android_app'] = array(
    'render element' => 'element',
  );
  $info['metatag_mobile_ios_app'] = array(
    'render element' => 'element',
  );
  $info['metatag_mobile_alt_handheld'] = array(
    'render element' => 'element',
  );
  return $info;
}

/**
 * Theme callback for an Android app link meta tag.
 *
 * The format is:
 * @code
 * <link rel="alternate" href="android-app://com.example.Example/sitesection/sitepage/thispage" />
 * @endcode
 */
function theme_metatag_mobile_android_app($variables) {

  // Pass everything through to the normal 'link' tag theme.
  $variables['element']['#name'] = 'alternate';
  $variables['element']['#value'] = 'android-app://' . $variables['element']['#value'];
  return theme('metatag_link_rel', $variables);
}

/**
 * Theme callback for an iOS app link meta tag.
 *
 * The format is:
 * @code
 * <link rel="alternate" href="ios-app://123456/example/hello-screen" />
 * @endcode
 */
function theme_metatag_mobile_ios_app($variables) {

  // Pass everything through to the normal 'link' tag theme.
  $variables['element']['#name'] = 'alternate';
  $variables['element']['#value'] = 'ios-app://' . $variables['element']['#value'];
  return theme('metatag_link_rel', $variables);
}

/**
 * Theme callback for a handheld-formatted alternative URL.
 *
 * The format is:
 * @code
 * <link rel="alternate" media="handheld" href="https://phone.example.com/the/page" />
 * @endcode
 */
function theme_metatag_mobile_alt_handheld($variables) {
  $element =& $variables['element'];
  $args = array(
    '#name' => 'rel',
    '#media' => 'media',
    '#value' => 'href',
  );
  element_set_attributes($element, $args);
  unset($element['#value']);
  return theme('html_tag', $variables);
}

/**
 * theme-color
 * MobileOptimized
 * HandheldFriendly
 * viewport
 * cleartype
 * apple-mobile-web-app-capable
 * apple-mobile-web-app-status-bar-style
 * format-detection
 * android-app
 */

Functions

Namesort descending Description
metatag_mobile_ctools_plugin_api Implements hook_ctools_plugin_api().
metatag_mobile_theme Implements hook_theme().
theme_metatag_mobile_alt_handheld Theme callback for a handheld-formatted alternative URL.
theme_metatag_mobile_android_app Theme callback for an Android app link meta tag.
theme_metatag_mobile_ios_app Theme callback for an iOS app link meta tag.