Skip Navigation

[Resolved] get_current_screen() is null on CRED edit post screen

This support ticket is created 6 years, 1 month ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

Tagged: 

This topic contains 8 replies, has 2 voices.

Last updated by Clifford 6 years ago.

Assisted by: Minesh.

Author
Posts
#1148669

Re: https://developer.wordpress.org/reference/functions/get_current_screen/

When at a URL like

/wp-admin/post.php?post=117&action=edit

, where 117 is a CRED form, running

get_current_screen()

is null

Please use the WP_Screen class for CRED in wp-admin.

Thank you.

#1148719
Image 2018-11-18 at 3.32.05 PM.png

Having to code around this (see screenshot), I noticed post, post_ID, and post_id all had to be checked. It felt cluttered/inefficient. Maybe could clean that up too, please.

Again, using WP_Screen should make much of this code unnecessary.

#1149018

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Well - could you please share file path for the code your shared and I will share your concern with our Devs.

#1151197

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Ok Beda contacted me with more information on that. I recognize now the screenshot you shared for the code is not part of Toolset but you wrote that custom code and as per our support policy, we do not entertain any custom programming needs.

Your point could be valid but I checked with one of our Dev and get_current_screen() is just works fine when he try to edit the Toolset form on backend (admin). Dev tested with PHP version 7.2.2 - could you please tell us what PHP version you are using?

Could you please send me debug information that will help us to investigate your issue.
=> https://toolset.com/faq/provide-debug-information-faster-support/

#1156422

No debug information is needed. This is just asking to conform to WordPress' best practices. Please share with the developers.

#1157549

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Yes - thank you. I will share this with our Devs.

#1161317

OK, thank you.

#1161329

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Your welcome - please feel free to close the ticket.

#1164534

OK