add_action('wp_uninitialize_site', __NAMESPACE__ . '\\clear_mappings_on_delete'); /** * Clear mappings for a site when it's deleted * * @param obj $site Site object that is being deleted */ function clear_mappings_on_delete($site) { $mappings = Mapping::get_by_site($site->blog_id); if (empty($mappings)) { return; } foreach ($mappings as $mapping) { $error = $mapping->delete(); if (is_wp_error($error)) { $message = sprintf( __('Unable to delete mapping %1$d for site %2$d', 'mercator'), $mapping->get_id(), $site_id ); trigger_error($message, E_USER_WARNING); } } }
add_action('wp_uninitialize_site', NAMESPACE . '\clear_mappings_on_delete');
/**
Clear mappings for a site when it's deleted
@param obj $site Site object that is being deleted
*/
function clear_mappings_on_delete($site)
{
$mappings = Mapping::get_by_site($site->blog_id);
if (empty($mappings)) {
return;
}
foreach ($mappings as $mapping) {
$error = $mapping->delete();
}
}