Settings API: Two update notices after saving settings?

The issue, as determined by Chip Bennett in our conversation above, was related to the settings_errors() call. The problem was that I didn’t specify a setting for which I wanted to display either errors or update notices mostly because the tutorial from which I was working didn’t either. By specifying that setting, I see one … Read more

Multiple fields with add_settings_field callback

It depends on what the fields do. If they are all of the same type – a label and a text input for example – then, yes, that’s a good approach. You can just use the sixth parameter to create a different output. But if these fields are different, need different escaping methods (esc_textarea() versus … Read more

Storing HTML in wp_options

Given that you are dealing with email, I’d run wp_kses() with a very limited $allowed_html array similar to this sample from the Codex: array( ‘a’ => array( ‘href’ => array(), ‘title’ => array() ), ‘br’ => array(), ’em’ => array(), ‘strong’ => array(), ); HTML rendering is even more squirrelly in email readers than browsers … Read more

What is the best way to save and retrieve Multiple rows of data with the Settings API?

Because you mentioned the Settings API I assume you want to do AJAX from the admin area of wordpress. You have some research to do, so my answer is to check out these: http://dobsondev.com/2015/06/12/wordpress-ajax-example/ https://pippinsplugins.com/custom-database-api-reasons-for-custom-tables-and-an-api/ That should get you where you need to go. Happy WordPressing!

Why this global array is returning NULL from a callback function

The problem here is that you never created $ppk_fields as a global variable. $ppk_fields = [ ‘field 1’ => [ ‘title’ => ‘Fieald One’, ‘type’ => ‘text’, ‘section’ => ‘section_1’, ‘default’ => ‘default’ ] ]; Here we have a variable that is created normally, and obeys normal scoping rules. It isn’t a global variable, and … Read more

WordPress setting with select – where is my mistake?

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, … Read more

Settings API – sanitize_callback is not called and it leads to an incorrect behavior

If I take the value sanitize_callback out of the argument array completely, everything works as desired, so error-free. Yes, and that’s because you used the wrong callable syntax which then causes PHP to use a global function named sanitize_options instead of the method/function of the same name in your class (i.e. Faqdesk_Settings::sanitize_options()). So to solve … Read more

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