Skip to content

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

@jerrickhakim

Description

@jerrickhakim

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

    }
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions