Wp widget (WP-CLI): verschil tussen versies

Uit De Vliegende Brigade
Naar navigatie springen Naar zoeken springen
 
Regel 60: Regel 60:
 
     Success: 2 widgets removed from sidebar.
 
     Success: 2 widgets removed from sidebar.
 
</pre>
 
</pre>
 
== wp widget add ==
 
 
== wp widget deactivate ==
 
 
== wp widget delete ==
 
 
== wp widget list ==
 
 
<pre>
 
$ 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
 
</pre>
 
 
=== Voorbeeld ===
 
 
<pre>
 
$ 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"}    |
 
+----------------------------------+----------------------------------+----------+-----------------------------------+
 
</pre>
 
 
=== --fields ===
 
 
Met de ''flag'' <code>--fields</code> heb je vermoedelijk de keuze uit
 
 
* <code>name</code>
 
* <code>id</code>
 
* <code>position</code>
 
* <code>options</code>
 
 
en ''niet'' de keuze uit de diverse velden die onder ''options'' worden getoond. De velden scheid je met een komma, zonder spatie. Voorbeeld:
 
 
<pre>
 
$ 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"}                          |
 
+-----------------------------------+----------------------------------------------------------------------------------------------------------------+
 
</pre>
 
 
== wp widget move ==
 
 
== wp widget reset ==
 

Huidige versie van 27 aug 2022 om 18:20

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.