Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fields "checkbox", "toggle" and "switch" don't save as boolean in PHP, instead integer 0/1 #1195

Closed
kmob2 opened this issue Dec 9, 2016 · 1 comment
Milestone

Comments

@kmob2
Copy link

kmob2 commented Dec 9, 2016

Issue description:

I noticed that the fields "checkbox", "toggle" and "switch" don't save as boolean (true/false) inside of the database, instead as integers 1 or 0.
When using those field inside of the customizer, javascript does return them as boolean.

In other words, when using PHP, the fields return either as 1 or 0 and when using javascript, they return as true or false.

This becomes an issue when using strict comparison with === and needing to check the values between the currently saved PHP value and the changed value inside of the customizer using Javascript.

I only came across this, since Kirki has currently the issue with active_callback not working with postMessage, and I am implementing a workaround using https://make.xwp.co/2016/07/24/dependently-contextual-customizer-controls/. Because the fields "checkbox", "toggle" and "switch" don't save as boolean inside of PHP, the dependencies will break when loading the customizer the first time, since on first page load, it uses the database values retrived via PHP to determine if a field is hidden or shown.

Version used:

2.3.7 (stable WP.org version)

Using theme_mods or options?

theme_mods

@aristath
Copy link
Contributor

This has already been fixed in the develop branch, though it will take some time to release the next version 'cause it's a rewrite of some parts of the plugin to make it more modular.
I'll have to ask for your patience on this one for now until we can have version 2.4.0 ready for release.

@aristath aristath modified the milestone: 3.0 Apr 23, 2017
cristeacosmin added a commit to ColorlibHQ/tyche that referenced this issue Jun 26, 2017
It saved toggles as 1/0, now it saves bools

themeum/kirki#1195
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants