Theme_Upgrader::check_parent_theme_filter( bool $install_result, array $hook_extra, array $child_result ): bool
- Since
- 3.4.0
- Source
wp-admin/includes/class-theme-upgrader.php:124
Description
Hooked to the 'upgrader_post_install' filter by Theme_Upgrader::install().
Compatibility
- WordPress
- since 3.4.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.
Parameters
$install_resultbool$hook_extraarray$child_resultarray
Return value
bool
Performance profile
How much work a call to Theme_Upgrader::check_parent_theme_filter() 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
- Expensive
- Scaling
- Constant
- Instructions
- 10–96
- Plugin surface
- None
- Called by
- 0
Reaches an outbound HTTP request via wp_remote_get().
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 130.
Nothing here hands control to plugin code.
Nothing in core calls this; the cost is only what you spend yourself.
What it touches
- hookthird-party callbacks
apply_filters()one call below Theme_Upgrader::check_parent_theme_filter() - httpoutbound HTTP request
wp_remote_get()one call below Theme_Upgrader::check_parent_theme_filter()
Further down the call graph this can also reach query, option, cache, serialize and transient. Those are the worst case, several calls deep and usually down an error path, not what a normal call pays.
What one call costs · 5 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost Theme_Upgrader::check_parent_theme_filter() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
!->parent() | 10 | ->theme_info(), ->parent() |
->parent() && !->errors() | 35 | ->theme_info(), ->parent(), ->feedback(), ->parent(), ->errors(), ->parent(), ->display(), ->parent(), ->display(), ->feedback() |
->parent() && ->errors() | 45 | ->theme_info(), ->parent(), ->feedback(), ->parent(), ->errors(), ->get(), slug(), ->get(), ->feedback() |
->parent() && ->errors() && is_wp_error() | 49 | ->theme_info(), ->parent(), ->feedback(), ->parent(), ->errors(), ->get(), slug(), is_wp_error(), ->get(), ->feedback() |
->parent() && ->errors() && !is_wp_error() | 89–96 | ->theme_info(), ->parent(), ->feedback(), ->parent(), ->errors(), ->get(), slug(), is_wp_error(), ->feedback(), add_filter(), get_theme_root(), package(), is_wp_error(), remove_filter() |
Across PHP versions
Compiles the same on PHP 7.4, 8.1, 8.2, 8.3, 8.4, 8.5 and 8.6-dev: 130 instructions, 10–96 executed per call, 5 branches. 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.
Uses · 7
- themes_api()Retrieves theme installer pages from the WordPress.org Themes API.
- is_wp_error()Checks whether the given variable is a WordPress Error.
- add_filter()Adds a callback function to a filter hook.
- get_theme_root()Retrieves path to themes directory.
- remove_filter()Removes a callback function from a filter hook.
- Theme_Upgrader::theme_info()Gets the WP_Theme object for a theme.
- Theme_Upgrader::run()
Source code
public function check_parent_theme_filter( $install_result, $hook_extra, $child_result ) { // Check to see if we need to install a parent theme. $theme_info = $this->theme_info(); if ( ! $theme_info->parent() ) { return $install_result; } $this->skin->feedback( 'parent_theme_search' ); if ( ! $theme_info->parent()->errors() ) { $this->skin->feedback( 'parent_theme_currently_installed', $theme_info->parent()->display( 'Name' ), $theme_info->parent()->display( 'Version' ) ); // We already have the theme, fall through. return $install_result; } // We don't have the parent theme, let's install it. $api = themes_api( 'theme_information', array( 'slug' => $theme_info->get( 'Template' ), 'fields' => array( 'sections' => false, 'tags' => false, ), ) ); // Save on a bit of bandwidth. if ( ! $api || is_wp_error( $api ) ) { $this->skin->feedback( 'parent_theme_not_found', $theme_info->get( 'Template' ) ); // Don't show activate or preview actions after installation. add_filter( 'install_theme_complete_actions', array( $this, 'hide_activate_preview_actions' ) ); return $install_result; } // Backup required data we're going to override: $child_api = $this->skin->api; $child_success_message = $this->strings['process_success']; // Override them. $this->skin->api = $api; $this->strings['process_success_specific'] = $this->strings['parent_theme_install_success']; $this->skin->feedback( 'parent_theme_prepare_install', $api->name, $api->version ); add_filter( 'install_theme_complete_actions', '__return_false', 999 ); // Don't show any actions after installing the theme. // Install the parent theme. $parent_result = $this->run( array( 'package' => $api->download_link, 'destination' => get_theme_root(), 'clear_destination' => false, // Do not overwrite files. 'clear_working' => true, ) ); if ( is_wp_error( $parent_result ) ) { add_filter( 'install_theme_complete_actions', array( $this, 'hide_activate_preview_actions' ) ); } // Start cleaning up after the parent's installation. remove_filter( 'install_theme_complete_actions', '__return_false', 999 ); // Reset child's result and data. $this->result = $child_result; $this->skin->api = $child_api; $this->strings['process_success'] = $child_success_message; return $install_result; }Changelog
Introduced in 3.4.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-admin/includes/class-theme-upgrader.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.