Skip to content

Broken asset URL generation when WP_PLUGIN_DIR not in ABSPATH #178

@denic

Description

@denic

I encountered a problem with my WP installation where I separated the WP core and the wp-content folder into different locations within the filesystem, eg.:

  • ABSPATH: /var/www/myblog/public/wp/
  • WP_CONTENT_DIR: /var/www/myblog/public/wp-content/

In this case the code will produce a broken URL like http://foo.bar-content/plugins/...

I solved it by using the WP_PLUGIN_DIR instead of ABSPATH:

if ( 0 === strpos( $module_dir, $plugin_dir ) ) {
    $rel_path = wp_normalize_path( str_replace( WP_PLUGIN_DIR, '', $module_dir));
    $url      = WP_PLUGIN_URL . $rel_path;
} else ...

Thanks and have a nice weekend!
Dennis

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions