Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin resource paths wrong with specific WP configuration #1036

Open
presidentnickson opened this issue Oct 23, 2023 · 3 comments
Open

Plugin resource paths wrong with specific WP configuration #1036

presidentnickson opened this issue Oct 23, 2023 · 3 comments
Assignees

Comments

@presidentnickson
Copy link

presidentnickson commented Oct 23, 2023

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

@archetyped
Copy link
Owner

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.

@presidentnickson
Copy link
Author

presidentnickson commented Oct 31, 2023

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

@archetyped
Copy link
Owner

Thank you, I will look into it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants