Automattic\WooCommerce\Blueprint\Importers
ImportInstallTheme::process
Process the schema to install the theme.
Метод класса: ImportInstallTheme{}
Хуков нет.
Возвращает
StepProcessorResult
. The result of the step processing.
Использование
$ImportInstallTheme = new ImportInstallTheme(); $ImportInstallTheme->process( $schema ): StepProcessorResult;
- $schema(объект) (обязательный)
- The schema containing theme installation details.
Код ImportInstallTheme::process() ImportInstallTheme::process WC 10.0.2
public function process( $schema ): StepProcessorResult { $installed_themes = $this->wp_get_themes(); // phpcs:ignore $theme = $schema->themeData; if ( 'wordpress.org/themes' !== $theme->resource ) { $this->result->add_info( "Skipped installing a theme. Unsupported resource type. Only 'wordpress.org/themes' is supported at the moment." ); return $this->result; } if ( ! isset( $schema->options ) ) { $schema->options = new \stdClass(); } if ( isset( $installed_themes[ $theme->slug ] ) ) { $this->activate_theme( $schema ); $this->result->add_info( "Skipped installing {$theme->slug}. It is already installed." ); return $this->result; } if ( $this->storage->is_supported_resource( $theme->resource ) === false ) { $this->result->add_error( "Invalid resource type for {$theme->slug}" ); return $this->result; } $downloaded_path = $this->storage->download( $theme->slug, $theme->resource ); if ( ! $downloaded_path ) { $this->result->add_error( "Unable to download {$theme->slug} with {$theme->resource} resource type." ); return $this->result; } $this->result->add_debug( "'$theme->slug' has been downloaded in $downloaded_path" ); $install = $this->install( $downloaded_path ); if ( $install ) { $this->result->add_debug( "Theme '$theme->slug' installed successfully." ); } else { $this->result->add_error( "Failed to install theme '$theme->slug'." ); } $this->activate_theme( $schema ); return $this->result; }