Conditional logic doesn’t work
-
Hello,
I updated the Widget Options to the latest version 4.1.2 in WordPress version 6.8.2, and conditional logic no longer appears.
Roll back to 4.1.1 and it works fine.
We would like you to proceed with an investigation into this matter.Best regards,
-
Hi @taka1,
Thank you for reaching out to us. Could you please let us know how the Conditional Logic does not appear on your end after updating Widget Options to version 4.1.2? Please also include which roles the Conditional Logic is not appearing for. Screenshots are highly appreciated too!
We’ll be glad to check this further once we have the details.
Kind Regards,
Mej, Widget Options TeamHi @mej,
Since this is a test environment in Japanese, we will send you a screenshot translated into English.
Below is the widget settings screen. The sidebar is only visible in certain categories.

Widget Options Version 4.1.1 shows the sidebar with widget options.

Widget Options Version 4.1.2 does not display the sidebar with widget options.

I have used the rollback plugin many times to see the difference in display due to version changes, but it doesn’t show well in 4.1.2. Additionally, there are no changes or updates other than the widget options.
thank you
Hi @mej,
Due to basic authentication, no screenshots were displayed, so we will post images.
thank you
Hi @taka1,
We will take our time to review this carefully and coordinate with our dev team for further action. Rest assured, we’ll keep you posted with any updates.
Hi @taka1,
Thanks for the screenshots. We have reviewed these issues, and the code execution functionality was flagged as potentially dangerous, so we decided to restrict the display logic feature to administrators only. This might cause the logic codes to be affected by the recent update.
If you are the website administrator and your conditional logic code is no longer working, we highly recommend updating the code or adjusting the conditions to ensure compatibility with the latest version.
Please let us know if you need further guidance. We’ll be glad to help.
Kind Regards,
Mej, Widget Options TeamHi @mej,
Please explain in detail about updating your code or adjusting your terms to ensure compatibility with the latest versions.
For example, how should I modify the following conditional logic?
in_category(array(‘example1,’example2’,’example3’))is_single( array( 1 , 2 ))thank you.
-
This reply was modified 8 months, 3 weeks ago by
taka1.
Hi @taka1,
We’ve relayed this to our dev team to request a detailed explanation. Once we receive their feedback, we’ll keep you updated right away.
We truly appreciate your patience in the meantime!
Hi @taka1,
We’ve received feedback from our developers regarding this issue. In the latest version of Widget Options, some of the display logic functions were removed due to vulnerability reports that might pose risks to users.
Based on the logic code you’re using, the function
in_categoryis not currently included in the list of allowed functions. To review the functions that are permitted by default, you may checkincludes/extras.phpand look forwidgetopts_get_allowed_php_functionsandwidgetopts_get_allowed_wp_functions.If you’d like to enable
in_category, you will need to extend the allowed functions list by adding a filter. Please note that adding custom functions may introduce security risks, so we recommend proceeding with caution.Here’s the code snippet you can add to your
functions.phpfile (or another suitable location in your theme/plugin):function add_extra_hooks( $allowed_functions ) {
$allowed_functions[] = 'in_category';
return $allowed_functions;
}
add_filter( 'widgetopts_allowed_php_functions', 'add_extra_hooks' );This should allow the
in_categoryfunction to work again on your site. Please feel free to modify the code based on your current setup.Thanks and let us know if this works on your end.
Kind Regards,
Mej, Widget Options TeamHi @mej,
We have confirmed that the code in
functions.phpyou provided has worked.It’s an essential plugin for me.
We would like to express our sincere gratitude.
thank you.
-
This reply was modified 8 months, 2 weeks ago by
taka1.
Hi @taka1,
Thanks for the update! We’re glad to hear that the issue is now resolved on your website. Please note that these filters are required for your conditional logic to work as expected. We recommend checking your functions.php file after theme updates to ensure the filters are not overwritten.
If you run into any other issues or have further questions, please don’t hesitate to reach out. We’re here to help!
Kind Regards,
Mej, Widget Options Team -
This reply was modified 8 months, 3 weeks ago by
The topic ‘Conditional logic doesn’t work’ is closed to new replies.