Dynamically Update Key in Associative Array When Saving Settings
Dynamically Update Key in Associative Array When Saving Settings
Dynamically Update Key in Associative Array When Saving Settings
qd_button-settings-group is a settings group, not an option. Use get_option for both items: get_option(‘qd_button_color_list’); get_option(‘qd_button_text_color_list’);
Use http://codex.wordpress.org/Settings_API to add new setting to existed group “general”: add_action( ‘admin_init’, ‘register_my_setting’ ); function register_my_setting() { add_settings_field(‘foo’, ‘Foo settings’, ‘foo_function’, ‘general’, ‘default’, array(‘label_for’ => ‘foo’)); register_setting(‘general’, ‘foo’, ‘foo value’); } function foo_function() { echo ‘<input name=”foo” id=”foo” value=”” class=”regular-text ltr”>’; } You must modify function to validate input and to show saved value.
After even more searching I’ve found an answer to this question here. I used the update_option_{$option_name} action to do what I needed.
Let users to add any number of input fields in the theme option page
Data not saved WordPress Custom Admin Page
A quick and dirty way of doing this is by adding a .htaccess file to the wp-admin directory, with the following content. <FilesMatch “^options-(.*)\.php$”> Order Allow,Deny Deny from all </FilesMatch>
How to change WordPress theme file path to a remote server?
Creating a register settings class that supports extended classes
If you look at the source of add_settings_error(), you will see that the errors are stored in the $wp_settings_errors global. So in your tearDown() function, you can do this: $GLOBALS[‘wp_settings_errors’] = array(); Also, don’t forget to call parent::tearDown(). I sometimes forget, and it can lead to strange behavior. 😉