I wrote the following custom conditions:
add_filter('bricks/conditions/groups', function ($groups) {
$groups[] = [
'name' => 'custom_functions',
'label' => esc_html__('Custom Functions', 'my-plugin'),
];
return $groups;
});
add_filter('bricks/conditions/options', function ($options) {
error_log('[CHECK] Registering Bricks condition');
$options[] = [
'key' => 'has_related_products',
'label' => esc_html__('Has Related Products', 'my-plugin'),
'group' => 'custom_functions',
'compare' => [
'type' => 'select',
'options' => [
'==' => esc_html__('is', 'my-plugin'),
'!=' => esc_html__('is not', 'my-plugin'),
],
'placeholder' => esc_html__('is', 'my-plugin'),
],
'value' => [
'type' => 'select',
'options' => [
'true' => esc_html__('True', 'my-plugin'),
'false' => esc_html__('False', 'my-plugin'),
],
],
'callback' => function($compare, $value) {
$product_id = get_the_ID();
error_log('[DEBUG] Bricks condition evaluating...');
error_log('[DEBUG] Current post ID: ' . $product_id);
$related = wc_get_related_products($product_id);
error_log('[DEBUG] Related count: ' . count($related));
error_log('[DEBUG] Related IDs: ' . implode(', ', $related));
// FORCE SHOW FOR DEBUGGING
return true;
},
];
return $options;
});
add_filter('bricks/conditions/groups', function ($groups) {
$groups[] = [
'name' => 'custom_debug',
'label' => esc_html__('Debug Group', 'my-plugin'),
];
return $groups;
});
add_filter('bricks/conditions/options', function ($options) {
$options[] = [
'key' => 'force_always_true',
'label' => esc_html__('Force True (Debug)', 'my-plugin'),
'group' => 'custom_debug',
'compare' => [
'type' => 'select',
'options' => [
'==' => esc_html__('is', 'my-plugin'),
],
],
'value' => [
'type' => 'select',
'options' => [
'true' => esc_html__('True', 'my-plugin'),
],
],
'callback' => function ($compare, $value) {
error_log('[DEBUG] Bricks forced debug condition executed');
return true;
},
];
return $options;
});
the conditions get registered (debug.log) but the callbacks are never being executed. I tried it in different scenarios. Could this be an execution bug?