Drop All Selected To Floor

Just a simple editor script, if someone will search for it. I was placing many tree sprites around terrain, I needed something to drop all selected objects to floor.

using UnityEngine;
using UnityEditor;

public class DropAll : ScriptableObject
{

    [MenuItem("Custom/DropAll")]
    static void DropAllObjects()
    {
        
        Transform[] all = Selection.transforms;
        for (int i = 0; i < all.Length; i++)
        {

            //Check the base first
            if(all[i].collider != null)
            CheckCollider(all[i]);

            //Then, check the children

            foreach (Transform child in all[i])
            {
                CheckCollider(child);
            }

        }


    }

    static void CheckCollider(Transform input)
    {

        RaycastHit[] hits;
        hits = Physics.RaycastAll(new Vector3(input.position.x,input.position.y-input.gameObject.collider.bounds.size.y/2,input.position.z), -Vector3.up, 1000.0F);
        int z = 0;
        while (z < hits.Length)
        {
            RaycastHit hit = hits[z];
            z++;
            input.Translate(new Vector3 (0, 0 ,hit.distance));
        }

    }

}

Hello, Sorry that I have very little knowdlege and experience in coding, so I have copied this to a new csharp script, and tried to use this but I get this 3 errors

1
Assets/DropAll.cs(8,10): error CS0246: The type or namespace name **MenuItem**' could not be found. Are you missing a using directive or an assembly reference? 2 **Assets/DropAll.cs(8,10)**: error CS0246: The type or namespace name MenuItemAttribute’ could not be found. Are you missing a using directive or an assembly reference?
3
Assets/DropAll.cs(12,31): error CS0103: The name `Selection’ does not exist in the current context

Please, does anyone can explain why is this happening and how to fix this?

Thanks very much for any possible help

Maybe the reason is that this from 2011 and we are in 2015 and the csharp inside unity could have changed.



UPDATE to the above

I have just found now this inside the Unity Asset Store that seems to be something in some similar way

Project and Drop to Floor