themeum/kirki

no support for custom plugin directory

wibed opened this issue · 1 comments

wibed commented

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

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