mtekk / Breadcrumb-NavXT

The longest maintained Breadcrumb plugin for WordPress
https://mtekk.us/code/breadcrumb-navxt
51 stars 25 forks source link

Import/Export Drops Boolean/Checkbox Default Values #289

Closed mtekk closed 1 year ago

mtekk commented 1 year ago

The current combined behavior of the settings exporter and the settings importer causes checkbox/boolean settings where the default value is "true"/checked to not export/import properly. This is due to the exporter just exporting the saved settings in the database, and the importer running these through the same function as saving/updating settings. Probably should get the importer to merge with the defaults before saving.

mtekk commented 1 year ago

This appears to be caused by attempting to re-use the options update code base (specifically the maybe_update_from_form_imput() function). This literally only affects booleans due to how checkboxes work (if not checked the value isn't sent).

mtekk commented 1 year ago

A couple of potential fixes:

1) Export all booleans, or at a minimum all default set to true booleans. 2) On import, merge in the defaults to the imports array (essentially merge in the opts array, which we're tying to get away from eventually) before going to the validation loop. 3) Add a parameter to maybe_update_from_form_input() to bypass for missing defaults.

I don't particularly like any of these, option 3 is probably the most correct.