changed the check against direct access to php files

These changes implement best practice for the check against direct access to the php files of the wp plugin. It returns proper 403 headers in most (nothing is perfect) environments.
It also reduces the usage of PHP globals. Usage of PHP globals where not absolutely necessary is considered bad practice.