[wp-trac] [WordPress Trac] #45861: Global variable in plugin main file

WordPress Trac noreply at wordpress.org
Tue Jan 8 10:51:14 UTC 2019


#45861: Global variable in plugin main file
--------------------------+-----------------------------
 Reporter:  rilwis        |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Plugins       |    Version:
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 In the main plugin file, if we declare a variable, it will be used as a
 global variable in WordPress.

 This might lead to conflict for global variable names.

 The code is in [https://core.trac.wordpress.org/browser/trunk/src/wp-
 settings.php#L342 wp-settings.php] file.

 A simple fix is creating a function to load a plugin and include main
 plugin file inside that function. So the scope is function scope, not
 global scope.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/45861>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list