ButlerBlog

chad butler's weblog

  • About
  • Blog
  • WordPress Plugins
  • Contact
Home / Web / WordPress / Plugin for WP Plugin Developers: Show Current Screen Object

Plugin for WP Plugin Developers: Show Current Screen Object

By Chad Butler Leave a Comment

You are working on your fancy new WordPress Plugin and you want to incorporate some nifty hooks into the menu system, or you are trying to add some contextual help without overriding the existing help text.  How can you find the id of the page to hook into?

Wonder no more.  I’ve written a simple plugin to help you.

On the admin side, WordPress uses an object to store information about the current screen you are on.  This includes the id, the action, the parent file, and some other miscellaneous and sundry items.  This is information a plugin developer needs to hook into, but, as good as the WordPress Codex is, sometimes it can be hard to find certain things, especially if you are tapping in to an area that there just hasn’t been a lot of outside development.  For me, this came while trying to add contextual help in the WP admin areas for my plugin WP-Members.

I wanted to add to the existing contextual help (that little help menu that pulls down from the WP admin header) for admin panels that WP-Members used, such as its own plugin page, but also the post and page edit screens, some of the settings screens, etc.  For this, I needed “screen_id” of the screen/panel to pass to the filter for contextual help.  Maybe I just wasn’t looking in the right place, but it seem that there really isn’t any documentation in the codex on this.

The screen_id is in a global array called $current_screen.  So I figured I could dump the contents of the array on the screen to find the ids I needed.  Enter the plugin.  I did this as a plugin so I could turn it on and off as needed.  It basically gets the value of $current_screen and uses print_r to dump the values.  With the plugin I was able to add a little css so it would display in a box at the upper right of each admin screen.  That way, as I browsed through the panels I wanted to hook into, I could get the screen info to apply to the filter.

[ Get the script ]

Enjoyed this article?

Don't miss a single post. Subscribe to our RSS feed!

  • Facebook
  • Twitter
  • Email
  • Print
  • More
  • LinkedIn
  • Reddit
  • Tumblr
  • Pocket
  • Pinterest

Filed Under: WordPress Tagged With: plugins, WordPress

About Chad Butler

Chad Butler is a freelance writer and web developer. He has developed several popular WordPress plugins and has written for forbes.com, sfomag.com, and investopedia.com. He also runs a small organic farm in east Georgia.

Join Us!

I will never share your information. No spam. No junk. No kidding. Unsubscribe anytime.

Recent Posts:

  • 3 Best Online Courses to
    Improve your Digital Marketing Skills
  • Full Site Editing –
    the Future of WordPress?
  • The Right Product at the Right Time
  • Top 3 Time Wasters
    Keeping You From Success
  • Top 8 Tips to Create Your Own Website Easily With WordPress
  • How to Fix wp_mail
    Settings for WordPress Email
  • 7 Reasons Why Social Networking Can Help Your Business
  • Understanding WordPress wp_mail and
    how to fix it
  • Prevent WordPress email sent
    to spam with this
  • Easy wp mail SMTP settings for WordPress





Archives

  • About
  • Blog
  • Archive
  • Contact

Site powered by WordPress, running on the Genesis Framework from StudioPress.

Unless otherwise noted, content on this site is © 2006-2022 ButlerBlog and may not be reproduced without express written permission from the author.

Some content may include affiliate links for which this site receives a small commission.

loading Cancel
Post was not sent - check your email addresses!
Email check failed, please try again
Sorry, your blog cannot share posts by email.