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

Problems updating from v3 to v4+ (question) #2517

Open
oobi opened this issue Sep 20, 2023 · 0 comments
Open

Problems updating from v3 to v4+ (question) #2517

oobi opened this issue Sep 20, 2023 · 0 comments

Comments

@oobi
Copy link

oobi commented Sep 20, 2023

Issue description:

I have a network with around 50 sites using a set of themes that depend on Kirki 3. I'm now adding a theme that requires a v4+ and having some issues with the older themes. I'd prefer not to have two versions of the plugin floating around so I'm trying to patch the older themes to function properly.

The basic problem is that none of the existing customiser values are retrieved when I activate the newer version.

What's odd is that it all works fine in the customiser view. The theme looks the way it should and the fields show up.

I have tried publishing the customiser - no luck. I have also tried updating the PHP to declare the fields/containers the "new" way - no luck.

The only thing that does seem to work is to manually change a setting off and back on (or otherwise change its value) -- then the new value is saved and shows up in both customiser and normal view. This only applies to the value changed. That's not viable as it would involve manually fiddling every customiser control in every site, though.

Any wisdom gratefully received!

Version used:

3.1.9

Using theme_mods or options?

theme_mods

Code to reproduce the issue (config + field(s))

There are dozens of fields, but the basic issue is the same for each one. Here are a couple of examples:

\Kirki::add_field( $this->config_id, array(
	'type'      => 'toggle',
	'settings'  => "{$section_id}_hero_show",
	'label'     => ff__( 'Show Hero Image' ),
	'section'   => $section_id,
	'default'	=> true
) );

\Kirki::add_field( $this->config_id, array(
	'type'     		=> 'multicheck',
	'settings'  	=> "{$section_id}_sharing",
	'label'     	=> ff__( 'Share buttons' ),
	'description'  	=> ff__( 'Share Buttons are used by the user to share articles on <strong>their feed</strong>' ),
	'section'		=> $section_id,
	'default'		=> [ 'facebook', 'twitter' ],
	'choices'		=> [
		'facebook' 		=> ff__( 'Facebook' ),
		'twitter' 		=> ff__( 'Twitter' ),
		'linkedin' 		=> ff__( 'LinkedIn' ),
	],
) );

If I dump the kirki fields collection these are not included:

         echo '<pre>';
	print_r(\Kirki::$fields);
	echo '</pre>';

Retrieve value:

$default_value = isset( \Kirki::$fields[$fieldname]['default'] ) ? \Kirki::$fields[$fieldname]['default'] : null;
return get_theme_mod( $fieldname, $default_value );
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

1 participant