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

The Dimensions field does not keep the default choices #2513

Open
irisinteractive opened this issue Aug 11, 2023 · 0 comments
Open

The Dimensions field does not keep the default choices #2513

irisinteractive opened this issue Aug 11, 2023 · 0 comments

Comments

@irisinteractive
Copy link

irisinteractive commented Aug 11, 2023

Issue description:

When adding a Dimensions type field with default values ​​and output as root css variables, the default values ​​are overwritten with a null value.

Version used:

5.0.0

Using theme_mods or options?

options

PHP error messages that might be related

Nothing

JS error messages that might be related

Nothing

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

new \Kirki\Field\Dimensions( array(
  "description" => "",
  "priority" => 9999,
  "default" => array(
    "Vertical" => "20px",
    "Horizontal" => "20px"
  ),
  "capability" => "iris_manage_customizer",
  "option_type" => "option",
  "kirki_config" => "iris_customize_config",
  "label" => "Marges internes",
  "section" => "iris-section-main-button",
  "output" => array(
    array(
      "element" => ":root",
      "property" => "--iris--button--padding-y",
      "choice" => "Vertical",
      "context" => array(
        "editor",
        "front"
      ),
    ),
    array(
      "element" => ":root",
      "property" => "--iris--button--padding-x",
      "choice" => "Horizontal",
      "context" => array(
        "editor",
        "front"
      )
    )
  ),
  "settings" => "iris_customize_option_button_padding",
  "required" => array()
) );

In the init method of the kirki/kirki-packages/field-dimensions/src/Dimensions.php file, I tested two fixes from line 80:

		new \Kirki\Field\Generic(
			wp_parse_args(
				array(
+					'settings'    => $args['settings'] . '-kirki-generic',
					'type'              => 'kirki-generic',
					'default'           => '',
					'wrapper_opts'      => array(
						'gap' => 'small',
					),
					'sanitize_callback' => isset( $args['sanitize_callback'] ) ? $args['sanitize_callback'] : array( __CLASS__, 'sanitize' ),
					'choices'           => array(
						'type'        => 'hidden',
						'parent_type' => 'kirki-dimensions',
					),
				),
				$args
			)
		);

OR

		new \Kirki\Field\Generic(
			wp_parse_args(
				array(
					'type'              => 'kirki-generic',
+					'default'           => isset( $args['default'] ) ? $args['default'] : '',
					'wrapper_opts'      => array(
						'gap' => 'small',
					),
					'sanitize_callback' => isset( $args['sanitize_callback'] ) ? $args['sanitize_callback'] : array( __CLASS__, 'sanitize' ),
					'choices'           => array(
						'type'        => 'hidden',
						'parent_type' => 'kirki-dimensions',
					),
				),
				$args
			)
		);

Looking forward to a resolution, thank you!

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