public static function revert_type_to_default($extension) {
        $extension = (string)$extension;

        // Check it actually is a default type.
        $defaults = self::get_default_types();
        if (!array_key_exists($extension, $defaults)) {
            throw new coding_exception('Extension ' . $extension . ' is not a default type');
        }

        // Loop through all the custom settings.
        $changed = false;
        $customs = self::get_custom_types();
        foreach ($customs as $key => $customentry) {
            if ($customentry->extension === $extension) {
                unset($customs[$key]);
                $changed = true;
            }
        }

        // Save changes if any.
        if ($changed) {
            self::set_custom_types($customs);
        }
        return $changed;
    }