wp_get_wp_version(): string
- Since
- 6.7.0
- Source
wp-includes/functions.php:9103
Description
Returns an unmodified value of $wp_version. Some plugins modify the global in an attempt to improve security through obscurity. This practice can cause errors in WordPress, so the ability to get an unmodified version is needed.
Compatibility
- WordPress
- since 6.7.0
- PHP
- 7.4–8.6-dev
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.
Return value
string- The current WordPress version.
Performance profile
How much work a call to wp_get_wp_version() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.
- Cost class
- Trivial
- Scaling
- Constant
- Instructions
- 4–9
- Plugin surface
- None
- Called by
- 32
Touches nothing outside its own arguments.
No loop in the body: the same number of instructions runs whatever you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 9.
Nothing here hands control to plugin code.
32 places in core call this, so the cost is paid more often than your own code shows.
What one call costs · 1 distinct outcome
One number would be a lie: the work depends on which branch runs. These are every distinct cost wp_get_wp_version() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
| always | 4–9 | none |
Across PHP versions
Compiles the same on PHP 7.4, 8.1, 8.2, 8.3, 8.4, 8.5 and 8.6-dev: 9 instructions, 4–9 executed per call, 1 branch. The work does not change between versions.
An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.
Used by · 32
- Plugin_Installer_Skin::do_overwrite()Checks if the plugin can be overwritten and outputs the HTML for overwriting a plugin on upload.
- Plugin_Upgrader::bulk_upgrade()Upgrades several plugins at once.
- Plugin_Upgrader::check_package()Checks that the source package contains a valid plugin.
- Theme_Installer_Skin::do_overwrite()Checks if the theme can be overwritten and outputs the HTML for overwriting a theme on upload.
- Theme_Upgrader::bulk_upgrade()Upgrades several themes at once.
- Theme_Upgrader::check_package()Checks that the package source contains a valid theme.
- WP_Automatic_Updater::after_core_update()Checks whether to send an email and avoid processing future updates after attempting a core update.
- WP_Automatic_Updater::run()Kicks off the background update process, looping through all pending updates.
- WP_Debug_Data::get_wp_core()Gets the WordPress core section of the debug data.
- WP_REST_Pattern_Directory_Controller::get_items()Search and retrieve block patterns metadata
- WP_Site_Health::get_test_wordpress_version()Tests for WordPress version and outputs it.
- _maybe_update_core()Determines whether core should be updated.
Show all 32
- core_auto_updates_settings()Display WordPress auto-updates settings.
- core_update_footer()Returns core update footer message.
- is_wp_version_compatible()Checks compatibility with the current WordPress version.
- list_core_update()Lists available core updates.
- list_plugin_updates()Display the upgrade plugins form.
- maintenance_nag()Displays maintenance nag HTML message.
- plugins_api()Retrieves plugin installer pages from the WordPress.org Plugins API.
- register_core_block_style_handles()Registers core block style handles.
- themes_api()Retrieves theme installer pages from the WordPress.org Themes API.
- translations_api()Retrieve translations from WordPress Translation API.
- wp_check_browser_version()Checks if the user needs a browser update.
- wp_credits()Retrieves the contributor credits.
- wp_generate_block_templates_export_file()Creates an export of the current templates and template parts from the site editor at the specified path in a ZIP file.
- wp_get_available_translations()Get available translations from the WordPress.org API.
- wp_get_popular_importers()Returns a list from WordPress.org of popular importer plugins.
- wp_update_plugins()Checks for available updates to plugins based on the latest versions hosted on WordPress.org.
- wp_update_themes()Checks for available updates to themes based on the latest versions hosted on WordPress.org.
- wp_version_check()Checks WordPress version against the newest version.
- wp_welcome_panel()Displays a welcome panel to introduce users to WordPress.
- wpdb::check_database_version()Determines whether the database server is at least the required minimum version.
Source code
function wp_get_wp_version() { static $wp_version; if ( ! isset( $wp_version ) ) { require ABSPATH . WPINC . '/version.php'; } return $wp_version;}Changelog
Introduced in 6.7.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 7.1.0 tag, from
src/wp-includes/functions.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.