Path to plugins dir

How do we get path to any plugin’s path? Say, we have:

plugins_url('img/test.jpg', __FILE__)

This is not working in Bedrock anymore if plugins are in app/plugins directory.

@chriscarr tested this yesterday on both Bedrock + Roots and Bedrock + TwentyFourteen without issues. What’s it returning for you?

For reference, Bedrock sets WP_CONTENT_DIR and WP_CONTENT_URL which are used in WP_PLUGIN_DIR and WP_PLUGIN_URL which are in turn used in plugins_url.

Hi,

I’m testing it on Bedrock + TwentyFourteen only, not using Roots for now.
Both WP_PLUGIN_URL and plugins_url return path to my script like: http://bedrock.local/app/plugins/someplugin/script.js.

Not sure if this is supposed to happen, but app/plugins path is resulting in 404.

With Bedrock your mu-plugins, plugins, and themes all live in app/ (see https://github.com/roots/bedrock#folder-structure) so the path is correct. What plugin are you trying?

With Bedrock you should be using Composer to manage your plugins. Even if you choose to install them via the admin, they will still be placed in app/plugins/.

I’m only using test plugin, have only code to inject js file into header via wp_head action. I used composer to install the plugin, so added my test plugin to packagist. here: https://packagist.org/packages/markzero/wplivejs (so you can see github repo too)

What are your results? Does it result in app/plugins path too and it works? Does it require Nginx rewrite?

Code looks fine at first glance. There’s no Nginx/Apache rewrites necessary for Bedrock assets out of the box. app/plugins/whatever is the actual folder structure.

Yesterday and today I’ve been fixing a nasty bug. Plugins just failed to work because they couldn’t load assets properly.
My setup is a multisite using Bedrock and added functionality using WordPress MU Domain Mapping (those three things combined I believe generated my bug).

This topic describes in some sense the things that also experienced:
http://wordpress.org/support/topic/plugin-front-end-editor-frontend-editor-and-wordpress-mu-domain-mapping-plugins

The ordered list in the first comment, point 3 about the added “s” was also my problem.

To make a long story short, MU Domain mapping has this hook:

function domain_mapping_plugins_uri( $full_url, $path=NULL, $plugin=NULL ) {
    return get_option( 'siteurl' ) . substr( $full_url, stripos( $full_url, PLUGINDIR ) - 1 );
}

The constant PLUGINDIR (I know it is deprecated) points by default heardcoded to wp-content/plugins. For it to work I had to define this constant in application.php with a value of app/plugins (without a slash in front of app).

Now the question is, should PLUGINDIR be defined like this in Bedrock by default just to be sure people do not get this problem in case plugins use this constant. Or should this be a fix for the plugin(s) themselves?

1 Like

It should be fixed in the plugins. They shouldn’t be using deprecated constants. And I really don’t want to add this into Bedrock by default since it goes against the philosophy of the project.

I agree. At least I have put the knowledge out there.
Perhaps I need to address the issue to the MU Domain Mapping plugin.

Btw, thanks for Bedrock and Roots!

harmless,

Thanks for sharing this info on Multisite setup.
You are the only post I have found using WPMU with Bedrock.

I am trying to setup WPMU with subdirectories using Bedrock.
The issue I am having is that WPMU keeps the /wp/ in the public path where I want this hidden.
Could you provide your application.php, wp-config.php, .htaccess code and any steps used to set this up properly? (I am only assuming those files were changed)

PS: I am following the instructions from this url: http://premium.wpmudev.org/manuals/wpmu-manual-2/creating-a-network-to-enable-wordpress-multisite/

Thanks,
–Joe