WordPress#

This past weekend, I had a bit of free time to try something I’ve always been curious about. What would it take to port the WP_Hook class from WordPress/PHP to C#?

So, I did it. It took a few hours, at most. I even went so far as to port the unit tests. It looks quite ugly. If you’d like to check it out, you can find it on Github: https://github.com/withinboredom/WordPress-sharp/tree/master/WordPress/Includes

Interestingly, while doing this little exercise, I found a typo in the existing WordPress unit tests and submitted a patch: https://core.trac.wordpress.org/ticket/42311

Using the WpHook Class

Well, you don’t. Instead you initiate a Hook Manager, which is a semi-smart hash map:

It still has some ways to go, mostly more tests which I’ll happily port back to WordPress since I discovered a couple of cases missed by tests.