simple-lightbox icon indicating copy to clipboard operation
simple-lightbox copied to clipboard

Plugin resource paths wrong with specific WP configuration

Open presidentnickson opened this issue 1 year ago • 3 comments

Description of Problem

In a specific Wordpress configuration, there is an issue with the paths used to load the plugin resources.

Details

Wordpress is installed in a subdirectory /wp/ - while the content folder sits along side in /wp-content/

So : base path is https://www.examplesite.com/wp wp-content path is https://www.examplesite.com/wp-content

In this scenario, the plugin attempts to load the following :

https://www.examplesite.com/wp/-content/plugins/simple-lightbox/client/css/app.css?ver=2.9.3

As you can see, it's mangled this part of the path : /wp/-content/

I think the root of the problem lies in the get_relative_path() function in /simple-lightbox/includes/class.utilities.php

In here we have :

$relative is https://www.examplesite.com/wp $path is https://www.examplesite.com/wp-content/plugins/simple-lightbox

With these values, $path = substr( $path, strlen( $relative ) ); will return -content/plugins/simple-lightbox

presidentnickson avatar Oct 23 '23 20:10 presidentnickson

Thank you for the report.

So that your issue can be reproduced, please provide details on the specific WP constants and/or admin options (including their customized values) that have been modified for your configuration.

archetyped avatar Oct 28 '23 02:10 archetyped

Here is what has been added into wp-config.php to allow for this configuration :

/**
 * Set custom paths
 *
 * These are required because wordpress is installed in a subdirectory.
 */
if (!defined('WP_SITEURL')) {
	define('WP_SITEURL', 'https://' . $_SERVER['SERVER_NAME'] . '/wp');
}
if (!defined('WP_HOME')) {
	define('WP_HOME',    'https://' . $_SERVER['SERVER_NAME'] . '');
}
if (!defined('WP_CONTENT_DIR')) {
	define('WP_CONTENT_DIR', dirname(__FILE__) . '/wp-content');
}
if (!defined('WP_CONTENT_URL')) {
	define('WP_CONTENT_URL', 'https://' . $_SERVER['SERVER_NAME'] . '/wp-content');
}

presidentnickson avatar Oct 31 '23 22:10 presidentnickson

Thank you, I will look into it.

archetyped avatar Nov 03 '23 01:11 archetyped