Wp option patch (WP-CLI): verschil tussen versies

Uit De Vliegende Brigade
Naar navigatie springen Naar zoeken springen
 
(3 tussenliggende versies door dezelfde gebruiker niet weergegeven)
Regel 1: Regel 1:
<code>wp option patch</code>: Verwijderen, invoegen & bijwerken van ''serialised value''.
+
<code>wp option patch</code>: Manipulate ''serialised values''.
  
 
<pre>
 
<pre>
Regel 47: Regel 47:
 
</pre>
 
</pre>
  
== wp option patch delete ==
+
== See also ==
 
 
== wp option patch insert ==
 
 
 
== wp option patch update ==
 
 
 
Update een serialised veld:
 
 
 
* Subvelden geef je aan door alle tussenliggende elementen te benoemen (spatie-gescheiden)
 
* LET OP: Het huidige serialised veld/subboom wordt overschreven door dit commando. Als je bv. tussenliggende elementen vergeet te vermelden, wis je het complete datamodel rondom dat veld
 
* Mogelijk een veilige manier om dit commando toe te passen: Lees eerst de huidige waarde uit met <code>wp option pluck</code> en update het pas daarna met dit commando.
 
* Numerieke waardes mogen zowel met als zonder enkele/dubbele aanhalingstekens
 
 
 
'''Voorbeeld (1)'''
 
 
 
<pre>
 
$ 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.
 
</pre>
 
 
 
'''Voorbeeld: Numerieke waardes & aanhalingstekens'''
 
 
 
<pre>
 
$ wp option pluck woocommerce_dhlpwc_settings price_option_home
 
 
 
6.95
 
 
 
$ wp option patch update woocommerce_dhlpwc_settings price_option_home "79.95"  # Met dubbele aanhalingstekens
 
 
 
Success: Updated 'woocommerce_dhlpwc_settings' option.
 
 
 
 
 
$ wp option pluck woocommerce_dhlpwc_settings price_option_home
 
 
 
79.95
 
 
 
 
 
$ wp option patch update woocommerce_dhlpwc_settings price_option_home "79.95"  # Zonder aanhalingstekens
 
 
 
Success: Value passed for 'woocommerce_dhlpwc_settings' option is unchanged.
 
</pre>
 
== Zie ook ==
 
  
 
* [[wp option (WP-CLI) |                            wp option]]
 
* [[wp option (WP-CLI) |                            wp option]]
Regel 155: Regel 54:
 
* [[wp option get (WP-CLI) |                        wp option get]]
 
* [[wp option get (WP-CLI) |                        wp option get]]
 
* [[wp option list (WP-CLI) |                      wp option list]]
 
* [[wp option list (WP-CLI) |                      wp option list]]
 +
* [[wp option patch delete (WP-CLI) |              wp option patch delete]]
 +
* [[wp option patch insert (WP-CLI) |              wp option patch insert]]
 +
* [[wp option patch update (WP-CLI) |              wp option patch update]]
 
* [[wp option pluck (WP-CLI) |                      wp option pluck]]
 
* [[wp option pluck (WP-CLI) |                      wp option pluck]]
 
* [[wp option update (WP-CLI) |                    wp option update]]
 
* [[wp option update (WP-CLI) |                    wp option update]]

Huidige versie van 29 aug 2022 om 07:11

wp option patch: Manipulate serialised values.

$ wp help option patch


NAME

  wp option patch

DESCRIPTION

  Updates a nested value in an option.

SYNOPSIS

  wp option patch <action> <key> <key-path>... [<value>] [--format=<format>]

OPTIONS

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

  <key>
    The option name.

  <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
    ---

See also