Skip to content

wp theme mod get --all produces malformed output for non-tabular formats #96

@johnbillion

Description

@johnbillion

The wp theme mod get --all command formats its output in a clever way (this is the first time I've seen this particular formatting, I'm not sure if it's used elsewhere) by listing the first level keys of a serialised option value as its own element.

Example:

+-------------------------+--------------------------------------------------------------------------------------------------+
| key                     | value                                                                                            |
+-------------------------+--------------------------------------------------------------------------------------------------+
| 0                       |                                                                                                  |
| background_color        | ffffff                                                                                           |
| nav_menu_locations      | =>                                                                                               |
|     primary             | 39                                                                                               |
| color_scheme            | yellow                                                                                           |
| sidebar_textcolor       | #111111                                                                                          |
| header_background_color | #ffffff                                                                                          |
| background_image        |                                                                                                  |
| background_attachment   | scroll                                                                                           |
| sidebars_widgets        | =>                                                                                               |
|     time                | 1458419959                                                                                       |
|     data                | {"wp_inactive_widgets":["calendar-3","search-3","search-5","categories-2","recent-comments-3","p |
|                         | ages-2","calendar-2","archives-2","meta-2","search-2","text-2","recent-posts-2","recent-comments |
|                         | -2","rss-2","tag_cloud-2","nav_menu-2","nav_menu-4"],"sidebar-1":["search-7","tag_cloud-5"],"sid |
|                         | ebar-2":["search-7","tag_cloud-5"],"sidebar-3":null}                                             |
| custom_css_post_id      | -1                                                                                               |
+-------------------------+--------------------------------------------------------------------------------------------------+

Observer that the primary element from the nav_menu_locations option, and the time and data elements from the sidebars_widgets option are displayed as their own sub-elements in the table.

This output works okay for the tabular output, but for other formats it's broken.

Example of broken CSV output:

key,value
0,
background_color,ffffff
nav_menu_locations,=>
"    primary",39
color_scheme,yellow
sidebar_textcolor,#111111
header_background_color,#ffffff
background_image,
background_attachment,scroll
sidebars_widgets,=>
"    time",1458419959
"    data","{""wp_inactive_widgets"":[""calendar-3"",""search-3"",""search-5"",""categories-2"",""recent-comments-3"",""pages-2"",""calendar-2"",""archives-2"",""meta-2"",""search-2"",""text-2"",""recent-posts-2"",""recent-comments-2"",""rss-2"",""tag_cloud-2"",""nav_menu-2"",""nav_menu-4""],""sidebar-1"":[""search-7"",""tag_cloud-5""],""sidebar-2"":[""search-7"",""tag_cloud-5""],""sidebar-3"":null}"
custom_css_post_id,-1

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions