In your example, there is currently no difference. You get the same object, if there is one. Try it:
global $current_screen;
$current_screen->foo = 1;
$screen = get_current_screen();
$screen->foo = 2;
echo '$current_screen->foo: ' . $current_screen->foo; // 2!
The simple reason: objects are not passed as a copy in PHP.
But: global variables are really bad, because everyone can change them any time. One day far, far away, WordPress might deprecate this global variable. If you are using the function wrapper to get the object, you should be fine. Otherwise, your code might raise notices.
And always check if you get indeed an object. $current_screen->post_type
might not exist.
Related Posts:
- Global Objects and Public Methods
- Getting List of all registered Dashboard Widgets
- What is the proper method of using global $post?
- how to get the post id in plugin
- How do I get a reference to the HTML memory buffer while the page is being constructed?
- Sessions in plugin development?
- What is the advantage of using wp_mail?
- Plugin Form Submission Best Practice
- Plugin directory “Last Updated” not changed after initial commit?
- What is the recommended way to create plugin administration forms?
- Dashboard like meta boxes in my plugin – how to save their position and open/closed state?
- Using AJAX in FrontEnd with WordPress Plugin Boilerplate (wppb.io)
- How do I implement a jQuery UI dialog modal in a WP plugin?
- WP Cron – Run Cron after evey 15 minutes at a specific time for the next three hours
- Which to use to execute code during the saving of a plugin settings page?
- Authoritative answer on which boots first – Plugins or Themes?
- How to Add Font Awesome Icons to WordPress Menus?
- Overwriting Core WordPress Functions with Plugins
- How do I handle multiple Submit buttons in plugin’s option page?
- add_meta_box() to Category Edit Screen?
- How to properly load text domain of custom mu plugin
- How to add quick edit and bulk edit fields to users admin section
- Whats the difference between blog_info(‘stylesheet_url’) difference get_stylesheet_uri()
- What does $_registered_pages do?
- using get_option to add a different js
- Add Submenu Link in add_submenu_page That Opens in a New Window
- How to check if a stylesheet is already loaded?
- How do I change the initial quantity of a product in woocommerce?
- Redirect traffic to plugin
- How to insert data to a database table when the field is not yet created?
- Show special field when correct shipping is chosen
- Custom Taxonomy to dropdown box on adminside wordpress
- On cliking add new post redirect user to a custom page first
- Create a new post using rest api and save featured image using an external image url
- wp.template() returns tags in Ajax response
- How to restrict access to image folder depending on whether product is purchased or not?
- Plugin directory says that my plugin it’s not availabe in Spanish, but it is
- Caching the_content calls
- How to hide or rename “X” and “x-child” references in website source?
- Using ob_get_content to get_search_form puts into infinite loop
- How to build a fool proof AdSense revenue sharing model?
- Run a function when new image is uploaded in media library
- Setting up Version Control for WordPress plugin development
- Let plugin check if taxonomy is already registered by another plugin
- get author of published post
- Error passing post_content to function
- How to access all array values from do_action_ref_array()?
- How to add custom post widgets as tags into wordpress
- How to register my code as a plugin
- Submit form to a different PHP file in the same plugin folder
- What might be the reason of Couldn’t fetch mysqli_result on another domain?
- How to get terms for taxonomy
- If $var is empty, return 404.
- Listing wordpress users with a search function
- Cannot stop wpautop from messing up my plug-in output
- Adjust query on single
- Plugin won’t activate
- dbdelta failing with error: “WordPress database error Table ‘wp_2_myPlugin’ already exists
- What should I pass for $needed_dirs when calling _unzip_file_pclzip (aka PclZip)?
- Custom Path for a Plugin
- Plugin could not be activated because it triggered a fatal error?
- Get cat parameter from admin-ajax
- Update product prices from remote file
- How to determine primary editor for a page/post
- Using wp_mail to send email?
- Which wp plugin can use Create, Edit and Delete Email address from WordPress Dashboard
- WPGut – Updating failed and shortcode?
- product-attribute-slug-is-too-long-28-characters-max
- Limit get_next_post to posts from the same author
- How the add_action is included in the plugin development
- how to create a shortcode from a variable in plugin
- Any way, hook to add content right before the “read more” link?
- Error Connecting to Database WHEN Installing WordPress on XAMPP [Tried All the Usual Stuff] (Pics Included)
- How do I ensure I can loop through every enqueued script and CSS?
- What is the source of the $post_id in a hook argument?
- WordPress Fatal error: Uncaught Error: Call to undefined function dbDelta()
- WordPress use template
- Adding body class in author page for custom role
- Plugins Settings page not updating
- TinyMCE 4.7.11 – Enable hidden WordPress core plugins? (referencing a wp-includes from plugin.php)
- Warning: Illegal string offset – on homepage
- Enqueue scripts based on site.
- My enqueue admin style function doesn’t work because of ?=ver
- Use content filter on the post that is password-protected
- WordPress filter custom posts by multi terms of of a taxonomy
- foreach argument to get specific file types getting too many returns
- Query only title/field/featured media of posts [closed]
- To remove rendering of menus and header, plugin or theme?
- How can I give access to my plugin sections in admin?
- Displaying External Data – Not Posts
- Making plugin output customizable
- Return all roles, including custom roles
- Mapping multiple URLs to same page
- Installing plugins on installation/activation
- Loading jQuery library from WordPress admin
- Render raw html in Gutenberg block
- How to create A – Z List with pictures?
- How do I display and edit other posts within the ‘Edit Post’ area of Wp-Admin Dashboard
- A better way of getting draft posts that has a particular post meta using get_posts function
- Save translation file of third party plugin in a custom plugin?