AITool
extends CLICommands
in package
AITool CLI class.
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.
- migrate() : void
- Migrates AI Tool data.
- 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
- migrate_likes() : void
- Migrates AI Tool likes to the database.
- migrate_reports() : void
- Migrates AI Tool reports to the database.
- remove_directory() : bool
- Removes a directory recursively.
- remove_folder() : void
- Removes the AI Tool uploads folder.
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.
migrate()
Migrates AI Tool data.
public
migrate(array<string|int, string> $args, array<string, mixed> $assoc_args) : void
OPTIONS
EXAMPLES
# Migrate all AI Tool data.
$ wp boomi migrate aitool all
Success: Migrated 13 reports.
Success: Migrated 13 likes.
Success: Removed the AI Tool uploads folder.
# Migrate AI Tool reports.
$ wp boomi migrate aitool reports
Success: Migrated 13 reports.
# Migrate AI Tool likes.
$ wp boomi migrate aitool likes
Success: Migrated 13 likes.
# Remove the AI Tool uploads folder.
$ wp boomi migrate aitool remove-folder
Success: Removed the AI Tool uploads folder.
Parameters
- $args : array<string|int, string>
-
CLI positional arguments.
- $assoc_args : array<string, mixed>
-
CLI associative arguments.
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()).
migrate_likes()
Migrates AI Tool likes to the database.
private
migrate_likes() : void
This method will log messages to the user about the migration process and report the number of migrated records.
migrate_reports()
Migrates AI Tool reports to the database.
private
migrate_reports() : void
This method will log messages to the user about the migration process and report the number of migrated records.
remove_directory()
Removes a directory recursively.
private
remove_directory(string $dir) : bool
Parameters
- $dir : string
-
The path to the directory to be deleted.
Return values
bool —True if the directory was deleted successfully, false otherwise.
remove_folder()
Removes the AI Tool uploads folder.
private
remove_folder() : void
This method will log messages to the user about the deletion process.