• Jorion Tech

    (@jorionng)


    Hi,

    We're experiencing a fatal error caused by the payment-forms-for-paystack plugin
    calling get_current_screen() in class-forms-update.php at line 602 via the
    save_post hook.

    This function only exists in the wp-admin context. When WordPress REST API
    requests trigger save_post (e.g. creating or updating posts programmatically),
    get_current_screen() is unavailable, causing an uncaught fatal error that crashes
    the entire site.

    Full error:
    Uncaught Error: Call to undefined function
    paystack\payment_forms\get_current_screen() in
    /wp-content/plugins/payment-forms-for-paystack/includes/classes/class-forms-update.php:602

    The fix is straightforward — wrap the get_current_screen() call with a context
    check:

    if (!function_exists('get_current_screen') || !is_admin()) {
    return;
    }
    $screen = get_current_screen();

    This prevents the function from running outside wp-admin while preserving all
    existing functionality within the admin interface.

    Could you please apply this fix in the next plugin update? As a temporary
    workaround we have added a custom plugin that removes the save_post hook during
    REST API requests, but this causes post previews to break.

    WordPress version: latest
    Plugin version: current (no updates available)

    Thank you.

You must be logged in to reply to this topic.