Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

delete_blog hook is delete_blog - Suggested hook wp_uninitialize_site mercator.php #113

Open
jerrickhakim opened this issue Dec 12, 2019 · 0 comments

Comments

@jerrickhakim
Copy link

jerrickhakim commented Dec 12, 2019

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);
     }
    

    }
    }

r-a-y added a commit to r-a-y/Mercator that referenced this issue Oct 13, 2020
'delete_blog' was deprecated in WordPress 5.1.0.

Fixes humanmade#108, humanmade#113.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant