Symlinked Plugins in WordPress 3.9

One of the cool little features included with 3.9 is the ability to symlink plugin directories. While it has been possible to symlink plugins in the past, functions such as plugins_url() return the wrong URL, which causes breakage in most plugins.

In #16953, r27158 and the followup r27999, we corrected this with the help of a new function: wp_register_plugin_realpath(). This function is called automatically during the plugin loading phase, and registers which plugin directories are symlinked, and where they’re symlinked to. This functionality is then used by plugin_basename() (the core of plugins_url(), along with other
functions) to reverse symlinks and find the correct plugin directory.

This enhancement means that you can symlink individual plugin directories, or even the whole plugins directory itself.

For anyone who’d like to use this, keep in mind that there are a few caveats:

  • Single-file plugins are not handled by this code. Any plugins you’d like to symlink must be in subdirectories of the main plugins folder. This restriction is due to the way these paths are registered.

    You can still symlink single-file plugins, however any use of plugin_basename() will be as broken as it was before 3.9. This is not a huge issue, as the main use of this is in plugins_url(), which is not frequently used in single-file plugins.

  • Must-use plugins cannot be symlinked. For the same reasons as single-file plugins, mu-plugins are not handled.

    For anyone using the common pattern of subdirectories within mu-plugins with a common loader file, you can use wp_register_plugin_realpath() directly to ensure that your subdirectories are handled.

    The following example code demonstrates how to use the function:

    <?php
    $plugins = array(
    	'my-mu-plugin/my-mu-plugin.php',
    );
    foreach ( $plugins as $plugin ) {
    	$path = dirname( __FILE__ ) . '/' . $plugin;
    
    	// Add this line to ensure mu-plugins subdirectories can be symlinked
    	wp_register_plugin_realpath( $path );
    
    	include $path;
    }
    

    Hopefully this change is as helpful for you as it was for me! One of the great advantages to this is that plugin developers can keep their plugin separate from their WordPress installation. This is a boon for developers with multiple installs who want to test compatibility; keep in mind that you can symlink the entire plugins directory if you’re testing multiple!

    If you have any questions about this, please leave a comment on this post and we’ll be happy to help you out!

    #3-9, #dev-notes, #plugins, #symlinks

In the better late than never category notes…

In the better late than never category: notes about plugins from core team meetup in December! https://make.wordpress.org/plugins/2012/08/18/93/

#wptybee, #meetup, #plugins

A bunch of unused images were removed from…

A bunch of unused images were removed from core in changeset 21498. Several of them were background gradients that were replaced with CSS 3 gradients. The rest have been unused in core for few releases.

However there are some plugins that use a few of these images and would need updating. Best thing to do would be to copy the images locally as that makes a plugin independent from core changes. If the images were gradients, best would be to use CSS 3 gradients (example).

#plugins

On Saturday Matt posted to the WordPress Blog…

On Saturday, Matt posted to the WordPress Blog that the plugin directory has been refreshed.

Also also posted to our new P2 at make.wordpress.org/plugins: what this means for developers. @otto42, @coffee2code, and I go through the changes in detail. They include:

  • The new Developers and Support tabs for plugins
  • Subscribing to commit emails (Hint: see the Developers tab)
  • Following and managing support threads
  • How the new support statics are calculated

(Sidebar: We hope to use make.wordpress.org/plugins for announcements and resources for plugin developers. This blog will also move to make.wordpress.org soon. More to come.)

#plugin-directory, #plugins

Plugin committers now receive svn notify emails with…

Plugin committers now receive svn notify emails with every commit to their plugin. This is something we’ve been planning to do to assist with collaboration, but we added it today without extra things like being able to sign up for other plugins. (Look for that soon, though.)

And not to sound like the PA in a subway or at an airport, but if you see something, say something. Say things to security@wordpress.org.

#plugins, #svn, #wordpress-org

Commit access has been restored for plugins If…

Commit access has been restored for plugins. If you get a 403 error, you need to go reset your password. Please, to something new.

#plugins, #svn, #wordpress-org

It was pointed out to me that I never me…

It was pointed out to me that I never mentioned it anywhere when I made this change last month, but the plugin search engine at https://wordpress.org/extend/plugins/ has been much improved. So now when you search for things like “buddypress”, you should get what you’re looking for on the first page of results more often.

It was a minor adjustment, so it didn’t occur to me to tell anybody. Sorry about that. 🙂

#extend, #plugins, #wordpress-org

New for Extend/Plugins: If a user clicks…

New for Extend/Plugins:

If a user clicks the “Broken” link, it will record the click as usual, but now also redirect them to the start a new topic support form, and nicely ask them to leave a new topic explaining what’s broken. Hopefully, this will make the broken button more useful.

Note: if you want to test this, feel free, but realize that you’re marking the plugin as broken by doing so, whether you leave a new topic or not. So please, go back afterwards and change your vote to “works” if it really does work.

#compatibility, #extend, #plugins

Gravatars are now shown on the plugin li…

Gravatars are now shown on the plugin listing page. It’s a minor thing, but people like pictures and clicking on pictures. Clicking on somebody’s picture will take you to their plugin profile, showing all their plugins.

#plugins

Plugin Developer Handbook Chapter List

#3-org, #handbooks, #plugins