You are here

function google_tag_update_7104 in GoogleTagManager 7

Same name and namespace in other branches
  1. 7.2 google_tag.install \google_tag_update_7104()

Rename 'compact_tag' setting to 'compact_snippet'.

File

./google_tag.install, line 217
Provides install, update, and uninstall functions.

Code

function google_tag_update_7104(&$sandbox) {
  $count = 0;
  $tables = array(
    'variable',
  );
  if (module_exists('variable_realm') && module_exists('variable_store')) {
    global $conf;
    $tables[] = 'variable_store';
    $realms = variable_realm_list();
    foreach ($realms as $realm_name => $realm_title) {
      if (!empty($conf["variable_realm_list_{$realm_name}"])) {
        $items = $conf["variable_realm_list_{$realm_name}"];
        if ($key = array_search('google_tag_compact_tag', $items, TRUE)) {
          $items[$key] = 'google_tag_compact_snippet';
          variable_set("variable_realm_list_{$realm_name}", $items);
          $count++;
        }
      }
    }
  }
  foreach ($tables as $table) {
    $count += db_update($table)
      ->fields(array(
      'name' => 'google_tag_compact_snippet',
    ))
      ->condition('name', 'google_tag_compact_tag')
      ->execute();
  }
  cache_clear_all('variables', 'cache_bootstrap');
  cache_clear_all('variable:', 'cache_bootstrap', TRUE);
  if (module_exists('variable')) {
    variable_cache_clear();
  }
  return t('Converted @count occurrences of setting', array(
    '@count' => $count,
  ));
}