Skip to content

Resource loading outside of the WP plugins directory #35

@xsynaptic

Description

@xsynaptic

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;
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions