• Resolved Mariette

    (@mariettej)


    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?

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author Mej de Castro

    (@mej)

    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 Team

    Thread Starter Mariette

    (@mariettej)

    I’m very glad to hear this as I use this kind of logic a lot on several websites

    Thank you!

    Plugin Author Mej de Castro

    (@mej)

    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,

    Thread Starter Mariette

    (@mariettej)

    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

    Plugin Author Mej de Castro

    (@mej)

    Hi @mariettej,

    We have relayed this to our dev to look for a workaround. We’ll keep you posted for updates!

    Thread Starter Mariette

    (@mariettej)

    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

    Plugin Author Mej de Castro

    (@mej)

    Hey @mariettej,

    Could you please try adding the code below to your functions.php file 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_page and get_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_id function 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!

    Thread Starter Mariette

    (@mariettej)

    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

    Plugin Author Mej de Castro

    (@mej)

    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 Team

    Thread Starter Mariette

    (@mariettej)

    OK, 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.
    Plugin Author Mej de Castro

    (@mej)

    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!

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

The topic ‘Conditional logic has stopped working after update’ is closed to new replies.