Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resource loading outside of the WP plugins directory #35

Open
xsynaptic opened this issue Jun 13, 2017 · 1 comment
Open

Resource loading outside of the WP plugins directory #35

xsynaptic opened this issue Jun 13, 2017 · 1 comment

Comments

@xsynaptic
Copy link

I encountered a minor issue while directly integrating this plugin into a theme using Composer + WPackagist: admin-side resources (CSS/images) don't load properly, something I traced back to the taxonomy_image_plugin_url function. It turns out the core plugin_dir_path function returns a malformed URL (absolute URL + relative path) when the file calling it isn't in the WP plugins folder. An easy fix would be to add a filter to the taxonomy_image_plugin_url function... but for the time being, and in case anyone else encounters the issue, this little workaround seems to do the trick:

add_filter( 'plugins_url', function($url) {
  if ( strpos($url, 'taxonomy-images') !== false )
    return get_template_directory_uri() . '/vendor/wp-plugins/taxonomy-images/';
  return $url;
});
@benhuson
Copy link
Owner

Hi,

It is not recommended to bundle a plugin directly with a theme. Doing this means that it won't be updatable via the WordPress admin should any important updates become available, such as security fixes.

One method which many themes now use is to provide prompts to install and activate required plugins when a theme is activate which requires certain plugins. The TGM Plugin Activation PHP library can help with this.

See:
https://make.wordpress.org/themes/handbook/review/required/#plugins
http://tgmpluginactivation.com
https://wordimpress.com/how-to-easily-require-plugins-for-your-wordpress-themes/

I will consider making the plugin less dependent on being in the plugins folder, perhaps via a filter, but I would advise against this for the reasons above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants