Conditional logic has stopped working after update
-
Hi
I have been using this kind of logic to specify a specific page and its child pages:
is_page(1424) || 1424 == wp_get_post_parent_id(get_the_ID())
(along with “show on checked pages > “Pages” post types)
but this has stopped working since the latest update.
Can you help please?
-
Hi @mariettej,
Thank you for bringing this to our attention. Our team will carefully review the matter and coordinate with the dev team to determine the next steps. Rest assured, weβre prioritizing this and will keep you updated with any progress.
Kind Regards,
Mej, Widget Options TeamI’m very glad to hear this as I use this kind of logic a lot on several websites
Thank you!
Hi @mariettej,
Thanks for your inputs. The code execution functionality was flagged as potentially dangerous, so we decided to restrict the display logic feature to administrators only.
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.
Thanks and let us know if you have further questions.
Kind Regards,
Thank you for explaining the situation Mej
In which case, would you be able to help me get this code working again (for “is page id and children of page id”):
is_page(1424) || 1424 == wp_get_post_parent_id(get_the_ID())
many thanks
Hi @mariettej,
We have relayed this to our dev to look for a workaround. We’ll keep you posted for updates!
Hi Mej
Will they make this a priority as, to be honest, it’s really inconvenient how things are at the moment. Can we have an expected delivery date for this please.
And is the plan to make the workaround fix the current issue (without further input from me) as re-doing all the conditional logic I have in place at the moment on a number of websites would be a very labourious task.
This is bearing in mind that I have already had to re-do the logic once already 7 months ago (see previous support thread https://wordpress.org/support/topic/conditional-logic-not-working-any-more/)
thanks
Hey @mariettej,
Could you please try adding the code below to your
functions.phpfile or another suitable location, and let us know if this resolves the issue?function add_extra_hooks( $allowed_functions ) {
$allowed_functions[] = 'wp_get_post_parent_id';
return $allowed_functions;
}
add_filter( 'widgetopts_allowed_php_functions', 'add_extra_hooks' );To clarify, the functions
is_pageandget_the_ID()are already included in the allowed WordPress functions for Widget Options. You can review the full list here: List of Allowed WordPress Functions. Please note that functions are now limited.On the other hand, the
wp_get_post_parent_idfunction is not included by default, which is why we suggest adding the code above. Kindly test this out and let us know if the display logic works again.Looking forward to your response!
Hello Mej
Thank you very much for your quick fix. That seems to have worked π
Will this function be included by default in future updates or will I need to add this manually every time?
thanks
Hi @mariettej,
Thanks for the update! The filters youβve added to your functions.php file are part of your theme files. We recommend creating a child theme to ensure your customizations remain safe and intact during theme updates.
Please also note that these filters were added manually because the functions you are using for your conditional logic are not currently included in the list of allowed functions for Widget Options.
Thanks again!
Kind Regards,
Mej, Widget Options TeamOK, thanks for clarifying. I did add the code to the child theme – was just hoping I wouldn’t need to do this for future websites. I’ve made a note to remember… π
-
This reply was modified 6 months, 3 weeks ago by
Mariette.
Hi @mariettej,
For any future websites, please note that the provided filters will need to be added as well if you plan to use the same conditional logic code for your widgets. Thanks!
-
This reply was modified 6 months, 3 weeks ago by
The topic ‘Conditional logic has stopped working after update’ is closed to new replies.