How to add a secondary button to a settings page with a custom action?

I have written a plugin that interfaces with a third-party mailing API. I have created a settings page for my plugin that includes two buttons: a submit button created with submit_button() which saves the form a “test settings” button that should use the current values from the form without saving them This is what I … Read more

How to validate register settings array

I would like to know how to perform a proper validation with the register_setting() callback function. Here is a sample part of my code I want to work with: register_setting( ‘wpPart_options’, ‘wpPart_options’, array( &$this, ‘wpPartValidate_settings’ ) ); $this is an array of objects. And here is the content of my wpPartValidate_settings(); function. public function wpPartValidate_settings( … Read more

Is it safe to post form data via Ajax to the settings api? Am I missing something?

In my WordPress Admin, I have my theme options set-up using the Settings API. I am trying to save the theme options form using Ajax so that the page does not refresh. The only thing i needed to add was this jQuery code : $(“#cgform”).submit(function() { var form_data = $(‘#cgform input’).serializeArray(); $.post( ‘options.php’, form_data ).error(function() … Read more

Settings API – generating field value based on a different field?

I store my themes settings using Settings API. If I create a new setting using add_settings_field() is it possible to create another setting that will be based on the first one? Why? Imagine I have three settings: main_color lighter_color darker_color User opens Theme Options page and sets main_color to #444. Now I want lighter_color and … Read more

How do I save custom options on the options page ‘Reading’?

I want to add some options to the default “Reading” options page. The code I have is: add_settings_section(“section_share”, __(“Sharing & Publishing”, “honeycomb-wp”), __NAMESPACE__.”\\displaySection”, “reading”); register_setting(“group_share”, “honeycomb-reading-share”); register_setting(“group_share”, “honeycomb-reading-tweet”); register_setting(“group_share”, “honeycomb-reading-delay”); register_setting(“group_share”, “honeycomb-reading-footer”); add_settings_field(“honeycomb-reading-share”, __(“Share”, “honeycomb-wp”), __NAMESPACE__.”\\displayField_share”, “reading”, “section_share”); add_settings_field(“honeycomb-reading-tweet”, __(“Tweet”, “honeycomb-wp”), __NAMESPACE__.”\\displayField_tweet”, “reading”, “section_share”); add_settings_field(“honeycomb-reading-delay”, __(“Delay”, “honeycomb-wp”), __NAMESPACE__.”\\displayField_delay”, “reading”, “section_share”); add_settings_field(“honeycomb-reading-footer”, __(“Footer in RSS”, “honeycomb-wp”), … Read more