You are here

metatag_opengraph.install in Metatag 7

Installation and update scripts for Metatag:OpenGraph.

File

metatag_opengraph/metatag_opengraph.install
View source
<?php

/**
 * @file
 * Installation and update scripts for Metatag:OpenGraph.
 */

/**
 * Implements hook_requirements().
 */
function metatag_opengraph_requirements($phase) {
  $requirements = array();

  // Ensure translations don't break during installation.
  $t = get_t();
  if ($phase == 'runtime') {
    if (module_exists('rdf')) {

      // Work out the release of D7 that is currently running.
      list($major, $minor) = explode('.', VERSION);

      // Strip off any suffixes on the version string, e.g. "17-dev".
      if (strpos('-', $minor)) {
        list($minor, $suffix) = explode('-', $minor);
      }
      if ($minor < 33) {
        $requirements['metatag_og_rdf'] = array(
          'severity' => REQUIREMENT_WARNING,
          'title' => 'Metatag:OpenGraph',
          'value' => $t('RDF problems with Drupal core releases before v7.33'),
          '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.'),
        );
      }
    }
  }
  return $requirements;
}

/**
 * Implements hook_update_dependencies().
 */
function metatag_opengraph_update_dependencies() {

  // OpenGraph update 7103 requires the complete Metatag schema, so lets wait
  // for Metatag update 7100 just to be sure.
  $dependencies['metatag_opengraph'][7103] = array(
    'metatag' => 7100,
  );
  return $dependencies;
}

/**
 * Implements hook_uninstall().
 */
function metatag_opengraph_uninstall() {

  // Remove all of the maxlength variables.
  variable_del('metatag_maxlength_og:title');
  variable_del('metatag_maxlength_og:description');
}

/**
 * Implementations of hook_update_N().
 */

/**
 * Enable the new Metatag:Facebook submodule.
 */
function metatag_opengraph_update_7100() {
  module_enable(array(
    'metatag_facebook',
  ));
  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.'));
}

/**
 * Leave a warning about the two og:type value changes.
 */
function metatag_opengraph_update_7101() {
  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.'));
}

/**
 * The Open Graph Products meta tags are now in a new submodule.
 */
function metatag_opengraph_update_7102() {
  drupal_set_message(t('The Open Graph Products meta tags have been moved into the new "Metatag: Open Graph Products" submodule.'));
}

/**
 * Change og:video to og:video:url in all metatags.
 */
function metatag_opengraph_update_7103(&$sandbox) {
  module_load_include('install', 'metatag');
  $old_tag = 'og:video';
  $new_tag = 'og:video:url';
  return metatag_update_replace_entity_tag($sandbox, $old_tag, $new_tag);
}

/**
 * Rename the 'og:video' meta tag to 'og:video:url' in the configs.
 */
function metatag_opengraph_update_7104() {
  module_load_include('install', 'metatag');
  $old_tag = 'og:video';
  $new_tag = 'og:video:url';
  return metatag_update_replace_config_tag($old_tag, $new_tag);
}

/**
 * Clear the Metatag cache to pick up changes to og:video.
 */
function metatag_opengraph_update_7105() {
  cache_clear_all('*', 'cache_metatag', TRUE);
  return t('All Metatag caches cleared.');
}

/**
 * Clear the Metatag cache to pick up changes to og:audio:secure_url.
 */
function metatag_opengraph_update_7106() {
  cache_clear_all('*', 'cache_metatag', TRUE);
  return t('All Metatag caches cleared.');
}

Functions

Namesort descending Description
metatag_opengraph_requirements Implements hook_requirements().
metatag_opengraph_uninstall Implements hook_uninstall().
metatag_opengraph_update_7100 Enable the new Metatag:Facebook submodule.
metatag_opengraph_update_7101 Leave a warning about the two og:type value changes.
metatag_opengraph_update_7102 The Open Graph Products meta tags are now in a new submodule.
metatag_opengraph_update_7103 Change og:video to og:video:url in all metatags.
metatag_opengraph_update_7104 Rename the 'og:video' meta tag to 'og:video:url' in the configs.
metatag_opengraph_update_7105 Clear the Metatag cache to pick up changes to og:video.
metatag_opengraph_update_7106 Clear the Metatag cache to pick up changes to og:audio:secure_url.
metatag_opengraph_update_dependencies Implements hook_update_dependencies().