I am developing a WooCommerce plugin and I am using get_current_screen
to identify the current screen slug to load css and js.
But when using WooCommerce Branding plugin or any other language than English, the slug changes.
Eg : default slug will be like woocommerce-settings
.
If using branding, then it changes like this wp-dev-settings
.
I just wanted to know how I can identify the current screen slug ?
You can Try WordPress global variable in some contexts
global $pagename;
or
You can identify the current screen slug from the ‘parent’ attribute of the screen object. For example, if my shop name via WC Branding plugin is “Vishals Shop”, then:
[base] => vishals-shop_page_wc-settings
[parent_base] => woocommerce
Now you can replace the shop name with the parent_base & get the real slug name of that page.