convert code to WordPress plugin.