function metatag_hreflang_metatag_bundled_config_alter in Metatag 7
Implements hook_metatag_bundled_config_alter().
This provides recommended defaults that should be sufficient for most sites.
File
- metatag_hreflang/
metatag_hreflang.metatag.inc, line 13 - Metatag integration for the Metatag:hreflang module.
Code
function metatag_hreflang_metatag_bundled_config_alter(array &$configs) {
// This only makes sense if either the Translation or Entity Translation
// modules are enabled.
if (!(module_exists('translation') || module_exists('entity_translation'))) {
return;
}
foreach ($configs as &$config) {
switch ($config->instance) {
case 'node':
// The x-default should default to the source language.
$config->config += array(
'hreflang_xdefault' => array(
'value' => '[node:url-original]',
),
);
// Add all of the other hreflang values.
$languages = language_list('enabled');
if (!empty($languages[1])) {
foreach (array_keys($languages[1]) as $langcode) {
$config->config += array(
'hreflang_' . $langcode => array(
'value' => '[node:url-' . $langcode . ']',
),
);
}
}
break;
}
}
}