PHP code example of wp-cli / wp-cli
1. Go to this page and download the library: Download wp-cli/wp-cli library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
wp-cli / wp-cli example snippets
/**
* Delete an option from the database.
*
* Returns an error if the option didn't exist.
*
* ## OPTIONS
*
* <key>
* : Key for the option.
*
* ## EXAMPLES
*
* $ wp option delete my_option
* Success: Deleted 'my_option' option.
*/
$delete_option_cmd = function( $args ) {
list( $key ) = $args;
if ( ! delete_option( $key ) ) {
WP_CLI::error( "Could not delete '$key' option. Does it exist?" );
} else {
WP_CLI::success( "Deleted '$key' option." );
}
};
WP_CLI::add_command( 'option delete', $delete_option_cmd );
bash
php wp-cli.phar --info