• Resolved emrl

    (@emrl)


    Using WooCommerce with FSE theme/blocks, the inputs need to use input-text class, so I went looking to see if I was able to add this class to the fields.

    There is a wapf/field_classes/{$field->key} filter available, but it’s being applied to both the container AND the input. I believe that Html::field_container_classes() should use wapf/field_container_classes/{$field->key} instead, that way input-text won’t be applied to both resulting in wrong styling.

    Also, $field->key seems to be NULL, and not assigned anywhere in the plugin, so it doesn’t make sense to use in the filter name. I believe simply using wapf/field_classes would be great, but it should also pass the reference to the $field variable (apply_filters('wapf/field_classes, [], $field)) as this would allow developers to check what field type is being filtered, etc.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Wombat Plugins

    (@maartenbelmans)

    Hi @emrl

    You’re absolutely right! We’ve fixed this oversight now by renaming the container class filter to “wapf/field_container_classes/” and in both cases using $field->id rather than the key (which was an old property, not used anymore)

    If you update to the latest version (1.6.13, as of writing), that should be fixed.

    Thread Starter emrl

    (@emrl)

    @maartenbelmans thank you, that was very quick. This does help with our current use case, but having $field->id as part of the filter name is very limiting, as you would need to write code to apply this to every single field since the ID is unique. So if you have 10 extra fields, you’d need to have 10 filters. So it becomes difficult to add classes for all types of inputs, or only text inputs, etc. Thus why I mentioned leaving out the $field->id in the filter name, and just passing the entire $field object as the second parameter to the filter, so then you can do anything conditionally in the callback based on the all properties of $field.

    Thank you.

    Plugin Author Wombat Plugins

    (@maartenbelmans)

    Hi @emrl

    That’s true! A workaround is to hook into WordPress’ “all” filter which fires after every filter, and then check if the current filter starts with “wapf/field_classes”.

    I haven’t tested this but should work!

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Extra classes filter bug’ is closed to new replies.