Site logo

Archived topic

Trailing slash in GP_PREMIUM_DIR_URL

2 replies · Started by TOMAS on November 25, 2021

Viewing posts 1–3 of 3

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!

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

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 :)

This archived topic is closed to new replies.