CLICommands
in package
CLI Commands
Table of Contents
Properties
- $notices : array<string|int, array{type: string, message: string}>
- WP CLI notices.
- $upload_path : string
- Upload path
- $upload_url : string
- Upload URL
Methods
- add_notice() : void
- Adds a notice to be displayed at the end of the command.
- display_notices() : void
- Display the notices. The output is WP_CLI.
- get_notices() : array<string|int, array{type: string, message: string}>
- Get all notices.
- get_upload_path() : string
- Get the upload path.
- get_upload_url() : string
- Get the upload URL.
- reset_notices() : void
- Reset all notices.
- set_upload_path() : void
- Set the upload path.
- set_upload_url() : void
- Set the upload URL.
- export_csv() : void
- Create and write to a CSV file
- create_dir() : void
- Create dir if does not exist.
- pick_fields() : array<string, mixed>
- Pick fields from an associative array or object.
Properties
$notices
WP CLI notices.
public
array<string|int, array{type: string, message: string}>
$notices
= array()
$upload_path
Upload path
public
string
$upload_path
$upload_url
Upload URL
public
string
$upload_url
Methods
add_notice()
Adds a notice to be displayed at the end of the command.
public
add_notice([string $message = '' ][, string $type = 'log' ]) : void
Parameters
- $message : string = ''
-
The message to display.
- $type : string = 'log'
-
The type of notice. One of 'log', 'success', 'warning', 'error'. Default is 'log'.
display_notices()
Display the notices. The output is WP_CLI.
public
display_notices() : void
get_notices()
Get all notices.
public
get_notices() : array<string|int, array{type: string, message: string}>
Return values
array<string|int, array{type: string, message: string}> —The array of notices.
get_upload_path()
Get the upload path.
public
get_upload_path() : string
Return values
string —The full path.
get_upload_url()
Get the upload URL.
public
get_upload_url() : string
Return values
string —The full URL.
reset_notices()
Reset all notices.
public
reset_notices() : void
set_upload_path()
Set the upload path.
public
set_upload_path([string $path = '' ]) : void
If the path is a directory, it will create it if it does not exist.
Parameters
- $path : string = ''
-
The complete path to use.
set_upload_url()
Set the upload URL.
public
set_upload_url([string $url = '' ]) : void
Parameters
- $url : string = ''
-
The full URL to use.
export_csv()
Create and write to a CSV file
protected
export_csv(string $filename, array<int|string, mixed> $rows[, array<int|string, string> $headers = array() ]) : void
Parameters
- $filename : string
-
the full name of the file.
- $rows : array<int|string, mixed>
-
array of data.
- $headers : array<int|string, string> = array()
-
(default: array()).
create_dir()
Create dir if does not exist.
private
create_dir(string $path) : void
Parameters
- $path : string
-
The directory path.
pick_fields()
Pick fields from an associative array or object.
private
pick_fields(array<string, mixed>|object $item, array<string|int, string> $fields) : array<string, mixed>
Parameters
- $item : array<string, mixed>|object
-
Associative array or object to pick fields from.
- $fields : array<string|int, string>
-
List of fields to pick.
Return values
array<string, mixed> —The picked fields as an associative array.