PHP Функции (API)
WP-CLI включает в себя ряд утилит для создания собственных команд.
Оглавление:
Регистрация команды
- WP_CLI::add_command()
- Register a command to WP-CLI.
- WP_CLI::do_hook()
- Execute callbacks registered to a given hook.
- WP_CLI::add_hook()
- Schedule a callback to be executed at a certain point.
- WP_CLI::add_wp_hook()
- Add a callback to a WordPress action or filter.
Вывод
- WP_CLI\Utils\ make_progress_bar()
- Create a progress bar to display percent completion of a given operation.
- WP_CLI\Utils\ format_items()
- Render a collection of items as an ASCII table, JSON, CSV, YAML, list of ids, or count.
- WP_CLI::colorize()
- Colorize a string for output.
- WP_CLI::line()
- Display informational message without prefix, and ignore --quiet.
- WP_CLI::log()
- Display informational message without prefix.
- WP_CLI::success()
- Display success message prefixed with "Success: ".
- WP_CLI::debug()
- Display debug message prefixed with "Debug: " when --debug is used.
- WP_CLI::warning()
- Display warning message prefixed with "Warning: ".
- WP_CLI::error()
- Display error message prefixed with "Error: " and exit script.
- WP_CLI::halt()
- Halt script execution with a specific return code.
- WP_CLI::error_multi_line()
- Display a multi-line error message in a red box. Doesn't exit script.
Ввод
- WP_CLI\Utils\ parse_str_to_argv()
- Parse a string of command line arguments into an $argv-esqe variable.
- WP_CLI\Utils\ report_batch_operation_results()
- Report the results of the same operation against multiple resources.
- WP_CLI\Utils\ get_flag_value()
- Return the flag value or, if it's not set, the $default value.
- WP_CLI\Utils\ launch_editor_for_input()
- Launch system's $EDITOR for the user to edit some text.
- WP_CLI::confirm()
- Ask for confirmation before running a destructive operation.
- WP_CLI::read_value()
- Read a value, from various formats.
- WP_CLI::has_config()
- Confirm that a global configuration parameter does exist.
- WP_CLI::get_config()
- Get values of global configuration parameters.
Исполнение
- WP_CLI::launch()
- Launch an arbitrary external process that takes over I/O.
- WP_CLI::launch_self()
- Run a WP-CLI command in a new process reusing the current runtime arguments.
- WP_CLI::runcommand()
- Run a WP-CLI command.
- WP_CLI::run_command()
- Run a given command within the current process using the same global parameters.
Система
- WP_CLI\Utils\ get_php_binary()
- Get the path to the PHP binary used when executing WP-CLI.
- get_temp_dir()
- Получает путь до папки в которую можно записывать временные файлы. Со слэшем на конце.
- WP_CLI\Utils\ normalize_path()
- Normalize a filesystem path.
- trailingslashit()
- Добавляет слэш / в конец строки.
- WP_CLI\Utils\ get_home_dir()
- Get the home directory.
- WP_CLI::get_php_binary()
- Get the path to the PHP binary used when executing WP-CLI.
Разное
- WP_CLI\Utils\ esc_like()
- First half of escaping for LIKE special characters % and _ before preparing for MySQL.
- WP_CLI\Utils\ proc_open_compat()
- Windows compatible proc_open(). Works around bug in PHP, and also deals with *nix-like ENV_VAR=blah cmd environment variable prefixes.
- WP_CLI\Utils\ basename()
- Locale-independent version of basename()
- WP_CLI\Utils\ get_named_sem_ver()
- Compare two version strings to get the named semantic version.
- WP_CLI\Utils\ http_request()
- Make a HTTP request to a remote URL.
- WP_CLI\Utils\ write_csv()
- Write data as CSV to a given file.