While the addon in the first linked answer works, it has a main flaw, it either toggles or sets the selectability of the selected objects, so you can easily disable the selectability but you can't enable it unless you can select the object/s to start with.
The other answer works as expected, which is it toggles every object that is selected in the outliner. While selecting all is easy enough, that may include objects you don't want to toggle. This is really just the same result as the answer by WKG which has always been in blender.
For a simple brute force solution that just enables the three options shown in the outliner for every object -
for o in bpy.data.objects:
o.hide_select = False
o.hide_render = False
o.hide = False
You can easily adjust that to disable them again or just alter one of the options. You could change
bpy.context.selected_objects if you wanted to disable a selection of objects.