Persist fields with Setting API

This a really good question – my suggestion is to use transients. For instance, in your validation callback: wpse51669_validation_cb($settings){ //Perform validation checks if( $valid ){ //If settings validate return $validate_settings; } //Otherwise add settings error add_settings_error(‘my-plug-in-settings’,’error-with-xyz’, ‘I fell over’,’error’); //And add the failed settings to a transient set_transient( ‘my-plug-in-settings-invalid’, $settings, 60); return false; } Then … Read more

Adding labels to Setting titles with API

You need to pass last parameter $args, if you want add_settings_field to output <label> use `label_for’ argument, see code snippet below <?php add_settings_field( ‘my-id’, ‘Test Filed’, ‘mamaduka_test_field’, ‘general’, ‘my-section’, array( ‘label_for’ => ‘my-test-field’ ) ); ?>

wordpress settings api add fields

You’re passing the same ID to every single setting of a given type, rather than passing the $setting to the callback. Have a look at how I implement this type of callback in Oenology. function oenology_setting_callback( $option ) { $oenology_options = oenology_get_options(); $option_parameters = oenology_get_option_parameters(); $optionname = $option[‘name’]; $optiontitle = $option[‘title’]; $optiondescription = $option[‘description’]; $fieldtype … Read more

Saving multiple checkboxes with WordPress settings api

The field name should be uwcc_settings[uwcc_checkbox_field_1][], i.e. turn the field into an array. Secondly, when saved as an array, you should use in_array() along with the checked() function. But first, let’s put the uwcc_checkbox_field_1 option’s values into a variable: $uwcc_checkbox_field_1 = isset( $options[‘uwcc_checkbox_field_1’] ) ? (array) $options[‘uwcc_checkbox_field_1’] : []; Now you call checked() like so … Read more

Import / Export Settings API fields values?

I just came across this wp.tuts tutorial a few days ago: Creating a Simple Backup/Restore Settings Feature Lee Pham on Jun 22nd 2012 In this tutorial, I’m going to show you how to create a simple backup/restore feature for your WordPress blog. With this feature, you can backup all options to another place, that you … Read more

do_settings_sections() doesn’t escape quotes

I found the problem. You need to escape the values in the _render functions, using esc_attr, like this: function my_setting_render() { $options = get_option(‘my_option_name’); ?><input name=”my_option_name[my_setting]” value=”<?php echo esc_attr($options[‘my_setting’]);?>”> <?php }

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)