WC_WCCOM_Site_Installer::move_product()
Move product to plugins directory.
Метод класса: WC_WCCOM_Site_Installer{}
Хуков нет.
Возвращает
Массив|\WP_Error
.
Использование
$result = WC_WCCOM_Site_Installer::move_product( $product_id, $upgrader );
- $product_id(int) (обязательный)
- Product ID.
- $upgrader(\WP_Upgrader) (обязательный)
- Core class to handle installation.
Список изменений
С версии 3.7.0 | Введена. |
Код WC_WCCOM_Site_Installer::move_product() WC WCCOM Site Installer::move product WC 7.3.0
private static function move_product( $product_id, $upgrader ) { $steps = self::get_state( 'steps' ); if ( empty( $steps[ $product_id ]['unpacked_path'] ) ) { return new WP_Error( 'missing_unpacked_path', __( 'Could not find unpacked path.', 'woocommerce' ) ); } $destination = 'plugin' === $steps[ $product_id ]['product_type'] ? WP_PLUGIN_DIR : get_theme_root(); $package = array( 'source' => $steps[ $product_id ]['unpacked_path'], 'destination' => $destination, 'clear_working' => true, 'hook_extra' => array( 'type' => $steps[ $product_id ]['product_type'], 'action' => 'install', ), ); $result = $upgrader->install_package( $package ); /** * If install package returns error 'folder_exists' threat as success. */ if ( is_wp_error( $result ) && array_key_exists( self::$folder_exists, $result->errors ) ) { return array( self::$folder_exists => true, 'destination' => $result->error_data[ self::$folder_exists ], ); } return $result; }