initial version, from WordPress 3.9.1 with some changes