Tested and updated for WordPress 4.0