Settings API with checkbox boolean input

Hi, before yesterday I knew virtually nothing about the settings API.
I knew how to set and retrieve options, but settings I knew nothing about.

In my first WP plugin in years (as in about a decade), I have it figured out enough to adequately create the form in the settings panel but controlling what happens on submit I have not a clue.

The github is at the link that is only shown to logged in users.

Settings related functions are at lower end of inc/functions.php except for the one function that creates the form, which is in its own file inc/options.php as it has mixed html/php (which I loathe but will fix later, I really wish WordPress used DOMDocument but that is too radical of a change to expect)

The file “screenshot-1.jpg” there shows the visual output.

Three settings options (fourth will be added once these three are working)

The option values are binary so I am using a checkbox input.

Both the “name” and “id” attributes are identical to the name of the option that is set.

All of them have a value="true" but only have checked="checked" if the current option value is true.

That all works, but it seems on submit the processing of the data does not happen and I am certainly missing something that tells the settings API to set the option to boolean true if checked and boolean false if not checked.


When this is working, the plan is to add a fourth option allowing the user to select from a list of CDNs they can use (same list at code[dot]jquery[dot]com)

There probably already similar plugins but this seemed like a functional learning experience to create.

The page I need help with: [log in to see the link]

Source link