WC_WCCOM_Site_Installer
in package
WC_WCCOM_Site_Installer Class
Contains functionalities to install products via WooCommerce.com helper connection.
Table of Contents
- $default_state : array<string|int, mixed>
- Default state.
- $default_step_state : array<string|int, mixed>
- Represents product step state.
- $folder_exists : string
- Error message returned install_package if the folder already exists.
- $install_steps : array<string|int, mixed>
- Product install steps. Each step is a method name in this class that will be passed with product ID arg \WP_Upgrader instance.
- $wp_upgrader : WP_Upgrader
- An instance of the WP_Upgrader class to be used for installation.
- activate_plugin() : WP_Error|null
- Activate plugin given its product ID.
- get_plugin_info() : bool|array<string|int, mixed>
- Get plugin info
- get_state() : array<string|int, mixed>
- Get the product install state.
- get_wp_upgrader() : WP_Upgrader
- Get an instance of WP_Upgrader to use for installing plugins.
- get_wporg_plugin_main_file() : bool|string
- Get WP.org plugin's main file.
- install() : mixed
- Install a given product IDs.
- reset_state() : mixed
- Reset product install state.
- schedule_install() : array<string|int, mixed>
- Schedule installing given list of products.
- update_state() : mixed
- Update the product install state.
- activate_product() : WP_Error|null
- Activate product given its product ID.
- activate_theme() : WP_Error|null
- Activate theme given its product ID.
- do_install_step() : mixed
- Perform product installation step.
- download_product() : WP_Error|string
- Download product by its ID and returns the path of the zip package.
- finish_installation() : mixed
- Finish installation by updating the state.
- get_product_info() : array<string|int, mixed>|WP_Error
- Get product info from its ID.
- get_wporg_product_dir_name() : bool|string
- Get installed directory of WP.org product.
- install_product() : mixed
- Install a single product given its ID.
- move_product() : array<string|int, mixed>|WP_Error
- Move product to plugins directory.
- unpack_product() : WP_Error|string
- Unpack downloaded product.
Properties
$default_state
Default state.
private
static array<string|int, mixed>
$default_state
= array('status' => 'idle', 'steps' => array(), 'current_step' =>
ull)
$default_step_state
Represents product step state.
private
static array<string|int, mixed>
$default_step_state
= array('download_url' => '', 'product_type' => '', 'last_step' => '', 'last_error' => '', 'download_path' => '', 'unpacked_path' => '', 'installed_path' => '', 'activate' => alse)
$folder_exists
Error message returned install_package if the folder already exists.
private
static string
$folder_exists
= 'folder_exists'
$install_steps
Product install steps. Each step is a method name in this class that will be passed with product ID arg \WP_Upgrader instance.
private
static array<string|int, mixed>
$install_steps
= array('get_product_info', 'download_product', 'unpack_product', 'move_product', 'activate_product')
$wp_upgrader
An instance of the WP_Upgrader class to be used for installation.
private
static WP_Upgrader
$wp_upgrader
Methods
activate_plugin()
Activate plugin given its product ID.
public
static activate_plugin(int $product_id) : WP_Error|null
Parameters
- $product_id : int
-
Product ID.
Tags
Return values
WP_Error|null —get_plugin_info()
Get plugin info
public
static get_plugin_info(string $dir) : bool|array<string|int, mixed>
Parameters
- $dir : string
-
Directory name of the plugin.
Tags
Return values
bool|array<string|int, mixed> —get_state()
Get the product install state.
public
static get_state([string $key = '' ]) : array<string|int, mixed>
Parameters
- $key : string = ''
-
Key in state data. If empty key is passed array of state will be returned.
Tags
Return values
array<string|int, mixed> — Product install state.get_wp_upgrader()
Get an instance of WP_Upgrader to use for installing plugins.
public
static get_wp_upgrader() : WP_Upgrader
Return values
WP_Upgrader —get_wporg_plugin_main_file()
Get WP.org plugin's main file.
public
static get_wporg_plugin_main_file(string $dir) : bool|string
Parameters
- $dir : string
-
Directory name of the plugin.
Tags
Return values
bool|string —install()
Install a given product IDs.
public
static install(array<string|int, mixed> $products) : mixed
Run via woocommerce_wccom_install_products
hook.
Parameters
- $products : array<string|int, mixed>
-
Array of products where key is product ID and element is install args.
Tags
Return values
mixed —reset_state()
Reset product install state.
public
static reset_state([array<string|int, mixed> $products = array() ]) : mixed
Parameters
- $products : array<string|int, mixed> = array()
-
List of product IDs.
Tags
Return values
mixed —schedule_install()
Schedule installing given list of products.
public
static schedule_install(array<string|int, mixed> $products) : array<string|int, mixed>
Parameters
- $products : array<string|int, mixed>
-
Array of products where key is product ID and element is install args.
Tags
Return values
array<string|int, mixed> — State.update_state()
Update the product install state.
public
static update_state(string $key, mixed $value) : mixed
Parameters
- $key : string
-
Key in state data.
- $value : mixed
-
Value.
Tags
Return values
mixed —activate_product()
Activate product given its product ID.
private
static activate_product(int $product_id) : WP_Error|null
Parameters
- $product_id : int
-
Product ID.
Tags
Return values
WP_Error|null —activate_theme()
Activate theme given its product ID.
private
static activate_theme(int $product_id) : WP_Error|null
Parameters
- $product_id : int
-
Product ID.
Tags
Return values
WP_Error|null —do_install_step()
Perform product installation step.
private
static do_install_step(int $product_id, array<string|int, mixed> $install_args, string $step, WP_Upgrader $upgrader) : mixed
Parameters
- $product_id : int
-
Product ID.
- $install_args : array<string|int, mixed>
-
Install args.
- $step : string
-
Installation step.
- $upgrader : WP_Upgrader
-
Core class to handle installation.
Tags
Return values
mixed —download_product()
Download product by its ID and returns the path of the zip package.
private
static download_product(int $product_id, WP_Upgrader $upgrader) : WP_Error|string
Parameters
- $product_id : int
-
Product ID.
- $upgrader : WP_Upgrader
-
Core class to handle installation.
Tags
Return values
WP_Error|string —finish_installation()
Finish installation by updating the state.
private
static finish_installation() : mixed
Tags
Return values
mixed —get_product_info()
Get product info from its ID.
private
static get_product_info(int $product_id) : array<string|int, mixed>|WP_Error
Parameters
- $product_id : int
-
Product ID.
Tags
Return values
array<string|int, mixed>|WP_Error —get_wporg_product_dir_name()
Get installed directory of WP.org product.
private
static get_wporg_product_dir_name(int $product_id) : bool|string
Parameters
- $product_id : int
-
Product ID.
Tags
Return values
bool|string —install_product()
Install a single product given its ID.
private
static install_product(int $product_id, array<string|int, mixed> $install_args, WP_Upgrader $upgrader) : mixed
Parameters
- $product_id : int
-
Product ID.
- $install_args : array<string|int, mixed>
-
Install args.
- $upgrader : WP_Upgrader
-
Core class to handle installation.
Tags
Return values
mixed —move_product()
Move product to plugins directory.
private
static move_product(int $product_id, WP_Upgrader $upgrader) : array<string|int, mixed>|WP_Error
Parameters
- $product_id : int
-
Product ID.
- $upgrader : WP_Upgrader
-
Core class to handle installation.
Tags
Return values
array<string|int, mixed>|WP_Error —unpack_product()
Unpack downloaded product.
private
static unpack_product(int $product_id, WP_Upgrader $upgrader) : WP_Error|string
Parameters
- $product_id : int
-
Product ID.
- $upgrader : WP_Upgrader
-
Core class to handle installation.