Because the order of operations means you’re passing that variable into your checked function before the printf function is even being run, which is what’s parsing the enumerated variables.
Here’s a possible solution haven’t tested it though:
printf(
'<input type="checkbox" id="%2$s" name="%1$s[%2$s]" %3$s)'.
'<label for="%2$s">%4$s</label>' .
'<hr />',
$args['option_name'],
$args['name'],
checked("on", $args['value'], false ),
$args['description']
);
Related Posts:
- How can I save a multiple select array with the settings API for a plug-in options page?
- How can one utilize a variable as a callback function name for add_settings_field
- How to get bool with `get_option()` when already registered setting with type `boolean`
- Settings API – sanitize_callback is not called and it leads to an incorrect behavior
- Why use the Settings API over a new administration menu?
- Implement toggle switch for theme options in settings API
- Set the checkbox as checked by default at options page
- Fatal Error relating to sessions.php
- Whitelisting items from custom options page
- Settings API callback function inserts html quotes from nowhere
- Uploading files using the Settings API
- Get URL Parameters from referer
- Saving plugin settings – ERROR: options page not found
- Get categories names as an array to use it in theme settings
- how to save checkbox data for custom setting?
- register_setting & add_settings_error validation issues with multiple fields
- Reading settings in the home page precisely home.php
- Cloning add_settings_field() with jQuery
- WordPress Settings API unable to save settings
- Settings API form – submit with AJAX
- Custom plugin: how do I call a PHP file if settings option is set to true?
- register_setting not save checkbox
- How to call a WP Class inside my theme
- image on homepage disappeared due to change of permalink name
- WordPress Setting API – There is no field in options.php
- Undefined index notice when using the $args parameter in add_settings_field()
- User registration followed by automatic login
- WordPress and event-driven programming – what is it about?
- How WordPress encrypt password? [duplicate]
- wp_insert_user role not working
- Retrieve POST data from AJAX call
- Adding a custom image upload size and making it selected by default?
- Conditionally loading JavaScript based on the Advanced Custom Fields in the post
- Limit the Excerpt field in WP-Admin in words
- How to change / delete product short description in Woocommerce
- How do I add HTML to a PHP function [closed]
- register_activation_hook isn’t adding table to DB
- how to get the value of time left for a transient
- wp_mail not sending
- PHP Date display as time ago
- Pass get_option value to an array [closed]
- Strip characters, Including spaces, for tel: link
- Can’t get page content in WordPress
- how could I load a different template part by page
- Notice : add_theme_support( ‘post-formats’ ) was called incorrectly [closed]
- How to call plugin function per site in a multisite?
- PHP, Creating a dynamic variable
- How to Internationalize WordPress – Extract strings with textdomains, per textdomain individually
- How to make own crop image function for WordPress plugin
- Auto 301 to full post permalink? (using : /archive/%post_id% to %post_name% )
- Showing latest post without 301 redirect
- Display custom field on 404 page outside loop
- Pagination broken on is_front_page()
- Why doesn’t PhotoSmash plugin play well with wp_query?
- get_the_ID() doesnt work
- Integrating Yii2 and WordPress
- PHP E_WARNING being shown despite php.ini [closed]
- After disabling WPML multi currency, the currency is still handled by the WPML
- preg_replace on all HTML content in WordPress
- GravityForms Limit Submission Per Time Period by User or IP by 30 minutes?
- Post class only applying to first excerpt; why?
- PHP Warning: preg_match() expects & PHP Warning: strip_tags()
- Prevent post from being published and show error
- how to get wordpress page url php code [duplicate]
- Problems updating nested ACF field groups
- how to pull all usernames from a custom user role, then do some array modification
- Can I ‘order by’ date that is in a text field?
- Unable to delete related media attachments with deleted post
- How to retrieve taxonomy Metabox fields in frontend
- separate list of programs in html/javascript coming from php
- Is there a PHP function that will return the block ID generated by WordPress?
- retrieve “Link Color” value
- Creating a Function and Call It
- Adding column to wpex_users
- Issues adding Recaptcha v3 to WordPress Registration
- WordPress ajax filter returning all posts when it should be filtering by category
- WooCommerce Quantity in Dropdown menu instead of clasic [closed]
- Trying To Call a Dynamic Email Address
- Hide comment notification number and buttons in wp backend
- Create html tree sitemap
- meta field for numerous links
- Custom HTML form using PHP – help with ajax/username validation
- Where can I find the declaration of `$_wp_theme_features`?
- redirect 301 with special character like WIX site “#!”
- How I can add div to menu?
- Display tab title as ‘blog tagline | blog title’
- Conditional statement within WP SQL query
- How to print redirected query string variables to the page?
- Multiple URL from Custom post name
- Admin-area broken through weird issues
- Display a query with multiple post types and same relationship on a single page
- Get string from array and start loop [closed]
- Custom query_posts() parameter
- wp_link_pages return value even when is condition inside if statement
- How to quickly/easily make an analysis (reverse engineering) of WordPress?
- New to wordpress. Need Help with templates [closed]
- Background Tasks in a WP Cronjob?
- How to execute a shortcode within a custom field?
- using custom pages for myaccount in woocommerce
- Putting form result in my database