• Resolved grwebadmin

    (@grwebadmin)


    Hello,

    We are experiencing a fatal PHP error that completely breaks the WordPress Customizer when the Beautiful Taxonomy Filters plugin is active.

    We see this screen:

    Environment

    • WordPress: Latest version
    • Theme: Astra 4.11.16
    • PHP Version: 8+
    • Plugin: Beautiful Taxonomy Filters
    • Issue occurs when navigating to Appearance → Customize

    We also receive an email with the following error:

    An error of type E_ERROR was caused in line 107 of the file /nas/content/live/astra-theme-ext/wp-content/plugins/beautiful-taxonomy-filters/widgets/beautiful-taxonomy-filters-widget.php. Error message: Uncaught TypeError: in_array(): Argument #2 ($haystack) must be of type array, string given in /nas/content/live/astra-theme-ext/wp-content/plugins/beautiful-taxonomy-filters/widgets/beautiful-taxonomy-filters-widget.php:107
    Stack trace:
    #0 /nas/content/live/astra-theme-ext/wp-content/plugins/beautiful-taxonomy-filters/widgets/beautiful-taxonomy-filters-widget.php(107): in_array('elementor_libra...', '')
    #1 /nas/content/live/astra-theme-ext/wp-includes/class-wp-widget.php(535): Beautiful_Taxonomy_Filters_Widget->form(Array)
    #2 /nas/content/live/astra-theme-ext/wp-admin/includes/widgets.php(276): WP_Widget->form_callback(Array)
    #3 /nas/content/live/astra-theme-ext/wp-includes/class-wp-customize-widgets.php(1169): wp_widget_control(Array, Array)
    #4 /nas/content/live/astra-theme-ext/wp-includes/class-wp-customize-widgets.php(1117): WP_Customize_Widgets->get_widget_control(Array)
    #5 /nas/content/live/astra-theme-ext/wp-includes/class-wp-customize-widgets.php(714): WP_Customize_Widgets->get_available_widgets()
    #6 /nas/content/live/astra-theme-ext/wp-includes/class-wp-hook.php(324): WP_Customize_Widgets->enqueue_scripts('')
    #7 /nas/content/live/astra-theme-ext/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array)
    #8 /nas/content/live/astra-theme-ext/wp-includes/plugin.php(517): WP_Hook->do_action(Array)
    #9 /nas/content/live/astra-theme-ext/wp-admin/customize.php(133): do_action('customize_contr...')
    #10 {main}
    thrown

    Description of the Issue

    Inside beautiful-taxonomy-filters-widget.php on line 107, the plugin calls in_array() on a variable that is assumed to be an array. However, under certain conditions (such as when the Customizer loads widget controls), WordPress supplies a string or an empty value instead of an array. This results in a PHP 8+ TypeError that prevents:

    • Access to the Customizer
    • Widget screen loading
    • Theme customization

    This makes it impossible to manage the site’s design while the plugin is active.

    At the moment, this error completely blocks the Customizer, which is a critical part of WordPress administration. Any assistance or patch would be greatly appreciated.

    Thank you.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Jonathandejong

    (@jonathandejong)

    @grwebadmin

    Hi!

    Thank you for reporting this. I think the error is actually that for some reason the option don’t get loaded or you have never saved the settings and the plugin assumes it will exist as an array.

    Either that, or you have made modifications using the beautiful_filters_post_types and do not return an array to it but rather a string.

    <?php

    $post_types = get_post_types(

    array(

    'public' => true,

    '_builtin' => false

    ),

    'objects'

    );

    $activated_post_types = apply_filters( 'beautiful_filters_post_types', get_option('beautiful_taxonomy_filters_post_types') );

    ?>

    <?php if($post_types): foreach($post_types as $single_post_type): ?>

    // HERE IS WHERE THE ERROR OCCURS BECAUSE $activated_post_types is not an array.
    <?php if(in_array($single_post_type->name, $activated_post_types)): ?>

    I’ve just pushed a new bugfix version 2.4.6 which should resolve this by both adding a fallback value to get_option and a type coercion into an array.

    Still, I would suggest you check that you don’t use the filter and return a string.

    Thread Starter grwebadmin

    (@grwebadmin)

    Yes it worked fine – thank you for the quick response.

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

You must be logged in to reply to this topic.