WooCommerce Code Reference

ImportStep Uses UseWPFunctions

Class ImportStep

Import a single step from a JSON definition.

Table of Contents

$builtin_step_processors  : BuiltInStepProcessors
Built-in step processors.
$filesystem_initialized  : bool
Whether the filesystem has been initialized.
$importers  : array<string|int, mixed>
Importers.
$indexed_importers  : array<string|int, mixed>
Indexed importers.
$step_definition  : object
Step definition.
$validator  : Validator
Validator object.
__construct()  : mixed
ImportStep constructor.
import()  : StepProcessorResult
Import the schema steps.
is_wp_error()  : bool
Checks if a variable is a WP_Error.
wp_activate_plugin()  : WP_Error|null
Activates a plugin.
wp_add_action()  : mixed
Adds an action to a specified tag.
wp_add_filter()  : mixed
Adds a filter to a specified tag.
wp_apply_filters()  : mixed
Calls the functions added to a filter hook.
wp_delete_plugins()  : array<string|int, mixed>|WP_Error|null
Deletes plugins.
wp_do_action()  : mixed
Executes the functions hooked on a specific action hook.
wp_download_url()  : string|WP_Error
Downloads a file from a URL.
wp_filesystem_get_contents()  : string|false
Alias for WP_Filesystem::get_contents().
wp_filesystem_put_contents()  : bool
Alias for WP_Filesystem::put_contents().
wp_get_current_user_id()  : int
Retrieves the current user's ID.
wp_get_option()  : mixed
Retrieves an option from the database.
wp_get_plugins()  : array<string|int, mixed>
Retrieves all plugins.
wp_get_theme()  : WP_Theme
Retrieves a theme.
wp_get_theme_root()  : string
Retrieves the root directory of the current theme.
wp_get_themes()  : array<string|int, mixed>
Retrieves all themes.
wp_init_filesystem()  : bool
Initializes the WordPress filesystem.
wp_is_plugin_active()  : bool
Checks if a plugin is active.
wp_plugins_api()  : object|WP_Error
Retrieves plugin information from the WordPress Plugin API.
wp_switch_theme()  : mixed
Switches the current theme.
wp_themes_api()  : object|WP_Error
Retrieves theme information from the WordPress Theme API.
wp_unzip_file()  : bool|WP_Error
Unzips a file to a specified location.
wp_update_option()  : bool
Updates an option in the database.
wp_upload_dir()  : array<string|int, mixed>
Retrieves the upload directory information.
can_import()  : bool
Check if the step can be imported.
validate_step_schemas()  : bool
Validate the step schemas.

Properties

Methods

__construct()

ImportStep constructor.

public __construct(object $step_definition[, Validator|null $validator = null ]) : mixed
Parameters
$step_definition : object

The step definition.

$validator : Validator|null = null

The validator instance, optional.

Return values
mixed

is_wp_error()

Checks if a variable is a WP_Error.

public is_wp_error(mixed $thing) : bool
Parameters
$thing : mixed

Variable to check.

Return values
boolTrue if the variable is a WP_Error, false otherwise.

wp_activate_plugin()

Activates a plugin.

public wp_activate_plugin(string $plugin[, string $redirect = '' ][, bool $network_wide = false ][, bool $silent = false ]) : WP_Error|null
Parameters
$plugin : string

Path to the plugin file relative to the plugins directory.

$redirect : string = ''

Optional. URL to redirect to after activation.

$network_wide : bool = false

Optional. Whether to enable the plugin for all sites in the network.

$silent : bool = false

Optional. Whether to prevent calling activation hooks.

Return values
WP_Error|nullWP_Error on failure, null on success.

wp_add_action()

Adds an action to a specified tag.

public wp_add_action(string $tag, callable $function_to_add[, int $priority = 10 ][, int $accepted_args = 1 ]) : mixed
Parameters
$tag : string

The name of the action to hook the $function_to_add to.

$function_to_add : callable

The callback to be run when the action is triggered.

$priority : int = 10

Optional. Used to specify the order in which the functions associated with a particular action are executed. Default 10.

$accepted_args : int = 1

Optional. The number of arguments the function accepts. Default 1.

Return values
mixed

wp_add_filter()

Adds a filter to a specified tag.

public wp_add_filter(string $tag, callable $function_to_add[, int $priority = 10 ][, int $accepted_args = 1 ]) : mixed
Parameters
$tag : string

The name of the filter to hook the $function_to_add to.

$function_to_add : callable

The callback to be run when the filter is applied.

$priority : int = 10

Optional. Used to specify the order in which the functions associated with a particular action are executed. Default 10.

$accepted_args : int = 1

Optional. The number of arguments the function accepts. Default 1.

Return values
mixed

wp_apply_filters()

Calls the functions added to a filter hook.

public wp_apply_filters(string $tag, mixed $value) : mixed
Parameters
$tag : string

The name of the filter hook.

$value : mixed

The value on which the filters hooked to $tag are applied on.

Return values
mixedThe filtered value after all hooked functions are applied to it.

wp_delete_plugins()

Deletes plugins.

public wp_delete_plugins(array<string|int, mixed> $plugins) : array<string|int, mixed>|WP_Error|null
Parameters
$plugins : array<string|int, mixed>

List of plugins to delete.

Return values
array<string|int, mixed>|WP_Error|nullArray of results or WP_Error on failure, null if filesystem credentials are required to proceed.

wp_do_action()

Executes the functions hooked on a specific action hook.

public wp_do_action(string $tag, mixed ...$args) : mixed
Parameters
$tag : string

The name of the action to be executed.

$args : mixed

Optional. Additional arguments which are passed on to the functions hooked to the action.

Return values
mixed

wp_download_url()

Downloads a file from a URL.

public wp_download_url(string $url) : string|WP_Error
Parameters
$url : string

The URL of the file to download.

Return values
string|WP_ErrorThe local file path on success, WP_Error on failure.

wp_filesystem_get_contents()

Alias for WP_Filesystem::get_contents().

public wp_filesystem_get_contents(string $file_path) : string|false
Parameters
$file_path : string

The path to the file to read.

Return values
string|falseThe contents of the file, or false on failure.

wp_filesystem_put_contents()

Alias for WP_Filesystem::put_contents().

public wp_filesystem_put_contents(string $file_path, mixed $content) : bool
Parameters
$file_path : string

The path to the file to write.

$content : mixed

The data to write to the file.

Return values
boolTrue on success, false on failure.

wp_get_option()

Retrieves an option from the database.

public wp_get_option(string $option[, mixed $default_value = false ]) : mixed
Parameters
$option : string

Name of the option to retrieve.

$default_value : mixed = false

Optional. Default value to return if the option does not exist.

Return values
mixedValue of the option or $default if the option does not exist.

wp_get_plugins()

Retrieves all plugins.

public wp_get_plugins([string $plugin_folder = '' ]) : array<string|int, mixed>
Parameters
$plugin_folder : string = ''

Optional. Path to the plugin folder to scan.

Return values
array<string|int, mixed>Array of plugins.

wp_get_theme()

Retrieves a theme.

public wp_get_theme([string|null $stylesheet = null ]) : WP_Theme
Parameters
$stylesheet : string|null = null

Optional. The theme's stylesheet name.

Return values
WP_ThemeThe theme object.

wp_get_theme_root()

Retrieves the root directory of the current theme.

public wp_get_theme_root() : string
Return values
stringThe root directory of the current theme.

wp_get_themes()

Retrieves all themes.

public wp_get_themes([array<string|int, mixed> $args = array() ]) : array<string|int, mixed>
Parameters
$args : array<string|int, mixed> = array()

Optional. Arguments to pass to the API.

Return values
array<string|int, mixed>Array of themes.

wp_is_plugin_active()

Checks if a plugin is active.

public wp_is_plugin_active(string $plugin) : bool
Parameters
$plugin : string

Path to the plugin file relative to the plugins directory.

Return values
boolTrue if the plugin is active, false otherwise.

wp_plugins_api()

Retrieves plugin information from the WordPress Plugin API.

public wp_plugins_api(string $action[, array<string|int, mixed> $args = array() ]) : object|WP_Error
Parameters
$action : string

The type of information to retrieve from the API.

$args : array<string|int, mixed> = array()

Optional. Arguments to pass to the API.

Return values
object|WP_ErrorThe API response object or WP_Error on failure.

wp_switch_theme()

Switches the current theme.

public wp_switch_theme(string $name) : mixed
Parameters
$name : string

The name of the theme to switch to.

Return values
mixed

wp_themes_api()

Retrieves theme information from the WordPress Theme API.

public wp_themes_api(string $action[, array<string|int, mixed> $args = array() ]) : object|WP_Error
Parameters
$action : string

The type of information to retrieve from the API.

$args : array<string|int, mixed> = array()

Optional. Arguments to pass to the API.

Return values
object|WP_ErrorThe API response object or WP_Error on failure.

wp_unzip_file()

Unzips a file to a specified location.

public wp_unzip_file(string $path, string $to) : bool|WP_Error
Parameters
$path : string

Path to the ZIP file.

$to : string

Destination directory.

Return values
bool|WP_ErrorTrue on success, WP_Error on failure.

wp_update_option()

Updates an option in the database.

public wp_update_option(string $option, mixed $value[, string|null $autoload = null ]) : bool
Parameters
$option : string

Name of the option to update.

$value : mixed

New value for the option.

$autoload : string|null = null

Optional. Whether to load the option when WordPress starts up.

Return values
boolTrue if option was updated, false otherwise.

wp_upload_dir()

Retrieves the upload directory information.

public wp_upload_dir() : array<string|int, mixed>
Return values
array<string|int, mixed>Array of upload directory information.