This is because when a checkbox isn’t checked it didn’t send to the server. This is why the POST array doesn’t have the upo_enable
index.
You can, however, check if the value is empty or not:
$upo_enable = !empty($_POST['upo_enable']) ? true : false;
Or
$upo_enable = !empty($_POST['upo_enable']) ? $_POST['upo_enable'] : false;
More on this:
https://www.w3.org/TR/html401/interact/forms.html
checkboxes
Checkboxes (and radio buttons) are on/off switches that may be toggled
by the user. A switch is “on” when the control element’s checked
attribute is set. When a form is submitted, only “on” checkbox
controls can become successful.
Related Posts:
- How to find out if option exists but is empty?
- Redirect to another page using contact form 7? [closed]
- Saving an array to get_options
- What are the differences between WPINC and ABSPATH?
- Problems with autoloading classes via sp_autoload_register / maybe interfering WP-specific autoloader
- How to remove duplicate sub-menu name for top level menu items in a plugin?
- Customizing subject in comment notification e-mails
- category_name not working (not showing up in sql query debug)
- Using require_once in a Plugin?
- How can I make my custom shortcode work in a Custom HTML Widget?
- How to Loop Plugin Option Field Set?
- Making plugin unique to not conflict with plugins with the same name
- Update Multiple Post Meta for the Same Post In One call?
- Custom plugin settings: clicking “save changes” does not display success message
- How to pass JavaScript variable to PHP in wordpress widget?
- Unable to add admin notice on plugin activation
- How To Ignore a Filter On Applying Filter the Content In a Function
- Saving Plugin settings to the database
- How do I configure WordPress to talk to a Microsoft SQL Server database?
- WordPress widget / plugin….fields not appearing in my widget
- Add CSS animation as Preloader to WordPress
- Rename existing old uploaded images containing accented French characters (not during upload)
- How to list the Hooks and order of execution in current loading page? [duplicate]
- How to fetch serialized data from wordpress options
- How to Create a Directory in a Plugin Folder?
- Errors while using ajax from external wordpress page
- shortcode doesn’t work
- Ajax call doesn’t work in frontend but it’s working in backend (when I’m logged in)
- Create plugin that works in background
- Checking for user role in a custom plugin
- Get all options saved by another plugin
- Deleting images through upload folder, but not deleting from media library
- Custom Shipping method not showing in checkout
- HELP: Integrating WP with raw PHP code once published button is hit
- Loading class files via autoload method
- WordPress plugin installation
- I would like to use create a function in my custom plugin to tell WP to use a different header
- Getting media library popup in custom plugin admin page
- Create or Update thousands of woocommerce products via PHP
- send_headers don’t work on wordpress multisite
- jQuery function didn’t work in my plugin
- add action wp_head not working
- Why is the Settings API is not saving my array of options
- Sanitizing, Validating and Escaping in WordPress (Plugin)
- Escape when echoed
- Scope for PHP Variables Assigned in functions.php or a plugin
- Plugin exceeds memory limit
- Default Plugin Settings Not Writing to Database
- Write to / remove from default .htaccess file from plugin?
- Plugin Development sqlite or WordPress’ database
- How to cancel WordPress’ action/filter when using OOP with anonymous callback
- WordPress Plugin Page is Loading in Admin Content Container Instead of Separate Page
- Serialize data for wp options
- How to trigger $_GET request within admin plugin page?
- How to generate video out of images via WordPress plugin
- How can I add an options page for my class based plugin?
- How can I get WordPress to save comments in markdown format?
- problems with wordpress and php version 5.3.3-1
- WooCommerce get_price returning wrong price when used via ajax
- How to ‘clone’ a wp plugin to make small changes
- Open Post Thumbnail in New Child Theme File in WordPress
- Where should I save an API key of my user when installing my plugin?
- Is Wrapping intval() Around esc_attr() Redundant for Escaping Input?
- Programatically download a plugin
- Redirecting to home page after login as custom role WordPress
- Add keywords meta to index.php page
- Custom form action to handle data inside a plugin
- Self deactivate plugins after an action occurs
- Pulling data from custom plugin settings using PHP shortcode and Javascript
- How to periodically scrape and cache strings from remote txt files. – My First Plugin
- WP Post Template – Templates in own folder
- Get plugin option in another PHP file
- Avoid class name collision when using third party libraries in plugins?
- wordpress plugin is not activating from widget
- Edit Yoast SEO breadcrumbs output [closed]
- How would I go about creating a user ranked post popularity page?
- How to get specific setting by settings_fields()?
- Redirection of users away from wp-admin (but not administrators)
- Using a custom plugin to capture input data via Ajax and PHP
- code is working properly in Core PHP but writing coding in WordPress
- Creating a custom post type, adding custom meta fields, preventing all future editability of posts of this type
- How to fetch products with the price in a page on woocommerce using a form or live search with php
- Add Plugin options as subpage to Theme options page
- Image upload and download from front-end
- Show admin notice on incorrect value on form field
- wp_remote_get() returns 403 while file_get_contents() does not
- How to output CMB2 select options from repeated groups select elements?
- Creating a Callback URL for WordPress Woocommerce to update Order Status
- 306 MB of wp_options occupied by WordPress SEO Plugin, is that normal? [closed]
- What are the specifics of WordPress development I need to know? [closed]
- Ajax call returning 0
- php page not found for plugin options menu
- How to deal with WordPress and Pocket API to automate content curation on my hosted wordpress blog? [closed]
- WP All Import – Execute Imports
- How to replace WordPress Media Upload Window with user’s device window?
- Conditional attributes and logic per product category
- add tabs in rdp-plugin/includes/settings.php and get settings saved
- How to create a custom post type that contains another custom post type?
- Perform internal redirect in WordPress?
- How to prevent plugins from loading jQuery