Title: Extra classes filter bug
Last modified: April 2, 2025

---

# Extra classes filter bug

 *  Resolved [emrl](https://wordpress.org/support/users/emrl/)
 * (@emrl)
 * [1 year, 2 months ago](https://wordpress.org/support/topic/extra-classes-filter-bug/)
 * 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](https://wordpress.org/support/users/maartenbelmans/)
 * (@maartenbelmans)
 * [1 year, 2 months ago](https://wordpress.org/support/topic/extra-classes-filter-bug/#post-18396574)
 * Hi [@emrl](https://wordpress.org/support/users/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](https://wordpress.org/support/users/emrl/)
 * (@emrl)
 * [1 year, 2 months ago](https://wordpress.org/support/topic/extra-classes-filter-bug/#post-18396616)
 * [@maartenbelmans](https://wordpress.org/support/users/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](https://wordpress.org/support/users/maartenbelmans/)
 * (@maartenbelmans)
 * [1 year, 2 months ago](https://wordpress.org/support/topic/extra-classes-filter-bug/#post-18396651)
 * Hi [@emrl](https://wordpress.org/support/users/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](https://developer.wordpress.org/reference/functions/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.

 * ![](https://ps.w.org/advanced-product-fields-for-woocommerce/assets/icon-256x256.
   gif?rev=3347990)
 * [Advanced Product Fields (Product Addons) for WooCommerce](https://wordpress.org/plugins/advanced-product-fields-for-woocommerce/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/advanced-product-fields-for-woocommerce/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/advanced-product-fields-for-woocommerce/)
 * [Active Topics](https://wordpress.org/support/plugin/advanced-product-fields-for-woocommerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/advanced-product-fields-for-woocommerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/advanced-product-fields-for-woocommerce/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [Wombat Plugins](https://wordpress.org/support/users/maartenbelmans/)
 * Last activity: [1 year, 2 months ago](https://wordpress.org/support/topic/extra-classes-filter-bug/#post-18396651)
 * Status: resolved