Esempio n. 1
0
 function __construct()
 {
     $this->themeOptions = WIP_get_options();
     #build header
     $this->WIPanel_create_header();
     #build body (options sections)
     $this->WIPanel_create_content();
     #build footer
     $this->WIPanel_create_footer();
 }
function WIPanel_ajax_reset_function()
{
    global $wpdb;
    # get the array options,  check panel.options.php
    $options = WIP_get_options();
    #check the type
    if (isset($_POST['type']) && $_POST['type']) {
        $save_type = $_POST['type'];
    } else {
        $save_type = null;
    }
    #get the section, for reset all setting this is should be "all"
    if (isset($_POST['data']) && $_POST['data']) {
        $section = $_POST['data'];
    }
    #check again, just to make sure
    if ($save_type == 'reset') {
        #first level array, let get into inside :)
        foreach ($options as $parent => $ops) {
            #if not all, that's mean user only reset the spesific section
            if ($section != 'all') {
                #let's go into deep array!!!!
                if ($parent == $section) {
                    foreach ($ops['options'] as $a => $b) {
                        foreach ($b as $c => $d) {
                            if ($c == "id") {
                                delete_option($d);
                            }
                        }
                    }
                } else {
                    if (isset($ops['child'])) {
                        foreach ($ops['child'] as $childName => $childKey) {
                            if ($childName == $section) {
                                foreach ($childKey as $cn => $cv) {
                                    foreach ($cv as $kl => $vb) {
                                        if ($kl == "id") {
                                            delete_option($vb);
                                        }
                                    }
                                }
                                /** end for each; */
                            }
                        }
                    }
                }
                if ($section == 'general_settings') {
                    delete_option('height_of_bd_logo');
                }
            } else {
                #if all - then delete'em all
                #let's go into deep array!!!!
                foreach ($ops['options'] as $a => $b) {
                    foreach ($b as $c => $d) {
                        if ($c == "id") {
                            delete_option($d);
                        }
                    }
                }
                delete_option('height_of_bd_logo');
            }
        }
    }
    #let's sent the right message into the ajax
    if ($section == 'all') {
        die('2');
    } else {
        die('1');
    }
}