The problem is that in your calls to selected() you haven’t set the 3rd parameter to false. For both selected() and checked() if you don’t do this it will echo the attribute immediately, which won’t work properly if you’re using it inside a concatenated string.
So change:
selected( get_option('myplugin_admin_bar'), 1 )
To:
selected( get_option('myplugin_admin_bar'), 1, false )
Related Posts:
- Performance of several get_option() calls
- “Error: Options Page Not Found” on Settings Page Submission for an OOP Plugin
- Is get_option function cached?
- What are the advantages to the Settings API?
- Where to store plugin settings fields
- What’s the best method for emptying an option created with the Settings API?
- Why won’t register_setting() create a setting?
- Extend plugin options page
- Can I use the different settings sections over different pages using the save options group?
- Correct way check nonce (security) using old Options API
- How to add settings subpage from a plugin to a settings page created in theme?
- Remove Internal Style Sheet if no Value Provided?
- Custom delete option button in plugin settings
- Prevent invalid or empty values from being saved to the database and retain the form field values upon error
- Update problem with update_option() in combination with register_setting()
- Issue on Checkbox with Custom Option Page
- Settings API: Setting default option via ‘get_option’ fails
- What could cause a WP Option to get truncated?
- update_option() passing empty array() but still updating
- Plugin setting page – update_option problem
- add_settings_error on validating plugin options API
- How do I build a settings panel under the plugin
- Add_menu_page and saving settings
- Options don’t save, validation callback not executed
- Settings API not Saving to Database or Display
- Admin Message after Plugin Option Updated
- the function do_settings_section($page) generate error “Allowed memory size of … bytes exhausted”
- framework for plugin/theme options panel? [closed]
- Settings API with arrays example
- How do I add CSS options to my plugin without using inline styles?
- How come `wp_options` table does not have an index on `autoload`?
- Update Option Stored in Multi-Dimensional Array
- Adding Widget form fields dynamically
- Is get_option() faster than accessing get_transient()?
- How to Use Checkbox in Custom Option Page Using The Setting API
- How should one implement add_settings_error on custom menu pages?
- Accessing plugin settings in gutenberg
- Releasing new plugin version, how to rename old options keys?
- WordPress updates defined vs add_filter?
- Creating Settings Page with dropdowns for Plugin
- How to properly sanitize strings for update_option()
- How to add a new plugin page under desired Options page?
- Save Plugin Version Number as Option?
- Which to use to execute code during the saving of a plugin settings page?
- Nonce in settings API with tabbed navigation
- Custom plugin settings: clicking “save changes” does not display success message
- How to use the settings API to set multidimensional arrays
- How do I handle multiple Submit buttons in plugin’s option page?
- Deletion of shared options using uninstall.php
- Add default value from selection
- Settings API not saving
- Multiple checkbox doesn’t work in wordpress settings api
- Custom plugin: how do I call a PHP file if settings option is set to true?
- Sanitization and validation input fields – Settings API
- Hide / show settings field based on other field’s value
- Plugins Settings page not updating
- Integrating colorpicker into array field
- How to save the option’s new values plus old value without overwrite old one
- How to create plugin settings page for each admin user?
- WordPress Boilerplate Plugin doesn’t see callback functions for add_settings_field and add_settings_section
- How do I add a textarea (multirow) option to my WordPress plugin?
- How Can I Update wp_enqueue_scripts () From WordPress Option Page Radio Buttons
- Cannot save settings value
- Select field value not returned after saving changes
- add_option_{$option} action hook not being called
- Implementing Select2 plugin into WordPress
- Array/List Edit in Backend
- How to Modify My Plugin’s Admin Settings so that the Plugin can be Added to a Specific Page?
- Plugin options page: grouping checkboxes
- What should I use instead of get_blog_option?
- Tie specific functions to options-update for limiting API requests
- From my Plugin Settings Page use check boxes to load specific css files (e.g. Bootstrap / Foundation)
- When using an options array the Settings API isn’t creating the database record
- Dropdown pages in Settings API
- Can’t switch theme after activation
- Generate activation url
- Validating values using Settings API?
- Settings API with arrays example
- Plugin settings checkbox
- update_option() updating the option with an empty value?
- the correct way to use options from settings page [closed]
- Updating Style From WP Options Setting Page
- Plugin options page – save two related options as one entry
- Combo/Drop down box on plugin settings page that allows additional options to be added
- Saving multiple fields as array
- Menu_slug used for creating options page
- How to delete all the options in an option group
- WordPress Plugin default option
- Modify a Themes Appearance >> Header admin screen from a plugin
- Update custom settings field in plugin
- Update option hook not firing
- How to use register_setting()
- WordPress plugin options page not saving options, no errors
- move setting data from wordpress api to codestar freamwork
- update_option with array_push adding mutiple copies
- Plugin forms overwrite each other’s options
- When to store store plugin options as a single database record?
- How can I use the WordPress Settings API to create a settings page for my plugin?
- Theme / Divi change visitor css and site logo and all site urls based on REQUEST_URI non logged in wp user
- adding an options menu that allows saving multiple sets of said options