Callback Function no longer found after 3.0 update
-
Hi there,
After updating Filter & Grids (YMC Smart Filter) to the latest major version (v3+), my custom callback that used to work perfectly is no longer recognized by the plugin. I’ve followed the new documentation and upgrade notes, but the plugin still says the function can’t be found.Context
I’m using a custom callback to enable true AND filtering for a single taxonomy on a “project” custom post type.
This worked fine before the architecture change. My function was defined in a mu-plugin (a functionality plugin) and whitelisted via
YMC_CALLBACK_FUNCTION_WHITELIST, and selected in the grid’s “Callback (theme function)” field, like this:
After the update, the grid no longer detects or executes the callback. Instead I now see a notice that no callbacks are found:

This is my code (in a mu-plugin):
// Whitelist the function for YMC Smart Filter
if ( ! defined( 'YMC_CALLBACK_FUNCTION_WHITELIST' ) ) {
define( 'YMC_CALLBACK_FUNCTION_WHITELIST', array(
'ww_filter_cpt_by_terms'
) );
}
/**
* Reusable filter callback for multiple CPTs and taxonomies.
* Supports true AND filtering with fallback to "show all" when no filters are applied.
*/
// Custom callback function for YMC Smart Filter
function ww_filter_cpt_by_terms( $atts ) {
$cpt = isset($atts['cpt'][0]) ? sanitize_key($atts['cpt'][0]) : 'post';
$taxonomy = isset($atts['tax'][0]) ? sanitize_key($atts['tax'][0]) : '';
$terms = isset($atts['term']) && is_array($atts['term']) ? array_map('intval', $atts['term']) : [];
if ( empty($taxonomy) ) {
// No taxonomy to filter by – return all posts for this CPT
return [
'post_type' => $cpt,
'posts_per_page' => -1,
'post_status' => 'publish',
];
}
// Get all active (non-empty) term IDs in this taxonomy
$active_term_ids = get_terms([
'taxonomy' => $taxonomy,
'fields' => 'ids',
'hide_empty' => true,
]);
/**
* Detect if this is the plugin's default "all filters preselected" case.
* If all active terms are in the selected list, return all posts instead.
*/
/**
* Important:
* When no filters are selected on the frontend,
* the plugin still sends *all* active terms to this callback.
* This makes it look like filters were applied, when they weren't.
*
* To detect this, we check if the selected terms match all active terms.
* If so, we return all posts (i.e., no filtering).
*
* ⚠️ Note: If a user selects *all filters manually*, or a post happens
* to have *all categories*, this will still show all posts.
* This is acceptable in our use case, but worth knowing.
*/
if ( empty($terms) || count($terms) === count($active_term_ids) ) {
return [
'post_type' => $cpt,
'posts_per_page' => -1,
'post_status' => 'publish',
];
}
// Apply AND filter logic
return [
'post_type' => $cpt,
'posts_per_page' => -1,
'post_status' => 'publish',
'tax_query' => array(
array(
'taxonomy' => $taxonomy,
'field' => 'id',
'terms' => $terms,
'operator' => 'AND',
),
),
];
}Would you be able to point me in the right direction with this?
Many thanks in advance for your help.
You must be logged in to reply to this topic.