Logger
in package
Uses
UseWPFunctions
Class Logger
Table of Contents
- $filesystem_initialized : bool
- Whether the filesystem has been initialized.
- $logger : WC_Logger_Interface
- WooCommerce logger class instance.
- __construct() : mixed
- Constructor.
- complete_export() : mixed
- Log the completion of an export operation.
- complete_import() : mixed
- Log the successful completion of an import step.
- export_step_failed() : mixed
- Log an export step failure.
- import_step_failed() : mixed
- Log an import step failure.
- is_wp_error() : bool
- Checks if a variable is a WP_Error.
- log() : mixed
- Log a message as a debug log entry.
- start_export() : mixed
- Log the start of an export operation.
- start_import() : mixed
- Log the start of an import step.
- 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.
- get_export_data() : array<string|int, mixed>
- Extract export step names and exporter classes from exporters.
Properties
$filesystem_initialized
Whether the filesystem has been initialized.
private
bool
$filesystem_initialized
= false
$logger
WooCommerce logger class instance.
private
WC_Logger_Interface
$logger
Methods
__construct()
Constructor.
public
__construct() : mixed
Return values
mixed —complete_export()
Log the completion of an export operation.
public
complete_export(array<string|int, mixed> $exporters) : mixed
Parameters
- $exporters : array<string|int, mixed>
-
Array of exporters.
Return values
mixed —complete_import()
Log the successful completion of an import step.
public
complete_import(string $step_name, StepProcessorResult $result) : mixed
Parameters
- $step_name : string
-
The name of the step that was imported.
- $result : StepProcessorResult
-
The result of the import.
Return values
mixed —export_step_failed()
Log an export step failure.
public
export_step_failed(string $step_name, Throwable $exception) : mixed
Parameters
- $step_name : string
-
The name of the step that failed.
- $exception : Throwable
-
The exception that was thrown.
Return values
mixed —import_step_failed()
Log an import step failure.
public
import_step_failed(string $step_name, StepProcessorResult $result) : mixed
Parameters
- $step_name : string
-
The name of the step that failed.
- $result : StepProcessorResult
-
The result of the import.
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
bool — True if the variable is a WP_Error, false otherwise.log()
Log a message as a debug log entry.
public
log(string $message[, string $level = WC_Log_Levels::DEBUG ][, array<string|int, mixed> $context = array() ]) : mixed
Parameters
- $message : string
-
The message to log.
- $level : string = WC_Log_Levels::DEBUG
-
The log level.
- $context : array<string|int, mixed> = array()
-
The context of the log.
Return values
mixed —start_export()
Log the start of an export operation.
public
start_export(array<string|int, mixed> $exporters) : mixed
Parameters
- $exporters : array<string|int, mixed>
-
Array of exporters.
Return values
mixed —start_import()
Log the start of an import step.
public
start_import(string $step_name, string $importer_class) : mixed
Parameters
- $step_name : string
-
The name of the step being imported.
- $importer_class : string
-
The class name of the importer.
Return values
mixed —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|null — WP_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
mixed — The 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|null — Array 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_Error — The 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|false — The 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
bool — True on success, false on failure.wp_get_current_user_id()
Retrieves the current user's ID.
public
wp_get_current_user_id() : int
Return values
int — The current user's ID.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
mixed — Value 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_Theme — The theme object.wp_get_theme_root()
Retrieves the root directory of the current theme.
public
wp_get_theme_root() : string
Return values
string — The 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_init_filesystem()
Initializes the WordPress filesystem.
public
wp_init_filesystem() : bool
Return values
bool —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
bool — True 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_Error — The 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_Error — The 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_Error — True 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
bool — True 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.get_export_data()
Extract export step names and exporter classes from exporters.
private
get_export_data(array<string|int, mixed> $exporters) : array<string|int, mixed>
Parameters
- $exporters : array<string|int, mixed>
-
Array of exporters.