Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

How can I add a reset button when using the Settings API?

I've have something like this that's storing my defaults:

$slider_options = get_option( 'nextslider_options' );

 /* Define the array of defaults */ 
$defaults = array(
    'width'             => 0,
    'height'            => 0,
    'effect'            => 'fade',
    'bullets'           => 0,
    'arrows'            => 0,
    'slidelength'       => 4000,
    'animationlength'   => 600
);

$slider_options = wp_parse_args( $slider_options, $defaults );

As a boilerplate I've used the Settings Sandbox.

share|improve this question
    
What exactly is your problem? Checking for the key of the reset button and deleting the option? –  toscho Oct 15 '12 at 7:37
    
Basically I want to add a 'Reset Options' button that will reset the options to their defaults, and I honestly have no idea how to do so. –  bryceadams Oct 15 '12 at 7:39

1 Answer 1

Add a new settings section for the reset button that is called on every tab. In the callback function for the field create the reset button. I would include the submit button here too to get both side by side.

In the validation function delete the whole option if the reset button is present in the request.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.