plugins_url

URL Path Bug In WordPress.com Video Server

You’ve got to both respect Automattic for releasing their internal code as open source while also giving them a break for not assuring that it works for anybody else. One of their projects, the WordPress.com Video Server is a sophisticated WordPress plugin that handles video transcoding and offers a bit of a YouTube in a box solution for WordPress.

The bug I found is that the code assumes WPMU is running in subdomain mode, rather than subdirectory mode. This assumption causes an ajax request to go to the wrong URL and return the wrong data. The patch simply applies WordPress’ plugins_url() function that debuted in 2.6.

Determining Paths and URLs In WordPress 2.6+

WP 2.6 allows sites to move the wp-content directory around, so plugin developers like me can’t depend on them being in a predictable location. We can look to the WP_CONTENT_DIR and WP_PLUGIN_DIR constants for answers, but a better solution is likely to use the X_url() functions. The most useful of those is likely to be plugins_url(). Even better, you can give these functions a relative path and they’ll return a fully qualified URL to the item.