Adding A Gutenberg CheckBox to fix an old child theme function

I have two old functions in my child theme and I need your help updating one of them. I need an easy, simple, eloquent, copy/past way to add a checkbox to the Gutenberg editor. I assume somewhere in the sidebar under the document tab?

This will replace the first function which hooks into ‘post_submitbox_misc_actions’. That hook no longer exists, and obviously no longer works!

Function One

The old function had this line in it. The replacement needs the same results (for Function Two).

<input type=”checkbox” id=”do-the-thing-tukod-927″ name=”do_the_thing_tukod_927″ value=”1″ />

It produced a checkbox output that said:

[_] Do the Thing!

Of course, when this is checked and updated,

$_POST[ ‘do_the_thing_tukod_927’ ] was created.

The new function needs to replace Function One.

Function Two

This function seems to be working!

Near the top is this code:

<?php
// Check if checkbox is empty or not.

if ( ! isset ( $_POST[ ‘do_the_thing_tukod_927’ ] ) ) {
return;
}

Obviously, without the first function, the second will always return.

To test my theory, I commented out these lines, and every time I updated, the 2nd function ran. I need the checkbox to selectively allow this to run.

History

For clarification (supporting information):
I am running into my 8th decade of life. Been hacking code for over 50 years. That is Fortran, Cobol, Pascal, PL1 and about 25 years of PHP from back when it was called Personal Home Page!

But as to Java-Script, I am basically a cut and paste Noob!

Likewise, with kids, grandkids, and great-grandkids, I really do not develop code anymore and have little interest in learning Java-Script. That would take time from my family and my blogs.

I am a WordPress user! Will you help me?

Read more here:: Adding A Gutenberg CheckBox to fix an old child theme function

Leave a Reply

Your email address will not be published. Required fields are marked *