• Resolved matthijscremers

    (@matthijscremers)


    Expression contains disallowed function calls. error when moving our conditional code to the snippet functionality.

    See our code which worked before, why does this not work anymore?

    is_product_category( ‘Category’ ) || term_is_ancestor_of( 123, get_queried_object_id(), ‘product_cat’ )

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Ryan from Marketing Fire

    (@atxlovesplugins)

    Hey @matthijscremers sorry you’re running into an issue! Can you confirm if you’re using the latest version? We released two in succession and the latest one should have fixed this issue. (But please confirm and send the version number!)

    Thread Starter matthijscremers

    (@matthijscremers)

    @atxlovesplugins we are on 4.2.1

    I checked the plugin source code to see where it’s coming from and in the array with allowed php and wordpress functions is_product_category, term_is_ancestor_of & get_queried_object_id are missing.

    Is this done with a reason? We used above condition to determine if we are on Woocommerce product category X, or on a child-category of this parent product category.

    Plugin Author Mej de Castro

    (@mej)

    Hi @matthijscremers,

    Sorry to hear that you ran into these issues while moving your logic code to the new snippet system.

    This error occurs because the functions you were using are not included in the list of allowed WordPress/PHP functions. To enable these functions again, please add the following filter to your functions.php file:

    function add_extra_hooks( $allowed_functions ) {
    // Add your custom functions here
    $allowed_functions[] = 'is_product_category';
    $allowed_functions[] = 'term_is_ancestor_of';
    $allowed_functions[] = 'get_queried_object_id';

    return $allowed_functions;
    }

    add_filter( 'widgetopts_allowed_php_functions', 'add_extra_hooks' );

    Please make sure to add this filter to your functions.php file before migrating or adding the code again in the Widget Options Snippets page.

    I’ve also included a screenshot below for your reference, showing that the code you provided is no longer producing any errors.

    We reduced the list of allowed WordPress and PHP functions to help prevent potential vulnerabilities, which is why some functions now need to be manually added through a filter.

    Thanks and let us know how it goes on your end.

    Kind Regards,
    Mej, Widget Options Team

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

You must be logged in to reply to this topic.