themeum / kirki

Extending the customizer

Home Page:https://kirki.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

403 errors for kirki css and js files on localhost

mapsteps opened this issue · comments

Issue description:

I'm getting 403 errors on a local machine (windows) using UwAMP with PHP7. I embedded kirki in the theme as mentioned here: https://aristath.github.io/kirki/docs/advanced/integration.html

Version used:

3.0.0-beta.1

Attachments:

18193198_1678057739166027_4421741195562371260_o
18216827_1678052835833184_4296797516582704925_o
18238575_1678053305833137_8067459839092666002_o

Did you use the function to update the path of the files?

I saw that you placed KIRKI manually in the /assets folder of your theme. Then the function should point to it. Try this:

if ( ! function_exists( 'my_theme_kirki_update_url' ) ) {
    function my_theme_kirki_update_url( $config ) {
        $config['url_path'] = get_stylesheet_directory_uri() . '/assets/kirki/';
        return $config;
    }
}
add_filter( 'kirki/config', 'my_theme_kirki_update_url' );

Hey @AdsonCicilioti,

thanks for your fast response! Of course that did the trick, totally overlooked it.

Thanks!

Reopening this one.
Using the filter should not be necessary...
Unfortunately I don't have a Windows machine to test and debug these kind of issues so it's just going to take a bit longer 'till I manage to setup a proper Virtual Machine for Windows tests.

I hate Windows...
So far I was unable to build a proper dev environment on a Windows VM, so I pushed a commit that - in theory - should fix some of the issues you're having.

Can you please remove the filter you previously added and test if that last commit fixes your issue?

If it does not, then please add the following in your functions.php file and paste here what the results in your screen are:

add_action( 'wp', function() {
	var_dump( 'Kirki Path: ' . Kirki::$path );
	var_dump( 'Kirki URL: ' . Kirki::$url );
	var_dump( 'Template Path: ' . get_template_directory() );
	var_dump( 'Template URL: ' . get_template_directory_uri() );
	var_dump( 'Stylesheet Path: ' . get_stylesheet_directory() );
	var_dump( 'Stylesheet URL: ' . get_stylesheet_directory_uri() );
	var_dump( 'ABSPATH: ' . ABSPATH );
	var_dump( 'KIRKI_PLUGIN_FILE: ' . KIRKI_PLUGIN_FILE );
	var_dump( 'plugin-dir-url: ' . plugin_dir_url( KIRKI_PLUGIN_FILE ) );
});

This should help me figure out what to do 👍

Hey @aristath,

thanks! That error ocurred on one of my customers machines. I'm also on a mac and unable to recreate it. Let me send him the latest version of the theme and try to get his feedback.

Best,
David

OK, I was finally able to setup my dev VM, tested it, replicated the issue, found another bug, pushed a fix and now everything works fine on Windows localhosts when the plugin is embedded in a theme. 👍
Please note that if you sent the files to your customer before this last commit I just pushed the bug is still there, it just got fixes 5 minutes ago.

Closing this one again, hopefully for the last time!
The filter is no longer required, Kirki will find if it's in a theme, child-theme, or installed as a plugin and it will use the correct URLs depending on the installation.

You're the man! Thanks!

Nice work @aristath!... Remember to update documentation on site!
Or this is only for version 3?