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

Active callback with contains operator not works with not-array controls #1730

Closed
ArekZw opened this issue Dec 26, 2017 · 0 comments
Closed

Comments

@ArekZw
Copy link

ArekZw commented Dec 26, 2017

Issue description:

Active callback with contains operator not works with not-array (for example with radio-image control).
Code works with Kirki 3.0.9.

From old documentation:
"contains, in : If the context is an array then we’ll check if the value defined exists in the array (using PHP’s in_array() function. If on the other hand the context is a string then we’ll check if the string contains the value defined using PHP’s strpos() and checking not the position of the string but whether the result returns false or not (using === for safety)."

Version used:

3.0.22

Using theme_mods or options?

theme_mods

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

function my_fields() { 

	Kirki::add_section('general', array(
		'title'       => __('General settings'),
		'description' => __(''),
		'priority'    => 10,
		));

	Kirki::add_field('page_layout', array(
		'type'        => 'radio-image',
		'settings'    => 'page_layout',
		'label'       => esc_attr__('Układ strony-home', 'isb'),
		'section'     => 'general',
		'priority'    => 1,
		'choices'     => array(
			'hor_test1' => admin_url() . '/images/align-right-2x.png',
			'hor_test2' => admin_url() . '/images/align-right-2x.png',
			'hor_test3' => admin_url() . '/images/align-right-2x.png',
			'hor_test4' => admin_url() . '/images/align-right-2x.png',
			'ver_test1' => admin_url() . '/images/align-right-2x.png',
			'ver_test2' => admin_url() . '/images/align-right-2x.png',
			'ver_test3' => admin_url() . '/images/align-right-2x.png'
			),
		));

	Kirki::add_field('header_background_subpage', array(
		'type'        => 'image',
		'settings'    => 'header_background_subpage',
		'label'       => __('Header background subpage', 'isb'),
		'section'     => 'general',
		'default'     => 'http://loremflickr.com/1280/450',
		'priority'    => 10,
		'active_callback'    => array(
			array(
				'setting'  => 'page_layout',
				'operator' => 'contains',
				'value'    => 'hor',
				),
			),
		));
}
add_action('customize_register', 'my_fields');
ArekZw added a commit to ArekZw/kirki that referenced this issue Feb 7, 2018
aristath added a commit that referenced this issue Mar 17, 2018
* develop: (73 commits)
  fixes #1730
  fixes #1830
  GDPR: Load webfont-loader locally
  Update fonts
  fixes #1834
  Apply WordPress Coding Standards
  Update kirki-helper-class.md
  see #1797
  cleanup unused vars
  See #1807
  Additional fix for #1809
  fixes #1828
  fixes #1808
  fix #1814
  fix #1797
  fixes #1809
  Update sortable.md
  fixes #1787
  update webfonts & grunt
  changelog
  ...

# Conflicts:
#	modules/postmessage/class-kirki-modules-postmessage.php
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