wp-cli/widget-command 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

wp-cli/widget-command

Composer 安装命令:

composer require wp-cli/widget-command

包简介

Adds, moves, and removes widgets; lists sidebars.

README 文档

README

Adds, moves, and removes widgets; lists sidebars.

Testing Code Coverage

Quick links: Using | Installing | Contributing | Support

Using

This package implements the following commands:

wp widget

Manages widgets, including adding and moving them within sidebars.

wp widget

A widget adds content and features to a widget area (also called a sidebar).

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

Adds a widget to a sidebar.

wp widget add <name> <sidebar-id> [<position>] [--<field>=<value>]

Creates a new widget entry in the database, and associates it with the sidebar.

OPTIONS

<name>
	Widget name.

<sidebar-id>
	ID for the corresponding sidebar.

[<position>]
	Widget's current position within the sidebar. Defaults to last

[--<field>=<value>]
	Widget option to add, with its new value

EXAMPLES

# Add a new calendar widget to sidebar-1 with title "Calendar"
$ wp widget add calendar sidebar-1 2 --title="Calendar"
Success: Added widget to sidebar.

wp widget deactivate

Deactivates one or more widgets from an active sidebar.

wp widget deactivate <widget-id>...

Moves widgets to Inactive Widgets.

OPTIONS

<widget-id>...
	Unique ID for the widget(s)

EXAMPLES

# Deactivate the recent-comments-2 widget.
$ wp widget deactivate recent-comments-2
Success: 1 widget deactivated.

wp widget delete

Deletes one or more widgets from a sidebar.

wp widget delete <widget-id>...

OPTIONS

<widget-id>...
	Unique ID for the widget(s)

EXAMPLES

# Delete the recent-comments-2 widget from its sidebar.
$ wp widget delete recent-comments-2
Success: Deleted 1 of 1 widgets.

wp widget list

Lists widgets associated with a sidebar.

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

wp widget move

Moves the position of a widget.

wp widget move <widget-id> [--position=<position>] [--sidebar-id=<sidebar-id>]

Changes the order of a widget in its existing sidebar, or moves it to a new sidebar.

OPTIONS

<widget-id>
	Unique ID for the widget

[--position=<position>]
	Assign the widget to a new position.

[--sidebar-id=<sidebar-id>]
	Assign the widget to a new sidebar

EXAMPLES

# Change position of widget
$ wp widget move recent-comments-2 --position=2
Success: Widget moved.

# Move widget to Inactive Widgets
$ wp widget move recent-comments-2 --sidebar-id=wp_inactive_widgets
Success: Widget moved.

wp widget patch

Updates a nested value in a widget's options.

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

OPTIONS

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

<widget-id>
	Unique ID for the widget.

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

EXAMPLES

# Update a nested value in the options of the archives-1 widget
$ wp widget patch update archives-1 title "My Archives"
Success: Widget updated.

# Insert a new nested value into the options of the archives-1 widget
$ wp widget patch insert archives-1 new_key "New Value"
Success: Widget updated.

# Delete a nested value from the options of the archives-1 widget
$ wp widget patch delete archives-1 title
Success: Widget updated.

wp widget reset

Resets sidebar.

wp widget reset [<sidebar-id>...] [--all] [--inactive]

Removes all widgets from the sidebar and places them in Inactive Widgets.

OPTIONS

[<sidebar-id>...]
	One or more sidebars to reset.

[--all]
	If set, all sidebars will be reset.

[--inactive]
	If set, all inactive sidebars will also be reset, in addition to any sidebars specified via <sidebar-id>... or selected with --all.

EXAMPLES

# Reset a sidebar
$ wp widget reset sidebar-1
Sidebar 'sidebar-1' reset.

# Reset multiple sidebars
$ wp widget reset sidebar-1 sidebar-2
Sidebar 'sidebar-1' reset.
Sidebar 'sidebar-2' reset.

# Reset all sidebars
$ wp widget reset --all
Sidebar 'sidebar-1' reset.
Sidebar 'sidebar-2' reset.
Sidebar 'sidebar-3' reset.

# Reset all inactive sidebars
$ wp widget reset --inactive
Sidebar 'old-sidebar-1' reset.

wp widget update

Updates options for an existing widget.

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.

wp sidebar

Lists registered sidebars.

wp sidebar

A sidebar is any widgetized area of your theme.

EXAMPLES

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

wp sidebar exists

Check if a sidebar exists.

wp sidebar exists <id>

OPTIONS

<id>
	The sidebar ID.

EXAMPLES

$ wp sidebar exists sidebar-1
$ wp sidebar exists wp_inactive_widgets && echo "exists"

wp sidebar get

Get details about a specific sidebar.

wp sidebar get <id> [--fields=<fields>] [--format=<format>]

OPTIONS

<id>
	The sidebar ID.

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

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

EXAMPLES

$ wp sidebar get sidebar-1
$ wp sidebar get wp_inactive_widgets --format=json

wp sidebar list

Lists registered sidebars.

wp sidebar list [--inactive] [--fields=<fields>] [--format=<format>]

OPTIONS

[--inactive]
	If set, only inactive sidebars will be listed.

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

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

AVAILABLE FIELDS

These fields will be displayed by default for each sidebar:

  • name
  • id
  • description

These fields are optionally available:

  • class
  • before_widget
  • after_widget
  • before_title
  • after_title

EXAMPLES

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

$ wp sidebar list --inactive --fields=id --format=csv
id
old-sidebar-1

Installing

This package is included with WP-CLI itself, no additional installation necessary.

To install the latest version of this package over what's included in WP-CLI, run:

wp package install git@github.com:wp-cli/widget-command.git

Contributing

We appreciate you taking the initiative to contribute to this project.

Contributing isn’t limited to just code. We encourage you to contribute in the way that best fits your abilities, by writing tutorials, giving a demo at your local meetup, helping other users with their support questions, or revising our documentation.

For a more thorough introduction, check out WP-CLI's guide to contributing. This package follows those policy and guidelines.

Reporting a bug

Think you’ve found a bug? We’d love for you to help us get it fixed.

Before you create a new issue, you should search existing issues to see if there’s an existing resolution to it, or if it’s already been fixed in a newer version.

Once you’ve done a bit of searching and discovered there isn’t an open or fixed issue for your bug, please create a new issue. Include as much detail as you can, and clear steps to reproduce if possible. For more guidance, review our bug report documentation.

Creating a pull request

Want to contribute a new feature? Please first open a new issue to discuss whether the feature is a good fit for the project.

Once you've decided to commit the time to seeing your pull request through, please follow our guidelines for creating a pull request to make sure it's a pleasant experience. See "Setting up" for details specific to working on this package locally.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Support

GitHub issues aren't for general support questions, but there are other venues you can try: https://wp-cli.org/#support

This README.md is generated dynamically from the project's codebase using wp scaffold package-readme (doc). To suggest changes, please submit a pull request against the corresponding part of the codebase.

wp-cli/widget-command 适用场景与选型建议

wp-cli/widget-command 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 7.77M 次下载、GitHub Stars 达 6, 最近一次更新时间为 2017 年 04 月 17 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 wp-cli/widget-command 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 wp-cli/widget-command 我们能提供哪些服务?
定制开发 / 二次开发

基于 wp-cli/widget-command 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 7.77M
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 6
  • 点击次数: 26
  • 依赖项目数: 3
  • 推荐数: 0

GitHub 信息

  • Stars: 6
  • Watchers: 4
  • Forks: 11
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-04-17