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.

So I managed to get the issue of headers working properly in my theme, but I have a new issue with options though.

I have the three following pieces of code that work in the order I paste them:

Peice 1

All we do is capture that you hit the reset button, call the reset function, when we come back if the option aisis_reset is set to 'true' we then render a message and then update the option to false. pretty simple.

        $theme = AisisCore_Factory_Pattern::create('AisisCore_Template_Builder');

        if(isset($_POST['aisis_reset'])){
            $theme->reset_theme_options();
        }

        $options = get_option('aisis_reset');
        if($options == 'true'){
            echo '<div class="alert alert-success"><strong>SUCCESS!!!!</strong> All Options have been reset! You can start again!</div>';
            update_option('aisis_reset', 'false');
        }

piece 2

All we do here is say, do we have multiple options, if so delete each one, update the option to 'true' and redirect, else if we only have one, delete it, update the option and redirect. redirecting is done by getting the current url for your page and essentially redirecting to it. (IMO better then JS redirect.)

public function reset_theme_options(){
    if(isset($this->_theme_option['admin_options'])){
        foreach($this->_theme_option['admin_options'] as $option_name=>$value){
            if($value != false){
                delete_option($option_name);
            }
        }

        $this->_update_option();
        $http = new AisisCore_Http_Http();
        wp_safe_redirect($http->get_current_url());

    }else{
        delete_option($this->_options['admin_options']);
        $this->_update_option();
        $http = new AisisCore_Http_Http();
        wp_safe_redirect($http->get_current_url());
    }

}

piece 3 (final)

For now I have hard coded an option in for testing. all we do is say does this option exist? no, create it and set it to true, else set it to true.

protected function _update_option(){
    if(get_option('aisis_reset')){
        $option = get_option('aisis_reset');
        update_option('aisis_reset', 'true');
    }else{
        add_option('aisis_reset', 'true');
    }
}

So with that in hand:

  1. Why Dose, upon a "redirect" the option, aisis_reset, never == 'true'? it's always false. Is it because I am redirecting? I assumed that if I save the option BEFORE I redirect then everything is fine.
share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

Maybe a little debugging will help. Try this in your piece no.1

$theme = AisisCore_Factory_Pattern::create('AisisCore_Template_Builder');

        if(isset($_POST['aisis_reset'])){
            $theme->reset_theme_options();
        }

        $options = get_option('aisis_reset');

        print_r( $options ); //outputs $options value
        wp_die(); //will halt further process

        if($options == 'true'){
            echo '<div class="alert alert-success"><strong>SUCCESS!!!!</strong> All Options have been reset! You can start again!</div>';
            update_option('aisis_reset', 'false');
        }

What value do you get?

share|improve this answer
    
false, How ever doing the same thing in peice number 2, I get true. If I remove update_option('aisis_reset', 'false'); then I get the message..... –  TheWebs Mar 13 '13 at 18:23
add comment

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.