WP-CLI (commando's)

Uit De Vliegende Brigade
(Doorverwezen vanaf Wp plugin deactivate)
Ga naar: navigatie, zoeken

Shortcuts

Inhoud

Global parameters

Ik herhaal de global parameters niet in elke helptekst. Daarom hierbij:

GLOBAL PARAMETERS

--path=<path>
    Path to the WordPress files.

--url=<url>
    Pretend request came from given URL. In multisite, this argument is how the target site is specified.

--ssh=[<scheme>:][<user>@]<host|container>[:<port>][<path>]
    Perform operation against a remote server over SSH (or a container using scheme of "docker", "docker-compose",
    "vagrant").

--http=<http>
    Perform operation against a remote WordPress installation over HTTP.

--user=<id|login|email>
    Set the WordPress user.

--skip-plugins[=<plugins>]
    Skip loading all plugins, or a comma-separated list of plugins. Note: mu-plugins are still loaded.

--skip-themes[=<themes>]
    Skip loading all themes, or a comma-separated list of themes.

--skip-packages
    Skip loading all installed packages.

--require=<path>
    Load PHP file before running the command (may be used more than once).

--[no-]color
    Whether to colorize the output.

--debug[=<group>]
    Show all PHP errors and add verbosity to WP-CLI output. Built-in groups include: bootstrap, commandfactory, and
    help.

--prompt[=<assoc>]
    Prompt the user to enter values for all command arguments, or a subset specified as comma-separated values.

--quiet
    Suppress informational messages.

--debug

De optie --debug toont debugging-informatie gedurende de executie van het WP-CLI-commando. Als het betreffende WP-CLI commando klaar is, ga je weer terug naar het gewone terminalscherm. Ik heb de indruk dat deze optie niet geschikt is als je gedurende executie van bv. een groot script, globaal op de hoogte gehouden wilt worden omtrent de voortgang.

Je kunt aangeven om welke groep van debug-informatie het gaat. Ik denk dat je dat vanzelf ziet als je deze optie eerst zonder waarde gebruikt. De waardes die ik zo snel voorbij zag komen (onderbreek exectie met Ctrl-C, anders gaat 't vermoedelijk te snel):

  • bootstrap
  • commands
  • hooks

Voorbeelden:

# Toon alle debug-informatie
########################################
#
wp option list --fields=option_name --debug


# Toon alleen commands-debug-informatie
########################################
#
wp option list --fields=option_name --debug=commands

wp

wp is het hoofdcommando.

  • Als je dit commando (zonder argmenten) geeft terwijl de werkmap geen WP-installatie betreft, krijg je een overzicht van de 'generieke' wp-commando's
  • Als je dit commando (zonder argumenten) geeft terwijl de werkmap een WP-installatie betreft, krijg je tevens plugin-specifieke commando's te zien.

Voorbeeld deel van de output binnen een WP-installatie waar WooCommerce is geïnstalleerd ('wp wc'):

NAME

  wp

DESCRIPTION

  Manage WordPress through the command-line.

SYNOPSIS

  wp <command>

SUBCOMMANDS

  cache               Manage the object cache.
  cap                 Manage user capabilities.
  checksum            Verify WordPress core checksums.
  cli                 Review current WP-CLI info, check for updates, or see
                      defined aliases.
  comment             Manage comments.
  config              Manage the wp-config.php file
  core                Download, install, update and manage a WordPress
                      install.
  cron                Manage WP-Cron events and schedules.
  db                  Perform basic database operations using credentials
                      stored in wp-config.php
  eval                Execute arbitrary PHP code.
  eval-file           Load and execute a PHP file.
  export              Export WordPress content to a WXR file.
  help                Get help on WP-CLI, or on a specific command.
  import              Import content from a WXR file.
  language            
  media               Import new attachments or regenerate existing ones.
  menu                List, create, assign, and delete menus.
  network             
  option              Manage options.
  package             Manage WP-CLI packages.
  plugin              Manage plugins.
  post                Manage posts.
  post-type           Manage post types.
  rewrite             Manage rewrite rules.
  role                Manage user roles.
  scaffold            Generate code for post types, taxonomies, plugins,
                      child themes, etc.
  search-replace      Search/replace strings in the database.
  server              Launch PHP's built-in web server for this specific
                      WordPress installation.
  shell               Interactive PHP console.
  sidebar             Manage sidebars.
  site                Perform site-wide operations.
  super-admin         Manage super admins on WordPress multisite.
  taxonomy            Manage taxonomies.
  term                Manage terms.
  theme               Manage themes.
  transient           Manage transients.
  user                Manage users.
  wc                  
  widget              Manage sidebar widgets.

wp action-scheduler

Updates an option value (a plugin?)

wp cache

Adds, removes, fetches, and flushes the WP Object Cache object.

wp cap

Adds, removes, and lists capabilities of a user role

wp cli

Reviews current WP-CLI info, checks for updates, or views defined aliases.

wp cli update

Je kunt WP-CLI updaten middels

wp cli update

of door 'm opnieuw te installeren.

wp comment

Creates, updates, deletes, and moderates comments.

https://developer.wordpress.org/cli/commands/comment/:

wp comment approve  Approve a comment.
wp comment count  Count comments, on whole blog or on a given post.
wp comment create   Create a new comment.
wp comment delete   Delete a comment.
wp comment exists   Verify whether a comment exists.
wp comment generate   Generate some number of new dummy comments.
wp comment get          Get data of a single comment.
wp comment list   Get a list of comments.
wp comment meta   Manage comment custom fields.
wp comment recount  Recalculate the comment_count value for one or more posts.
wp comment spam   Mark a comment as spam.
wp comment status   Get status of a comment.
wp comment trash  Trash a comment.
wp comment unapprove  Unapprove a comment.
wp comment unspam   Unmark a comment as spam.
wp comment untrash  Untrash a comment.
wp comment update   Update one or more comments.

wp comment delete

Bv.:

> wp comment list
+------------+-----------------+--------------------+------------------+--------------------+-----------------------+
| comment_ID | comment_post_ID | comment_date       | comment_approved | comment_author     | comment_author_email  |
+------------+-----------------+--------------------+------------------+--------------------+-----------------------+
| 1          | 1               | 2017-10-13 13:02:3 | 1                | A WordPress Commen | wapuu@wordpress.examp |
|            |                 | 7                  |                  | ter                | le                    |
+------------+-----------------+--------------------+------------------+--------------------+-----------------------+

> wp comment delete 1
Success: Trashed comment 1.

wp comment list

Bv.:

> wp comment list
+------------+-----------------+--------------------+------------------+--------------------+-----------------------+
| comment_ID | comment_post_ID | comment_date       | comment_approved | comment_author     | comment_author_email  |
+------------+-----------------+--------------------+------------------+--------------------+-----------------------+
| 1          | 1               | 2017-10-13 13:02:3 | 1                | A WordPress Commen | wapuu@wordpress.examp |
|            |                 | 7                  |                  | ter                | le                    |
+------------+-----------------+--------------------+------------------+--------------------+-----------------------+

wp config

Generates and reads the wp-config.php file.

* wp config create
* wp config get
* wp config path

wp core

Download, install, update and manage a WordPress install. Subcommando's:

* wp core check-update        Check for WordPress updates via Version Check API.
* wp core config              Creëer een config-bestand, voorafgaand aan installatie van een site
* wp core download        Download core WordPress files.
* wp core install         Runs the standard WordPress installation process.
* wp core is-installed        Check if WordPress is installed.
* wp core multisite-convert   Transform a single-site install into a WordPress multisite install.
* wp core multisite-install   Install WordPress multisite from scratch.
* wp core update        Update WordPress to a newer version.
* wp core update-db           Run the WordPress database update procedure.
* wp core version         Display the WordPress version.

wp core config

Creëer een nieuw wp-config.php-bestand. Dit commando wordt niet genoemd op de site. Daar heb je het vergelijkbare commando wp config create.

wp config create

   --dbname=<dbname>            Set the database name.
   --dbuser=<dbuser>            Set the database user.
   [--dbpass=<dbpass>]          Set the database user password.
   [--dbhost=<dbhost>]          Set the database host.
                                default: localhost
   [--dbprefix=<dbprefix>]      Set the database table prefix.
                                default: wp_
   [--dbcharset=<dbcharset>]    Set the database charset.
                                default: utf8
   [--dbcollate=<dbcollate>]    Set the database collation.
                                default:
   [--locale=<locale>]          Set the WPLANG constant. 
                                Defaults to $wp_local_package variable.
   [--extra-php]                If set, the command copies additional PHP code 
                                into wp-config.php from STDIN.
   [--skip-salts]               If set, keys and salts won’t be generated, 
                                but should instead be passed via --extra-php.
   [--skip-check]               If set, the database connection is not checked.
   [--force]                    Overwrites existing files, if present. 

wp core download

Voorbeeld van gedownloade WordPress-instanties als zip-bestanden

download een actuele WordPress-instantie en plaats die uitgepakt en MD5-geverifiëerd in de werkmap, of in de map die wordt meegegeven.

wp core download

   [--path=<path>]         Specify the path in which to install WordPress. Defaults to current directory.
   [--locale=<locale>]     Select which language you want to download.
   [--version=<version>]   Select which version you want to download. Accepts a version number, ‘latest’ or ‘nightly’
   [--force]               Overwrites existing files, if present. 

Wat-ie precies doet:

  • De WordPress-instantie wordt gedownload als gezipped phar-archief naar /tmp. Zie afbeelding hiernaast
  • md5-hash van dit archiefbestand wordt geverifiëerd
  • Het archiefbestand wordt uitgepakt naar een tijdelijke locatie

Foutmelding: Couldn't decompress

Het probleem:

wp core download
Downloading WordPress 4.8.2 (en_US)...
md5 hash verified: 2e8744a702a3d9527782d9135a4c9544
Error: Couldn't extract WordPress archive. unable to decompress gzipped phar archive "/tmp/wp_59c276fb45c4b.tar.gz" to temporary file

Aanvullende gegevens:

  • sudo chmod o+w /tmp - Hielp niet
  • sudo /usr/local/bin/wp core download --allow-root - Hielp niet
  • wp cli ge-update - Hielp niet

wp core install

Installeer een gedownloade WordPress-instantie:

wp core install 

   --url=<url> 
   --title=<site-title> 
   --admin_user=<username>
   [--admin_password=<password>]   # Defaults to randomly generated string
   [--admin_email=<email>]
   [--skip-email]                  # Don't send email notification
  • Dit commando moet uitgevoerd worden in de working map waar de installatiebestanden staan, en waar de site geïnstalleerd moet worden
  • Op mijn ontwikkelcomputer kreeg ik een foutmelding dat Sendmail niet gevonden kon worden. Ik weet niet of dat door het script komt, of een configuratiefout ergen op m'n computer.

wp core update

Simpel:

wp core update

Plugins worden hierbij niet bijgewerkt.

wp core update-db

Geen idee waarom er een apart commando is om de db bij te werken. Eén keer gedaan na update van een site die al een tijdje niet was bijgewerkt: Geen verschil.

wp cron

Tests, runs, and deletes WP-Cron events; manages WP-Cron schedules.

wp cron event

wp cron schedule

  • Er lijkt maar één subcommando te zijn: schedule
  • wp cron schedule list: Overzicht van alle cron-jobs

wp cron test

wp db

Performs basic database operations using credentials stored in wp-config.php.

Output van wp help db:

NAME

  wp db

DESCRIPTION

  Performs basic database operations using credentials stored in wp-config.php.

SYNOPSIS

  wp db <command>

SUBCOMMANDS

  check         Checks the current status of the database.
  clean         Removes all tables with `$table_prefix` from the database.
  cli           Opens a MySQL console using credentials from wp-config.php
  columns       Displays information about a given table.
  create        Creates a new database.
  drop          Deletes the existing database.
  export        Exports the database to a file or to STDOUT.
  import        Imports a database from a file or from STDIN.
  optimize      Optimizes the database.
  prefix        Displays the database table prefix.
  query         Executes a SQL query against the database.
  repair        Repairs the database.
  reset         Removes all tables from the database.
  search        Finds a string in the database.
  size          Displays the database name and size.
  tables        Lists the database tables.

EXAMPLES

    # Create a new database.
    $ wp db create
    Success: Database created.

    # Drop an existing database.
    $ wp db drop --yes
    Success: Database dropped.

    # Reset the current database.
    $ wp db reset --yes
    Success: Database reset.

    # Execute a SQL query stored in a file.
    $ wp db query < debug.sql


wp embed

Inspects oEmbed providers, clears embed cache, and more.

wp eval

Executes arbitrary PHP code.

wp eval-file

Loads and executes a PHP file.

wp eval

Exports WordPress content to a WXR file.

wp gf

wp gf betreft WP-CLI commando's voor Gravity Forms.

Uitvoer wp help gf (behoudens de gebruikelijke globale parameters):

NAME

  wp gf

DESCRIPTION

  Manage Gravity Forms.

SYNOPSIS

  wp gf <command>

SUBCOMMANDS

  check_update      Checks for available updates for Gravity Forms or a Gravity Forms
                    official add-on.
  entry             Manage Gravity Forms Entries.
  field             Manage Gravity Forms Form Fields.
  form              Manage Gravity Forms.
  install           Installs Gravity Forms or a Gravity Forms official add-on.
  license           Manage the Gravity Forms License Key.
  notification      Manage Gravity Forms Notifications.
  setup             Runs the setup for Gravity Forms or a Gravity Forms official add-on.
  tool              Misc Gravity Forms Tools.
  update            Updates Gravity Forms or a Gravity Forms official add-on.
  version           Returns the version of Gravity Forms.

wp gf check_update

wp gf entry

wp help gf entry

NAME

  wp gf entry

DESCRIPTION

  Manage Gravity Forms Entries.

SYNOPSIS

  wp gf entry <command>

SUBCOMMANDS

  create            Creates a new entry from either a JSON string with the raw entry or from field-value pairs.
  delete            Deletes an entry.
  duplicate         Duplicates an entry
  edit              Launch system editor to edit the JSON representation of the Entry.
  export            Exports entries.
  get               Returns a JSON representation of an entry.
  import            Imports entries.
  list              Displays a list of entries.
  notification      Send Gravity Forms Notifications.
  update            Updates an entry.

wp gf entry delete

wp help gf entry delete

NAME

  wp gf entry delete

DESCRIPTION

  Deletes an entry.

SYNOPSIS

  wp gf entry delete <entry-id>... [--force]

Met de Boolean optie --force worden entries direct verwijderd, ipv. verplaatst te worden naar de prullenbak.

Voorbeelden

# Delete a form entry
########################################
#
# Delete - Don't move it to trash
#
wp gf entry list 1 --format="ids"

1921 1920 1918 1909 1903 1898 1897 1896 1893 1889 1885 1884 1883 1882 1877 1876 1875 1867 1866 1863^C

$ wp gf entry delete --force 1921

Success: Deleted entry 1921


# Trying out wildcard * to delete all
########################################
#
# Some unexpected behaviour:
#
wp gf entry delete *


Error: Entry with id dvb not found
Error: Entry with id favicon.ico not found
Error: Entry with id help.txt not found
Error: Entry with id index.php not found
Error: Entry with id license.txt not found
Error: Entry with id list.txt not found
Error: Entry with id login.txt not found
Error: Entry with id malcare-waf.php not found
Error: Entry with id order-ids.txt not found
Error: Entry with id order_list.txt not found
Error: Entry with id readme.html not found
Error: Entry with id robots.txt not found
Error: Entry with id text2.txt not found
Error: Entry with id text.txt not found
Error: Entry with id wp not found
Error: Entry with id wp-activate.php not found
Error: Entry with id wp-admin not found
Error: Entry with id wp-blog-header.php not found
Error: Entry with id wp-comments-post.php not found
Error: Entry with id wp-config.php not found
Error: Entry with id wp-config-sample.php not found
Error: Entry with id wp-content not found
Error: Entry with id wp-cron.php not found
Error: Entry with id wp-includes not found
Error: Entry with id wp-links-opml.php not found
Error: Entry with id wp-load.php not found
Error: Entry with id wp-login.php not found
Error: Entry with id wp-mail.php not found
Error: Entry with id wp-salt.php not found
Error: Entry with id wp-settings.php not found
Error: Entry with id wp-signup.php not found
Error: Entry with id wp-trackback.php not found
Error: Entry with id xargs not found
Error: Entry with id xmlrpc.php not found


# "--all" to delete all? Nope
########################################
#
wp gf entry delete --all

usage: wp gf entry delete <entry-id>... [--force]


# No argument to delete all? Nope
########################################
#
wp gf entry delete

usage: wp gf entry delete <entry-id>... [--force]

# Delete all entries form 1-3
########################################
#
wp gf entry delete --force $(wp gf entry list 1 --format="ids" --page_size=100000)
wp gf entry delete --force $(wp gf entry list 2 --format="ids" --page_size=100000)
wp gf entry delete --force $(wp gf entry list 3 --format="ids" --page_size=100000)

wp gf entry list

wp help gf entry list

NAME

  wp gf entry list

DESCRIPTION

  Displays a list of entries.

SYNOPSIS

  wp gf entry list <form-id> [--status=<status>] [--format=<format>] [--page_size=<page_size>] [--offset=<offset>]

--format

Mogelijke waardes:

  • table
  • csv
  • json
  • count
  • ids - Deze optie vind je niet snel terug in de documentatie.

-page_size

Standaard worden er 20 entries weergegeven. Met de parameter --page_size kun je dit aanpassen. Ik heb dit getest op formulieren met bijna 900 entries, en dat ging prima. Er lijkt vooralsnog geen bovengrens te zijn.

Voorbeelden:

# Returns number of entries for form 1
########################################
#
wp gf entry list 1 --format="count"


# Return first 20 entry id's form 1
########################################
#
# The option --format="ids" is hardly mentioned on their help page https://docs.gravityforms.com/managing-entries
# and completely not on the inline help, eventhough it's crucial for me to automatically delete entries
#
wp gf entry list 1 --format="ids"


# Return all entry id's form 1
########################################
#
wp gf entry list 1 --format="ids" --page_size=100000

wp gf field

wp gf form

wp gf install

wp gf license

wp gf notification

wp gf setup

wp gf tool

wp gf update

wp gf version

wp help

Gets help on WP-CLI, or on a specific command.

wp i18n

Provides internationalization tools for WordPress projects.

wp import

Imports content from a given WXR file.

wp jetpack

Control your local Jetpack installation.

wp jetpack-heartbeat

Interact with the Heartbeat.

wp language

wp language core

  • wp language core heeft betrekking op de default site language, wat ik meestal site-language noem - WordPress & Taal » Site-language.
  • In codes zoals nl_NL, is de eerste code de taal, en de tweede code het land - Niet andersom, zoals ik het vaak interpreteer. Daarnaast is dit case-sensitive.

Voorbeelden van alle subcommando's:

wp language core activate nl_NL
wp language core install nl_NL
wp language core is-installed <language>
wp language core list
wp language core uninstall <language>
wp language core update

https://developer.wordpress.org/cli/commands/language/core/

wp language core activitate

Voorbeeld:

wp language core activate fr_BE

Warning: This command is deprecated. use wp site switch-language instead
Success: Language activated.

Deze foutmelding vind ik vreemd, want wp site heeft betrekking op multi-sites en dat is hier niet het geval (ik werk nooit met multi-sites).

wp language core is-installed <language>

Met commando wp language core is-installed <language> kun je verifiëren of een bepaalde taal is geïnstalleerd.

wp language core list

Met dit commando kun je deiverse overzichten genereren.

Overzicht van geïnstalleerde talen - voorbeeld:

wp language core list --status=installed


+----------+--------------+-------------+-----------+--------+---------------------+
| language | english_name | native_name | status    | update | updated             |
+----------+--------------+-------------+-----------+--------+---------------------+
| nl_NL    | Dutch        | Nederlands  | installed | none   | 2021-07-20 20:12:13 |
+----------+--------------+-------------+-----------+--------+---------------------+

Nog een voorbeeld van een Waalse site. Opmerkelijk dat en_US hier apart vermeld wordt:

wp language core list --status=installed

+----------+-------------------------+-------------------------+-----------+--------+---------------------+
| language | english_name            | native_name             | status    | update | updated             |
+----------+-------------------------+-------------------------+-----------+--------+---------------------+
| en_US    | English (United States) | English (United States) | installed | none   |                     |
| fr_BE    | French (Belgium)        | Français de Belgique    | installed | none   | 2021-02-22 13:54:46 |
| nl_NL    | Dutch                   | Nederlands              | installed | none   | 2021-07-20 11:18:28 |
+----------+-------------------------+-------------------------+-----------+--------+---------------------+

Overzicht van alle beschikbare talen - Handig om de juiste code te achterhalen:

wp language core list

+----------------+--------------------------------+-------------------------+-------------+-----------+---------------------+
| language       | english_name                   | native_name             | status      | update    | updated             |
+----------------+--------------------------------+-------------------------+-------------+-----------+---------------------+
| af             | Afrikaans                      | Afrikaans               | uninstalled | none      | 2021-05-13 15:59:22 |
| ar             | Arabic                         | العربية                 | uninstalled | none      | 2021-06-30 21:16:05 |
| ary            | Moroccan Arabic                | العربية المغربية        | uninstalled | none      | 2017-01-26 15:42:35 |
| as             | Assamese                       | অসমীয়া                    | uninstalled | none      | 2021-06-14 14:01:58 |
| az             | Azerbaijani                    | Azərbaycan dili         | uninstalled | none      | 2016-11-06 00:09:27 |
| azb            | South Azerbaijani              | گؤنئی آذربایجان         | uninstalled | none      | 2016-09-12 20:34:31 |
| bel            | Belarusian                     | Беларуская мова         | uninstalled | none      | 2019-10-29 07:54:22 |
| bg_BG          | Bulgarian                      | Български               | uninstalled | none      | 2021-06-20 19:46:45 |
| bn_BD          | Bengali (Bangladesh)           | বাংলা                      | uninstalled | none      | 2020-10-31 08:48:37 |
| bo             | Tibetan                        | བོད་ཡིག                   | uninstalled | none      | 2020-10-30 03:24:38 |
| bs_BA          | Bosnian                        | Bosanski                | uninstalled | none      | 2021-04-25 07:27:37 |
| ca             | Catalan                        | Català                  | uninstalled | none      | 2021-06-14 13:15:40 |
| ceb            | Cebuano                        | Cebuano                 | uninstalled | none      | 2016-03-02 17:25:51 |
| ckb            | Kurdish (Sorani)               | كوردی‎                  | uninstalled | none      | 2021-06-17 10:36:11 |
| cs_CZ          | Czech                          | Čeština                 | uninstalled | none      | 2021-06-30 15:14:54 |
| cy             | Welsh                          | Cymraeg                 | uninstalled | none      | 2021-04-15 10:32:41 |
| da_DK          | Danish                         | Dansk                   | uninstalled | none      | 2021-06-18 02:04:16 |
| de_AT          | German (Austria)               | Deutsch (Österreich)    | uninstalled | none      | 2021-06-08 07:32:43 |
| de_CH          | German (Switzerland)           | Deutsch (Schweiz)       | uninstalled | none      | 2021-03-14 20:06:23 |
| de_CH_informal | German (Switzerland, Informal) | Deutsch (Schweiz, Du)   | uninstalled | none      | 2021-03-14 20:06:52 |
| de_DE          | German                         | Deutsch                 | uninstalled | none      | 2021-06-22 16:13:32 |
| de_DE_formal   | German (Formal)                | Deutsch (Sie)           | uninstalled | none      | 2021-06-22 17:40:37 |
| dsb            | Lower Sorbian                  | Dolnoserbšćina          | uninstalled | none      | 2021-04-15 13:33:04 |
| dzo            | Dzongkha                       | རྫོང་ཁ                    | uninstalled | none      | 2016-06-29 08:59:03 |
| el             | Greek                          | Ελληνικά                | uninstalled | none      | 2021-06-30 19:50:02 |
| en_AU          | English (Australia)            | English (Australia)     | uninstalled | none      | 2021-04-15 04:12:40 |
| en_CA          | English (Canada)               | English (Canada)        | uninstalled | none      | 2021-04-15 04:12:51 |
| en_GB          | English (UK)                   | English (UK)            | uninstalled | none      | 2021-06-16 08:10:36 |
| en_NZ          | English (New Zealand)          | English (New Zealand)   | uninstalled | none      | 2021-04-15 04:12:28 |
| en_US          | English (United States)        | English (United States) | installed   | none      |                     |
| en_ZA          | English (South Africa)         | English (South Africa)  | uninstalled | none      | 2021-04-15 07:22:30 |
| eo             | Esperanto                      | Esperanto               | uninstalled | none      | 2021-04-18 09:35:35 |
| es_AR          | Spanish (Argentina)            | Español de Argentina    | uninstalled | none      | 2021-04-16 02:17:21 |
| es_CL          | Spanish (Chile)                | Español de Chile        | uninstalled | none      | 2021-06-14 16:02:22 |
| es_CO          | Spanish (Colombia)             | Español de Colombia     | uninstalled | none      | 2021-06-04 22:59:08 |
| es_CR          | Spanish (Costa Rica)           | Español de Costa Rica   | uninstalled | none      | 2021-06-02 03:00:51 |
| es_EC          | Spanish (Ecuador)              | Español de Ecuador      | uninstalled | none      | 2021-04-15 02:05:34 |
| es_ES          | Spanish (Spain)                | Español                 | uninstalled | none      | 2021-06-10 20:43:51 |
| es_GT          | Spanish (Guatemala)            | Español de Guatemala    | uninstalled | none      | 2019-03-02 06:35:01 |
| es_MX          | Spanish (Mexico)               | Español de México       | uninstalled | none      | 2021-04-16 13:07:32 |
| es_PE          | Spanish (Peru)                 | Español de Perú         | uninstalled | none      | 2020-12-11 02:12:59 |
| es_PR          | Spanish (Puerto Rico)          | Español de Puerto Rico  | uninstalled | none      | 2020-04-29 15:36:59 |
| es_UY          | Spanish (Uruguay)              | Español de Uruguay      | uninstalled | none      | 2021-03-31 18:33:26 |
| es_VE          | Spanish (Venezuela)            | Español de Venezuela    | uninstalled | none      | 2021-04-15 02:05:15 |
| et             | Estonian                       | Eesti                   | uninstalled | none      | 2020-08-12 08:38:59 |
| eu             | Basque                         | Euskara                 | uninstalled | none      | 2021-06-24 16:08:10 |
| fa_AF          | Persian (Afghanistan)          | (فارسی (افغانستان       | uninstalled | none      | 2021-06-14 12:40:09 |
| fa_IR          | Persian                        | فارسی                   | uninstalled | none      | 2021-06-28 10:15:19 |
| fi             | Finnish                        | Suomi                   | uninstalled | none      | 2021-05-06 05:21:48 |
| fr_BE          | French (Belgium)               | Français de Belgique    | uninstalled | none      | 2021-02-22 13:54:46 |
| fr_CA          | French (Canada)                | Français du Canada      | uninstalled | none      | 2021-04-30 13:29:35 |
| fr_FR          | French (France)                | Français                | installed   | available | 2021-06-24 08:28:29 |
| fur            | Friulian                       | Friulian                | uninstalled | none      | 2018-01-29 17:32:35 |
| gd             | Scottish Gaelic                | Gàidhlig                | uninstalled | none      | 2016-08-23 17:41:37 |
| gl_ES          | Galician                       | Galego                  | uninstalled | none      | 2021-06-21 09:58:55 |
| gu             | Gujarati                       | ગુજરાતી                    | uninstalled | none      | 2018-09-14 12:33:48 |
| haz            | Hazaragi                       | هزاره گی                | uninstalled | none      | 2015-12-05 00:59:09 |
| he_IL          | Hebrew                         | עִבְרִית                   | uninstalled | none      | 2021-05-28 16:42:59 |
| hi_IN          | Hindi                          | हिन्दी                     | uninstalled | none      | 2020-11-06 12:34:38 |
| hr             | Croatian                       | Hrvatski                | uninstalled | none      | 2021-05-13 08:03:31 |
| hsb            | Upper Sorbian                  | Hornjoserbšćina         | uninstalled | none      | 2021-04-15 13:34:18 |
| hu_HU          | Hungarian                      | Magyar                  | uninstalled | none      | 2021-06-26 14:52:10 |
| hy             | Armenian                       | Հայերեն                 | uninstalled | none      | 2016-12-03 16:21:10 |
| id_ID          | Indonesian                     | Bahasa Indonesia        | uninstalled | none      | 2021-04-24 02:11:27 |
| is_IS          | Icelandic                      | Íslenska                | uninstalled | none      | 2018-12-11 10:40:02 |
| it_IT          | Italian                        | Italiano                | uninstalled | none      | 2021-06-18 13:45:37 |
| ja             | Japanese                       | 日本語                  | uninstalled | none      | 2021-05-20 01:00:08 |
| jv_ID          | Javanese                       | Basa Jawa               | uninstalled | none      | 2019-02-16 23:58:56 |
| kab            | Kabyle                         | Taqbaylit               | uninstalled | none      | 2021-06-30 20:40:17 |
| ka_GE          | Georgian                       | ქართული                 | uninstalled | none      | 2021-06-15 08:23:19 |
| kk             | Kazakh                         | Қазақ тілі              | uninstalled | none      | 2018-07-10 11:35:44 |
| km             | Khmer                          | ភាសាខ្មែរ                   | uninstalled | none      | 2019-06-10 16:18:28 |
| kn             | Kannada                        | ಕನ್ನಡ                    | uninstalled | none      | 2020-09-30 14:08:59 |
| ko_KR          | Korean                         | 한국어                  | uninstalled | none      | 2021-06-24 01:16:16 |
| lo             | Lao                            | ພາສາລາວ                 | uninstalled | none      | 2016-11-12 09:59:23 |
| lt_LT          | Lithuanian                     | Lietuvių kalba          | uninstalled | none      | 2021-03-23 12:35:40 |
| lv             | Latvian                        | Latviešu valoda         | uninstalled | none      | 2021-06-27 17:07:17 |
| mk_MK          | Macedonian                     | Македонски јазик        | uninstalled | none      | 2020-07-01 09:16:57 |
| ml_IN          | Malayalam                      | മലയാളം                    | uninstalled | none      | 2017-01-27 03:43:32 |
| mn             | Mongolian                      | Монгол                  | uninstalled | none      | 2017-01-12 07:29:35 |
| mr             | Marathi                        | मराठी                     | uninstalled | none      | 2019-11-22 15:32:08 |
| ms_MY          | Malay                          | Bahasa Melayu           | uninstalled | none      | 2018-08-31 11:57:07 |
| my_MM          | Myanmar (Burmese)              | ဗမာစာ                   | uninstalled | none      | 2017-12-26 11:57:10 |
| nb_NO          | Norwegian (Bokmål)             | Norsk bokmål            | uninstalled | none      | 2021-06-08 06:18:21 |
| ne_NP          | Nepali                         | नेपाली                     | uninstalled | none      | 2020-05-31 16:07:59 |
| nl_BE          | Dutch (Belgium)                | Nederlands (België)     | uninstalled | none      | 2021-06-18 08:55:40 |
| nl_NL          | Dutch                          | Nederlands              | active      | none      | 2021-06-17 11:46:51 |
| nl_NL_formal   | Dutch (Formal)                 | Nederlands (Formeel)    | uninstalled | none      | 2021-05-10 14:42:01 |
| nn_NO          | Norwegian (Nynorsk)            | Norsk nynorsk           | uninstalled | none      | 2021-03-18 10:59:16 |
| oci            | Occitan                        | Occitan                 | uninstalled | none      | 2017-08-25 10:03:08 |
| pa_IN          | Punjabi                        | ਪੰਜਾਬੀ                     | uninstalled | none      | 2017-01-16 05:19:43 |
| pl_PL          | Polish                         | Polski                  | uninstalled | none      | 2021-07-01 12:36:36 |
| ps             | Pashto                         | پښتو                    | uninstalled | none      | 2015-12-02 21:41:29 |
| pt_AO          | Portuguese (Angola)            | Português de Angola     | uninstalled | none      | 2021-05-30 09:51:29 |
| pt_BR          | Portuguese (Brazil)            | Português do Brasil     | uninstalled | none      | 2021-06-02 12:53:00 |
| pt_PT          | Portuguese (Portugal)          | Português               | uninstalled | none      | 2021-06-18 10:37:59 |
| pt_PT_ao90     | Portuguese (Portugal, AO90)    | Português (AO90)        | uninstalled | none      | 2021-04-15 08:18:42 |
| rhg            | Rohingya                       | Ruáinga                 | uninstalled | none      | 2016-03-16 13:03:18 |
| ro_RO          | Romanian                       | Română                  | uninstalled | none      | 2021-06-30 14:06:26 |
| ru_RU          | Russian                        | Русский                 | uninstalled | none      | 2021-06-14 18:30:49 |
| sah            | Sakha                          | Сахалыы                 | uninstalled | none      | 2017-01-21 02:06:41 |
| si_LK          | Sinhala                        | සිංහල                     | uninstalled | none      | 2016-11-12 06:00:52 |
| skr            | Saraiki                        | سرائیکی                 | uninstalled | none      | 2021-04-23 11:54:14 |
| sk_SK          | Slovak                         | Slovenčina              | uninstalled | none      | 2021-05-13 04:10:29 |
| sl_SI          | Slovenian                      | Slovenščina             | uninstalled | none      | 2019-04-30 13:03:56 |
| snd            | Sindhi                         | سنڌي                    | uninstalled | none      | 2020-07-07 01:53:37 |
| sq             | Albanian                       | Shqip                   | uninstalled | none      | 2021-05-13 15:40:47 |
| sr_RS          | Serbian                        | Српски језик            | uninstalled | none      | 2021-06-14 19:47:34 |
| sv_SE          | Swedish                        | Svenska                 | uninstalled | none      | 2021-06-29 18:47:40 |
| sw             | Swahili                        | Kiswahili               | uninstalled | none      | 2019-10-13 15:35:35 |
| szl            | Silesian                       | Ślōnskŏ gŏdka           | uninstalled | none      | 2016-09-24 19:58:14 |
| tah            | Tahitian                       | Reo Tahiti              | uninstalled | none      | 2016-03-06 18:39:39 |
| ta_IN          | Tamil                          | தமிழ்                     | uninstalled | none      | 2017-01-27 03:22:47 |
| ta_LK          | Tamil (Sri Lanka)              | தமிழ்                     | uninstalled | none      | 2015-12-03 01:07:44 |
| te             | Telugu                         | తెలుగు                     | uninstalled | none      | 2017-01-26 15:47:39 |
| th             | Thai                           | ไทย                     | uninstalled | none      | 2021-04-22 18:43:36 |
| tl             | Tagalog                        | Tagalog                 | uninstalled | none      | 2017-09-30 09:04:29 |
| tr_TR          | Turkish                        | Türkçe                  | uninstalled | none      | 2021-05-23 09:26:34 |
| tt_RU          | Tatar                          | Татар теле              | uninstalled | none      | 2016-11-20 20:20:50 |
| ug_CN          | Uighur                         | ئۇيغۇرچە                | uninstalled | none      | 2018-05-16 07:36:13 |
| uk             | Ukrainian                      | Українська              | uninstalled | none      | 2021-06-17 19:11:00 |
| ur             | Urdu                           | اردو                    | uninstalled | none      | 2020-04-09 11:17:33 |
| uz_UZ          | Uzbek                          | O‘zbekcha               | uninstalled | none      | 2021-02-28 12:02:22 |
| vi             | Vietnamese                     | Tiếng Việt              | uninstalled | none      | 2021-05-23 07:16:16 |
| zh_CN          | Chinese (China)                | 简体中文                | uninstalled | none      | 2021-06-15 12:16:10 |
| zh_HK          | Chinese (Hong Kong)            | 香港中文版              | uninstalled | none      | 2021-06-27 10:46:14 |
| zh_TW          | Chinese (Taiwan)               | 繁體中文                | uninstalled | none      | 2021-05-13 03:20:55 |
+----------------+--------------------------------+-------------------------+-------------+-----------+---------------------+

wp language core install

Dit voorbeeld laat zien, dat de taal_land-code écht case-sensitive is:

wp language core install fr_be

Warning: Language 'fr_be' not available.
Language 'fr_be' not installed.
Success: Installed 0 of 1 languages (1 skipped).


wp language core install fr_BE

Downloading translation from https://downloads.wordpress.org/translation/core/5.7.2/fr_BE.zip...
Unpacking the update...
Installing the latest version...
Removing the old version of the translation...
Translation updated successfully.
Language 'fr_BE' installed.
Success: Installed 1 of 1 languages.

wp language core uninstall

Voorbeeld:

wp language core list --status=installed

+----------+--------------+-------------+-----------+--------+---------------------+
| language | english_name | native_name | status    | update | updated             |
+----------+--------------+-------------+-----------+--------+---------------------+
| nl_NL    | Dutch        | Nederlands  | installed | none   | 2021-07-20 20:12:13 |
+----------+--------------+-------------+-----------+--------+---------------------+

wp language core uninstall nl_NL

Success: Language uninstalled.


wp language core list --status=installed

+----------+--------------+-------------+--------+--------+---------+
| language | english_name | native_name | status | update | updated |
+----------+--------------+-------------+--------+--------+---------+
+----------+--------------+-------------+--------+--------+---------+

wp language plugin

Helptekst:

usage: wp language plugin install [<plugin>] [--all] <language>... [--format=<format>]
   or: wp language plugin is-installed <plugin> <language>...
   or: wp language plugin list [<plugin>...] [--all] [--field=<field>] [--<field>=<value>] [--fields=<fields>] [--format=<format>]
   or: wp language plugin uninstall <plugin> <language>...
   or: wp language plugin update [<plugin>...] [--all] [--dry-run]

Voorbeelden:

wp language plugin install akismet nl_NL
wp language plugin update --all

Bron: https://developer.wordpress.org/cli/commands/language/plugin/

wp language plugin list

Bv. (selectie):

wp language plugin list --status=installed --all

+------------------------+----------+--------------+-------------+-----------+--------+------------------------------+
| plugin                 | language | english_name | native_name | status    | update | updated                      |
+------------------------+----------+--------------+-------------+-----------+--------+------------------------------+
| tinymce-advanced       | nl_NL    | Dutch        | Nederlands  | installed | none   | 2021-04-21 10:32:33          |
| better-search-replace  | nl_NL    | Dutch        | Nederlands  | installed | none   | 2020-06-02 13:27:21          |
| breadcrumb-navxt       | nl_NL    | Dutch        | Nederlands  | installed | none   | 2020-06-04 10:50:18          |
| classic-editor         | nl_NL    | Dutch        | Nederlands  | installed | none   | 2021-07-20 20:02:51          |
+------------------------+----------+--------------+-------------+-----------+--------+------------------------------+

wp language plugin install

Bv.:

wp language plugin install --all fr_FR

...

Success: Installed 2 of 36 languages (34 skipped).
+------------------------------------------+--------+-------------------+
| name                                     | locale | status            |
+------------------------------------------+--------+-------------------+
| advanced-custom-fields-pro               | fr_FR  | not available     |
| tinymce-advanced                         | fr_FR  | already installed |
| advanced-woo-search                      | fr_FR  | not available     |
| advanced-woo-search-pro                  | fr_FR  | not available     |
| wp-time-capsule                          | fr_FR  | not available     |
| better-search-replace                    | fr_FR  | already installed |
| breadcrumb-navxt                         | fr_FR  | not available     |
| classic-editor                           | fr_FR  | already installed |
| dhl-for-woocommerce                      | fr_FR  | not available     |
| disable-cart-fragments-1.3.0             | fr_FR  | not available     |
| ewww-image-optimizer                     | fr_FR  | already installed |
| export-all-urls                          | fr_FR  | not available     |
| duracelltomi-google-tag-manager          | fr_FR  | not available     |
| gravityforms                             | fr_FR  | already installed |
| hotjar                                   | fr_FR  | not available     |
| iwp-client                               | fr_FR  | not available     |
| jetpack                                  | fr_FR  | already installed |
| mollie-payments-for-woocommerce          | fr_FR  | installed         |
| query-monitor                            | fr_FR  | already installed |
| redis-cache                              | fr_FR  | already installed |
| woocommerce                              | fr_FR  | already installed |
| woocommerce-google-analytics-integration | fr_FR  | not available     |
| woocommerce-pdf-invoices-packing-slips   | fr_FR  | already installed |
| woocommerce-pdf-ips-templates            | fr_FR  | not available     |
| woocommerce-pip                          | fr_FR  | not available     |
| woocommerce-quantity-increment           | fr_FR  | installed         |
| wordfence                                | fr_FR  | not available     |
| wp-dbmanager                             | fr_FR  | already installed |
| wp-crontrol                              | fr_FR  | already installed |
| wp-mail-smtp                             | fr_FR  | already installed |
| wp-maintenance-mode                      | fr_FR  | already installed |
| wpovernight-sidekick                     | fr_FR  | not available     |
| wp-rocket                                | fr_FR  | not available     |
| wp-sync-db-1.6                           | fr_FR  | not available     |
| wp-sync-db-media-files-master            | fr_FR  | not available     |
| wordpress-seo                            | fr_FR  | already installed |
+------------------------------------------+--------+-------------------+

Overigens: Veel plugins hebben geen user-interface. Dus hebben ze ook geen taalpakket.

wp language plugin uninstall

Eih, dit subcommando ondersteunt --all niet:

wp language plugin uninstall --all nl_NL

usage: wp language plugin uninstall <plugin> <language>...

Voorbeeld:

wp language plugin uninstall woocommerce nl_NL

Dit leek me een nog betere oplossing, maar werkt niet:

wp language plugin uninstall $(wp language plugin list --status=installed --all --field=plugin) nl_NL

Error: Language not installed.

wp language theme install

Bv.:

wp language theme install twentyseventeen nl_NL

https://developer.wordpress.org/cli/commands/language/theme/

wp language theme status

bv.:

wp language theme list --status=installed --all

+-----------------+----------+--------------+-------------+-----------+--------+---------------------+
| theme           | language | english_name | native_name | status    | update | updated             |
+-----------------+----------+--------------+-------------+-----------+--------+---------------------+
| storefront      | nl_NL    | Dutch        | Nederlands  | installed | none   | 2021-07-25 07:13:42 |
| twentytwenty    | nl_NL    | Dutch        | Nederlands  | installed | none   | 2021-07-25 19:59:56 |
| twentytwentyone | nl_NL    | Dutch        | Nederlands  | installed | none   | 2021-03-09 23:00:46 |
+-----------------+----------+--------------+-------------+-----------+--------+---------------------+

of

wp language theme list --status=installed --all --field=theme

storefront
twentytwenty
twentytwentyone

wp language theme uninstall

Jammer dat dit niet lukt:

wp language theme uninstall $(wp language theme list --status=installed --all --field=theme) nl_NL

Error: Language not installed.

Dit werkt gelukkig wel:

wp language theme uninstall storefront nl_NL
wp language theme uninstall twentytwenty nl_NL
wp language theme uninstall twentytwentyone nl_NL

wp loco

Loco Translate commands

wp maintenance-mode

Activates, deactivates or checks the status of the maintenance mode of a site.

wp media

Imports files as attachments, regenerates thumbnails, or lists registered image sizes.

wp media image-size

Lists image sizes registered with WordPress.

wp media import

Met wp media import kun je afbeeldingen importeren inclusief attributen, en allerlei bijbehorende truuks uithalen. Wat je niet lijkt te kunnen doen: De bestandsnaam aanpassen (dus dat de bestandsnaam na import anders is dan daarvoor).

Zie Wp media import (WP-CLI) voor details.

wp media regenerate

  • Regenerates thumbnails for one or more attachments.
  • Dit blijkt de oplossing te zijn voor update-lag zoals ik die ervoer in maart 2021 - Update-lag (WordPress)

Voorbeelden (maart 2021):

wp media regenerate 19328   # 19328 = attachment-id
# Regenerate all images
#
# * Approx. 33.000 images (x several presets)
# * Processing speed: About 100 images/minute
# * Total time: 8h24min
#
wp media regenerate

wp menu

Werk met menu's en menu-items. Deze laatste gaan via het subcommando wp menu item

$ wp help menu

NAME

  wp menu

DESCRIPTION

  Lists, creates, assigns, and deletes the active theme's navigation menus.

SYNOPSIS

  wp menu <command>

SUBCOMMANDS

  create        Creates a new menu.
  delete        Deletes one or more menus.
  item          List, add, and delete items associated with a menu.
  list          Gets a list of menus.
  location      Assigns, removes, and lists a menu's locations.

  See the [Navigation Menus][1] reference in the Theme Handbook.

  ---
  [1] https://developer.wordpress.org/themes/functionality/navigation-menus/

EXAMPLES

    # Create a new menu
    $ wp menu create "My Menu"
    Success: Created menu 200.

    # List existing menus
    $ wp menu list
    +---------+----------+----------+-----------+-------+
    | term_id | name     | slug     | locations | count |
    +---------+----------+----------+-----------+-------+
    | 200     | My Menu  | my-menu  |           | 0     |
    | 177     | Top Menu | top-menu | primary   | 7     |
    +---------+----------+----------+-----------+-------+

    # Create a new menu link item
    $ wp menu item add-custom my-menu Apple http://apple.com --porcelain
    1922

    # Assign the 'my-menu' menu to the 'primary' location
    $ wp menu location assign my-menu primary
    Success: Assigned location to menu.

wp menu create

wp menu Delete

wp menu item

$ wp help menu item

NAME

  wp menu item

DESCRIPTION

  List, add, and delete items associated with a menu.

SYNOPSIS

  wp menu item <command>

SUBCOMMANDS

  add-custom      Adds a custom menu item.
  add-post        Adds a post as a menu item.
  add-term        Adds a taxonomy term as a menu item.
  delete          Deletes one or more items from a menu.
  list            Gets a list of items associated with a menu.
  update          Updates a menu item.

EXAMPLES

    # Add an existing post to an existing menu
    $ wp menu item add-post sidebar-menu 33 --title="Custom Test Post"
    Success: Menu item added.

    # Create a new menu link item
    $ wp menu item add-custom sidebar-menu Apple http://apple.com
    Success: Menu item added.

    # Delete menu item
    $ wp menu item delete 45
    Success: 1 menu item deleted.

wp menu item list

$ wp help menu item list

NAME

  wp menu item list

DESCRIPTION

  Gets a list of items associated with a menu.

SYNOPSIS

  wp menu item list <menu> [--fields=<fields>] [--format=<format>]

OPTIONS

  <menu>
    The name, slug, or term ID for the menu.

  [--fields=<fields>]
    Limit the output to specific object fields.

  [--format=<format>]
    Render output in a particular format.
    ---
    default: table
    options:
      - table
      - csv
      - json
      - count
      - ids
      - yaml
    ---

AVAILABLE FIELDS

  These fields will be displayed by default for each menu item:

  * db_id
  * type
  * title
  * link
  * position

  These fields are optionally available:

  * menu_item_parent
  * object_id
  * object
  * type
  * type_label
  * target
  * attr_title
  * description
  * classes
  * xfn

EXAMPLES

    $ wp menu item list main-menu
    +-------+-----------+-------------+---------------------------------+----------+
    | db_id | type      | title       | link                            | position |
    +-------+-----------+-------------+---------------------------------+----------+
    | 5     | custom    | Home        | http://example.com              | 1        |
    | 6     | post_type | Sample Page | http://example.com/sample-page/ | 2        |
    +-------+-----------+-------------+---------------------------------+----------+

Voorbeeld

$ wp menu item list main-menu

+-------+-----------+-----------------------------------------+-------------------------------------------+----------+
| db_id | type      | title                                   | link                                      | position |
+-------+-----------+-----------------------------------------+-------------------------------------------+----------+
| 60057 | post_type | Widgets op Merk                         | http://en.s1/alle-merken/                 | 1        |
| 52263 | post_type | ABL                                     | http://en.s1/widgets12345-voor-aeg-kies-j | 2        |
|       |           |                                         | e-apparaat/                               |          |
| 52264 | post_type | Black & Blacker                         | http://en.s1/widgets12345-voor-black-deck | 3        |
|       |           |                                         | er-kies-je-apparaat/                      |          |
| 61499 | custom    | Bros                                    | http://en.s1/widgets12345-voor-bosch-kies | 4        |
|       |           |                                         | -je-apparaat/                             |          |
| 52266 | post_type | DeWil                                   | http://en.s1/widgets12345-voor-de-walt-ki | 5        |
|       |           |                                         | es-je-apparaat/                           |          |
| 52267 | post_type | Fenn                                    | http://en.s1/widgets12345-voor-fein-kies- | 6        |
+-------+-----------+-----------------------------------------+-------------------------------------------+----------+

wp menu item update

$ wp help menu item update

NAME

  wp menu item update

DESCRIPTION

  Updates a menu item.

SYNOPSIS

  wp menu item update <db-id> [--title=<title>] [--link=<link>] [--description=<description>]
  [--attr-title=<attr-title>] [--target=<target>] [--classes=<classes>] [--position=<position>]
  [--parent-id=<parent-id>]

OPTIONS

  <db-id>
    Database ID for the menu item.

  [--title=<title>]
    Set a custom title for the menu item.

  [--link=<link>]
    Set a custom url for the menu item.

  [--description=<description>]
    Set a custom description for the menu item.

  [--attr-title=<attr-title>]
    Set a custom title attribute for the menu item.

  [--target=<target>]
    Set a custom link target for the menu item.

  [--classes=<classes>]
    Set a custom link classes for the menu item.

  [--position=<position>]
    Specify the position of this menu item.

  [--parent-id=<parent-id>]
    Make this menu item a child of another menu item.

EXAMPLES

    $ wp menu item update 45 --title=WordPress --link='http://wordpress.org' --target=_blank --position=2
    Success: Menu item updated.

wp menu list

Verkrijg een lijst van menu's in het actieve thema. Die lijst heb je nodig als je menu-items wilt bewerken, omdat je dan de slug, naam of ID van het bijbehorende menu moet geven. De lijst van menu's is doorgaans nogal statisch en voorspelbaar - Zie het voorbeeld onderaan dit hoofdstuk:

$ wp help menu list

NAME

  wp menu list

DESCRIPTION

  Gets a list of menus.

SYNOPSIS

  wp menu list [--fields=<fields>] [--format=<format>]

OPTIONS

  [--fields=<fields>]
    Limit the output to specific object fields.

  [--format=<format>]
    Render output in a particular format.
    ---
    default: table
    options:
      - table
      - csv
      - json
      - count
      - ids
      - yaml
    ---

AVAILABLE FIELDS

  These fields will be displayed by default for each menu:

  * term_id
  * name
  * slug
  * count

  These fields are optionally available:

  * term_group
  * term_taxonomy_id
  * taxonomy
  * description
  * parent
  * locations

EXAMPLES

    $ wp menu list
    +---------+----------+----------+-----------+-------+
    | term_id | name     | slug     | locations | count |
    +---------+----------+----------+-----------+-------+
    | 200     | My Menu  | my-menu  |           | 0     |
    | 177     | Top Menu | top-menu | primary   | 7     |
    +---------+----------+----------+-----------+-------+

Voorbeeld

$ wp menu list

+---------+-------------------------+-------------------------+----------------------+-------+
| term_id | name                    | slug                    | locations            | count |
+---------+-------------------------+-------------------------+----------------------+-------+
| 17      | Main menu               | main-menu               | primary              | 38    |
| 1646    | Mobile Bottom Menu      | mobile-bottom-menu      | mobile-bottom,footer | 5     |
| 1645    | Mobile Top Menu         | mobile-top-menu         | mobile-top           | 12    |
| 22      | Product categories menu | product-categories-menu | product_categories   | 1     |
| 44753   | Utility menu            | utility-menu            | utility              | 1     |
+---------+-------------------------+-------------------------+----------------------+-------+

wp menu location

wp network

Perform network-wide operations.

wp option

Met wp option beheer je instellingen die doorgaans in tabel wp_options worden bijgehouden. Waarschijnlijk is dit commando een belangrijke sleutel om een site volledig via de shell te beheren. Te meer daar dit commando overweg kan met serialised data - Iets waar ik op SQL-niveau moeite mee heb.

Uitvoer wp help option:

NAME

  wp option

DESCRIPTION

  Retrieves and sets site options, including plugin and WordPress settings.

SYNOPSIS

  wp option <command>

SUBCOMMANDS

  add         Adds a new option value.
  delete      Deletes an option.
  get         Gets the value for an option.
  list        Lists options and their values.
  patch       Updates a nested value in an option.
  pluck       Gets a nested value from an option.
  update      Updates an option value.

  See the [Plugin Settings API][1] and the [Theme Options][2] for more information on adding customized options.

  ---
  [1] https://developer.wordpress.org/plugins/settings/settings-api/
  [2] https://developer.wordpress.org/themes/customize-api/

EXAMPLES

    # Get site URL.
    $ wp option get siteurl
    http://example.com

    # Add option.
    $ wp option add my_option foobar
    Success: Added 'my_option' option.

    # Update option.
    $ wp option update my_option '{"foo": "bar"}' --format=json
    Success: Updated 'my_option' option.

    # Delete option.
    $ wp option delete my_option
    Success: Deleted 'my_option' option.

wp option add

Adds a new option value.

$wp help option add

NAME

  wp option add

DESCRIPTION

  Adds a new option value.

SYNOPSIS

  wp option add <key> [<value>] [--format=<format>] [--autoload=<autoload>]

  Errors if the option already exists.

OPTIONS

  <key>
    The name of the option to add.

  [<value>]
    The value of the option to add. If ommited, the value is read from STDIN.

  [--format=<format>]
    The serialization format for the value.
    ---
    default: plaintext
    options:
      - plaintext
      - json
    ---

  [--autoload=<autoload>]
    Should this option be automatically loaded.
    ---
    options:
      - 'yes'
      - 'no'
    ---

EXAMPLES

    # Create an option by reading a JSON file.
    $ wp option add my_option --format=json < config.json
    Success: Added 'my_option' option.

wp option delete

Deletes an option.

wp option get

Gets the value for an option - Als het een veld met serialised data betreft, krijg je dat complete veld. Je kunt geen deel van de boom selecteren - Daarvoor heb je wp option pluck nodig:

$ wp help option get

wp option get

DESCRIPTION

  Gets the value for an option.

SYNOPSIS

  wp option get <key> [--format=<format>]

OPTIONS

  <key>
    Key for the option.

  [--format=<format>]
    Get value in a particular format.
    ---
    default: var_export
    options:
      - var_export
      - json
      - yaml
    ---

EXAMPLES

    # Get option.
    $ wp option get home
    http://example.com

    # Get blog description.
    $ wp option get blogdescription
    A random blog description

    # Get blog name
    $ wp option get blogname
    A random blog name

    # Get admin email.
    $ wp option get admin_email
    someone@example.com

    # Get option in JSON format.
    $ wp option get active_plugins --format=json
    {"0":"dynamically-dynamic-sidebar\/dynamically-dynamic-sidebar.php","1":"monster-widget\/monster-widget.php","2":"show-current-template\/show-current-template.php","3":"theme-check\/theme-check.php","5":"wordpress-importer\/wordpress-importer.php"}

Voorbeelden

wp option get admin_email

info@example.com

Dit werkt ook voor serialised data:

wp option get options_footer_links_1_0_link


array (
  'title' => 'Widgets GLX',
  'url' => 'http://en.s1/shop/glx/',
  'target' => '',
)

wp option list

Met wp option list krijg je een lijst van alle opties + waardes. Dat kan een flinke lijst zijn en het commando doet er al snel een minuut over voordat output verschijnt.

Voorbeelden hoe dit handzamer te maken:

  • wp option list --field=option_name
  • wp option list | grep woocommerce > woocommerce.txt - Daarna openen in editor.

wp option patch

Bewerk een serialised veld.

Voorbeeld:

$ wp option get aws_settings

array (
  'seamless' => 'true',
  'cache' => 'true',
  'autoupdates' => 'true',
  'search_in' => 
  array (
    'title' => 1,
    'content' => 0,
    'sku' => 1,
    'excerpt' => 0,
    'category' => 0,
    'tag' => 0,
    'id' => 0,
  ),
  'outofstock' => 'true',
  'stopwords' => 'a, also, am, an, and, are, as, at, be, but, by, call, can, co, con, de, do, due, eg, eight, etc, even, ever, every, for, from, full, go, had, has, hasnt, have, he, hence, her, here, his, how, ie, if, in, inc, into, is, it, its, ltd, me, my, no, none, nor, not, now, of, off, on, once, one, only, onto, or, our, ours, out, over, own, part, per, put, re, see, so, some, ten, than, that, the, their, there, these, they, this, three, thru, thus, to, too, top, un, up, us, very, via, was, we, well, were, what, when, where, who, why, will',
  'synonyms' => 'buy, pay, purchase, acquire
box, housing, unit, package',
  'use_analytics' => 'true',
  'search_field_text' => 'Zoek producten...',
  'show_more_text' => 'Laat alle resultaten zien',
  'not_found_text' => 'Oeps, geen zoekresultaten.',
  'min_chars' => '1',
  'show_loader' => 'true',
  'show_clear' => 'true',
  'show_more' => 'true',
  'mobile_overlay' => 'false',
  'show_page' => 'true',
  'buttons_order' => '2',
  'desc_source' => 'excerpt',
  'mark_words' => 'true',
  'excerpt_length' => '20',
  'results_num' => '10',
  'highlight' => 'true',
  'show_image' => 'true',
  'show_excerpt' => 'false',
  'show_price' => 'true',
  'show_outofstock_price' => 'true',
  'show_cats' => 'false',
  'show_tags' => 'false',
  'show_sale' => 'true',
  'show_sku' => 'false',
  'show_stock' => 'false',
  'show_featured' => 'false',
  'search_archives' => 
  array (
    'archive_category' => 0,
    'archive_tag' => 0,
  ),
)


$ wp option pluck aws_settings search_field_text

Zoek producten...


$ wp option patch update aws_settings search_field_text "Search products"

Success: Updated 'aws_settings' option.

wp option pluck

Vraag een serialised waarde op. Je kunt hiermee een deelboom opvragen, itt. tot wp option get, wat alleen de complete boom kan tonen (zie verderop).

$ wp help option pluck

NAME

  wp option pluck

DESCRIPTION

  Gets a nested value from an option.

SYNOPSIS

  wp option pluck <key> <key-path>... [--format=<format>]

OPTIONS

  <key>
    The option name.

  <key-path>...
    The name(s) of the keys within the value to locate the value to pluck.

  [--format=<format>]
    The output format of the value.
    ---
    default: plaintext
    options:
      - plaintext
      - json
      - yaml
    ---

Simpel voorbeeld

wp option get options_footer_links_1_0_link

array (
  'title' => 'Widget GLX',
  'url' => 'http://en.s1/shop/glx/',
  'target' => '',
)


wp option pluck options_footer_links_1_0_link title

Widget GLX

Voorbeeld nested tree

Nu wordt het leuker: Een serialised veld met een subboom:

# Display whole serial field
########################################
#
# With "wp option get", you cannot select a part of the tree, only the whole tree
#
wp option get aws_pro_settings

array (
  1 => 
  array (
    'search_instance' => 'Search Form',
    'filter_num' => '1',
    'search_field_text' => 'Zoek producten...',
    'show_more_text' => 'Laat alle resultaten zien',
    'not_found_text' => 'Oeps, geen zoekresultaten.',
    'min_chars' => '1',
    'show_loader' => 'true',
    'show_clear' => 'true',
    'show_more' => 'true',
    'mobile_overlay' => 'false',
    'show_page' => 'true',
    'show_addon' => 'false',
    'disable_smooth' => 'false',
    'buttons_order' => '2',
    'filters' => 
    array (
      1 => 
      array (
        'filter_name' => 'All',
        'style' => 'style-inline',
        'mark_words' => 'true',
        'excerpt_length' => '20',
        'results_num' => '10',
        'outofstock' => 'true',
        'var_rules' => 'parent',
        'on_sale' => 'true',
        'product_visibility' => 
        array (
          'visible' => '1',
          'catalog' => '1',
          'search' => '1',
          'hidden' => '0',
        ),
        'search_in' => 
        array (
          'title' => 0,
          'content' => 1,
          'sku' => 1,
          'excerpt' => 0,
          'category' => '0',
          'tag' => '0',
          'id' => '0',
          'attr' => 0,
          'tax' => 0,
          'meta' => 1,
        ),
        'search_archives' => 
        array (
          'archive_category' => '0',
          'archive_tag' => '0',
          'archive_tax' => '0',
          'archive_attr' => '0',
          'archive_users' => '0',
        ),
        'highlight' => 'true',
        'show_image' => 'true',
        'show_excerpt' => 'false',
        'show_result_cats' => 'false',
        'show_result_brands' => '',
        'show_rating' => 'false',
        'show_featured' => 'false',
        'show_variations' => 'false',
        'show_price' => 'true',
        'show_outofstock_price' => 'true',
        'show_sale' => 'true',
        'show_sku' => 'false',
        'show_cart' => 'false',
        'show_stock' => 'false',
        'exclude_rel' => 'exclude',
        'adv_filters' => '',
        'search_in_attr' => 
        array (
          'attr_pa_breedte' => 0,
        ),
        'search_in_meta' => 
        array (
          'meta_post_tools' => 1,
          'meta_sku_oem' => 1,
        ),
        'product_stock_status' => 
        array (
          'in_stock' => 1,
          'out_of_stock' => 1,
          'on_backorder' => 1,
        ),
      ),
    ),
    'cache' => 'true',
    'search_logic' => 'and',
    'search_exact' => 'false',
    'desc_source' => 'content',
    'target_blank' => 'false',
    'image_source' => 'featured,gallery,content,description,default',
    'default_img' => '',
    'use_analytics' => 'false',
  ),
)

# Select part of the tree
########################################
#
wp option pluck aws_pro_settings 1

array (
  'search_instance' => 'Search Form',
  'filter_num' => '1',
  'search_field_text' => 'Zoek producten...',
  'show_more_text' => 'Laat alle resultaten zien',
  'not_found_text' => 'Oeps, geen zoekresultaten.',
  'min_chars' => '1',
  'show_loader' => 'true',
  'show_clear' => 'true',
  'show_more' => 'true',
  'mobile_overlay' => 'false',
  'show_page' => 'true',
  'show_addon' => 'false',
  'disable_smooth' => 'false',
  'buttons_order' => '2',
  'filters' => 
  array (
    1 => 
    array (
      'filter_name' => 'All',
      'style' => 'style-inline',
      'mark_words' => 'true',
      'excerpt_length' => '20',
      'results_num' => '10',
      'outofstock' => 'true',
      'var_rules' => 'parent',
      'on_sale' => 'true',
      'product_visibility' => 
      array (
        'visible' => '1',
        'catalog' => '1',
        'search' => '1',
        'hidden' => '0',
      ),
      'search_in' => 
      array (
        'title' => 0,
        'content' => 1,
        'sku' => 1,
        'excerpt' => 0,
        'category' => '0',
        'tag' => '0',
        'id' => '0',
        'attr' => 0,
        'tax' => 0,
        'meta' => 1,
      ),
      'search_archives' => 
      array (
        'archive_category' => '0',
        'archive_tag' => '0',
        'archive_tax' => '0',
        'archive_attr' => '0',
        'archive_users' => '0',
      ),
      'highlight' => 'true',
      'show_image' => 'true',
      'show_excerpt' => 'false',
      'show_result_cats' => 'false',
      'show_result_brands' => '',
      'show_rating' => 'false',
      'show_featured' => 'false',
      'show_variations' => 'false',
      'show_price' => 'true',
      'show_outofstock_price' => 'true',
      'show_sale' => 'true',
      'show_sku' => 'false',
      'show_cart' => 'false',
      'show_stock' => 'false',
      'exclude_rel' => 'exclude',
      'adv_filters' => '',
      'search_in_attr' => 
      array (
        'attr_pa_breedte' => 0,
      ),
      'search_in_meta' => 
      array (
        'meta_post_tools' => 1,
        'meta_sku_oem' => 1,
      ),
      'product_stock_status' => 
      array (
        'in_stock' => 1,
        'out_of_stock' => 1,
        'on_backorder' => 1,
      ),
    ),
  ),
  'cache' => 'true',
  'search_logic' => 'and',
  'search_exact' => 'false',
  'desc_source' => 'content',
  'target_blank' => 'false',
  'image_source' => 'featured,gallery,content,description,default',
  'default_img' => '',
  'use_analytics' => 'false',
)

# Zoom in on just 1 value...
########################################
#
wp option pluck aws_pro_settings 1 search_instance

Search Form

Bronnen

wp option update

Updates an option value. Voorbeelden:

wp option update blogname "$site_title"    # Site title
wp option update blogdescription "$slogan" # Tagline

wp package

Lists, installs, and removes WP-CLI packages:

* wp package browse [--fields=<fields>] [--format=<format>]
* wp package install <name|git|path|zip>
* wp package list [--fields=<fields>] [--format=<format>]
* wp package path [<name>]
* wp package uninstall <name>
* wp package update 

wp plugin

Manages plugins, including installs, activations, and updates.

* wp plugin activate     Activate a plugin.
* wp plugin deactivate     Deactivate a plugin.
* wp plugin delete     Delete plugin files without deactivating or uninstalling.
* wp plugin get      Get details about an installed plugin.
* wp plugin install      Install a plugin.
* wp plugin is-installed   Check if the plugin is installed.
* wp plugin list     Get a list of plugins.
* wp plugin path     Get the path to a plugin or to the plugin directory.
* wp plugin search     Search the WordPress.org plugin directory.
* wp plugin status     See the status of one or all plugins.
* wp plugin toggle     Toggle a plugin’s activation state.
* wp plugin uninstall      Uninstall a plugin.
* wp plugin update     Update one or more plugins.

wp plugin activate

Bv.

wp plugin activate hello

wp plugin deactivate

Bv.

wp plugin deactivate hello

Je kunt in één keer meerdere plugins deactiveren. Scheid de namen met spaties (niet met komma's):

wp plugin deactivate wp-rocket redis-cache wp-dbmanager iwp-client

wp plugin delete

Bv.

wp plugin delete hello
wp plugin delete contact-form-7
  • WP-CLI kan schrijven en bestanden verwijderen - Handig!
  • Je hoeft een plugin niet eerst te stoppen.

wp plugin install

Installeer een WP-plugin op een site:

wp plugin install

   <plugin-naam|zip|url>   # A plugin slug, the path to a local zip file, or URL to a remote zip file.

   [--version=<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 plugin, 
                           # without prompting for confirmation.

   [--activate]            # If set, the plugin will be activated immediately after install.

   [--activate-network]    # If set, the plugin will be network activated immediately after install

Voorbeeld

wp plugin install duplicate-page --activate

Met URL

Heel handig dat je ipv. de slug, ook een URL naar een remote zip file kunt aangeven: Soms weet ik de URL wel, maar gek genoeg niet de slug, zoals hier:

wp plugin install https://downloads.wordpress.org/plugin/google-analytics-dashboard-for-wp.6.2.1.zip

...Werkt perfect.

wp plugin search

Zoek in de online plugin-bibliotheek:

wp plugin search

   <search>                  The string to search for.

   [--page=<page>]           Optional page to display.
                             default: 1

   [--per-page=<per-page>]   Optional number of results to display.
                             default: 10
   [--field=<field>]         Prints the value of a single field for each plugin.
   [--fields=<fields>]       Ask for specific fields from the API. Defaults to name,slug,author_profile,rating. Acceptable values:

    name: Plugin Name
    slug: Plugin Slug
    version: Current Version Number
    author: Plugin Author
    author_profile: Plugin Author Profile
    contributors: Plugin Contributors
    requires: Plugin Minimum Requirements
    tested: Plugin Tested Up To
    compatibility: Plugin Compatible With
    rating: Plugin Rating
    num_ratings: Number of Plugin Ratings
    homepage: Plugin Author’s Homepage
    description: Plugin’s Description
    short_description: Plugin’s Short Description 

[--format=<format>]          Render output in a particular format.

    default: table
    options:
    – table
    – csv
    – count
    – json
    – yaml

wp plugin status

Bv.:

> wp plugin status

15 installed plugins:
 UA advanced-custom-fields-pro             5.7.10
  A classic-editor                         1.4
  A contact-form-7                         5.1.1
  A contact-form-7-honeypot                1.14
  A mollie-payments-for-woocommerce        5.1.0
  A tinymce-advanced                       5.0.1
  A woocommerce                            3.5.4
  A woocommerce-pdf-invoices-packing-slips 2.2.7
  A woocommerce-pdf-ips-templates          2.1.12
  A woocommerce-pip                        3.6.1
  A woocommerce-quantity-increment         1.1.0
  A wordfence                              7.2.2
  A wp-mail-smtp                           1.4.1
  A wp-sync-db-1.6                         1.6
  A wp-sync-db-media-files-master          1.1.4b1

Legend: A = Active, U = Update Available

of

> wp plugin status duplicate-post

wp plugin status duplicate-post

Plugin duplicate-post details:
    Name: Duplicate Post
    Status: Active
    Version: 3.2.2
    Author: Enrico Battocchi
    Description: Clone posts and pages.

Toepassingen

  • De output van wp plugin status kan handig zijn als input voor een script om een nieuwe site te bouwen
  • Voor eigen routines om propriëtaire plugins bij te werken. Dan zou ik alleen het nummer aan het eind willen hebben

Versie-nummer uitfilteren

Je kunt het format van de output niet aanpassen middels parameters, maar wellicht dat bv. grep de output al een stuk hanteerbaarder maakt. Voorbeeld:

wp plugin status advanced-custom-fields-pro
Unable to open /var/www/example.com/wp-content/wflogs/config.php for reading and writing.
Plugin advanced-custom-fields-pro details:
    Name: Advanced Custom Fields PRO
    Status: Active
    Version: 5.7.10 (Update available)
    Author: Elliot Condon
    Description: Customize WordPress with powerful, professional and intuitive fields.

In dit geval geeft de string Update available precies de info die ik zoek.

Ander voorbeeld:

wp plugin status advanced-custom-fields-pro | grep Update
Unable to open /var/www/example.com/wp-content/wflogs/config.php for reading and writing.
    Version: 5.7.10 (Update available)

De waarschuwingstekst tav. wflogs krijg ik trouwens niet zomaar weggetoverd.

wp plugin update

wp plugin update

   [<plugin>…]              One or more plugins to update.
   [--all]                  If set, all plugins that have updates will be updated.
   [--exclude=<name>]       Comma separated list of plugin names that should be excluded from updating.
   [--minor]                Only perform updates for minor releases (e.g. from 1.3 to 1.4 instead of 2.0)
   [--patch]                Only perform updates for patch releases (e.g. from 1.3 to 1.3.3 instead of 1.4)
   [--format=<format>]      Render output in a particular format.
    ---
    default: table
    options:
    – table
    – csv
    – json
    – summary
    ---
   [--version=<version>]   If set, the plugin will be updated to the specified version.
   [--dry-run]             Preview which plugins would be updated. 

Bv.:

wp plugin update --all

wp post

Manages posts, content (pages), and meta

wp help post:

NAME

  wp post

DESCRIPTION

  Manages posts, content, and meta.

SYNOPSIS

  wp post <command>

SUBCOMMANDS

  create        Creates a new post.
  delete        Deletes an existing post.
  edit          Launches system editor to edit post content.
  exists        Verifies whether a post exists.
  generate      Generates some posts.
  get           Gets details about a post.
  list          Gets a list of posts.
  meta          Adds, updates, deletes, and lists post custom fields.
  term          Adds, updates, removes, and lists post terms.
  update        Updates one or more existing posts.

EXAMPLES

    # Create a new post.
    $ wp post create --post_type=post --post_title='A sample post'
    Success: Created post 123.

    # Update an existing post.
    $ wp post update 123 --post_status=draft
    Success: Updated post 123.

    # Delete an existing post.
    $ wp post delete 123
    Success: Trashed post 123.

Bronnen

wp post create

Voorbeelden

# * Zonder post_status wordt de status "draft"
# * Als je dit commando herhaalt, krijg je een nieuwe pagina met dezelfde titel
#   Er wordt dus geen bestaande pagina aangepast
#
wp post create \
               \
  --post_type=page \
  --post_title='test (3)' \
  --post_content="Jantje zag eens pruimen hangen" \
  --post_status="publish"
##############################################################
# Creeer een pagina + get id
##############################################################
#
i2=$( \
  wp post create \
                 \
    --post_type=page \
    --post_title='test (3)' \
    --post_content="Jantje zag eens pruimen hangen" \
    --post_status="publish" \
| sed "s/^Success: Created post //" | sed "s/\.//"  
)

echo "Gevonden: $i2"

Bronnen

wp post delete

Let op: Dit commando verwijdert zowel posts als pages. Dat kan soms verwarring geven.

Voorbeeld:

##############################################################
# Verwijder sample pagina
##############################################################
#
wp post list
wp post delete 1

Output:

+----+--------------+-------------+---------------------+-------------+
| ID | post_title   | post_name   | post_date           | post_status |
+----+--------------+-------------+---------------------+-------------+
| 1  | Hello world! | hello-world | 2017-12-02 11:37:28 | publish     |
+----+--------------+-------------+---------------------+-------------+
Success: Trashed post 1.

Nog een keer, maar nu echt:

##############################################################
# Verwijder sample pagina
##############################################################
#
wp post list --post_type="page"
wp post delete 2

Output:

+----+-------------+-------------+---------------------+-------------+
| ID | post_title  | post_name   | post_date           | post_status |
+----+-------------+-------------+---------------------+-------------+
| 2  | Sample Page | sample-page | 2017-12-02 11:37:28 | publish     |
+----+-------------+-------------+---------------------+-------------+
Success: Trashed post 2.

wp post edit

wp post generate

Creates a specified number of new posts with dummy data.

wp post get

Get details about a post.

Voorbeeld:

$ wp post get 51110

+-----------------------+---------------------------------------------+
| Field                 | Value                                       |
+-----------------------+---------------------------------------------+
| ID                    | 51110                                       |
| post_author           | 4                                           |
| post_date             | 2020-05-05 18:13:15                         |
| post_date_gmt         | 2020-05-05 18:13:15                         |
| post_content          |                                             |
| post_title            | Widgets for ABC - Kies je Toepassing        |
| post_excerpt          |                                             |
| post_status           | publish                                     |
| comment_status        | closed                                      |
| ping_status           | closed                                      |
| post_password         |                                             |
| post_name             | widgets-voor-abc-kies-je-apparaat           |
| to_ping               |                                             |
| pinged                |                                             |
| post_modified         | 2021-03-12 13:17:54                         |
| post_modified_gmt     | 2021-03-12 12:17:54                         |
| post_content_filtered |                                             |
| post_parent           | 0                                           |
| guid                  | http://en.s1/?page_id=51110                 |
| menu_order            | 0                                           |
| post_type             | page                                        |
| post_mime_type        |                                             |
| comment_count         | 0                                           |
| nl                    | null                                        |
+-----------------------+---------------------------------------------+

wp post list

Retrieve a list of posts/pages/etc.

The trick is, that without additional specifications, this command is limited to posts only - Pages, products, etc. will be excluded. Do note however, that ID is global. So this problem doesn't occur when editing stuff.

$ wp help post list

NAME

  wp post list

DESCRIPTION

  Gets a list of posts.

SYNOPSIS

  wp post list [--<field>=<value>] [--field=<field>] [--fields=<fields>] [--format=<format>]

  Display posts based on all arguments supported by
  [WP_Query()][1].

  ---
  [1] https://developer.wordpress.org/reference/classes/wp_query/

OPTIONS

  [--<field>=<value>]
    One or more args to pass to WP_Query.

  [--field=<field>]
    Prints the value of a single field for each post.

  [--fields=<fields>]
    Limit the output to specific object fields.

  [--format=<format>]
    Render output in a particular format.
    ---
    default: table
    options:
      - table
      - csv
      - ids
      - json
      - count
      - yaml
    ---

AVAILABLE FIELDS

  These fields will be displayed by default for each post:

  * ID
  * post_title
  * post_name
  * post_date
  * post_status

  These fields are optionally available:

  * post_author
  * post_date_gmt
  * post_content
  * post_excerpt
  * comment_status
  * ping_status
  * post_password
  * to_ping
  * pinged
  * post_modified
  * post_modified_gmt
  * post_content_filtered
  * post_parent
  * guid
  * menu_order
  * post_type
  * post_mime_type
  * comment_count
  * filter
  * url

EXAMPLES

    # List post
    $ wp post list --field=ID
    568
    829
    1329
    1695

    # List posts in JSON
    $ wp post list --post_type=post --posts_per_page=5 --format=json
    [{"ID":1,"post_title":"Hello world!","post_name":"hello-world","post_date":"2015-06-20
    09:00:10","post_status":"publish"},{"ID":1178,"post_title":"Markup: HTML Tags and
    Formatting","post_name":"markup-html-tags-and-formatting","post_date":"2013-01-11
    20:22:19","post_status":"draft"}]

    # List all pages
    $ wp post list --post_type=page --fields=post_title,post_status
    +-------------+-------------+
    | post_title  | post_status |
    +-------------+-------------+
    | Sample Page | publish     |
    +-------------+-------------+

    # List ids of all pages and posts
    $ wp post list --post_type=page,post --format=ids
    15 25 34 37 198

    # List given posts
    $ wp post list --post__in=1,3
    +----+--------------+-------------+---------------------+-------------+
    | ID | post_title   | post_name   | post_date           | post_status |
    +----+--------------+-------------+---------------------+-------------+
    | 3  | Lorem Ipsum  | lorem-ipsum | 2016-06-01 14:34:36 | publish     |
    | 1  | Hello world! | hello-world | 2016-06-01 14:31:12 | publish     |
    +----+--------------+-------------+---------------------+-------------+

Voorbeelden

wp post list

+----+--------------+-------------+---------------------+-------------+
| ID | post_title   | post_name   | post_date           | post_status |
+----+--------------+-------------+---------------------+-------------+
| 1  | Hello world! | hello-world | 2017-11-26 11:11:28 | publish     |
+----+--------------+-------------+---------------------+-------------+
wp post list --post_type="page"

+----+---------------+---------------+---------------------+-------------+
| ID | post_title    | post_name     | post_date           | post_status |
+----+---------------+---------------+---------------------+-------------+
| 7  | test (3)      |               | 2017-11-26 12:26:42 | draft       |
| 6  | test (2)      | test-2        | 2017-11-26 12:23:05 | publish     |
| 2  | Sample Page   | sample-page   | 2017-11-26 11:11:28 | publish     |
+----+---------------+---------------+---------------------+-------------+
# Je kunt filteren op post_name, maar niet op post_title
#
wp post list --post_type=page --name="test-3" --field=ID

8
# Redirect output naar een variable: Gebruik i=$(...)
#
i=$(wp post list --post_type=page --name="test-3" --field=ID)
echo "gevonden id: $i"
# When selecting multiple fields, there is no space after the comma
#
wp post list --post_type="page" --fields=ID,post_title,post_name


+-------+---------------------------------------------------------------------------+--------------------------------------------------------------------+
| ID    | post_title                                                                | post_name                                                          |
+-------+---------------------------------------------------------------------------+--------------------------------------------------------------------+
| 63472 | Widgets met kortste afmeting groter dan 10 mm                             | Widgets-met-kortste-afmeting-groter-dan10-mm                       |
| 63469 | Widgets met kortste afmeting 10mm                                         | Widgets-met-kortste-afmeting-10mm                                  |
| 63467 | Widgets met kortste afmeting tussen 8 & 10 mm                             | Widgets-met-kortste-afmeting-tussen-8-10-mm                        |
| 63252 | Alle afmetingen                                                           |                                                                    |
| 63239 | Widgets met kortste afmeting tot 5mm                                      | Widgets-met-kortste-afmeting-tot-5mm                               |
| 63233 | Widgets 5x8mm - Zonder stroomdraad, zonder connector - With spring        | Widgets-5x8mm-zonder-stroomdraad-zonder-connector-met-veer         |
| 51513 | Zoeken op afbeelding - Diagram 93                                         | zoeken-op-afbeelding-diagram-93                                    |
| 51507 | Zoeken op afbeelding - Diagram 79                                         | zoeken-op-afbeelding-diagram-79                                    |
| 51167 | Widgets for Vritex - Kies je Toepassing                                   | Widgets-voor-vritex-kies-je-apparaat                               |
| 51165 | Widgets for Styr - Kies je Toepassing                                     | Widgets-voor-styr-kies-je-apparaat                                 |
| 51163 | Widgets for Spt - Kies je Toepassing                                      | Widgets-voor-spt-kies-je-apparaat                                  |
| 413   | Shop                                                                      | shop                                                               |
| 393   | Zoeken op Afbeelding                                                      | zoeken-op-afbeelding                                               |
| 181   | Over ons                                                                  | over-ons                                                           |
| 101   | Contact                                                                   | contact                                                            |
| 11    | Winkelmand                                                                | winkelmand                                                         |
| 12    | Checkout                                                                  | checkout                                                           |
| 13    | Mijn account                                                              | mijn-account                                                       |
| 7     | Webshop for Widgets                                                       | webshop-widgets                                                    |
+-------+---------------------------------------------------------------------------+--------------------------------------------------------------------+

wp post meta

$ wp help post meta

NAME

  wp post meta

DESCRIPTION

  Adds, updates, deletes, and lists post custom fields.

SYNOPSIS

  wp post meta <command>

SUBCOMMANDS

  add         Add a meta field.
  delete      Delete a meta field.
  get         Get meta field value.
  list        List all metadata associated with an object.
  patch       Update a nested value for a meta field.
  pluck       Get a nested value from a meta field.
  update      Update a meta field.

EXAMPLES

    # Set post meta
    $ wp post meta set 123 _wp_page_template about.php
    Success: Updated custom field '_wp_page_template'.

    # Get post meta
    $ wp post meta get 123 _wp_page_template
    about.php

    # Update post meta
    $ wp post meta update 123 _wp_page_template contact.php
    Success: Updated custom field '_wp_page_template'.

    # Delete post meta
    $ wp post meta delete 123 _wp_page_template
    Success: Deleted custom field.

wp post meta get

Dit voorbeeld is gebaseerd op het voorbeeld hieronder tav. wp post meta list:

wp post meta get 7 hero_text

<!--
First version - Until 2020.09.25
<h2>BlahBlah</h2>
-->
<!--
<h2>BlahBlah-2</h2>
-->
<h2>BlahBlah-3</h2>

Dit werkt ook voor serialised data:

wp post meta get 7 banner_pick_tool_link

array (
  'title' => 'Onze widget-Keuzehulp >',
  'url' => 'http://en.s1/widget-keuzehulp/',
  'target' => '',
)

wp post meta list

Verkrijg een lijst met alle maatwerkvelden voor de betreffende post. Voor een home page met een handjevol buttonbars, zijn dit al snel een paar honderd velden.

Voorbeeld: Handjevol velden van een home page met 1.308 maatwerk-velden (hoe ik dat weet? wp post meta list 7 | wc -l):

wp post meta list 7

+---------+----------------------------------------------------+-----------------------------------------------------+
| post_id | meta_key                                           | meta_value                                          |
+---------+----------------------------------------------------+-----------------------------------------------------+
| 7       | _edit_last                                         | 9                                                   |
| 7       | _wp_page_template                                  | templates/page-home2021.php                         |
| 7       | _edit_lock                                         | 1627579027:4                                        |
| 7       | hero_background                                    | 55538                                               |
| 7       | _hero_background                                   | field_5d4d3c8072ecc                                 |
| 7       | hero_text                                          | <!-- First version - Until 2020.09.25 <h2>blah</h2> |                                |
| 7       | _hero_text                                         | field_5d4d3c8f72ecd                                 |
| 7       | hero_ctas_0_link                                   | a:3:{s:5:"title";s:24:"Bekijk alle widgets";s:      |
+---------+----------------------------------------------------+-----------------------------------------------------+

Voorbeeld: Alleen de velden meta_key en meta_value en alleen als ergens het woord shop voorkomt. En schrijf dit naar een bestand (als het om veel informatie gaat, vind ik tekstbestanden een stuk handiger dan de output in een terminal):

wp post meta list 51114 --fields=meta_key,meta_value | grep shop > tmp.txt

Help-tekst

$ wp help post meta list

NAME

  wp post meta list

DESCRIPTION

  List all metadata associated with an object.

SYNOPSIS

  wp post meta list <id> [--keys=<keys>] [--fields=<fields>] [--format=<format>] [--orderby=<fields>]
  [--order=<order>] [--unserialize]

OPTIONS

  <id>
    ID for the object.

  [--keys=<keys>]
    Limit output to metadata of specific keys.

  [--fields=<fields>]
    Limit the output to specific row fields. Defaults to id,meta_key,meta_value.

  [--format=<format>]
    Render output in a particular format.
    ---
    default: table
    options:
      - table
      - csv
      - json
      - yaml
      - count
    ---

  [--orderby=<fields>]
    Set orderby which field.
    ---
    default: id
    options:
     - id
     - meta_key
     - meta_value
    ---

  [--order=<order>]
    Set ascending or descending order.
    ---
    default: asc
    options:
     - asc
     - desc
    ---

  [--unserialize]
    Unserialize meta_value output.

wp post meta patch

Gebruik wp post meta patch om een serialised veld bij te werken.

$ wp help post meta patch

NAME

  wp post meta patch

DESCRIPTION

  Update a nested value for a meta field.

SYNOPSIS

  wp post meta patch <action> <id> <key> <key-path>... [<value>] [--format=<format>]

OPTIONS

  <action>
    Patch action to perform.
    ---
    options:
      - insert
      - update
      - delete
    ---

  <id>
    The ID of the object.

  <key>
    The name of the meta field to update.

  <key-path>...
    The name(s) of the keys within the value to locate the value to patch.

  [<value>]
    The new value. If omitted, the value is read from STDIN.

  [--format=<format>]
    The serialization format for the value.
    ---
    default: plaintext
    options:
      - plaintext
      - json
    ---

Voorbeeld:

$ wp post meta get 7 banner_pick_tool_link

array (
  'title' => 'Onze widget-Keuzehulp >',
  'url' => 'http://en.s1/widget-keuzehulp/',
  'target' => '',
)


$ wp post meta pluck 7 banner_pick_tool_link "title"

Onze widget-Keuzehulp >


$ wp post meta patch update 7 banner_pick_tool_link "title" "Our Widget Selection Tool >"

Success: Updated custom field 'banner_pick_tool_link'.

wp post meta pluck

Gebruik wp post meta pluck om een serialised veld uit te lezen.

Voorbeeld:

$ wp post meta get 7 banner_pick_tool_link

array (
  'title' => 'Onze widget-Keuzehulp >',
  'url' => 'http://en.s1/widget-keuzehulp/',
  'target' => '',
)


$ wp post meta pluck 7 banner_pick_tool_link "title"

Onze widget-Keuzehulp >

wp post meta update

Bewerkt een bestaand enkelvoudig (non-serialised) meta-veld:

$ wp help post meta update

NAME

  wp post meta update

DESCRIPTION

  Update a meta field.

SYNOPSIS

  wp post meta update <id> <key> [<value>] [--format=<format>]

ALIAS

  set

OPTIONS

  <id>
    The ID of the object.

  <key>
    The name of the meta field to update.

  [<value>]
    The new value. If omitted, the value is read from STDIN.

  [--format=<format>]
    The serialization format for the value.
    ---
    default: plaintext
    options:
      - plaintext
      - json
    ---

wp post term

wp post update

wp post update <id>... 
   [--post_author=<post_author>] 
   [--post_date=<post_date>] 
   [--post_date_gmt=<post_date_gmt>] 
   [--post_content=<post_content>] 
   [--post_content_filtered=<post_content_filtered>] 
   [--post_title=<post_title>] 
   [--post_excerpt=<post_excerpt>] 
   [--post_status=<post_status>] 
   [--post_type=<post_type>] 
   [--comment_status=<comment_status>] 
   [--ping_status=<ping_status>] 
   [--post_password=<post_password>] 
   [--post_name=<post_name>] 
   [--to_ping=<to_ping>] 
   [--pinged=<pinged>] 
   [--post_modified=<post_modified>] 
   [--post_modified_gmt=<post_modified_gmt>] 
   [--post_parent=<post_parent>] 
   [--menu_order=<menu_order>] 
   [--post_mime_type=<post_mime_type>] 
   [--guid=<guid>] 
   [--post_category=<post_category>] 
   [--tags_input=<tags_input>] 
   [--tax_input=<tax_input>] 
   [--meta_input=<meta_input>] 
   [<file>] 
   --<field>=<value> 
   [--defer-term-counting]

Voorbeelden [1]:

# post_name = slug <> post_title
########################################
#
wp post update 123 --post_name=something --post_status=draft
Success: Updated post 123.

# Update a post with multiple meta values.
########################################
#
wp post update 123 --meta_input='{"key1":"value1","key2":"value2"}'
Success: Updated post 123.

Eigen voorbeeld:

# Titel & name bijwerken:
########################################
#
wp post update 7 --post_name="webshop-widgets"
wp post update 7 --post_title="Webshop for Widgets"

wp post-type

Retrieves details on the site's registered post types.

wp redirection (plugin)

Commando wp redirection hoort bij de redirection-plugin. Subcommando's:

  • wp redirection import – import from a file
  • wp redirection export – export to a file
  • wp redirection database – install or upgrade a site
  • wp redirection setting – set or get a Redirection setting
  • wp redirection plugin – import from other plugins

wp rewrite

Lists or flushes the site's rewrite rules, updates the permalink structure.

wp role

Manages user roles, including creating new roles and resetting to defaults.

wp scaffold

Generates code for post types, taxonomies, plugins, child themes, etc.

Volgens mij niet wat ik zoek (juli 2021 - klonen & vertalen van sites), want dit commando genereert code.

wp help scaffold

NAME

  wp scaffold

DESCRIPTION

  Generates code for post types, taxonomies, plugins, child themes, etc.

SYNOPSIS

  wp scaffold <command>

SUBCOMMANDS

  block             Generates PHP, JS and CSS code for registering a Gutenberg block for a plugin or theme.
  child-theme       Generates child theme based on an existing theme.
  plugin            Generates starter code for a plugin.
  plugin-tests      Generates files needed for running PHPUnit tests in a plugin.
  post-type         Generates PHP code for registering a custom post type.
  taxonomy          Generates PHP code for registering a custom taxonomy.
  theme-tests       Generates files needed for running PHPUnit tests in a theme.
  underscores       Generates starter code for a theme based on _s.

EXAMPLES

    # Generate a new plugin with unit tests
    $ wp scaffold plugin sample-plugin
    Success: Created plugin files.
    Success: Created test files.

    # Generate theme based on _s
    $ wp scaffold _s sample-theme --theme_name="Sample Theme" --author="John Doe"
    Success: Created theme 'Sample Theme'.

    # Generate code for post type registration in given theme
    $ wp scaffold post-type movie --label=Movie --theme=simple-life
    Success: Created /var/www/example.com/public_html/wp-content/themes/simple-life/post-types/movie.php

wp scaffold block

wp scaffold child-theme

wp scaffold plugin

wp scaffold plugin-tests

wp scaffold taxonomy

Create custom taxonomies

wp help scaffold taxonomy

NAME

  wp scaffold taxonomy

DESCRIPTION

  Generates PHP code for registering a custom taxonomy.

SYNOPSIS

  wp scaffold taxonomy <slug> [--post_types=<post-types>] [--label=<label>] [--textdomain=<textdomain>] [--theme]
  [--plugin=<plugin>] [--raw] [--force]

ALIAS

  tax

OPTIONS

  <slug>
    The internal name of the taxonomy.

  [--post_types=<post-types>]
    Post types to register for use with the taxonomy.

  [--label=<label>]
    The text used to translate the update messages.

  [--textdomain=<textdomain>]
    The textdomain to use for the labels.

  [--theme]
    Create a file in the active theme directory, instead of sending to
    STDOUT. Specify a theme with `--theme=<theme>` to have the file placed in that theme.

  [--plugin=<plugin>]
    Create a file in the given plugin's directory, instead of sending to STDOUT.

  [--raw]
    Just generate the `register_taxonomy()` call and nothing else.

  [--force]
    Overwrite files that already exist.

EXAMPLES

    # Generate PHP code for registering a custom taxonomy and save in a file
    $ wp scaffold taxonomy venue --post_types=event,presentation > taxonomy.php

wp scaffold theme-tests

wp scaffold underscores

wp search-replace

Voorbeeld wp search-replace waarbij siteurl en home worden aangepast - Oude situatie
Voorbeeld wp search-replace waarbij siteurl en home worden aangepast - Nieuwe situatie

wp search-replace vervangt strings in de database. Kan handig zijn rondom migraties.

Syntaxis

wp search-replace <old> <new> [<table>...] 
   [--dry-run] 
   [--network] 
   [--all-tables-with-prefix] 
   [--all-tables] 
   [--export[=<file>]] 
   [--export_insert_size=<rows>] 
   [--skip-tables=<tables>] 
   [--skip-columns=<columns>] 
   [--include-columns=<columns>] 
   [--precise] 
   [--recurse-objects] 
   [--verbose] 
   [--regex] 
   [--regex-flags=<regex-flags>] 
   [--regex-delimiter=<regex-delimiter>] 
   [--format=<format>] 
   [--report] 
   [--report-changed-only] 
   [--log[=<file>]] 
   [--before_context=<num>] 
   [--after_context=<num>]

Als het niet lukt om te connecten met een database middels de gegevens in wp-config.php, krijg je een foutmelding.

Welke tabellen & velden?

Dit commando vervangt niet in alle tabellen, maar in specifieke tabellen en in specifieke velden. Zie [2] voor details. Een indicatie (met de optie --dry-run van de tabellen en velden waar dit commando standaard actie op onderneemt:

+----------------------------------+-----------------------+--------------+------+
| Table                            | Column                | Replacements | Type |
+----------------------------------+-----------------------+--------------+------+
| wp_actionscheduler_actions       | hook                  | 0            | SQL  |
| wp_actionscheduler_actions       | status                | 0            | SQL  |
| wp_actionscheduler_actions       | args                  | 0            | SQL  |
| wp_actionscheduler_actions       | schedule              | 0            | PHP  |
| wp_actionscheduler_actions       | extended_args         | 0            | SQL  |
| wp_actionscheduler_groups        | slug                  | 0            | SQL  |
| wp_actionscheduler_logs          | message               | 0            | SQL  |
| wp_commentmeta                   | meta_key              | 0            | SQL  |
| wp_commentmeta                   | meta_value            | 0            | SQL  |
| wp_comments                      | comment_author        | 0            | SQL  |
| wp_comments                      | comment_author_email  | 0            | SQL  |
| wp_comments                      | comment_author_url    | 0            | SQL  |
| wp_comments                      | comment_author_IP     | 0            | SQL  |
| wp_comments                      | comment_content       | 0            | SQL  |
| wp_comments                      | comment_approved      | 0            | SQL  |
| wp_comments                      | comment_agent         | 0            | SQL  |
| wp_comments                      | comment_type          | 0            | SQL  |
| wp_links                         | link_url              | 0            | SQL  |
| wp_links                         | link_name             | 0            | SQL  |
| wp_links                         | link_image            | 0            | SQL  |
| wp_links                         | link_target           | 0            | SQL  |
| wp_links                         | link_description      | 0            | SQL  |
| wp_links                         | link_visible          | 0            | SQL  |
| wp_links                         | link_rel              | 0            | SQL  |
| wp_links                         | link_notes            | 0            | SQL  |
| wp_links                         | link_rss              | 0            | SQL  |
| wp_options                       | option_name           | 0            | SQL  |
| wp_options                       | option_value          | 14           | PHP  |
| wp_options                       | autoload              | 0            | SQL  |
| wp_postmeta                      | meta_key              | 0            | SQL  |
| wp_postmeta                      | meta_value            | 16167        | PHP  |
| wp_posts                         | post_content          | 5            | PHP  |
| wp_posts                         | post_title            | 0            | SQL  |
| wp_posts                         | post_excerpt          | 0            | SQL  |
| wp_posts                         | post_status           | 0            | SQL  |
| wp_posts                         | comment_status        | 0            | SQL  |
| wp_posts                         | ping_status           | 0            | SQL  |
| wp_posts                         | post_password         | 0            | SQL  |
| wp_posts                         | post_name             | 0            | SQL  |
| wp_posts                         | to_ping               | 0            | SQL  |
| wp_posts                         | pinged                | 0            | SQL  |
| wp_posts                         | post_content_filtered | 0            | SQL  |
| wp_posts                         | guid                  | 16456        | SQL  |
| wp_posts                         | post_type             | 0            | SQL  |
| wp_posts                         | post_mime_type        | 0            | SQL  |
| wp_term_taxonomy                 | taxonomy              | 0            | SQL  |
| wp_term_taxonomy                 | description           | 0            | SQL  |
| wp_termmeta                      | meta_key              | 0            | SQL  |
| wp_termmeta                      | meta_value            | 0            | SQL  |
| wp_terms                         | name                  | 0            | SQL  |
| wp_terms                         | slug                  | 0            | SQL  |
| wp_usermeta                      | meta_key              | 0            | SQL  |
| wp_usermeta                      | meta_value            | 1            | PHP  |
| wp_users                         | user_login            | 0            | SQL  |
| wp_users                         | user_nicename         | 0            | SQL  |
| wp_users                         | user_email            | 0            | SQL  |
| wp_users                         | user_url              | 0            | SQL  |
| wp_users                         | user_activation_key   | 0            | SQL  |
| wp_users                         | display_name          | 0            | SQL  |
| wp_wc_product_meta_lookup        | sku                   | 0            | SQL  |
| wp_wc_product_meta_lookup        | stock_status          | 0            | SQL  |
| wp_wc_product_meta_lookup        | tax_status            | 0            | SQL  |
| wp_wc_product_meta_lookup        | tax_class             | 0            | SQL  |
| wp_wc_tax_rate_classes           | name                  | 0            | SQL  |
| wp_wc_tax_rate_classes           | slug                  | 0            | SQL  |
| wp_woocommerce_order_itemmeta    | meta_key              | 0            | SQL  |
| wp_woocommerce_order_itemmeta    | meta_value            | 0            | PHP  |
| wp_woocommerce_payment_tokenmeta | meta_key              | 0            | SQL  |
| wp_woocommerce_payment_tokenmeta | meta_value            | 0            | SQL  |
| wp_yoast_seo_links               | url                   | 0            | SQL  |
| wp_yoast_seo_links               | type                  | 0            | SQL  |
+----------------------------------+-----------------------+--------------+------+
Success: 32643 replacements to be made.

wp server

Launches PHP's built-in web server for a specific WordPress installation.

wp shell

Opens an interactive PHP console for running and testing PHP code.

wp sidebar

Lists registered sidebars. Dit commando kent maar één subcommando. Het komt wellicht van pas als je gebruik wilt maken van wp widget:

$wp help sidebar

NAME

  wp sidebar

DESCRIPTION

  Lists registered sidebars.

SYNOPSIS

  wp sidebar <command>

SUBCOMMANDS

  list      Lists registered sidebars.

  A [sidebar][1] is any widgetized area of your theme.

  ---
  [1] https://developer.wordpress.org/themes/functionality/sidebars/

EXAMPLES

    # List sidebars
    $ wp sidebar list --fields=name,id --format=csv
    name,id
    "Widget Area",sidebar-1
    "Inactive Widgets",wp_inactive_widgets

' Voorbeeld

wp sidebar list

+---------------------+---------------------+----------------------------------------------------------------------------+
| name                | id                  | description                                                                |
+---------------------+---------------------+----------------------------------------------------------------------------+
| Primary Widget Area | sidebar-1           |                                                                            |
| Header Widget Area  | mini-cart-widget    |                                                                            |
| Inactive Widgets    | wp_inactive_widgets | Drag widgets here to remove them from the sidebar but keep their settings. |
+---------------------+---------------------+----------------------------------------------------------------------------+

wp site

Creates, deletes, empties, moderates, and lists one or more sites on a multisite installation.

wp site


usage: wp site activate <id>...
   or: wp site archive <id>...
   or: wp site create --slug=<slug> [--title=<title>] [--email=<email>] [--network_id=<network-id>] [--private] [--porcelain]
   or: wp site deactivate <id>...
   or: wp site delete [<site-id>] [--slug=<slug>] [--yes] [--keep-tables]
   or: wp site empty [--uploads] [--yes]
   or: wp site list [--network=<id>] [--<field>=<value>] [--site__in=<value>] [--field=<field>] [--fields=<fields>] [--format=<format>]
   or: wp site mature <id>...
   or: wp site meta <command>
   or: wp site option <command>
   or: wp site private <id>...
   or: wp site public <id>...
   or: wp site spam <id>...
   or: wp site switch-language <language>
   or: wp site unarchive <id>...
   or: wp site unmature <id>...
   or: wp site unspam <id>...

See 'wp help site <command>' for more information on a specific command.

wp site switch-language

Dit is de opvolger van wp language core install. Voorbeeld:

wp site switch-language fr_FR

wp super-admin

Lists, adds, or removes super admin users on a multisite installation.

wp taxonomy

Met wp taxonomy kun je informatie opvragen over taxononomieën, maar niet wijzigen. Dat laatste kan wel met bijvoorbeeld wp term, en diverse wp wc-subcommando's.

wp help taxonomy

wp taxonomy

DESCRIPTION

  Retrieves information about registered taxonomies.

SYNOPSIS

  wp taxonomy <command>

SUBCOMMANDS

  get       Gets details about a registered taxonomy.
  list      Lists registered taxonomies.

  See references for [built-in taxonomies][1] and [custom taxonomies][2].

  ---
  [1] https://developer.wordpress.org/themes/basics/categories-tags-custom-taxonomies/
  [2] https://developer.wordpress.org/plugins/taxonomies/working-with-custom-taxonomies/

EXAMPLES

    # List all taxonomies with 'post' object type.
    $ wp taxonomy list --object_type=post --fields=name,public
    +-------------+--------+
    | name        | public |
    +-------------+--------+
    | category    | 1      |
    | post_tag    | 1      |
    | post_format | 1      |
    +-------------+--------+

    # Get capabilities of 'post_tag' taxonomy.
    $ wp taxonomy get post_tag --field=cap
    {"manage_terms":"manage_categories","edit_terms":"manage_categories","delete_terms":"manage_categories","assign_terms":"edit_posts"}


wp taxonomy get

wp taxonomy list

Krijg een overzicht van taxonomieën.

Voorbeeld (impressie):

wp taxonomy list

+------------------+------------------+-------------+------------------------+---------------+--------------+--------+
| name             | label            | description | object_type            | show_tagcloud | hierarchical | public |
+------------------+------------------+-------------+------------------------+---------------+--------------+--------+
| category         | Categories       |             | post                   | 1             | 1            | 1      |
| post_tag         | Tags             |             | post                   | 1             |              | 1      |
| nav_menu         | Navigation Menus |             | nav_menu_item          |               |              |        |
| link_category    | Link Categories  |             | link                   | 1             |              |        |
| post_format      | Formats          |             | post                   |               |              | 1      |
| wp_theme         | Themes           |             | wp_template            |               |              |        |
| product_type     | Product type     |             | product                |               |              |        |
| product_visibili | Product visibili |             | product, product_varia |               |              |        |
| ty               | ty               |             | tion                   |               |              |        |
| product_cat      | Product categori |             | product                | 1             | 1            | 1      |
|                  | es               |             |                        |               |              |        |
| product_tag      | Product tags     |             | product                | 1             |              | 1      |
| product_shipping | Product shipping |             | product, product_varia |               |              | 1      |
| _class           |  classes         |             | tion                   |               |              |        |
| pa_apparaat      | Product Apparaat |             | product                | 1             |              | 1      |
| pa_as_code       | Product As-code  |             | product                | 1             |              | 1      |
| pa_stop          | Product stop?    |             | product                | 1             |              | 1      |
+------------------+------------------+-------------+------------------------+---------------+--------------+--------+

wp term

Manages taxonomy terms and term meta, with create, delete, and list commands.

wp theme

Manages themes, including installs, activations, and updates.

Subcommando's:

wp theme activate   Activate a theme.
wp theme delete   Delete a theme.
wp theme disable  Disable a theme on a WordPress multisite install.
wp theme enable   Enable a theme on a WordPress multisite install.
wp theme get    Get details about a theme.
wp theme install  Install a theme.
wp theme is-installed   Check if the theme is installed.
wp theme list     Get a list of themes.
wp theme mod    Manage theme mods.
wp theme path     Get the path to a theme or to the theme directory.
wp theme search   Search the WordPress.org theme directory.
wp theme status   See the status of one or all themes.
wp theme update   Update one or more themes.

wp theme delete

Bv.

$ wp theme status
4 installed themes:
  I divi            3.0.7
  I twentyfifteen   1.8
  A twentyseventeen 1.3
  I twentysixteen   1.3

Legend: I = Inactive, A = Active

$ wp theme delete divi
Deleted 'divi' theme.
Success: Deleted 1 of 1 themes.

$ wp theme status
3 installed themes:
  I twentyfifteen   1.8
  A twentyseventeen 1.3
  I twentysixteen   1.3

Legend: I = Inactive, A = Active 

wp theme status

Bv.

wp theme status

4 installed themes:
  I divi            3.0.7
  I twentyfifteen   1.8
  A twentyseventeen 1.3
  I twentysixteen   1.3

Legend: I = Inactive, A = Active

wp transient

Adds, gets, and deletes entries in the WordPress Transient Cache.

wp transient delete

Bv.

wp transient delete --all

wp transient get

wp transient list

wp transient set

wp transient type

wp user

Manages users, along with their roles, capabilities, and meta.

wp user add-cap

wp user add-role

wp user create

wp user delete

wp user generate

wp user get

wp user import-csv

wp user list

wp user list-caps

wp user meta

wp user remove-cap

wp user remove-role

wp user session

wp user set-role

wp user spam

wp user term

wp user unspam

wp user update

Syntaxis:

wp user update <user-id> <argument + waarde>

Admin-wachtwoord aanpassen:

wp user update 1 --user_pass=12345

wp wc

Commando's voor interactie met WooCommerce.

Belangrijkste bronnen:


Helptekst

$ wp help wc

NAME

  wp wc

SYNOPSIS

  wp wc <command>

SUBCOMMANDS

  customer                    
  customer_download           
  order_note                  
  payment_gateway             
  product                     
  product_attribute           
  product_attribute_term      
  product_cat                 
  product_review              
  product_shipping_class      
  product_tag                 
  product_variation           
  shipping_method             
  shipping_zone               
  shipping_zone_location      
  shipping_zone_method        
  shop_coupon                 
  shop_order                  
  shop_order_refund
  tax                         
  tax_class                   
  tool                        
  tracker                     
  update
  webhook                     
  webhook_delivery

wp wc customer

wp wc customer_download

wp wc order_note

wp wc payment_gateway

wp wc product

wp help wc product:

NAME

  wp wc product

SYNOPSIS

  wp wc product <command>

SUBCOMMANDS

  create      Create a new item.
  delete      Delete an existing item.
  get         Get a single item.
  list        List all items.
  update      Update an existing item.

wp wc product create

Zie wp wc product create (WP-CLI).

wp wc product list

Bekijk alle productgegevens:

$wp wc product list

NAME

  wp wc product list

DESCRIPTION

  List all items.

SYNOPSIS

  wp wc product list [--context=<context>] [--page=<page>] [--per_page=<per_page>] [--search=<search>] [--after=<after>] [--before=<before>] [--dates_are_gmt=<dates_are_gmt>] [--exclude=<exclude>] [--include=<include>] [--offset=<offset>]
  [--order=<order>] [--orderby=<orderby>] [--parent=<parent>] [--parent_exclude=<parent_exclude>] [--slug=<slug>] [--status=<status>] [--type=<type>] [--sku=<sku>] [--featured=<featured>] [--category=<category>] [--tag=<tag>]
  [--shipping_class=<shipping_class>] [--attribute=<attribute>] [--attribute_term=<attribute_term>] [--tax_class=<tax_class>] [--in_stock=<in_stock>] [--on_sale=<on_sale>] [--min_price=<min_price>] [--max_price=<max_price>]
  [--fields=<fields>] [--field=<field>] [--format=<format>]

OPTIONS

  [--context=<context>]
    Scope under which the request is made; determines fields present in response.

  [--page=<page>]
    Current page of the collection.

  [--per_page=<per_page>]
    Maximum number of items to be returned in result set.

  [--search=<search>]
    Limit results to those matching a string.

  [--after=<after>]
    Limit response to resources published after a given ISO8601 compliant date.

  [--before=<before>]
    Limit response to resources published before a given ISO8601 compliant date.

  [--dates_are_gmt=<dates_are_gmt>]
    Whether to use GMT post dates.

  [--exclude=<exclude>]
    Ensure result set excludes specific IDs.

  [--include=<include>]
    Limit result set to specific ids.

  [--offset=<offset>]
    Offset the result set by a specific number of items.

  [--order=<order>]
    Order sort attribute ascending or descending.

  [--orderby=<orderby>]
    Sort collection by object attribute.

  [--parent=<parent>]
    Limit result set to those of particular parent IDs.

  [--parent_exclude=<parent_exclude>]
    Limit result set to all items except those of a particular parent ID.

  [--slug=<slug>]
    Limit result set to products with a specific slug.

  [--status=<status>]
    Limit result set to products assigned a specific status.

  [--type=<type>]
    Limit result set to products assigned a specific type.

  [--sku=<sku>]
    Limit result set to products with specific SKU(s). Use commas to separate.

  [--featured=<featured>]
    Limit result set to featured products.

  [--category=<category>]
    Limit result set to products assigned a specific category ID.

  [--tag=<tag>]
    Limit result set to products assigned a specific tag ID.

  [--shipping_class=<shipping_class>]
    Limit result set to products assigned a specific shipping class ID.

  [--attribute=<attribute>]
    Limit result set to products with a specific attribute. Use the taxonomy name/attribute slug.

  [--attribute_term=<attribute_term>]
    Limit result set to products with a specific attribute term ID (required an assigned attribute).

  [--tax_class=<tax_class>]
    Limit result set to products with a specific tax class.

  [--in_stock=<in_stock>]
    Limit result set to products in stock or out of stock.

  [--on_sale=<on_sale>]
    Limit result set to products on sale.

  [--min_price=<min_price>]
    Limit result set to products based on a minimum price.

  [--max_price=<max_price>]
    Limit result set to products based on a maximum price.

  [--fields=<fields>]
    Limit response to specific fields. Defaults to all fields.

  [--field=<field>]
    Get the value of an individual field.

  [--format=<format>]
    Render response in a particular format.
    ---
    default: table
    options:
      - table
      - json
      - csv
      - ids
      - yaml
      - count
      - headers
      - body
      - envelope
    ---

Overkill

Op 2 aug. 2021 kreeg ik de output van maar liefst 65 velden. Sommige hiervan zijn vermoedelijk maatwerk en soms was de output serialised:

  • id
  • name
  • slug
  • permalink
  • date_created
  • date_created_gmt
  • date_modified
  • date_modified_gmt
  • type
  • status
  • featured
  • catalog_visibility
  • description
  • short_description
  • sku
  • price
  • regular_price
  • sale_price
  • date_on_sale_from
  • date_on_sale_from_gmt
  • date_on_sale_to
  • date_on_sale_to_gmt
  • price_html
  • on_sale
  • purchasable
  • total_sales
  • virtual
  • downloadable
  • downloads
  • download_limit
  • download_expiry
  • external_url
  • button_text
  • tax_status
  • tax_class
  • manage_stock
  • stock_quantity
  • in_stock
  • backorders
  • backorders_allowed
  • backordered
  • sold_individually
  • weight
  • dimensions - serialised
  • shipping_required
  • shipping_taxable
  • shipping_class
  • shipping_class_id
  • reviews_allowed
  • average_rating
  • rating_count
  • related_ids
  • upsell_ids
  • cross_sell_ids
  • parent_id
  • purchase_note
  • categories - Serialised
  • tags
  • images - Serialised
  • attributes - Serialised
  • default_attributes
  • variations
  • grouped_products
  • menu_order
  • meta_data - Serialised

Dit is niet te doen via de terminal. Het is wel goed te doen door de output in csv-format te redirecten naar een bestand en daarna te openen met Calc. Bv. via wp wc product --user=4 list --per_page=5 --format="csv" > prod1.csv.

Het goede nieuws: Tijdens klonen-&-vertalen in aug. 2021, had ik slechts deze velden nodig:

  • name
  • description
  • short_description.

Daarnaast zijn er nog een aantal maatwerkvelden. Die zijn serialised ondergebracht in het laatste veld meta_data. Daarvan waren de volgende velden relevant zijn qua vertaalwerk:

  • post_tools
  • _yoast_wpseo_focuskw
  • _yoast_wpseo_metadesc
  • _yoast_wpseo_title

Hoeveel producten?

Hoeveel producten zitten er in de webwinkel?

Voorbeeld:

$ wp wc product --user=4 list --format="count"

16972

wp wc product_attribute

$ wp wc product_attribute

usage: wp wc product_attribute create --name=<name> [--slug=<slug>] [--type=<type>] [--order_by=<order_by>] [--has_archives=<has_archives>] [--porcelain]
   or: wp wc product_attribute delete <id> [--id=<id>] [--force=<force>] [--porcelain]
   or: wp wc product_attribute get <id> [--id=<id>] [--context=<context>] [--fields=<fields>] [--field=<field>] [--format=<format>]
   or: wp wc product_attribute list [--context=<context>] [--fields=<fields>] [--field=<field>] [--format=<format>]
   or: wp wc product_attribute update <id> [--id=<id>] [--name=<name>] [--slug=<slug>] [--type=<type>] [--order_by=<order_by>] [--has_archives=<has_archives>] [--porcelain]

See 'wp help wc product_attribute <command>' for more information on a specific command.

wp wc product_attribute get

Zie voorbeeld hieronder voor context. Voorbeeld:

$ wp wc product_attribute get 29 --user=4


+--------------+-------------+
| Field        | Value       |
+--------------+-------------+
| id           | 29          |
| name         | Apparaat    |
| slug         | pa_apparaat |
| type         | select      |
| order_by     | menu_order  |
| has_archives | true        |
+--------------+-------------+

wp wc product_attribute list

Vraag een lijst op van attribute taxonomies.

Voorbeeld:

$ wp wc product_attribute list --user=4

+----+-----------------------+--------------------------+--------+------------+--------------+
| id | name                  | slug                     | type   | order_by   | has_archives |
+----+-----------------------+--------------------------+--------+------------+--------------+
| 29 | Apparaat              | pa_apparaat              | select | menu_order | 1            |
| 16 | As-code               | pa_as_code               | select | menu_order | 1            |
| 17 | Stop?                 | pa_automatische_stop     | select | menu_order | 1            |
| 18 | Breedte (mm)          | pa_breedte               | text   | menu_order | 1            |
| 19 | Connector?            | pa_connector             | select | menu_order | 1            |
| 20 | Diagram               | pa_diagram               | text   | menu_order | 1            |
| 21 | Diepte (mm)           | pa_diepte                | text   | menu_order | 1            |
| 22 | Lengte (mm)           | pa_lengte                | text   | menu_order | 1            |
| 30 | Materiaal             | pa_materiaal             | select | name       | 1            |
| 25 | Model                 | pa_model                 | select | menu_order | 1            |
| 23 | Originele Widget      | pa_originele_widget      | select | menu_order | 1            |
| 28 | Productlijn           | pa_productlijn           | select | menu_order | 1            |
| 24 | Stroomdraad?          | pa_stroomdraad           | select | menu_order | 1            |
| 26 | Submodel              | pa_submodel              | select | menu_order | 1            |
| 27 | Veer?                 | pa_veer                  | select | menu_order | 1            |
| 31 | Zoeken-op-afbeelding  | pa_zoeken-op-afbeelding  | select | menu_order | 1            |
+----+-----------------------+--------------------------+--------+------------+--------------+

wp wc product_attribute update

Pas de definitie van een taxonomie aan. De truuk is, dat je met de flag aangeeft, welk veld je wilt aanpassen, gevolgd door de nieuwe waarde

wp help wc product_attribute update

NAME

  wp wc product_attribute update

DESCRIPTION

  Update an existing item.

SYNOPSIS

  wp wc product_attribute update <id> [--id=<id>] [--name=<name>] [--slug=<slug>] [--type=<type>]
  [--order_by=<order_by>] [--has_archives=<has_archives>] [--porcelain]

OPTIONS

  <id>
    The ID for the resource.

  [--id=<id>]
    Unique identifier for the resource.

  [--name=<name>]
    Attribute name.

  [--slug=<slug>]
    An alphanumeric identifier for the resource unique to its type.

  [--type=<type>]
    Type of attribute.

  [--order_by=<order_by>]
    Default sort order.

  [--has_archives=<has_archives>]
    Enable/Disable attribute archives.

  [--porcelain]
    Output just the id when the operation is successful.

Voorbeeld

In dit voorbeeld wordt de naam aangepast. Merk op dat de slug automatisch meeverandert.

$ wp wc product_attribute get 29 --user=4

+--------------+-------------+
| Field        | Value       |
+--------------+-------------+
| id           | 29          |
| name         | Apparaat    |
| slug         | pa_apparaat |
| type         | select      |
| order_by     | menu_order  |
| has_archives | true        |
+--------------+-------------+


$ wp wc product_attribute update 29 --user=4 --name="Device"

Success: Updated product_attribute 29.


$ wp wc product_attribute get 29 --user=4

+--------------+------------+
| Field        | Value      |
+--------------+------------+
| id           | 29         |
| name         | Device     |
| slug         | pa_device  |
| type         | select     |
| order_by     | menu_order |
| has_archives | false      |
+--------------+------------+

Meerdere updates tegelijkertijd

Je kunt meerdere aspecten tegelijkertijd bijwerken. Bv:

wp wc product_attribute update 29 --user=4 --name="Device" --has_archives=1

wp wc product_attribute_term

$ wp help wc product_attribute_term

NAME

  wp wc product_attribute_term

SYNOPSIS

  wp wc product_attribute_term <command>

SUBCOMMANDS

  create      Create a new item.
  delete      Delete an existing item.
  get         Get a single item.
  list        List all items.
  update      Update an existing item.

wp wc product_attribute_term create

wp wc product_attribute_term delete

wp wc product_attribute_term get

wp wc product_attribute_term list

Voorbeeld (taxonomy 29):

wp wc product_attribute_term list 29 --user=4


+-------+------------------+------------------+---------------------------------+------------+-------+
| id    | name             | slug             | description                     | menu_order | count |
+-------+------------------+------------------+---------------------------------+------------+-------+
| 45244 | Alternator       | alternator       | Alle widgets voor alternators   | 0          | 12    |
| 34601 | Blazer           | blazer           | Alle widgers voor Blazer        | 0          | 26    |
| 45246 | Boorhamer        | boorhamer        | Alle widgets voor boorhamers    | 0          | 0     |
| 34582 | Boormachine      | boormachine      | Alle widgets - Boormachine      | 0          | 2929  |
+-------+------------------+------------------+---------------------------------+------------+-------+

wp wc product_attribute_term update

wp wc product_attribute_term update

usage: wp wc product_attribute_term update <attribute_id> <id> [--id=<id>] 
[--attribute_id=<attribute_id>] [--name=<name>] [--slug=<slug>] 
[--description=<description>] [--menu_order=<menu_order>] [--porcelain]

Voorbeeld

Attribuut-taxonomie nummer 29, is elders getoond. 45244 is het id van de individuele term. Blijkbaar moet je beide id's geven.

$ wp wc product_attribute_term update 29 45244 --description="All carbon brushes for alternators" --user=4


Success: Updated product_attribute_term 45244.

wp wc product_cat

Werk met taxons in de product_cat-taxonomie: Creëer, verwijder, update en geef taxons en hun eigenschappen weer.

Een WooCommerce-site kent precies één product_cat-taxonomie! Daarom heb je geen commando's om met de product_cat-taxonomie als geheel te werken!

$ wp help wc product_cat

NAME

  wp wc product_cat

SYNOPSIS

  wp wc product_cat <command>

SUBCOMMANDS

  create      Create a new item.
  delete      Delete an existing item.
  get         Get a single item.
  list        List all items.
  update      Update an existing item.

Bronnen

wp wc product_cat create

Maak een nieuwe taxon aan in de product_cat-taxonomie:

$ wp help wc product_cat create

NAME

  wp wc product_cat create

DESCRIPTION

  Create a new item.

SYNOPSIS

  wp wc product_cat create --name=<name> [--slug=<slug>] [--parent=<parent>] [--description=<description>]
  [--display=<display>] [--image=<image>] [--menu_order=<menu_order>] [--porcelain]

OPTIONS

  --name=<name>
    Name for the resource.

  [--slug=<slug>]
    An alphanumeric identifier for the resource unique to its type.

  [--parent=<parent>]
    The ID for the parent of the resource.

  [--description=<description>]
    HTML description of the resource.

  [--display=<display>]
    Category archive display type.

  [--image=<image>]
    Image data.

  [--menu_order=<menu_order>]
    Menu order, used to custom sort the resource.

  [--porcelain]
    Output just the id when the operation is successful.

wp wc product_cat delete

Verwijder een bestaande taxon uit de product_cat-taxonomie:

$ wp help wc product_cat delete

NAME

  wp wc product_cat delete

DESCRIPTION

  Delete an existing item.

SYNOPSIS

  wp wc product_cat delete <id> [--id=<id>] [--force=<force>] [--porcelain]

OPTIONS

  <id>
    The ID for the resource.

  [--id=<id>]
    Unique identifier for the resource.

  [--force=<force>]
    Required to be true, as resource does not support trashing.

  [--porcelain]
    Output just the id when the operation is successful.

wp wc product_cat get

Lees gegevens uit van individuele product_cat-taxons:

$ wp help wc product_cat get

NAME

  wp wc product_cat get

DESCRIPTION

  Get a single item.

SYNOPSIS

  wp wc product_cat get <id> [--id=<id>] [--context=<context>] [--fields=<fields>] [--field=<field>]
  [--format=<format>]

OPTIONS

  <id>
    The ID for the resource.

  [--id=<id>]
    Unique identifier for the resource.

  [--context=<context>]
    Scope under which the request is made; determines fields present in response.

  [--fields=<fields>]
    Limit response to specific fields. Defaults to all fields.

  [--field=<field>]
    Get the value of an individual field.

  [--format=<format>]
    Render response in a particular format.
    ---
    default: table
    options:
      - table
      - json
      - csv
      - ids
      - yaml
      - count
      - headers
      - body
      - envelope
    ---

Voorbeelden

Gebruik bv. wp wc product_cat --user=4 list --per_page=2 om een taxon-id te achterhalen. Met dit taxon-id:

wp wc product_cat --user=4 get 44274


+-------------+------------------------------+
| Field       | Value                        |
+-------------+------------------------------+
| id          | 44274                        |
| name        | Alberka                      |
| slug        | alberka                      |
| parent      | 0                            |
| description | Alle widgets voor Alberka    |
| display     | default                      |
| image       | null                         |
| menu_order  | 79                           |
| count       | 8                            |
+-------------+------------------------------+

Count geeft het aantal producten aan, die met deze taxon zijn geassociëerd.

Verkrijg alleen het description-veld:

$ wp wc product_cat --user=4 get 44276 --field="description"

Alle widgets voor Advanilla

--context

De flag --context is niet beschreven op de site of via help. Door een willekeurige waarde op te geven, krijg je meer info:

$ wp wc product_cat --user=4 get 44276 --field="description" --context="blub"

Error: Invalid parameter(s): context {"status":400,"params":{"context":"context 

Ik merk echter geen verschil in output - Vooral niet binnen het kader van het leading character-probleem wat hieronder genoemd wordt:

$ echo "»"$(wp wc product_cat --user=4 get 44277 --field="description" --context="view")"«"
» Alle widgets voor A-C«

$ echo "»"$(wp wc product_cat --user=4 get 44277 --field="description" --context="edit")"«"
» Alle widgets voor A-C«

Probleem met leading character

Dit commando lijkt een leading ao-karakter (line feed) toe te voegen aan de output.

Eerste voorbeeld:

echo "»"$(wp wc product_cat --user=4 get 44276 --field="description")"«"

» All widgets for Advance«

Tweede voorbeeld:

$ i1=$(wp wc product_cat --user=4 get 18869 --field="description")
$ echo "»"$i1"«"

» Alle widgets voor AFX«

Gebruik van de flag --format lijkt niet te helpen:

i1=$(wp wc product_cat --user=4 get 18869 --field="description")
echo "»"$i1"«"

i1=$(wp wc product_cat --user=4 get 18869 --field="description" --format="csv")
echo "format=csv: »"$i1"«"

i1=$(wp wc product_cat --user=4 get 18869 --field="description" --format="body")
echo "format=body: »"$i1"«"

i1=$(wp wc product_cat --user=4 get 18869 --field="description" --format="json")
echo "format=json: »"$i1"«"

i1=$(wp wc product_cat --user=4 get 18869 --field="description" --format="envelope")
echo "format=envelope: »"$i1"«"

Oplossing (beter dan niets): Voeg |xargs toe aan het wp-commando:

$ i1=$(wp wc product_cat --user=4 get 18869 --field="description"|xargs)
$ echo "»"$i1"«"

»gelukt!«

wp wc product_cat list

Toon alle taxons uit de product_cat-taxonomie of een deelverzameling daarvan. Merk op dat je met dit commando niet kunt filteren op individuele id's. Daar heb je wp wc product_cat get voor.

$ wp help wc product_cat list

NAME

  wp wc product_cat list

DESCRIPTION

  List all items.

SYNOPSIS

  wp wc product_cat list [--context=<context>] [--page=<page>] [--per_page=<per_page>] [--search=<search>]
  [--exclude=<exclude>] [--include=<include>] [--offset=<offset>] [--order=<order>] [--orderby=<orderby>]
  [--hide_empty=<hide_empty>] [--parent=<parent>] [--product=<product>] [--slug=<slug>] [--fields=<fields>]
  [--field=<field>] [--format=<format>]

OPTIONS

  [--context=<context>]
    Scope under which the request is made; determines fields present in response.

  [--page=<page>]
    Current page of the collection.

  [--per_page=<per_page>]
    Maximum number of items to be returned in result set.

  [--search=<search>]
    Limit results to those matching a string.

  [--exclude=<exclude>]
    Ensure result set excludes specific IDs.

  [--include=<include>]
    Limit result set to specific ids.

  [--offset=<offset>]
    Offset the result set by a specific number of items. Applies to hierarchical taxonomies only.

  [--order=<order>]
    Order sort attribute ascending or descending.

  [--orderby=<orderby>]
    Sort collection by resource attribute.

  [--hide_empty=<hide_empty>]
    Whether to hide resources not assigned to any products.

  [--parent=<parent>] ← Gebruik parent-ID
    Limit result set to resources assigned to a specific parent. Applies to hierarchical taxonomies only.

  [--product=<product>]
    Limit result set to resources assigned to a specific product.

  [--slug=<slug>]
    Limit result set to resources with a specific slug.

  [--fields=<fields>]
    Limit response to specific fields. Defaults to all fields.

  [--field=<field>]
    Get the value of an individual field.

  [--format=<format>]
    Render response in a particular format.
    ---
    default: table
    options:
      - table
      - json
      - csv
      - ids
      - yaml
      - count
      - headers
      - body
      - envelope
    ---

--field

Gebruik de vlag --field om de output van één veld te krijgen. Voorbeeld:

$ wp wc product_cat --user=4 list --field="description"


All widgets for Alberko
Alle widgets voor Advanilla
...

--format="count"

Met de optie --format="count" wordt het aantal taxons vermeld. Dit is inclusief subtaxons

wp wc product_cat --user=4 list --format="count"

706
Gelukkig: De webinterface komt op hetzelfde nummer uit

--format="ids"

Met de flag --format="ids" worden alleen de id's van taxons geretourneerd. Cruciaal als je de output van dit commando wilt gebruiken als input voor verdere bewerkingen. Voorbeelden:

$ wp wc product_cat --user=4 list --format="ids"

44274 44276 18869 18906 44277 44278 45130 45146 44279 18926 44280 18870 44281 45165 18891 18936 18907 44283 18867 19038 19042 19043 19045 19133 19292 19293 19294 19309 45167 45139 18938 18954 18967 18982 18983 18985 18986 18988 18993 19012 19031 19046 19071 19094 19096 19112 19118 19140 19164 19171 19214 19234 19240 19241 19245 19263 19267 19281 19305 19307 19319 19340 19356 18866 18897 44282 19316 19369 45144 44286 18872 44297 44299 44285 18921 44812 44301 44305 18922 45134 44309 45147 44311 18868 18913 45170 44313 18903 45140 45141 18911 45242 18931 44315 18882 18925 18889 18894 44318 18899

Er worden max. 100 items getourneerd. Kijk maar:

$ wp wc product_cat --user=4 list --format="ids" | wc -w

100

--offset

Je kunt max. 100 taxons per keer zien. Gebruik daarom de flag --offset om voorbij de eerste 100 taxons te komen

--parent

Met --parent kun je filteren op parent-taxons.

Voorbeeld: Vind de eerste 10 taxons zonder parent-categorie:

wp wc product_cat --user=4 list --per_page=10 --parent=0

--per_page

Standaard worden er maximaal 100 items getoond. Dit getal kun je verlagen met --per_page, maar niet verhogen. Kijk maar:

wp wc product_cat --user=4 list --per_page=200

Error: Invalid parameter(s): per_page {"status":400,"params":{"per_page":"per_page must be between 1 (inclusive) and 100 (inclusive)"},"details":{"per_page":{"code":"rest_out_of_bounds","message":"per_page must be between 1 (inclusive) and 100 (inclusive)","data":null}}}

--search

Filter op strings die voorkomen in de velden name en slug. Standaard wordt er niet gezocht in het veld description. Wellicht is dat mogelijk, maar weet ik op dit moment niet hoe dat te doen.

Voorbeeld:

$ wp wc product_cat --user=4 list --search="Hamer"

wp wc product_cat update

Bewerk een bestaande taxon uit de product_cat-taxonomie. Geef met een flag aan wat de nieuwe waarde van het betreffende attribuut wordt.

$ wp help wc product_cat update

NAME

  wp wc product_cat update

DESCRIPTION

  Update an existing item.

SYNOPSIS

  wp wc product_cat update <id> [--id=<id>] [--name=<name>] [--slug=<slug>] [--parent=<parent>] [--description=<description>] [--display=<display>] [--image=<image>] [--menu_order=<menu_order>] [--porcelain]

OPTIONS

  <id>
    The ID for the resource.

  [--id=<id>]
    Unique identifier for the resource.

  [--name=<name>]
    Category name.

  [--slug=<slug>]
    An alphanumeric identifier for the resource unique to its type.

  [--parent=<parent>]
    The ID for the parent of the resource.

  [--description=<description>]
    HTML description of the resource.

  [--display=<display>]
    Category archive display type.

  [--image=<image>]
    Image data.

  [--menu_order=<menu_order>]
    Menu order, used to custom sort the resource.

  [--porcelain]
    Output just the id when the operation is successful.

Simpel voorbeeld

$ wp wc product_cat --user=4 get 44274


+-------------+------------------------------+
| Field       | Value                        |
+-------------+------------------------------+
| id          | 44274                        |
| name        | Alberka                      |
| slug        | Alberka                      |
| parent      | 0                            |
| description | Alle widgets voor Alberka    |
| display     | default                      |
| image       | null                         |
| menu_order  | 79                           |
| count       | 8                            |
+-------------+------------------------------+

$ wp wc product_cat --user=4 update 44274 --description="All widgets for Alberka"


Success: Updated product_cat 44274.

$ wp wc product_cat --user=4 get 44274


+-------------+------------------------------+
| Field       | Value                        |
+-------------+------------------------------+
| id          | 44274                        |
| name        | Alberka                      |
| slug        | Alberka                      |
| parent      | 0                            |
| description | All widgets for Alberka      |
| display     | default                      |
| image       | null                         |
| menu_order  | 79                           |
| count       | 8                            |
+-------------+------------------------------+

Voorbeeld: Find-and-replace

wp wc product_review

wp wc product_shipping_class

wp wc product_tag

wp wc product_variation

wp wc shipping_method

wp wc shipping_zone

wp wc shipping_zone_location

wp wc shipping_zone_method

wp wc shop_coupon

wp wc shop_order

Manage WooCommerce orders. Uitvoer wp help wc shop_order:

NAME

  wp wc shop_order

SYNOPSIS

  wp wc shop_order <command>

SUBCOMMANDS

  create      Create a new item.
  delete      Delete an existing item.
  get         Get a single item.
  list        List all items.
  update      Update an existing item.

wp wc shop_order delete

Verwijder orders.

Uitvoer van wp help wc shop_order delete:

NAME

  wp wc shop_order delete

DESCRIPTION

  Delete an existing item.

SYNOPSIS

  wp wc shop_order delete <id> [--id=<id>] [--force=<force>] [--porcelain]

OPTIONS

  <id>
    The ID for the resource.

  [--id=<id>]
    Unique identifier for the resource.

  [--force=<force>]
    Whether to bypass trash and force deletion.

  [--porcelain]
    Output just the id when the operation is successful.

Standaard wordt met dit commando een order verplaatst naar de prullenbak. Om orders direct definitief te verwijderen, gebruik de boolean switch --force. Bv.:

wp wc shop_order delete --user=4 --force=1 63003

Verwijder (ipv. trashing) alle orders:

wp wc shop_order list --user=4 --field=id | xargs -n1 wp wc shop_order delete --user=4 --force=1
  • Er lijken slechts ca. 25 orders per keer te worden verwijderd
  • Het duurt ca. 5s/order
  • Orders worden niet echt verwijderd, maar verplaatst naar de prullenbak.

Bron: Concatenation (Bash)

wp wc shop_order list

Toon alle orders.

wp help wc shop_order list (minus de globale opties):

NAME

  wp wc shop_order list

DESCRIPTION

  List all items.

SYNOPSIS

  wp wc shop_order list [--context=<context>] [--page=<page>] [--per_page=<per_page>] [--search=<search>]
  [--after=<after>] [--before=<before>] [--dates_are_gmt=<dates_are_gmt>] [--exclude=<exclude>] [--include=<include>]
  [--offset=<offset>] [--order=<order>] [--orderby=<orderby>] [--parent=<parent>] [--parent_exclude=<parent_exclude>]
  [--status=<status>] [--customer=<customer>] [--product=<product>] [--dp=<dp>] [--fields=<fields>] [--field=<field>]
  [--format=<format>]

OPTIONS

  [--context=<context>]
    Scope under which the request is made; determines fields present in response.

  [--page=<page>]
    Current page of the collection.

  [--per_page=<per_page>]
    Maximum number of items to be returned in result set.

  [--search=<search>]
    Limit results to those matching a string.

  [--after=<after>]
    Limit response to resources published after a given ISO8601 compliant date.

  [--before=<before>]
    Limit response to resources published before a given ISO8601 compliant date.

  [--dates_are_gmt=<dates_are_gmt>]
    Whether to use GMT post dates.

  [--exclude=<exclude>]
    Ensure result set excludes specific IDs.

  [--include=<include>]
    Limit result set to specific ids.

  [--offset=<offset>]
    Offset the result set by a specific number of items.

  [--order=<order>]
    Order sort attribute ascending or descending.

  [--orderby=<orderby>]
    Sort collection by object attribute.

  [--parent=<parent>]
    Limit result set to those of particular parent IDs.

  [--parent_exclude=<parent_exclude>]
    Limit result set to all items except those of a particular parent ID.

  [--status=<status>]
    Limit result set to orders assigned a specific status.

  [--customer=<customer>]
    Limit result set to orders assigned a specific customer.

  [--product=<product>]
    Limit result set to orders assigned a specific product.

  [--dp=<dp>]
    Number of decimal points to use in each resource.

  [--fields=<fields>]
    Limit response to specific fields. Defaults to all fields.

  [--field=<field>]
    Get the value of an individual field.

  [--format=<format>]
    Render response in a particular format.
    ---
    default: table
    options:
      - table
      - json
      - csv
      - ids
      - yaml
      - count
      - headers
      - body
      - envelope
    ---

User ID

Ik moest een ID oid. van een admin-account meegeven. Voorbeelden:

wp wc shop_order list --user=4
wp wc shop_order list --user=info@example.com

</pre>

Om alleen de order-id's op te vragen:

wp wc shop_order list --user=4 --field=id

Max. 100 orders

Dit commando geeft maximaal 100 orders weer. Met de paramater --per_page kun je dit getal verlagen, maar niet verhogen:

wp wc shop_order list --user=4 --field=id --per_page=100000

Error: Invalid parameter(s): per_page {"status":400,"params":{"per_page":"per_page must be between 1 (inclusive) and 100 (inclusive)"},"details":{"per_page":{"code":"rest_out_of_bounds","message":"per_page must be between 1 (inclusive) and 100 (inclusive)","data":null}}}

Oplossing: Dit commando meerdere keren herhalen. Bv. 68 keer in dit geval (30 juli 2021) om 6.771 orders te verwijderen ;). Daar is vast een slimme dynamische loop voor beschikbaar, maar ik houd het op simpelweg herhalen van het commando:

for i in {1..70}
do
  wp wc shop_order list --user=4 --field=id | xargs -n1 wp wc shop_order delete --user=4 --force=1
done

wp wc shop_order_refund

wp wc tax

$ wp help wc tax

NAME

  wp wc tax

SYNOPSIS

  wp wc tax <command>

SUBCOMMANDS

  create      Create a new item.
  delete      Delete an existing item.
  get         Get a single item.
  list        List all items.
  update      Update an existing item.

wp wc tax create

$ wp help wc tax create

NAME

  wp wc tax create

DESCRIPTION

  Create a new item.

SYNOPSIS

  wp wc tax create [--country=<country>] [--state=<state>] [--postcode=<postcode>] [--city=<city>] [--rate=<rate>]
  [--name=<name>] [--priority=<priority>] [--compound=<compound>] [--shipping=<shipping>] [--order=<order>]
  [--class=<class>] [--porcelain]

OPTIONS

  [--country=<country>]
    Country ISO 3166 code.

  [--state=<state>]
    State code.

  [--postcode=<postcode>]
    Postcode / ZIP.

  [--city=<city>]
    City name.

  [--rate=<rate>]
    Tax rate.

  [--name=<name>]
    Tax rate name.

  [--priority=<priority>]
    Tax priority.

  [--compound=<compound>]
    Whether or not this is a compound rate.

  [--shipping=<shipping>]
    Whether or not this tax rate also gets applied to shipping.

  [--order=<order>]
    Indicates the order that will appear in queries.

  [--class=<class>]
    Tax class.

  [--porcelain]
    Output just the id when the operation is successful.

wp wc tax delete

$ wp help wc tax delete

NAME

  wp wc tax delete

DESCRIPTION

  Delete an existing item.

SYNOPSIS

  wp wc tax delete <id> [--id=<id>] [--force=<force>] [--porcelain]

OPTIONS

  <id>
    The ID for the resource.

  [--id=<id>]
    Unique identifier for the resource.

  [--force=<force>]
    Required to be true, as resource does not support trashing.

  [--porcelain]
    Output just the id when the operation is successful.

Voorbeeld

Ondanks de foutmelding is het commando met succes uitgevoerd:

$ wp wc tax --user=4 delete 4 --force=true

Error: The resource cannot be deleted. {"status":500}

Voorbeeld: Verwijder alle bestaande tarieven

In deze situatie waren er al een hoop tarieven gedefineerd. Die wilde ik graag in één keer verwijderen:

  • Merk opnieuw op, dat je de foutmeldingen kunt negeren
  • Merk op dat de rijen in de tabel ogenschijnlijk ongesorteerd zijn. Gelukkig boeit dat op geen enkele manier.
$ wp --user=4 wc tax list

+----+---------+-------+----------+------+---------+------+----------+----------+----------+-------+-----------+
| id | country | state | postcode | city | rate    | name | priority | compound | shipping | order | class     |
+----+---------+-------+----------+------+---------+------+----------+----------+----------+-------+-----------+
| 44 | IE      |       |          |      | 23.0000 | VAT  | 1        |          | 1        | 0     | standard  |
| 57 |         |       |          |      | 0.0000  | VAT  | 1        |          | 1        | 0     | zero-rate |
| 56 | SK      |       |          |      | 20.0000 | VAT  | 1        |          | 1        | 0     | standard  |
| 55 | SI      |       |          |      | 22.0000 | VAT  | 1        |          | 1        | 0     | standard  |
| 54 | SE      |       |          |      | 25.0000 | VAT  | 1        |          | 1        | 0     | standard  |
| 53 | RO      |       |          |      | 19.0000 | VAT  | 1        |          | 1        | 0     | standard  |
| 52 | PT      |       |          |      | 23.0000 | VAT  | 1        |          | 1        | 0     | standard  |
| 51 | PL      |       |          |      | 23.0000 | VAT  | 1        |          | 1        | 0     | standard  |
| 50 | NL      |       |          |      | 21.0000 | VAT  | 1        |          | 1        | 0     | standard  |
| 49 | MT      |       |          |      | 18.0000 | VAT  | 1        |          | 1        | 0     | standard  |
| 48 | LV      |       |          |      | 21.0000 | VAT  | 1        |          | 1        | 0     | standard  |
| 47 | LU      |       |          |      | 17.0000 | VAT  | 1        |          | 1        | 0     | standard  |
| 46 | LT      |       |          |      | 21.0000 | VAT  | 1        |          | 1        | 0     | standard  |
| 45 | IT      |       |          |      | 22.0000 | VAT  | 1        |          | 1        | 0     | standard  |
| 30 | AT      |       |          |      | 20.0000 | VAT  | 1        |          | 1        | 0     | standard  |
| 43 | HU      |       |          |      | 27.0000 | VAT  | 1        |          | 1        | 0     | standard  |
| 42 | HR      |       |          |      | 25.0000 | VAT  | 1        |          | 1        | 0     | standard  |
| 41 | FR      |       |          |      | 20.0000 | VAT  | 1        |          | 1        | 0     | standard  |
| 40 | FI      |       |          |      | 24.0000 | VAT  | 1        |          | 1        | 0     | standard  |
| 39 | ES      |       |          |      | 21.0000 | VAT  | 1        |          | 1        | 0     | standard  |
| 38 | EL      |       |          |      | 24.0000 | VAT  | 1        |          | 1        | 0     | standard  |
| 37 | EE      |       |          |      | 20.0000 | VAT  | 1        |          | 1        | 0     | standard  |
| 36 | DK      |       |          |      | 25.0000 | VAT  | 1        |          | 1        | 0     | standard  |
| 35 | DE      |       |          |      | 19.0000 | VAT  | 1        |          | 1        | 0     | standard  |
| 34 | CZ      |       |          |      | 21.0000 | VAT  | 1        |          | 1        | 0     | standard  |
| 33 | CY      |       |          |      | 19.0000 | VAT  | 1        |          | 1        | 0     | standard  |
| 32 | BG      |       |          |      | 20.0000 | VAT  | 1        |          | 1        | 0     | standard  |
| 31 | BE      |       |          |      | 21.0000 | VAT  | 1        |          | 1        | 0     | standard  |
+----+---------+-------+----------+------+---------+------+----------+----------+----------+-------+-----------+

$ wp --user=4 wc tax list --field=id | xargs -n1 wp --user=4 wc tax delete --force=true

Error: The resource cannot be deleted. {"status":500}
Error: The resource cannot be deleted. {"status":500}
Error: The resource cannot be deleted. {"status":500}
Error: The resource cannot be deleted. {"status":500}
Error: The resource cannot be deleted. {"status":500}
Error: The resource cannot be deleted. {"status":500}
Error: The resource cannot be deleted. {"status":500}
Error: The resource cannot be deleted. {"status":500}
Error: The resource cannot be deleted. {"status":500}
Error: The resource cannot be deleted. {"status":500}
Error: The resource cannot be deleted. {"status":500}
Error: The resource cannot be deleted. {"status":500}
Error: The resource cannot be deleted. {"status":500}
Error: The resource cannot be deleted. {"status":500}
Error: The resource cannot be deleted. {"status":500}
Error: The resource cannot be deleted. {"status":500}
Error: The resource cannot be deleted. {"status":500}
Error: The resource cannot be deleted. {"status":500}
Error: The resource cannot be deleted. {"status":500}
Error: The resource cannot be deleted. {"status":500}
Error: The resource cannot be deleted. {"status":500}
Error: The resource cannot be deleted. {"status":500}
Error: The resource cannot be deleted. {"status":500}
Error: The resource cannot be deleted. {"status":500}
Error: The resource cannot be deleted. {"status":500}
Error: The resource cannot be deleted. {"status":500}

$ wp --user=4 wc tax list

+----+---------+-------+----------+------+------+------+----------+----------+----------+-------+-------+
| id | country | state | postcode | city | rate | name | priority | compound | shipping | order | class |
+----+---------+-------+----------+------+------+------+----------+----------+----------+-------+-------+
+----+---------+-------+----------+------+------+------+----------+----------+----------+-------+-------+

wp wc tax get

wp wc tax list

$ wp help wc tax list

NAME

  wp wc tax list

DESCRIPTION

  List all items.

SYNOPSIS

  wp wc tax list [--context=<context>] [--page=<page>] [--per_page=<per_page>] [--offset=<offset>] [--order=<order>]
  [--orderby=<orderby>] [--class=<class>] [--fields=<fields>] [--field=<field>] [--format=<format>]

Voorbeeld:

$ wp wc --user=4 tax list

+----+---------+-------+----------+------+---------+------+----------+----------+----------+-------+----------+
| id | country | state | postcode | city | rate    | name | priority | compound | shipping | order | class    |
+----+---------+-------+----------+------+---------+------+----------+----------+----------+-------+----------+
| 1  | NL      |       |          |      | 21.0000 | BTW  | 1        |          | 1        | 0     | standard |
| 2  | DE      |       |          |      | 19.0000 | MwSt | 1        |          | 1        | 1     | standard |
| 3  |         |       |          |      | 21.0000 | BTW  | 1        |          | 1        | 2     | standard |
+----+---------+-------+----------+------+---------+------+----------+----------+----------+-------+----------+


wp wc tax update

wp wc tax_class

$ wp help wx tax_class

NAME

  wp wc tax_class

SYNOPSIS

  wp wc tax_class <command>

SUBCOMMANDS

  create      Create a new item.
  delete      Delete an existing item.
  get         Get a single item.
  list        List all items.

wp wc tax_class create

wp wc tax_class delete

$ wp help wc tax_class delete


NAME

  wp wc tax_class delete

DESCRIPTION

  Delete an existing item.

SYNOPSIS

  wp wc tax_class delete <slug> [--force=<force>] [--porcelain]

OPTIONS

  <slug>
    The slug for the resource.

  [--force=<force>]
    Required to be true, as resource does not support trashing.

  [--porcelain]
    Output just the id when the operation is successful.

Voorbeeld:

$ wp --user=4 wc tax_class list

+--------------------+--------------------+
| slug               | name               |
+--------------------+--------------------+
| standard           | Standard rate      |
| gereduceerd-tarief | Gereduceerd tarief |
| nultarief          | Nultarief          |
| reduced-rate       | Reduced rate       |
| zero-rate          | Zero rate          |
+--------------------+--------------------+

# Delete redundant tax classes
########################################
#
# * Stick to EN names
# * Keep the reduced-rate, just to be reminded that it exists
# * "--force=true" is needed, as there is no trashbin for
#   tax classes
#
wp --user=4 wc tax_class delete gereduceerd-tarief --force=true
wp --user=4 wc tax_class delete nultarief --force=true

wp wc tax_class get

wp wc tax_class list

Voorbeeld:

$ wp --user=4 wc tax_class list


+--------------------+--------------------+
| slug               | name               |
+--------------------+--------------------+
| standard           | Standard rate      |
| gereduceerd-tarief | Gereduceerd tarief |
| nultarief          | Nultarief          |
| reduced-rate       | Reduced rate       |
| zero-rate          | Zero rate          |
+--------------------+--------------------+

wp wc tool

wp wc tool

usage: wp wc tool list [--fields=<fields>] [--field=<field>] [--format=<format>]
   or: wp wc tool run <id>

See 'wp help wc tool <command>' for more information on a specific command.

Uitvoer wp wc tool --user=4:

+------------------------------------+----------------------------------+-----------------------------+-----------------------------------------------------------------------+
| id                                 | name                             | action                      | description                                                           |
+------------------------------------+----------------------------------+-----------------------------+-----------------------------------------------------------------------+
| clear_transients                   | WooCommerce transients           | Clear transients            | Clear the product/shop transients cache.               |
| clear_expired_transients           | Expired transients               | Clear transients            | Clear ALL expired transients from WordPress.           |
| delete_orphaned_variations         | Orphaned variations              | Delete orphaned variations  | Delete all variations which have no parent.            |
| clear_expired_download_permissions | Used-up download permissions     | Clean up download           | Delete expired download permissions and permissions    |
|                                    |                                  | permissions                 | with 0 remaining downloads.                                           |               
| regenerate_product_lookup_tables   | Product lookup tables            | Regenerate                  | Regenerate product lookup table data. This process may |
|                                    |                                  |                             | take a while                                                          |
| recount_terms                      | Term counts                      | Recount terms               | Recount product terms - useful when changing your      |
|                                                                                                       settings in a way which hides products from the catalog.              |
| reset_roles                        | Capabilities                     | Reset capabilities          | Reset the admin, customer and shop_manager roles to    |
|                                                                                                       default. Use this if your users cannot access all of the WooCommerce  | 
|                                    |                                  |                             | admin pages.                                                          |
| clear_sessions                     | Clear customer sessions          | Clear                       | Delete all customer session data from the        |
|                                                                                                       database, including current carts and saved carts in the database     |
| clear_template_cache               | Clear template cache             | Clear                       | Empty the template cache.                        |
| install_pages                      | Create default WooCommerce pages | Create pages                | Install all the missing WooCommerce pages.       |
|                                                                                                       Pages already defined and set up will not be replaced                 |
| delete_taxes                       | Delete WooCommerce tax rates     | Delete tax rates            | Delete ALL of your tax rate; use with caution  |
|                                                                                                       This action cannot be reversed                                        |
| regenerate_thumbnails              | Regenerate shop thumbnails       | Regenerate                  | Regenerate all shop thumbnails to match your theme and/or   | 
                                                                                                        image settings                                                        |
| db_update_routine                  | Update database                  | Update database             | Update your WooCommerce database to the latest   |
|                                                                                                       version. Please ensure you make sufficient backups before proceeding  |
| verify_db_tables                   | Verify base database tables      | Verify database             | Verify if all base database tables are present.                       |            
| clear_woocommerce_analytics_cache  | Clear analytics cache            | Clear                       | Reset the cached values used in WooCommerce Analytics. If numbers     |
|                                    |                                  |                             | still look off, try Reimporting Historical Data                       |
+------------------------------------+----------------------------------+-----------------------------+-----------------------------------------------------------------------+

wp wc webhook

wp wc webhook_delivery

wp widget

Manages widgets, including adding and moving them within sidebars.

  • Commando wp sidebar list kan van pas komen om de id's van de diverse sidebars te achterhalen
  • Ik heb het gevoel dat ik een commando mis om de specifieke waardes van de options van een widget te achterhalen. Zie ik iets over het hoofd?

Help-tekst:

$ wp help widget

NAME

  wp widget

DESCRIPTION

  Manages widgets, including adding and moving them within sidebars.

SYNOPSIS

  wp widget <command>

SUBCOMMANDS

  add             Adds a widget to a sidebar.
  deactivate      Deactivates one or more widgets from an active sidebar.
  delete          Deletes one or more widgets from a sidebar.
  list            Lists widgets associated with a sidebar.
  move            Moves the position of a widget.
  reset           Resets sidebar.
  update          Updates options for an existing widget.

  A [widget][1] adds content and features to a widget area (also called a [sidebar][2]).

  ---
  [1] https://developer.wordpress.org/themes/functionality/widgets/
  [2] https://developer.wordpress.org/themes/functionality/sidebars/

EXAMPLES

    # List widgets on a given sidebar
    $ wp widget list sidebar-1
    +----------+------------+----------+----------------------+
    | name     | id         | position | options              |
    +----------+------------+----------+----------------------+
    | meta     | meta-6     | 1        | {"title":"Meta"}     |
    | calendar | calendar-2 | 2        | {"title":"Calendar"} |
    +----------+------------+----------+----------------------+

    # Add a calendar widget to the second position on the sidebar
    $ wp widget add calendar sidebar-1 2
    Success: Added widget to sidebar.

    # Update option(s) associated with a given widget
    $ wp widget update calendar-1 --title="Calendar"
    Success: Widget updated.

    # Delete one or more widgets entirely
    $ wp widget delete calendar-2 archive-1
    Success: 2 widgets removed from sidebar.

wp widget add

wp widget deactivate

wp widget delete

wp widget list

$ wp help widget list

NAME

  wp widget list

DESCRIPTION

  Lists widgets associated with a sidebar.

SYNOPSIS

  wp widget list <sidebar-id> [--fields=<fields>] [--format=<format>]

OPTIONS

  <sidebar-id>
    ID for the corresponding sidebar.

  [--fields=<fields>]
    Limit the output to specific object fields.

  [--format=<format>]
    Render output in a particular format.
    ---
    default: table
    options:
      - table
      - csv
      - ids
      - json
      - count
      - yaml
    ---

AVAILABLE FIELDS

  These fields will be displayed by default for each widget:

  * name
  * id
  * position
  * options

  There are no optionally available fields.

EXAMPLES

    $ wp widget list sidebar-1 --fields=name,id --format=csv
    name,id
    meta,meta-5
    search,search-3

Voorbeeld

$ wp sidebar list

+---------------------+---------------------+---------------------------------------------------------------------------+
| name                | id                  | description                                                               |
+---------------------+---------------------+---------------------------------------------------------------------------+
| Primary Widget Area | sidebar-1           |                                                                           |
| Header Widget Area  | mini-cart-widget    |                                                                           |
| Inactive Widgets    | wp_inactive_widgets | Drag widgets here to remove them from the sidebar but keep their settings |
+---------------------+---------------------+---------------------------------------------------------------------------+

$ wp widget list sidebar-1

+----------------------------------+----------------------------------+----------+-----------------------------------+
| name                             | id                               | position | options                           |
+----------------------------------+----------------------------------+----------+-----------------------------------+
| woocommerce_layered_nav_filters  | woocommerce_layered_nav_filters- | 1        | {"title":"Filters"}               |
|                                  | 3                                |          |                                   |
| woocommerce_layered_nav          | woocommerce_layered_nav-19       | 2        | {"title":"Blub code","attribute"  |
|                                  |                                  |          | :"blub-code","display_type":"lis  |
|                                  |                                  |          | t","query_type":"and"}            |
| woocommerce_layered_nav          | woocommerce_layered_nav-13       | 3        | {"title":"Model","attribute":"mod |
|                                  |                                  |          | el","display_type":"list","query_ |
|                                  |                                  |          | type":"and"}                      |
| woocommerce_layered_nav          | woocommerce_layered_nav-14       | 4        | {"title":"Submodel","attribute":" |
|                                  |                                  |          | submodel","display_type":"list"," |
|                                  |                                  |          | query_type":"and"}                |
| woocommerce_layered_nav          | woocommerce_layered_nav-17       | 5        | {"title":"Diagram","attribute":"d |
|                                  |                                  |          | iagram","display_type":"list","qu |
|                                  |                                  |          | ery_type":"and"}                  |
| woocommerce_layered_nav          | woocommerce_layered_nav-5        | 6        | {"title":"Breedte (mm)","attribut |
|                                  |                                  |          | e":"breedte","display_type":"list |
|                                  |                                  |          | ","query_type":"and"}             |
| woocommerce_layered_nav          | woocommerce_layered_nav-6        | 7        | {"title":"Diepte (mm)","attribute |
|                                  |                                  |          | ":"diepte","display_type":"list", |
|                                  |                                  |          | "query_type":"and"}               |
| woocommerce_layered_nav          | woocommerce_layered_nav-7        | 8        | {"title":"Lengte (mm)","attribute |
|                                  |                                  |          | ":"lengte","display_type":"list", |
|                                  |                                  |          | "query_type":"and"}               |
| woocommerce_layered_nav          | woocommerce_layered_nav-8        | 9        | {"title":"Automatische flop?","at |
|                                  |                                  |          | tribute":"automatic-flop","displa |
|                                  |                                  |          | y_type":"list","query_type":"and" |
|                                  |                                  |          | }                                 |
| woocommerce_layered_nav          | woocommerce_layered_nav-9        | 10       | {"title":"Wire?","attribute":"wir |
|                                  |                                  |          | e","display_type":"list","query_t |
|                                  |                                  |          | ype":"and"}                       |
| woocommerce_layered_nav          | woocommerce_layered_nav-10       | 11       | {"title":"Connector?","attribute" |
|                                  |                                  |          | :"connector","display_type":"list |
|                                  |                                  |          | ","query_type":"and"}             |
| woocommerce_layered_nav          | woocommerce_layered_nav-11       | 12       | {"title":"Veer?","attribute":"vee |
|                                  |                                  |          | r","display_type":"list","query_t |
|                                  |                                  |          | ype":"and"}                       |
| woocommerce_layered_nav          | woocommerce_layered_nav-4        | 13       | {"title":"Original blub",         |
|                                  |                                  |          | "attribute":"original-blub",      |
|                                  |                                  |          | "display_type":"list","query_t    |
|                                  |                                  |          | ype":"and"}                       |
| woocommerce_layered_nav          | woocommerce_layered_nav-12       | 14       | {"title":"Diagram","attribute":"d |
|                                  |                                  |          | iagram","display_type":"list","qu |
|                                  |                                  |          | ery_type":"and"}                  |
| woocommerce_layered_nav          | woocommerce_layered_nav-16       | 15       | {"title":"Product line","attribut |
|                                  |                                  |          | e":"product-line","display_type": |
|                                  |                                  |          | "list","query_type":"and"}        |
| woocommerce_layered_nav          | woocommerce_layered_nav-15       | 16       | {"title":"blujb-productcode","att |
|                                  |                                  |          | ribute":"blub_code","display_typ  |
|                                  |                                  |          | e":"list","query_type":"and"}     |
+----------------------------------+----------------------------------+----------+-----------------------------------+

--fields

Met de flag --fields heb je vermoedelijk de keuze uit

  • name
  • id
  • position
  • options

en niet de keuze uit de diverse velden die onder options worden getoond. De velden scheid je met een komma, zonder spatie. Voorbeeld:

$ wp widget list sidebar-1 --fields=id,options

+-----------------------------------+----------------------------------------------------------------------------------------------------------------+
| id                                | options                                                                                                        |
+-----------------------------------+----------------------------------------------------------------------------------------------------------------+
| woocommerce_layered_nav_filters-3 | {"title":"Filters"}                                                                                            |
| woocommerce_layered_nav-19        | {"title":"Apparaat","attribute":"apparaat","display_type":"list","query_type":"and"}                           |
| woocommerce_layered_nav-13        | {"title":"Model","attribute":"model","display_type":"list","query_type":"and"}                                 |
| woocommerce_layered_nav-14        | {"title":"Submodel","attribute":"submodel","display_type":"list","query_type":"and"}                           |
+-----------------------------------+----------------------------------------------------------------------------------------------------------------+

wp widget move

wp widget reset

wp widget update

Bewerk de instellingen voor bestaande widgets:

  • Merk op dat je een widget-id moet meegeven, maar niet een sidebar-id
  • De namen bij --attribute zijn de slugs, dus doorgaans met dashes en niet met underscores. Je kunt de namen ook achterhalen middels select distinct taxonomy from wp_term_taxonomy;

Helptekst:

$ wp help widget update

NAME

  wp widget update

DESCRIPTION

  Updates options for an existing widget.

SYNOPSIS

  wp widget update <widget-id> [--<field>=<value>]

OPTIONS

  <widget-id>
    Unique ID for the widget

  [--<field>=<value>]
    Field to update, with its new value

EXAMPLES

    # Change calendar-1 widget title to "Our Calendar"
    $ wp widget update calendar-1 --title="Our Calendar"
    Success: Widget updated.

Voorbeeld - 2021.08.14

################################################################################
# Update widgets
################################################################################
#
wp widget update woocommerce_layered_nav-19 --title="Device"     --attribute="device"
wp widget update woocommerce_layered_nav-13 --title="Model"      --attribute="model"
wp widget update woocommerce_layered_nav-14 --title="Submodel"     --attribute="submodel"
wp widget update woocommerce_layered_nav-5  --title="Width (mm)"   --attribute="width-mm"
wp widget update woocommerce_layered_nav-6  --title="Depth (mm)"   --attribute="depth-mm"
wp widget update woocommerce_layered_nav-7  --title="Length (mm)"  --attribute="length-mm"
wp widget update woocommerce_layered_nav-16 --title="Product line" --attribute="product-line"

wp yoast

Het lijkt erop wp yoast maar één ding kan: Content indexeren. Jammer.

$ wp help yoast

NAME

  wp yoast

DESCRIPTION

  Command to generate indexables for all posts and terms.

SYNOPSIS

  wp yoast <command>

SUBCOMMANDS

  index      Indexes all your content to ensure the best performance.

wp yoast index

$ wp help yoast index

NAME

  wp yoast index

DESCRIPTION

  Indexes all your content to ensure the best performance.

SYNOPSIS

  wp yoast index [--network] [--reindex] [--skip-confirmation]

OPTIONS

  [--network]
    Performs the indexation on all sites within the network.

  [--reindex]
    Removes all existing indexables and then reindexes them.

  [--skip-confirmation]
    Skips the confirmations (for automated systems).

Aanroep is simpel:

wp yoast index

En het commando was gelijk klaar.

Zie ook

Bronnen