[wp-trac] [WordPress Trac] #39795: WordPress objects are only accessible via global variables
WordPress Trac
noreply at wordpress.org
Mon Feb 6 13:47:24 UTC 2017
#39795: WordPress objects are only accessible via global variables
--------------------------------------+-----------------------------
Reporter: jdmweb | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: trunk
Severity: normal | Keywords:
Focuses: administration, template |
--------------------------------------+-----------------------------
Hello.
Here's the context:
I'm trying to write some high quality plugins that go through some code
analysis tools before any new release is made available to the public.
That means that the code that is being analysed is on a repository of its
own.
When running the plugin code through such tools (sensio labs insights for
example), some errors are marked as major issues: "Global variable or
function should never be used" and that is related to the access of some
WordPress objects like $blog_id, $wpdb and $wp_filesystem to name a few.
Upon investigation I found out that for $blog_id, there was an
alternative, which is to use the get_current_blog_id() function. That is
great, because it respects the WordPress way of working on the WordPress
side, and in my plugin, I can now use a function instead of a global
variable.
Could we make some equivalent functions for the other global WordPress
objects? Like get_wp_db(), get_wp_filesystem() for example?
Thanking you.
Regards.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/39795>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list