function metatag_update_delete_config in Metatag 7
Remove a specific meta tag from all configs.
Parameters
string $tag_name: The meta tag that is to be removed.
2 calls to metatag_update_delete_config()
- metatag_verification_update_7100 in metatag_verification/
metatag_verification.install - Remove the Alexa verification tag.
- metatag_verification_update_7101 in metatag_verification/
metatag_verification.install - Remove the Yahoo verification tag.
File
- ./
metatag.install, line 805 - Install, update, and uninstall functions for the metatag module.
Code
function metatag_update_delete_config($tag_name) {
// Find all {metatag_config} records that contained an entry for the meta tag.
$records = db_select('metatag_config', 'm')
->fields('m', array(
'cid',
'config',
))
->condition('m.config', '%' . db_like('"' . $tag_name . '"') . '%', 'LIKE')
->execute();
// This message will be returned if nothing needed to be updated.
$none_message = t('No Metatag configuration records needed to have the "@tag" meta tag removed.', array(
'@tag' => $tag_name,
));
// Loop over the values and correct them.
if ($records
->rowCount() == 0) {
drupal_set_message($none_message);
}
else {
// Loop over the values and correct them.
$counter = 0;
foreach ($records as $record) {
$record->config = unserialize($record->config);
if (isset($record->config[$tag_name])) {
unset($record->config[$tag_name]);
drupal_write_record('metatag_config', $record, array(
'cid',
));
$counter++;
}
}
if ($counter == 0) {
drupal_set_message($none_message);
}
else {
drupal_set_message(t('Removed the "@tag" meta tag for @count configurations.', array(
'@tag' => $tag_name,
'@count' => $counter,
)));
}
}
// Clear all Metatag caches.
cache_clear_all('*', 'cache_metatag', TRUE);
drupal_static_reset('metatag_config_load_with_defaults');
drupal_static_reset('metatag_entity_supports_metatags');
drupal_static_reset('metatag_config_instance_info');
drupal_static_reset('metatag_get_info');
ctools_include('export');
ctools_export_load_object_reset('metatag_config');
}