[wp-trac] [WordPress Trac] #61627: Introduce helper function get the unmodified value of `$wp_version`.

WordPress Trac noreply at wordpress.org
Wed Jul 10 23:46:42 UTC 2024


#61627: Introduce helper function get the unmodified value of `$wp_version`.
---------------------------+------------------------------------------
 Reporter:  peterwilsoncc  |      Owner:  (none)
     Type:  enhancement    |     Status:  new
 Priority:  normal         |  Milestone:  Awaiting Review
Component:  General        |    Version:
 Severity:  normal         |   Keywords:  needs-patch needs-unit-tests
  Focuses:                 |
---------------------------+------------------------------------------
 In a number of locations WordPress requires the `version.php` file in
 order to get an accurate value for the current WordPress version. An
 [https://core.trac.wordpress.org/browser/trunk/src/wp-
 admin/includes/dashboard.php?marks=1822-1823&rev=58705#L1822 example from
 the dashboard] is:

 {{{#!php
 <?php
 // Include an unmodified $wp_version.
 require ABSPATH . WPINC . '/version.php';
 }}}

 The reason Core is required to do this is because there is advice on a
 number of websites to hide the WordPress version by overriding the
 `$wp_version` global in a plugin. The stated benefit is for security
 through obscurity but it will break WordPress functionality.

 To avoid the need to repeat the code and to allow for ease of access to
 the real version of WordPress, I suggest a helper function be introduced:

 {{{#!php
 <?php
 function wp_get_version() {
         // Include an unmodified $wp_version.
         require ABSPATH . WPINC . '/version.php';

         return $wp_version;
 }
 }}}

 Suggestions for improving the name of the function are welcomed.

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


More information about the wp-trac mailing list