• Resolved lkaufmann

    (@lkaufmann)


    Hey there! I tried installing Filter Everything to create filters alongside ACF. However, doing so crashes my WordPress admin dashboard for some reason, and I simply can’t find a way to fix it except for removing the plugin using my host’s file manager. Both the site and the plugin themselves work fine; The site loads, and I can edit pages with Elementor (including adding Filter Everything widgets, which seem to work okay), I just can’t access the dashboard as it gives out a “There has been a critical error on this website” warning. Activating debug mode reveals the following:

    Fatal error: Uncaught TypeError: in_array(): Argument #2 ($haystack) must be of type array, string given in /home50/asesorag/public_html/wp-content/plugins/filter-everything/src/Admin/AdminHooks.php:144 Stack trace: #0 /home50/asesorag/public_html/wp-content/plugins/filter-everything/src/Admin/AdminHooks.php(144): in_array('srch', '') #1 /home50/asesorag/public_html/wp-includes/class-wp-hook.php(324): FilterEverything\Filter\AdminHooks->checkForbiddenPrefixes('') #2 /home50/asesorag/public_html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(false, Array) #3 /home50/asesorag/public_html/wp-includes/plugin.php(517): WP_Hook->do_action(Array) #4 /home50/asesorag/public_html/wp-admin/admin-header.php(303): do_action('admin_notices') #5 /home50/asesorag/public_html/wp-admin/plugins.php(637): require_once('/home50/asesora…') #6 {main} thrown in /home50/asesorag/public_html/wp-content/plugins/filter-everything/src/Admin/AdminHooks.php on line 144

    Any help? I’m keeping the plugin disabled for now.

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Support fesupportteam

    (@fesupportteam)

    Hi @lkaufmann

    The problem might be because of the VAR names/URL prefixes you’re using for your filters. If one of your filter VAR names/URL prefixes is the same as the slug that WordPress already uses, it can mess up your admin dashboard.

    Make sure every filter VAR name/URL prefix is unique. For example, you could use fe_prod_cat for categories, fe_prod_col for colors, fe_prod_size for sizes, and so on. Also, you can have some issues with permalinks.

    If you can use a local server, install the latest version of WordPress with PHP version 8.2, a default WordPress theme, and our plugin, then try to recreate this issue. If you succeed, you can send us a step-by-step explanation of how you managed to achieve it, so we can review it and fix the problem. As we cannot simply recreate it, we tried multiple different options to do so. So it is either connected to a certain plugin, theme, or any custom functionality on the site.

    Best Regards – Victor

    Thread Starter lkaufmann

    (@lkaufmann)

    Hey there! Thank you for your reply. I tried it on a local server like you suggested and it works perfectly, I simply can’t recreate what happens on my client’s site. From what I can see, there are no repeat VARs, permalinks seem to be set up just fine, and the theme is Astra, which should be compatible from what I’ve seen.

    My experience is pretty similar to @mihailungu ‘s where it worked just fine on install, I created a test filter (can’t quite remember the specific params), then went to settings, and it crashed. Now no matter how many times I uninstall and re-install, the dashboard simply refuses to work when Filter Everything is active. I even temporarily changed the theme and uninstalled Astra to check if it was related, but still nothing. Here’s the list of plugins on the site just in case:

    • 3CX Live chat
    • ACF
    • ACF: Better Search
    • AirLift
    • Akismet Anti-spam
    • Backuply pro
    • Code snippets
    • Contact form 7
    • Custom post type UI
    • Elementor
    • EA for Elementor
    • GoSMTP Pro
    • Loginizer pro
    • Presto player
    • SiteSEO Pro
    • WP Optimize

    The site was just handed over to me, so I have no idea if there’s something else going on under the hood that caused / is causing this. Is there a leftover file / entry somewhere I’m not seeing? Ideally it’d be nice to be able to solve this without a fresh install, as I don’t think my client would be very happy to hear about it… That and this plugin seems to be THE one for my task, of course.

    Plugin Support fesupportteam

    (@fesupportteam)

    Hi @lkaufmann

    There is this function in filter-everything/src/Admin/AdminHooks.php line 137

        public function checkForbiddenPrefixes()
    {
    $forbiddenPrefixes = flrt_get_forbidden_prefixes();
    $savedPrefixes = get_option( 'wpc_filter_permalinks', [] );
    $warningPrefixes = [];

    foreach( $forbiddenPrefixes as $prefix ){
    if( in_array( $prefix, $savedPrefixes ) ){
    $warningPrefixes[] = $prefix;
    }
    }

    $permalinkOptionsUrl = admin_url( 'edit.php?post_type=filter-set&page=filters-settings&tab=prefixes' );
    $permalinksTab = new PermalinksTab();
    $permalinksTabLabel = strtolower( $permalinksTab->getLabel() );

    if( ! empty( $warningPrefixes ) ){

    $message = wp_kses(
    sprintf(
    _n(
    'Error: <strong>%s</strong> filter prefix is not allowed and must be changed on the Filter %s settings <a href="%s" target="_blank">page</a>. Otherwise this site will not work properly.',
    'Error: following filter prefixes <strong>%s</strong> are not allowed and must be changed on the Filter %s settings <a href="%s" target="_blank">page</a>. Otherwise this site will not work properly.',
    count($warningPrefixes),
    'filter-everything'
    ), implode( ', ', $warningPrefixes ), $permalinksTabLabel, $permalinkOptionsUrl
    ),
    array(
    'strong' => array(),
    'a' => array('href' => true, 'target' => true)
    )
    );

    ?>
    <div class="notice wpc-error is-dismissible">
    <p><?php echo $message; // Already escaped ?></p>
    </div>
    <?php

    }

    }

    And for some reason your site returning a string, which should not be like that. What you can do is modify it a bit in the plugin itself via FTP in order to check if the data is correct and if not do the var_dump on it to understand what type of data you have there that it is working like that.

    Best Regards,
    Victor

    I fixed it by modifying the AdminHooks.php code, that gaved me access to my admin. I deleted the filters i previously created, deactivated the filter everything plugin and deleted it. Then reinstalled it to have the orginal AdminHooks.php back, and now my admin works. Thank you @fesupportteam for being so useless.

    @lkaufmann here is the code. Replace everything in adminhooks from line 137 to 179 with:

    public function checkForbiddenPrefixes()
    {
    $forbiddenPrefixes = flrt_get_forbidden_prefixes();
    $savedPrefixes = get_option( 'wpc_filter_permalinks', [] );

    // Ensure $savedPrefixes is an array
    if (!is_array($savedPrefixes)) {
    $savedPrefixes = maybe_unserialize($savedPrefixes);
    }
    if (!is_array($savedPrefixes)) {
    $savedPrefixes = []; // If still not an array, default to an empty array
    }

    $warningPrefixes = [];

    foreach( $forbiddenPrefixes as $prefix ) {
    if( in_array( $prefix, $savedPrefixes, true ) ) {
    $warningPrefixes[] = $prefix;
    }
    }

    $permalinkOptionsUrl = admin_url( 'edit.php?post_type=filter-set&page=filters-settings&tab=prefixes' );
    $permalinksTab = new PermalinksTab();
    $permalinksTabLabel = strtolower( $permalinksTab->getLabel() );

    if( ! empty( $warningPrefixes ) ){
    $message = wp_kses(
    sprintf(
    _n(
    'Error: <strong>%s</strong> filter prefix is not allowed and must be changed on the Filter %s settings <a href="%s" target="_blank">page</a>. Otherwise this site will not work properly.',
    'Error: following filter prefixes <strong>%s</strong> are not allowed and must be changed on the Filter %s settings <a href="%s" target="_blank">page</a>. Otherwise this site will not work properly.',
    count($warningPrefixes),
    'filter-everything'
    ),
    implode( ', ', $warningPrefixes ), $permalinksTabLabel, $permalinkOptionsUrl
    ),
    array(
    'strong' => array(),
    'a' => array('href' => true, 'target' => true)
    )
    );

    ?>
    <div class="notice wpc-error is-dismissible">
    <p><?php echo $message; ?></p>
    </div>
    <?php
    }
    }
    Thread Starter lkaufmann

    (@lkaufmann)

    Thank you for the replies! Editing AdminHooks.php and replacing that whole section did, in fact, fix the issue. A little out there and I’m still confused as to why it happened, but I’ve been able to create filters just fine now. Cheers, and thank you @fesupportteam for looking into it!

    Plugin Support fesupportteam

    (@fesupportteam)

    Hi @mihailungu

    We apologize for our limited ability to assist with such technical issues, we’re doing our best to help. Our role lies more in providing support on the plugin functionality rather than in-depth development/bugs fixing, as we’re not at the level of the plugin developers.

    This issue has been forwarded to our development team from the first request, and they’ve assured us it will be resolved in the next updates.

    Best Regards – Victor

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

The topic ‘Plugin crashes admin dashboard’ is closed to new replies.