Summery Summery
Check if a child theme is being installed and we need to install its parent.
Syntax Syntax
Description Description
Hooked to the ‘upgrader_post_install’ filter by Theme_Upgrader::install().
Parameters Parameters
- $install_result
-
(Required)
- $hook_extra
-
(Required)
- $child_result
-
(Required)
Return Return
(bool)
Source Source
File: wp-admin/includes/class-theme-upgrader.php
if ( ! empty( $this->skin->overwrite ) ) { if ( 'update-theme' === $this->skin->overwrite ) { $this->strings['installing_package'] = __( 'Updating the theme…' ); $this->strings['process_failed'] = __( 'Theme update failed.' ); $this->strings['process_success'] = __( 'Theme updated successfully.' ); } if ( 'downgrade-theme' === $this->skin->overwrite ) { $this->strings['installing_package'] = __( 'Downgrading the theme…' ); $this->strings['process_failed'] = __( 'Theme downgrade failed.' ); $this->strings['process_success'] = __( 'Theme downgraded successfully.' ); } } } /** * Check if a child theme is being installed and we need to install its parent. * * Hooked to the {@see 'upgrader_post_install'} filter by Theme_Upgrader::install(). * * @since 3.4.0 * * @param bool $install_result * @param array $hook_extra * @param array $child_result * @return bool */ 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'];
Advertisement
Changelog Changelog
Version | Description |
---|---|
3.4.0 | Introduced. |