How to Convert a Script that Contains a Class into an Add-On?

I have a script to select the members of selected Collections in the Outliner:

import bpy

class Outliner_OT_Items_Selected(bpy.types.Operator): 
    bl_idname = 'outliner.items_selected'    
    bl_label = "Selected items in Outliner" 
    def execute(self,context):
        scene = context.scene
        scene['outl_coll']  = [c for c in context.selected_ids if c.name in bpy.data.collections]

        return {'FINISHED'}

bpy.utils.register_class(Outliner_OT_Items_Selected)

scene = bpy.data.scenes[bpy.context.scene.name]
scene['outl_coll'] = []

def call_op_with_override():
    ctxt = bpy.context.copy()
    for area in bpy.context.screen.areas:
        if area.type == 'OUTLINER':   
            ctxt["area"] = area
            bpy.ops.outliner.items_selected(ctxt)
            break
     
call_op_with_override()
   
selected_collections = scene['outl_coll']

for collection in selected_collections:
    # Iterate over objects in each collection
    for obj in collection.objects:
        # Select the object
        obj.select_set(True)

I would like to convert the script into an add-on, so I would be able to execute it by right-clicking the selected Collections in the Outliner and subsequently clicking a command, but the script contains a class.

How to convert the script into an add-on for the Outliner?

Go to the scripting Workspace in Blender. In the script editor use Menu → Templates → Python.
They are all sorts of mini examples there that get you started if this is new for you, eg “Addon Add Object” contains everything you need.