metatag_hreflang.install 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. /**
  3. * @file
  4. * Various update scripts for Metatag:hrelang.
  5. */
  6. /**
  7. * Implements hook_requirements().
  8. */
  9. function metatag_hreflang_requirements($phase) {
  10. $requirements = array();
  11. // Ensure translations don't break during installation.
  12. $t = get_t();
  13. if ($phase == 'runtime') {
  14. // Check if the Alternative Hreflang module is present.
  15. if (module_exists('hreflang')) {
  16. $requirements['metatag_hreflang'] = array(
  17. 'severity' => REQUIREMENT_ERROR,
  18. 'title' => 'Metatag',
  19. 'value' => $t('The Metatag:hreflang module should not be used at the same time as the hreflang module.'),
  20. 'description' => $t('If both the Metatag:hreflang module and the Alternative Hreflang (hreflang) module are used at the same time it is likely that they will output duplicate meta tags. As a result, it is recommended to only use one at a time.'),
  21. );
  22. }
  23. }
  24. return $requirements;
  25. }
  26. /**
  27. * Implements hook_uninstall().
  28. */
  29. function metatag_hreflang_uninstall() {
  30. // Delete any custom variables that are used.
  31. variable_del('metatag_hreflang_allow_dupe');
  32. }
  33. /**
  34. * Implementations of hook_update_N().
  35. */
  36. /**
  37. * Clear the Metatag cache so the updated hreflang default is caught.
  38. */
  39. function metatag_hreflang_update_7101() {
  40. cache_clear_all('*', 'cache_metatag', TRUE);
  41. return t('All Metatag caches cleared.');
  42. }
  43. /**
  44. * Fix hreflang=xdefault for config definitions.
  45. */
  46. function metatag_hreflang_update_7102() {
  47. module_load_include('install', 'metatag');
  48. $meta_tag = 'hreflang_xdefault';
  49. $old_value = '[node:source:url]';
  50. $new_value = '[node:url-original]';
  51. return metatag_update_replace_config_value($meta_tag, $old_value, $new_value);
  52. }
  53. /**
  54. * Fix hreflang=xdefault for all entities.
  55. */
  56. function metatag_hreflang_update_7103() {
  57. module_load_include('install', 'metatag');
  58. $meta_tag = 'hreflang_xdefault';
  59. $old_value = '[node:source:url]';
  60. $new_value = '[node:url-original]';
  61. return metatag_update_replace_entity_value($sandbox, $meta_tag, $old_value, $new_value);
  62. }