wp-shortcake / shortcake-bakery

A fine selection of shortcodes for WordPress
42 stars 16 forks source link

checkbox fields not present in shortcode as attributes #165

Closed montchr closed 8 years ago

montchr commented 8 years ago

When I select the disableresponsiveness checkbox in either the Giphy, Google Docs, or Iframe Shortcake modals, it is not added as an attribute in the shortcode, which means it is not present in the $attrs array.

montchr commented 8 years ago

Seems this is also happening when I select “Display spreadsheet header rows?” when adding a spreadsheet in the Google Docs shortcode.

Even if I go to edit the shortcode in visual mode and check the box then, the headers attribute still is not added.

goldenapples commented 8 years ago

The issue is in Shortcake here, where we're checking if the attribute type is boolean. But its actually getting the string "true".

montchr commented 8 years ago

I closed this out because I tested again a few minutes later and it worked. Tested on another site and it worked too. Not sure what changed, but I don't think there's an issue here.

goldenapples commented 8 years ago

No, I think it's definitely a bug in the shortcode attribute field rendering function in Shortcake.

I think there's a bit of confusion as to how boolean values should be stored in the shortcode model. Looks like when a checked checkbox value is initially set, it's set as true. Then, when the shortcode is passed to the editor, that becomes attribute="true". Reading it back, as in opening the edit UI for the shortcode again, that value is read as a string, not a boolean, and becomes unset on the model.

I'll open an issue in Shortcake to track it.