Copy the script and save it as wifi.sh in your home directory. Make it executable:
chmod +x wifi.sh
Now, to add the button. Switch to a desktop where you wish to place it, go to edit mode (long tap on the screen or tap on an empty space and tap the gear button that appears on top). Add Desktop Command Execution Widget from the menu, and click the wrench on the widget that appeared. Select the “Add cmd” option on the right. Name the command “Enable/Disable WiFi” or however you’d like, in command put this:
Add the command, you’ll be kicked back to the edit mode, so press the wrench again. You’ll see that the new command was already chosen (if it is not, chose it), so you need just to adjust a few options, check the “Update on click” option and uncheck “Update on boot” and “Update on desktop change” buttons. Ta-da! Now you have a button to completely disable the WiFi when you don’t need it and enable it on need, which will save up quite some battery charge.