Commits

Doug Stewart committed 404ac89

Okay, that option handling w/tabbed admin was WAY harder than it needed to be.

Too complicated, as well.

  • Participants
  • Parent commits c9aabaf

Comments (0)

Files changed (2)

includes/functions/admin.php

  * @param string $shortname 
  */
 function lblg_options_walker( $options, $default_options, $shortname ){
-	
-	echo "<h2>Options</h2>";
-	print_r($options);
-	
+
 	$section = '';
 	$lblg_options_group = $shortname . '_theme_options';
 

includes/functions/options.php

  * @return  array
  */
 function lblg_sanitize_options( $input ){
-	global $lblg_shortname, $lblg_default_options, $lblg_options;
-
+	global $lblg_shortname, $lblg_default_options, $lblg_options, $lblg_defaults;
+	
 	$submit = ( ! empty( $input['save']) ? true : false );
 	$reset = ( ! empty( $input['reset']) ? true : false );
 		
 			$valid_input = lblg_get_options_from_defaults( $lblg_default_options );
 		}
 
-		foreach( $valid_input as $key => $value ){
-			$tmp_type = $lblg_default_options[$key]['type'];
+		if( !isset( $lblg_default_options['tabs'] ) ){
+			foreach( $valid_input as $key => $value ){
+				$tmp_type = $lblg_default_options[$key]['type'];
 			
-			switch( $tmp_type ){
-				case 'text':
-				case 'textarea':
-					if( isset($input[$key]) ){
-						$valid_input[ $key ] = wp_kses_post( $input[ $key ] );
+				switch( $tmp_type ){
+					case 'text':
+					case 'textarea':
+						if( isset($input[$key]) ){
+							$valid_input[ $key ] = wp_kses_post( $input[ $key ] );
+						}
+					break;
+
+					case 'select':
+					case 'radio':
+						if( isset($input[$key]) ){
+							$valid_input[$key] = ( in_array( $input[$key], $lblg_default_options[$key]['options']) ? $input[$key] : $valid_input[$key] );
+						}
+					break;
+
+					case 'checkbox':
+						$valid_input[$key] = (( isset($input[$key]) && ( '1' == $input[$key] ) ) ? '1' : '0' );
+					break;
+				
+					default:
+					break;
+				}
+			}
+		} else {
+			foreach( $lblg_default_options['tabs'] as $tab ) {
+				foreach( $valid_input as $key => $value ){
+					$tmp_type = $lblg_default_options[$tab]['contents'][$key]['type'];
+
+					switch( $tmp_type ){
+						case 'text':
+						case 'textarea':
+							if( isset($input[$key]) ){
+								$valid_input[ $key ] = wp_kses_post( $input[ $key ] );
+							}
+						break;
+
+						case 'select':
+						case 'radio':
+							if( isset($input[$key]) ){
+								$valid_input[$key] = ( in_array( $input[$key], $lblg_default_options[$tab]['contents'][$key]['options']) ? $input[$key] : $valid_input[$key] );
+							}
+						break;
+
+						case 'checkbox':
+							$valid_input[$key] = (( isset($input[$key]) && ( '1' == $input[$key] ) ) ? '1' : '0' );
+						break;
+
+						default:
+						break;
 					}
-				break;
+				}
+			}
+		}
+	}
 
-				case 'select':
-				case 'radio':
-					if( isset($input[$key]) ){
-						$valid_input[$key] = ( in_array( $input[$key], $lblg_default_options[$key]['options']) ? $input[$key] : $valid_input[$key] );
-					}
-				break;
-
-				case 'checkbox':
-					$valid_input[$key] = (( isset($input[$key]) && ( '1' == $input[$key] ) ) ? '1' : '0' );
-				break;
-				
-				default:
-				break;
-			}
-		}		
-	}
-		
 	return $valid_input;
 }