PHP Class Site_Command, wp-cli

## EXAMPLES # Create site $ wp site create --slug=example Success: Site 3 created: www.example.com/example/ # Output a simple list of site URLs $ wp site list --field=url http://www.example.com/ http://www.example.com/subdir/ # Delete site $ wp site delete 123 Are you sure you want to delete the 'http://www.example.com/example' site? [y/n] y Success: The site at 'http://www.example.com/example' was deleted.
Inheritance: extends WP_CLI\CommandWithDBObject
Mostrar archivo Open project: wp-cli/wp-cli

Protected Properties

Property Type Description
$obj_id_key
$obj_type

Public Methods

Method Description
__construct ( )
_empty ( $args, $assoc_args ) Empty a site of its content (posts, comments, terms, and meta).
activate ( $args ) Activate one or more sites.
archive ( $args ) Archive one or more sites.
create ( $_, $assoc_args ) Create a site in a multisite install.
deactivate ( $args ) Deactivate one or more sites.
delete ( $args, $assoc_args ) Delete a site in a multisite install.
list_ ( $_, $assoc_args ) List all sites in a multisite install.
spam ( $args ) Mark one or more sites as spam.
unarchive ( $args ) Unarchive one or more sites.
unspam ( $args ) Remove one or more sites from spam.

Private Methods

Method Description
_empty_comments ( ) Delete comments.
_empty_posts ( ) Delete all posts.
_empty_taxonomies ( ) Delete terms, taxonomies, and tax relationships.
_get_network ( integer $network_id ) : boolean | array Get network data for a given id.
_insert_default_terms ( ) Insert default terms.
update_site_status ( $ids, $pref, $value )

Method Details

__construct() public method

public __construct ( )

_empty() public method

Truncates posts, comments, and terms tables to empty a site of its content. Doesn't affect site configuration (options) or users. If running a persistent object cache, make sure to flush the cache after emptying the site, as the cache values will be invalid otherwise. To also empty custom database tables, you'll need to hook into command execution: WP_CLI::add_hook( 'after_invoke:site empty', function(){ global $wpdb; foreach( array( 'p2p', 'p2pmeta' ) as $table ) { $table = $wpdb->$table; $wpdb->query( "TRUNCATE $table" ); } }); ## OPTIONS [--uploads] : Also delete *all* files in the site's in the uploads directory. [--yes] : Proceed to empty the site without a confirmation prompt. ## EXAMPLES $ wp site empty Are you sure you want to empty the site at http://www.example.com of all posts, comments, and terms? [y/n] y Success: The site at 'http://www.example.com' was emptied.
public _empty ( $args, $assoc_args )

activate() public method

## OPTIONS ... : One or more IDs of sites to activate. ## EXAMPLES $ wp site activate 123 Success: Site 123 activated.
public activate ( $args )

archive() public method

## OPTIONS ... : One or more IDs of sites to archive. ## EXAMPLES $ wp site archive 123 Success: Site 123 archived.
public archive ( $args )

create() public method

## OPTIONS --slug= : Path for the new site. Subdomain on subdomain installs, directory on subdirectory installs. [--title=] : Title of the new site. Default: prettified slug. [--email=<email>] : Email for Admin user. User will be created if none exists. Assignement to Super Admin if not included. [--network_id=<network-id>] : Network to associate new site with. Defaults to current network (typically 1). [--private] : If set, the new site will be non-public (not indexed) [--porcelain] : If set, only the site id will be output on success. ## EXAMPLES $ wp site create --slug=example Success: Site 3 created: http://www.example.com/example/ </div> </div> <div class="row doc-tags"> <div class="col-md-12"> <div class="tag-block tag-summary"> </div> <div class="tag-block tag-remarks"> </div> <div class="tag-block tag-exception"> </div> <div class="tag-block tag-see"> </div> <div class="tag-block tag-link"> </div> <div class="tag-block tag-deprecated"> </div> <div class="tag-block tag-since"> </div> <div class="tag-block tag-author"> </div> </div> </div> <div class="row"> <div class="col-md-12" style="overflow: auto"> <table class="table table-striped"> <tr> <td colspan="3" class="rendered"> <span class="modifier">public</span > <span class="method-name"><a class="method-link" href="https://doc.hotexamples.com/es/class/-/Site_Command#method-create">create</a></span> ( <span class="param-name">$_</span>, <span class="param-name">$assoc_args</span> ) </td> </tr> </table> </div> </div> </div> <div class="method-descr-full" id="method-deactivate"> <div class="row"> <div class="col-md-6"> <h3> deactivate() <span class="modifier">public</span > <span>method</span> </h3> </div> <div class="col-md-6 actions"> <a href="https://src.hotexamples.com/es/method/-/Site_Command/deactivate/-" rel="nofollow" title="Source code of method Site_Command::deactivate"><i class='icon-borderless icon-eye'></i></a> <a rel="nofollow" href="https://doc.hotexamples.com/es/class/-/Site_Command#method-deactivate" title="Direct link to the method Site_Command::deactivate documentation"><i class='icon-borderless icon-link'></i></a> </div> </div> <div class="row"> <div class="col-md-12"> ## OPTIONS <id>... : One or more IDs of sites to deactivate. ## EXAMPLES $ wp site deactivate 123 Success: Site 123 deactivated. </div> </div> <div class="row doc-tags"> <div class="col-md-12"> <div class="tag-block tag-summary"> </div> <div class="tag-block tag-remarks"> </div> <div class="tag-block tag-exception"> </div> <div class="tag-block tag-see"> </div> <div class="tag-block tag-link"> </div> <div class="tag-block tag-deprecated"> </div> <div class="tag-block tag-since"> </div> <div class="tag-block tag-author"> </div> </div> </div> <div class="row"> <div class="col-md-12" style="overflow: auto"> <table class="table table-striped"> <tr> <td colspan="3" class="rendered"> <span class="modifier">public</span > <span class="method-name"><a class="method-link" href="https://doc.hotexamples.com/es/class/-/Site_Command#method-deactivate">deactivate</a></span> ( <span class="param-name">$args</span> ) </td> </tr> </table> </div> </div> </div> <div class="method-descr-full" id="method-delete"> <div class="row"> <div class="col-md-6"> <h3> delete() <span class="modifier">public</span > <span>method</span> </h3> </div> <div class="col-md-6 actions"> <a href="https://src.hotexamples.com/es/method/-/Site_Command/delete/-" rel="nofollow" title="Source code of method Site_Command::delete"><i class='icon-borderless icon-eye'></i></a> <a rel="nofollow" href="https://doc.hotexamples.com/es/class/-/Site_Command#method-delete" title="Direct link to the method Site_Command::delete documentation"><i class='icon-borderless icon-link'></i></a> </div> </div> <div class="row"> <div class="col-md-12"> ## OPTIONS [<site-id>] : The id of the site to delete. If not provided, you must set the --slug parameter. [--slug=<slug>] : Path of the blog to be deleted. Subdomain on subdomain installs, directory on subdirectory installs. [--yes] : Answer yes to the confirmation message. [--keep-tables] : Delete the blog from the list, but don't drop it's tables. ## EXAMPLES $ wp site delete 123 Are you sure you want to delete the http://www.example.com/example site? [y/n] y Success: The site at 'http://www.example.com/example' was deleted. </div> </div> <div class="row doc-tags"> <div class="col-md-12"> <div class="tag-block tag-summary"> </div> <div class="tag-block tag-remarks"> </div> <div class="tag-block tag-exception"> </div> <div class="tag-block tag-see"> </div> <div class="tag-block tag-link"> </div> <div class="tag-block tag-deprecated"> </div> <div class="tag-block tag-since"> </div> <div class="tag-block tag-author"> </div> </div> </div> <div class="row"> <div class="col-md-12" style="overflow: auto"> <table class="table table-striped"> <tr> <td colspan="3" class="rendered"> <span class="modifier">public</span > <span class="method-name"><a class="method-link" href="https://doc.hotexamples.com/es/class/-/Site_Command#method-delete">delete</a></span> ( <span class="param-name">$args</span>, <span class="param-name">$assoc_args</span> ) </td> </tr> </table> </div> </div> </div> <div class="method-descr-full" id="method-list_"> <div class="row"> <div class="col-md-6"> <h3> list_() <span class="modifier">public</span > <span>method</span> </h3> </div> <div class="col-md-6 actions"> <a href="https://src.hotexamples.com/es/method/-/Site_Command/list_/-" rel="nofollow" title="Source code of method Site_Command::list_"><i class='icon-borderless icon-eye'></i></a> <a rel="nofollow" href="https://doc.hotexamples.com/es/class/-/Site_Command#method-list_" title="Direct link to the method Site_Command::list_ documentation"><i class='icon-borderless icon-link'></i></a> </div> </div> <div class="row"> <div class="col-md-12"> ## OPTIONS [--network=<id>] : The network to which the sites belong. [--<field>=<value>] : Filter by one or more fields (see "Available Fields" section). However, 'url' isn't an available filter, because it's created from domain + path. [--field=<field>] : Prints the value of a single field for each site. [--fields=<fields>] : Comma-separated list of fields to show. [--format=<format>] : Render output in a particular format. --- default: table options: - table - csv - count - ids - json - yaml --- ## AVAILABLE FIELDS These fields will be displayed by default for each site: * blog_id * url * last_updated * registered These fields are optionally available: * site_id * domain * path * public * archived * mature * spam * deleted * lang_id ## EXAMPLES # Output a simple list of site URLs $ wp site list --field=url http://www.example.com/ http://www.example.com/subdir/ </div> </div> <div class="row doc-tags"> <div class="col-md-12"> <div class="tag-block tag-summary"> </div> <div class="tag-block tag-remarks"> </div> <div class="tag-block tag-exception"> </div> <div class="tag-block tag-see"> </div> <div class="tag-block tag-link"> </div> <div class="tag-block tag-deprecated"> </div> <div class="tag-block tag-since"> </div> <div class="tag-block tag-author"> </div> </div> </div> <div class="row"> <div class="col-md-12" style="overflow: auto"> <table class="table table-striped"> <tr> <td colspan="3" class="rendered"> <span class="modifier">public</span > <span class="method-name"><a class="method-link" href="https://doc.hotexamples.com/es/class/-/Site_Command#method-list_">list_</a></span> ( <span class="param-name">$_</span>, <span class="param-name">$assoc_args</span> ) </td> </tr> </table> </div> </div> </div> <div class="method-descr-full" id="method-spam"> <div class="row"> <div class="col-md-6"> <h3> spam() <span class="modifier">public</span > <span>method</span> </h3> </div> <div class="col-md-6 actions"> <a href="https://src.hotexamples.com/es/method/-/Site_Command/spam/-" rel="nofollow" title="Source code of method Site_Command::spam"><i class='icon-borderless icon-eye'></i></a> <a rel="nofollow" href="https://doc.hotexamples.com/es/class/-/Site_Command#method-spam" title="Direct link to the method Site_Command::spam documentation"><i class='icon-borderless icon-link'></i></a> </div> </div> <div class="row"> <div class="col-md-12"> ## OPTIONS <id>... : One or more IDs of sites to be marked as spam. ## EXAMPLES $ wp site spam 123 Success: Site 123 marked as spam. </div> </div> <div class="row doc-tags"> <div class="col-md-12"> <div class="tag-block tag-summary"> </div> <div class="tag-block tag-remarks"> </div> <div class="tag-block tag-exception"> </div> <div class="tag-block tag-see"> </div> <div class="tag-block tag-link"> </div> <div class="tag-block tag-deprecated"> </div> <div class="tag-block tag-since"> </div> <div class="tag-block tag-author"> </div> </div> </div> <div class="row"> <div class="col-md-12" style="overflow: auto"> <table class="table table-striped"> <tr> <td colspan="3" class="rendered"> <span class="modifier">public</span > <span class="method-name"><a class="method-link" href="https://doc.hotexamples.com/es/class/-/Site_Command#method-spam">spam</a></span> ( <span class="param-name">$args</span> ) </td> </tr> </table> </div> </div> </div> <div class="method-descr-full" id="method-unarchive"> <div class="row"> <div class="col-md-6"> <h3> unarchive() <span class="modifier">public</span > <span>method</span> </h3> </div> <div class="col-md-6 actions"> <a href="https://src.hotexamples.com/es/method/-/Site_Command/unarchive/-" rel="nofollow" title="Source code of method Site_Command::unarchive"><i class='icon-borderless icon-eye'></i></a> <a rel="nofollow" href="https://doc.hotexamples.com/es/class/-/Site_Command#method-unarchive" title="Direct link to the method Site_Command::unarchive documentation"><i class='icon-borderless icon-link'></i></a> </div> </div> <div class="row"> <div class="col-md-12"> ## OPTIONS <id>... : One or more IDs of sites to unarchive. ## EXAMPLES $ wp site unarchive 123 Success: Site 123 unarchived. </div> </div> <div class="row doc-tags"> <div class="col-md-12"> <div class="tag-block tag-summary"> </div> <div class="tag-block tag-remarks"> </div> <div class="tag-block tag-exception"> </div> <div class="tag-block tag-see"> </div> <div class="tag-block tag-link"> </div> <div class="tag-block tag-deprecated"> </div> <div class="tag-block tag-since"> </div> <div class="tag-block tag-author"> </div> </div> </div> <div class="row"> <div class="col-md-12" style="overflow: auto"> <table class="table table-striped"> <tr> <td colspan="3" class="rendered"> <span class="modifier">public</span > <span class="method-name"><a class="method-link" href="https://doc.hotexamples.com/es/class/-/Site_Command#method-unarchive">unarchive</a></span> ( <span class="param-name">$args</span> ) </td> </tr> </table> </div> </div> </div> <div class="method-descr-full" id="method-unspam"> <div class="row"> <div class="col-md-6"> <h3> unspam() <span class="modifier">public</span > <span>method</span> </h3> </div> <div class="col-md-6 actions"> <a href="https://src.hotexamples.com/es/method/-/Site_Command/unspam/-" rel="nofollow" title="Source code of method Site_Command::unspam"><i class='icon-borderless icon-eye'></i></a> <a rel="nofollow" href="https://doc.hotexamples.com/es/class/-/Site_Command#method-unspam" title="Direct link to the method Site_Command::unspam documentation"><i class='icon-borderless icon-link'></i></a> </div> </div> <div class="row"> <div class="col-md-12"> ## OPTIONS <id>... : One or more IDs of sites to remove from spam. ## EXAMPLES $ wp site unspam 123 Success: Site 123 removed from spam. </div> </div> <div class="row doc-tags"> <div class="col-md-12"> <div class="tag-block tag-summary"> </div> <div class="tag-block tag-remarks"> </div> <div class="tag-block tag-exception"> </div> <div class="tag-block tag-see"> </div> <div class="tag-block tag-link"> </div> <div class="tag-block tag-deprecated"> </div> <div class="tag-block tag-since"> </div> <div class="tag-block tag-author"> </div> </div> </div> <div class="row"> <div class="col-md-12" style="overflow: auto"> <table class="table table-striped"> <tr> <td colspan="3" class="rendered"> <span class="modifier">public</span > <span class="method-name"><a class="method-link" href="https://doc.hotexamples.com/es/class/-/Site_Command#method-unspam">unspam</a></span> ( <span class="param-name">$args</span> ) </td> </tr> </table> </div> </div> </div> <h2>Property Details</h2> <div class="property-descr-full" id="prop-obj_id_key"> <div class="row"> <div class="col-md-6"> <h3 class="name">$obj_id_key <span>protected_oe property</span> </h3> </div> <div class="col-md-6 actions"> <a href="https://doc.hotexamples.com/es/class/-/Site_Command#prop-obj_id_key" title="Direct link to property Site_Command::obj_id_key documentation"> <i class='icon-borderless icon-link'></i> </a> </div> </div> <div class="row"> <div class="col-md-12"> </div> </div> <div class="row doc-tags"> <div class="col-md-12"> </div> </div> <div class="row"> <div class="col-md-12" style="overflow: auto"> <table class="table table-striped"> <!-- <tr> <td colspan="3"></td> </tr> --> <tr> <td colspan="3" class="rendered"> <span class="modifier">protected</span > <span class="var-name">$obj_id_key</span> </td> </tr> </table> </div> </div> </div> <div class="property-descr-full" id="prop-obj_type"> <div class="row"> <div class="col-md-6"> <h3 class="name">$obj_type <span>protected_oe property</span> </h3> </div> <div class="col-md-6 actions"> <a href="https://doc.hotexamples.com/es/class/-/Site_Command#prop-obj_type" title="Direct link to property Site_Command::obj_type documentation"> <i class='icon-borderless icon-link'></i> </a> </div> </div> <div class="row"> <div class="col-md-12"> </div> </div> <div class="row doc-tags"> <div class="col-md-12"> </div> </div> <div class="row"> <div class="col-md-12" style="overflow: auto"> <table class="table table-striped"> <!-- <tr> <td colspan="3"></td> </tr> --> <tr> <td colspan="3" class="rendered"> <span class="modifier">protected</span > <span class="var-name">$obj_type</span> </td> </tr> </table> </div> </div> </div> </div> </div> </div></div> <footer class="footer"> <div class="container"> <div class="row"> <div class="col-md-12" style="text-align: center"> <a href="https://hotexamples.com/es/site/trends?type=php%7Cf">Mejores funciones</a> | <a href="https://hotexamples.com/es/site/trends?type=php%7Cc"> Mejores clases </a> | <a href="https://doc.hotexamples.com/es/doc/map">Documentación</a> | <a href="/site/privacy">Política de privacidad</a> | <a href="https://cpp.hotexamples.com/direct-sales.html">Advertise with us</a> </div> </div> <div class="row"> <div class="col-md-12" style="text-align: center"> <a href="https://hotexamples.com/es/">PHP</a> | <a href="https://csharp.hotexamples.com/es/">C# (CSharp)</a> | <a href="https://java.hotexamples.com/es/">Java</a> | <a href="https://golang.hotexamples.com/es/">Golang</a> | <a href="https://cpp.hotexamples.com/es/">C++ (Cpp)</a> | <a href="https://python.hotexamples.com/es/">Python</a> | <a href="https://javascript.hotexamples.com/es/">JavaScript</a> | <a href="https://typescript.hotexamples.com/es/">TypeScript</a> </div> </div> <div class="row"> <div class="col-md-12" style="text-align: center"> <a href="https://doc.hotexamples.com/class/-/Site_Command">EN</a> | <a href="https://doc.hotexamples.com/ru/class/-/Site_Command">RU</a> | <a href="https://doc.hotexamples.com/de/class/-/Site_Command">DE</a> | <a href="https://doc.hotexamples.com/fr/class/-/Site_Command">FR</a> | <a href="https://doc.hotexamples.com/es/class/-/Site_Command">ES</a> | <a href="https://doc.hotexamples.com/pt/class/-/Site_Command">PT</a> | <a href="https://doc.hotexamples.com/it/class/-/Site_Command">IT</a> | <a href="https://doc.hotexamples.com/jp/class/-/Site_Command">JP</a> | <a href="https://doc.hotexamples.com/zh/class/-/Site_Command">ZH</a> | <a href="https://doc.hotexamples.com/ko/class/-/Site_Command">KO</a> </div> </div> <div class="row"> <div class="col-md-10 col-md-offset-1"> </div> <div class="col-md-1"> <!--LiveInternet counter--> <script type="text/javascript"><!-- document.write("<a href='//www.liveinternet.ru/click' " + "target=_blank><img src='//counter.yadro.ru/hit?t44.6;r" + escape(document.referrer) + ((typeof (screen) == "undefined") ? "" : ";s" + screen.width + "*" + screen.height + "*" + (screen.colorDepth ? screen.colorDepth : screen.pixelDepth)) + ";u" + escape(document.URL) + ";" + Math.random() + "' alt='' title='LiveInternet' " + "border='0' width='31' height='31'><\/a>"); //--></script><!--/LiveInternet--> </div> </div> </div> </footer> <script src="//ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <script src="/assets/30dd86a6f06b64184847037c52c63e07aa3c9a26.js"></script> <script>jQuery(function ($) { jQuery('#search-form').yiiActiveForm([{"id":"searchform-lang","name":"lang","container":".field-searchform-lang","input":"#searchform-lang","enableAjaxValidation":true},{"id":"searchform-search","name":"search","container":".field-searchform-search","input":"#searchform-search","enableAjaxValidation":true,"validate":function (attribute, value, messages, deferred, $form) {yii.validation.required(value, messages, {"message":"Search no puede estar vacío."});}}], []); });</script></body> </html>