PHP Class Theme_Command, wp-cli

Inheritance: extends WP_CLI_Command_With_Upgrade
Mostra file Open project: wp-cli/wp-cli Class Usage Examples

Protected Properties

Property Type Description
$item_type
$obj_fields
$upgrade_refresh
$upgrade_transient

Public Methods

Method Description
__construct ( )
activate ( $args = [] ) Activate a theme.
delete ( $args ) Delete a theme.
disable ( $args, $assoc_args ) Disable a theme on a WordPress multisite install.
enable ( $args, $assoc_args ) Enable a theme on a WordPress multisite install.
get ( $args, $assoc_args ) Get details about a theme.
install ( $args, $assoc_args ) Install a theme.
is_installed ( $args, $assoc_args = [] ) Check if the theme is installed.
list_ ( $_, $assoc_args ) Get a list of themes.
path ( $args, $assoc_args ) Get the path to a theme or to the theme directory.
search ( $args, $assoc_args ) Search the WordPress.org theme directory.
status ( $args ) See the status of one or all themes.
update ( $args, $assoc_args ) Update one or more themes.

Protected Methods

Method Description
filter_item_list ( $items, $args )
get_all_items ( )
get_item_list ( )
get_status ( $theme )
get_upgrader_class ( $force )
install_from_repo ( $slug, $assoc_args )
status_single ( $args )

Private Methods

Method Description
is_active_theme ( $theme )

Method Details

__construct() public method

public __construct ( )

activate() public method

## OPTIONS : The theme to activate. ## EXAMPLES $ wp theme activate twentysixteen Success: Switched to 'Twenty Sixteen' theme.
public activate ( $args = [] )

delete() public method

Removes the theme from the filesystem. ## OPTIONS ... : One or more themes to delete. ## EXAMPLES $ wp theme delete twentytwelve Deleted 'twentytwelve' theme. Success: Deleted 1 of 1 themes.
public delete ( $args )

disable() public method

Removes ability for a theme to be activated from the dashboard of a site on a WordPress multisite install. ## OPTIONS : The theme to disable. [--network] : If set, the theme is disabled on the network level. Note that individual sites may still have this theme enabled if it was enabled for them independently. ## EXAMPLES # Disable theme $ wp theme disable twentysixteen Success: Disabled the 'Twenty Sixteen' theme. # Disable theme in network level $ wp theme disable twentysixteen --network Success: Network disabled the 'Twenty Sixteen' theme.
public disable ( $args, $assoc_args )

enable() public method

Permits theme to be activated from the dashboard of a site on a WordPress multisite install. ## OPTIONS : The theme to enable. [--network] : If set, the theme is enabled for the entire network [--activate] : If set, the theme is activated for the current site. Note that the "network" flag has no influence on this. ## EXAMPLES # Enable theme $ wp theme enable twentysixteen Success: Enabled the 'Twenty Sixteen' theme. # Network enable theme $ wp theme enable twentysixteen --network Success: Network enabled the 'Twenty Sixteen' theme. # Network enable and activate theme for current site $ wp theme enable twentysixteen --activate Success: Enabled the 'Twenty Sixteen' theme. Success: Switched to 'Twenty Sixteen' theme.
public enable ( $args, $assoc_args )

filter_item_list() protected method

protected filter_item_list ( $items, $args )

get() public method

## OPTIONS : The theme to get. [--field=] : Instead of returning the whole theme, returns the value of a single field. [--fields=] : Limit the output to specific fields. Defaults to all fields. [--format=] : Render output in a particular format. --- default: table options: - table - csv - json - yaml --- ## EXAMPLES $ wp theme get twentysixteen --fields=name,title,version +---------+----------------+ | Field | Value | +---------+----------------+ | name | Twenty Sixteen | | title | Twenty Sixteen | | version | 1.2 | +---------+----------------+
public get ( $args, $assoc_args )

get_all_items() protected method

protected get_all_items ( )

get_item_list() protected method

protected get_item_list ( )

get_status() protected method

protected get_status ( $theme )

get_upgrader_class() protected method

protected get_upgrader_class ( $force )

install() public method

## OPTIONS ... : A theme slug, the path to a local zip file, or URL to a remote zip file. [--version=] : If set, get that particular version from wordpress.org, instead of the stable version. [--force] : If set, the command will overwrite any installed version of the theme, without prompting for confirmation. [--activate] : If set, the theme will be activated immediately after install. ## EXAMPLES # Install the latest version from wordpress.org and activate $ wp theme install twentysixteen --activate Installing Twenty Sixteen (1.2) Downloading install package from http://downloads.wordpress.org/theme/twentysixteen.1.2.zip... Unpacking the package... Installing the theme... Theme installed successfully. Activating 'twentysixteen'... Success: Switched to 'Twenty Sixteen' theme. # Install from a local zip file $ wp theme install ../my-theme.zip # Install from a remote zip file $ wp theme install http://s3.amazonaws.com/bucketname/my-theme.zip?AWSAccessKeyId=123&Expires=456&Signature=abcdef
public install ( $args, $assoc_args )

install_from_repo() protected method

protected install_from_repo ( $slug, $assoc_args )

is_installed() public method

Returns exit code 0 when installed, 1 when uninstalled. ## OPTIONS : The theme to check. ## EXAMPLES # Check whether theme is installed; exit status 0 if installed, otherwise 1 $ wp theme is-installed hello-dolly $ echo $? 1
public is_installed ( $args, $assoc_args = [] )

list_() public method

## OPTIONS [--=] : Filter results based on the value of a field. [--field=] : Prints the value of a single field for each theme. [--fields=] : Limit the output to specific object fields. [--format=] : Render output in a particular format. --- default: table options: - table - csv - json - count - yaml --- ## AVAILABLE FIELDS These fields will be displayed by default for each theme: * name * status * update * version These fields are optionally available: * update_version * update_package * update_id * title * description ## EXAMPLES # List themes $ wp theme list --status=inactive --format=csv name,status,update,version twentyfourteen,inactive,none,1.7 twentysixteen,inactive,available,1.1
public list_ ( $_, $assoc_args )

path() public method

## OPTIONS [] : The theme to get the path to. Path includes "style.css" file. If not set, will return the path to the themes directory. [--dir] : If set, get the path to the closest parent directory, instead of the theme's "style.css" file. ## EXAMPLES # Get theme path $ wp theme path var/www/example.com/public_html/wp-content/themes # Change directory to theme path $ cd $(wp theme path)
public path ( $args, $assoc_args )

status() public method

## OPTIONS [] : A particular theme to show the status for. ## EXAMPLES $ wp theme status twentysixteen Theme twentysixteen details: Name: Twenty Sixteen Status: Inactive Version: 1.2 Author: the WordPress team
public status ( $args )

status_single() protected method

protected status_single ( $args )

update() public method

## OPTIONS [...] : One or more themes to update. [--all] : If set, all themes that have updates will be updated. [--format=] : Output summary as table or summary. Defaults to table. [--version=] : If set, the theme will be updated to the specified version. [--dry-run] : Preview which themes would be updated. ## EXAMPLES # Update multiple themes $ wp theme update twentyfifteen twentysixteen Downloading update from https://downloads.wordpress.org/theme/twentyfifteen.1.5.zip... Unpacking the update... Installing the latest version... Removing the old version of the theme... Theme updated successfully. Downloading update from https://downloads.wordpress.org/theme/twentysixteen.1.2.zip... Unpacking the update... Installing the latest version... Removing the old version of the theme... Theme updated successfully. +---------------+-------------+-------------+---------+ | name | old_version | new_version | status | +---------------+-------------+-------------+---------+ | twentyfifteen | 1.4 | 1.5 | Updated | | twentysixteen | 1.1 | 1.2 | Updated | +---------------+-------------+-------------+---------+ Success: Updated 2 of 2 themes. # Update all themes $ wp theme update --all
public update ( $args, $assoc_args )

Property Details

$item_type protected_oe property

protected $item_type

$obj_fields protected_oe property

protected $obj_fields

$upgrade_refresh protected_oe property

protected $upgrade_refresh

$upgrade_transient protected_oe property

protected $upgrade_transient