1){ $query_inner .= ' OR '; } if($option_type == 'multicheck'){ $multicount = 0; foreach($option['options'] as $option_key => $option_option){ $multicount++; if($multicount > 1){ $query_inner .= ' OR '; } $query_inner .= "option_name = '" . $option_id . "_" . $option_key . "'"; } } else if(is_array($option_type)) { $type_array_count = 0; foreach($option_type as $inner_option){ $type_array_count++; $option_id = $inner_option['id']; if($type_array_count > 1){ $query_inner .= ' OR '; } $query_inner .= "option_name = '$option_id'"; } } else { $query_inner .= "option_name = '$option_id'"; } } } //When Theme Options page is reset - Add the of_options option if($page == 'siteoptions'){ $query_inner .= " OR option_name = 'of_options'"; } //echo $query_inner; $query = "DELETE FROM $wpdb->options WHERE $query_inner"; $wpdb->query($query); } /*-----------------------------------------------------------------------------------*/ /* Build the Options Page /*-----------------------------------------------------------------------------------*/ function siteoptions_options_page(){ $options = get_option('of_template'); $themename = get_option('of_themename'); ?>
Options Updated
Options Reset
options WHERE option_name LIKE '$id'"; $wpdb->query($query); } elseif ($save_type == 'options' OR $save_type == 'framework') { $data = $_POST['data']; parse_str($data,$output); //print_r($output); //Pull options $options = get_option('of_template'); foreach($options as $option_array){ $id = $option_array['id']; $old_value = get_option($id); $new_value = ''; if(isset($output[$id])){ $new_value = $output[$option_array['id']]; } if(isset($option_array['id'])) { // Non - Headings... $type = $option_array['type']; if ( is_array($type)){ foreach($type as $array){ if($array['type'] == 'text'){ $id = $array['id']; $std = $array['std']; $new_value = $output[$id]; if($new_value == ''){ $new_value = $std; } update_option( $id, stripslashes($new_value)); } } } elseif($new_value == '' && $type == 'checkbox'){ // Checkbox Save update_option($id,'false'); } elseif ($new_value == 'true' && $type == 'checkbox'){ // Checkbox Save update_option($id,'true'); } elseif($type == 'multicheck'){ // Multi Check Save $option_options = $option_array['options']; foreach ($option_options as $options_id => $options_value){ $multicheck_id = $id . "_" . $options_id; if(!isset($output[$multicheck_id])){ update_option($multicheck_id,'false'); } else{ update_option($multicheck_id,'true'); } } } elseif($type != 'upload_min'){ update_option($id,stripslashes($new_value)); } } } } die(); } /*-----------------------------------------------------------------------------------*/ /* Cases fpr various option types /*-----------------------------------------------------------------------------------*/ function siteoptions_machine($options) { $counter = 0; $menu = ''; $output = ''; foreach ($options as $value) { $counter++; $val = ''; //Start Heading if ( $value['type'] != "heading" ) { $class = ''; if(isset( $value['class'] )) { $class = $value['class']; } //$output .= '
'."\n".'
'."\n"; $output .= '
'."\n"; $output .= '

'. $value['name'] .'

'."\n"; $output .= '
'."\n" . '
'."\n"; } //End Heading $select_value = ''; switch ( $value['type'] ) { case 'text': $val = $value['std']; $std = get_option($value['id']); if ( $std != "") { $val = $std; } $output .= ''; break; case 'select': $output .= ''; break; case 'fontsize': /* Font Size */ $val = $default['size']; if ( $typography_stored['size'] != "") { $val = $typography_stored['size']; } $output .= ''; break; case "multicheck": $std = $value['std']; foreach ($value['options'] as $key => $option) { $tt_key = $value['id'] . '_' . $key; $saved_std = get_option($tt_key); if(!empty($saved_std)) { if($saved_std == 'true'){ $checked = 'checked="checked"'; } else{ $checked = ''; } } elseif( $std == $key) { $checked = 'checked="checked"'; } else { $checked = ''; } $output .= '
'; } break; case 'textarea': $cols = '8'; $ta_value = ''; if(isset($value['std'])) { $ta_value = $value['std']; if(isset($value['options'])){ $ta_options = $value['options']; if(isset($ta_options['cols'])){ $cols = $ta_options['cols']; } else { $cols = '8'; } } } $std = get_option($value['id']); if( $std != "") { $ta_value = stripslashes( $std ); } $output .= ''; break; case "radio": $select_value = get_option( $value['id']); foreach ($value['options'] as $key => $option) { $checked = ''; if($select_value != '') { if ( $select_value == $key) { $checked = ' checked'; } } else { if ($value['std'] == $key) { $checked = ' checked'; } } $output .= '' . $option .'
'; } break; case "checkbox": $std = $value['std']; $saved_std = get_option($value['id']); $checked = ''; if(!empty($saved_std)) { if($saved_std == 'true') { $checked = 'checked="checked"'; } else{ $checked = ''; } } elseif( $std == 'true') { $checked = 'checked="checked"'; } else { $checked = ''; } $output .= ''; break; case "upload": $output .= siteoptions_uploader_function($value['id'],$value['std'],null); break; case "upload_min": $output .= siteoptions_uploader_function($value['id'],$value['std'],'min'); break; case "color": $val = $value['std']; $stored = get_option( $value['id'] ); if ( $stored != "") { $val = $stored; } $output .= '
'; $output .= ''; break; case "images": $i = 0; $select_value = get_option( $value['id']); foreach ($value['options'] as $key => $option) { $i++; $checked = ''; $selected = ''; if($select_value != '') { if ( $select_value == $key) { $checked = ' checked'; $selected = 'of-radio-img-selected'; } } else { if ($value['std'] == $key) { $checked = ' checked'; $selected = 'of-radio-img-selected'; } elseif ($i == 1 && !isset($select_value)) { $checked = ' checked'; $selected = 'of-radio-img-selected'; } elseif ($i == 1 && $value['std'] == '') { $checked = ' checked'; $selected = 'of-radio-img-selected'; } else { $checked = ''; } } $output .= ''; $output .= ''; $output .= '
'. $key .'
'; $output .= ''; $output .= '
'; } break; case "info": $default = $value['std']; $output .= $default; break; case "heading": if($counter >= 2){ $output .= '
'."\n"; } $jquery_click_hook = ereg_replace("[^A-Za-z0-9]", "", strtolower($value['name']) ); $jquery_click_hook = "of-option-" . $jquery_click_hook; $menu .= '
  • '. $value['name'] .'
  • '; $output .= '

    '.$value['name'].'

    '."\n"; break; } // if TYPE is an array, formatted into smaller inputs... ie smaller values if ( is_array($value['type'])) { foreach($value['type'] as $array){ $id = $array['id']; $std = $array['std']; $saved_std = get_option($id); if($saved_std != $std){$std = $saved_std;} $meta = $array['meta']; if($array['type'] == 'text') { // Only text at this point $output .= ''; $output .= ''.$meta.''; } } } if ( $value['type'] != "heading" ) { if ( $value['type'] != "checkbox" ) { $output .= '
    '; } if(!isset($value['desc'])){ $explain_value = ''; } else{ $explain_value = $value['desc']; } $output .= '
    '. $explain_value .'
    '."\n"; $output .= '
    '."\n"; } } $output .= '
    '; return array($output,$menu); } /*-----------------------------------------------------------------------------------*/ /* File Uploading /*-----------------------------------------------------------------------------------*/ function siteoptions_uploader_function($id,$std,$mod){ $uploader = ''; $upload = get_option($id); if($mod != 'min') { $val = $std; if ( get_option( $id ) != "") { $val = get_option($id); } $uploader .= ''; } $uploader .= '
    Upload Image'; if(!empty($upload)) {$hide = '';} else { $hide = 'hide';} $uploader .= 'Remove'; $uploader .='
    ' . "\n"; $uploader .= '
    ' . "\n"; if(!empty($upload)){ $uploader .= ''; $uploader .= ''; $uploader .= ''; } $uploader .= '
    ' . "\n"; return $uploader; } ?>