metatag_opengraph.install 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <?php
  2. /**
  3. * @file
  4. * Installation and update scripts for Metatag:OpenGraph.
  5. */
  6. /**
  7. * Implements hook_requirements().
  8. */
  9. function metatag_opengraph_requirements($phase) {
  10. $requirements = array();
  11. // Ensure translations don't break during installation.
  12. $t = get_t();
  13. if ($phase == 'runtime') {
  14. if (module_exists('rdf')) {
  15. // Work out the release of D7 that is currently running.
  16. list($major, $minor) = explode('.', VERSION);
  17. // Strip off any suffixes on the version string, e.g. "17-dev".
  18. if (strpos('-', $minor)) {
  19. list($minor, $suffix) = explode('-', $minor);
  20. }
  21. if ($minor < 33) {
  22. $requirements['metatag_og_rdf'] = array(
  23. 'severity' => REQUIREMENT_WARNING,
  24. 'title' => 'Metatag:OpenGraph',
  25. 'value' => $t('RDF problems with Drupal core releases before v7.33'),
  26. 'description' => $t('The core RDF module in Drupal before v7.33 caused validation problems for Open Graph meta tags. The solution is to update to v7.33 or newer.'),
  27. );
  28. }
  29. }
  30. }
  31. return $requirements;
  32. }
  33. /**
  34. * Implements hook_update_dependencies().
  35. */
  36. function metatag_opengraph_update_dependencies() {
  37. // OpenGraph update 7103 requires the complete Metatag schema, so lets wait
  38. // for Metatag update 7100 just to be sure.
  39. $dependencies['metatag_opengraph'][7103] = array(
  40. 'metatag' => 7100,
  41. );
  42. return $dependencies;
  43. }
  44. /**
  45. * Implementations of hook_update_N().
  46. */
  47. /**
  48. * Enable the new Metatag:Facebook submodule.
  49. */
  50. function metatag_opengraph_update_7100() {
  51. module_enable(array('metatag_facebook'));
  52. drupal_set_message(t('Enabled the new Metatag:Facebook submodule. If the Facebook meta tags are not being used then it is safe to disable.'));
  53. }
  54. /**
  55. * Leave a warning about the two og:type value changes.
  56. */
  57. function metatag_opengraph_update_7101() {
  58. drupal_set_message(t('The "Movie" and "TV Show" values for the "Content type" open graph meta tag changed, if this site used those values they will need to be manually updated.'));
  59. }
  60. /**
  61. * The Open Graph Products meta tags are now in a new submodule.
  62. */
  63. function metatag_opengraph_update_7102() {
  64. drupal_set_message(t('The Open Graph Products meta tags have been moved into the new "Metatag: Open Graph Products" submodule.'));
  65. }
  66. /**
  67. * Change og:video to og:video:url in all metatags.
  68. */
  69. function metatag_opengraph_update_7103(&$sandbox) {
  70. module_load_include('install', 'metatag');
  71. $old_tag = 'og:video';
  72. $new_tag = 'og:video:url';
  73. return metatag_update_replace_entity_tag($sandbox, $old_tag, $new_tag);
  74. }
  75. /**
  76. * Rename the 'og:video' meta tag to 'og:video:url' in the configs.
  77. */
  78. function metatag_opengraph_update_7104() {
  79. module_load_include('install', 'metatag');
  80. $old_tag = 'og:video';
  81. $new_tag = 'og:video:url';
  82. return metatag_update_replace_config_tag($old_tag, $new_tag);
  83. }
  84. /**
  85. * Clear the Metatag cache to pick up changes to og:video.
  86. */
  87. function metatag_opengraph_update_7105() {
  88. cache_clear_all('*', 'cache_metatag', TRUE);
  89. return t('All Metatag caches cleared.');
  90. }
  91. /**
  92. * Clear the Metatag cache to pick up changes to og:audio:secure_url.
  93. */
  94. function metatag_opengraph_update_7106() {
  95. cache_clear_all('*', 'cache_metatag', TRUE);
  96. return t('All Metatag caches cleared.');
  97. }