In Wordpress, make allowances for web proxy if configured.

My Wordpress installation is behind a web proxy, so the request to Moodle was failing.
This is a quick fix for the issue, which uses the standard Wordpress defined global values for the proxy, which are set in wp-config.