themeum/kirki

Using a 'contains' active callback when compare values is of type int, creates a hidden warning in css block.

Opened this issue · 0 comments

Issue description:

I recognize that the current approach is not viable, as it stems from an error within "my" code that is producing a warning. In this scenario, the implementation should have utilized the == operator within the active callback. However, I hold the belief that Kirki has the capability to address such issues in a more effective manner.

The course of action to manage this error is still undetermined. One potential avenue could involve performing a typecast to convert the data into a string format. Alternatively, an approach of issuing a straightforward and informative "misusage" warning might be suitable.

It's worth noting that the underlying problem arises from the helper attempting to compare integers within the strpos function. This particular issue has adverse consequences on the CSS output and significantly hampers the development process, especially when wp_debug is enabled.

Version used:

5

Using theme_mods or options?

theme_mods

PHP error messages that might be related

<b>Deprecated</b>:  strrpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in <b>****/vendor/kirki/kirki-packages/util/src/Helper.php</b> on line <b>391</b><br>

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

\Kirki::add_field(\Municipio\Customizer::KIRKI_CONFIG, [
            'type'     => 'switch',
            'settings' => 'archive_' . $archive->name . '_display_google_maps_link',
            'label'    => esc_html__('Display Google Maps-link', 'municipio'),
            'description' => esc_html__('Display a link to Google Maps on each marker on the map?', 'municipio'),
            'section'  => $sectionID,
            'default'     => 0,
            'choices' => [
                1  => esc_html__('Show', 'municipio'),
                0 => esc_html__('Hide', 'municipio'),
            ],
            'output' => [ //Don't mind this, this is our own extension. 
                [
                    'type' => 'controller',
                    'as_object' => true,
                ],
            ],
            'active_callback' => [
                [
                    'setting'  => 'archive_' . $archive->name . '_display_openstreetmap',
                    'operator' => 'contains',
                    'value'    => 1,
                ]
            ],
        ]);