Skip to content

WooPayments screens are not identifiable with get_current_screen() – generic screen ID used for all screens #10439

@nagpai

Description

@nagpai

A unique screen ID for each admin page is very important for various use cases notably:

  • To conditionally execute code for a specific screen
  • To accurately track it using tools such as track tickets, tracks events, or any similar analytics tool.

WordPress core and WooCommerce have a unique screen ID for each admin page that can be sought using the get_current_screen() function. However, we have a discrepancy within almost all WooPayments admin pages.

Running get_current_screen()->id within any of the inner admin pages of WooPayments ( e.g. Payments -> Transactions , Payments -> Payouts , and Payments->Disputes) , does not give a unique screen ID, but rather returns - woocommerce_page_wc-admin . This is not unique and does not give us an accurate depiction of where the function was called.

Notes

  • The usage of unique screen ID instead of extrapolating it with query parameters came up in a review on another PR, where we were implementing a track event.
  • Related internal discussion - p1740360862997249-slack-C04MVBQC0MS

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions