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

no support for custom plugin directory #2490

Open
wibed opened this issue Sep 3, 2022 · 1 comment
Open

no support for custom plugin directory #2490

wibed opened this issue Sep 3, 2022 · 1 comment

Comments

@wibed
Copy link

wibed commented Sep 3, 2022

https://wordpress.org/support/topic/lots-of-404-errors-when-using-customizer/

this error still persists yet marked as resolved.
tl;dr
Seems like the Kirki plugin does not support custom plugin directory yet

suggestions:

define(‘WP_PLUGIN_DIR’, ‘/bitnami/wordpress’ . ‘/wp-content/plugins’);
You can use an addon named redirection, and set something like this
Origin Url: ^\/bitnami\/wordpress\/wp-content\/(.*)
destiny url: /wp-content/$1

i just started out therefor reluctant to make changes right away

@acrois
Copy link

acrois commented Sep 3, 2022

I spent over an hour trying to resolve it "the right way", in hopes that I could submit a proper PR, but the code is literal spaghetti and needs to be refactored carefully by someone who can ensure it doesn't break whatever edge cases that justify the URL.php class' existence (not me).

I also wasn't sure if overriding the WP_PLUGIN_DIR made sense, since it should be already configured for whatever the optimal setup is in that Docker image, so I wasn't going to potentially break a bunch of other plugins working fine just to get this one to work properly.

There's another way. What's wrong with using the plugins_url() function?


QUICK FIX

Anyway, here's a fix that will work until someone figures this out for good and gets a fix integrated & published.

Here's a three-liner to put onto line 151

		if (\stripos($this->path, '/bitnami/wordpress') !== false) {
			$this->url = \str_replace('/bitnami/wordpress', '', $this->path);
		}

Seems to fix the paths for me on the Bitnami WordPress setup. 🥂

Patch file might look something like:

--- packages/kirki-framework/url-getter/src/URL.php	Sat Sep  3 00:10:24 2022
+++ packages/kirki-framework/url-getter/src/URL.php	Sat Sep  3 00:10:27 2022
@@ -148,6 +148,10 @@
 		if ( ! $this->in_parent_theme() && $this->in_child_theme() ) {
 			$this->url = \get_stylesheet_directory_uri() . \str_replace( \get_stylesheet_directory(), '', $this->path );
 		}
+		
+		if (\stripos($this->path, '/bitnami/wordpress') !== false) {
+			$this->url = \str_replace('/bitnami/wordpress', '', $this->path);
+		}
 
 		$this->url = \set_url_scheme( $this->url );
 		return \apply_filters( 'kirki_path_url', $this->url, $this->path );

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

No branches or pull requests

2 participants