[Resolved] Trailing slash in GP_PREMIUM_DIR_URL

Home Forums Support [Resolved] Trailing slash in GP_PREMIUM_DIR_URL

Home Forums Support Trailing slash in GP_PREMIUM_DIR_URL

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #2022021
    TOMAS

    Hello, I just migrated content of our site built on GeneratePress with GP Premium plugin to a production environment and noticed a problem: In administration on generatepress dashboard, there are missing styles and JS files, the problem seems to be that there is a trailing slash inside GP_PREMIUM_DIR_URL constant defined in gp-premium.php :

    define( ‘GP_PREMIUM_DIR_URL’, plugin_dir_url( __FILE__ ) );

    According to WP docs, https://developer.wordpress.org/reference/functions/plugin_dir_url/
    the plugin_dir_url returns url containing a trailing slash.

    Next, this constant is used in class-dashboard.php to enqueue scripts for the dashboard:
    wp_enqueue_script(
    ‘generate-pro-dashboard’,
    GP_PREMIUM_DIR_URL . ‘/dist/dashboard.js’,
    array(),
    GP_PREMIUM_VERSION,
    true
    );
    (Which, i think should be without the / before dist : GP_PREMIUM_DIR_URL . ‘dist/dashboard.js’ )

    which results, in our case, in trying to load dashboard.js file from the following url: https://oursite.com/wp-content/plugins/gp-premium//dist/dashboard.js?ver=2.1.1

    This url contains double slashes before dist folder, which i suspect might not be a problem in most cases, however our hosting environment is set up such that this returns a 404.

    Is this a correct behaviour? Am I missing something?

    Thank you for your help!

    #2022043
    TOMAS

    Forgot to mention that we are running generatepress 3.1.0, gp premium 2.1.1 and wordpress 5.7.2

    #2022595
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    Nice catch here! Definitely something that works fine in most environments, but can cause an issue for some. We’ll get it fixed in our next update.

    Appreciate the heads up 🙂

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.