1. Doug Stewart
  2. elbee-elgee

Source

elbee-elgee / includes / functions / options.php

Diff from to

File includes/functions/options.php

 				break;
 				case 'subhead':
 				break;
-				case 'imageradio':
-				//$stripped_opts[$key] = ;
-				echo '$std: ';
-				print_r($value['std']);
-				break;
 				default:
 				$stripped_opts[$key] = $value['std'];
 				break;
 function lblg_sanitize_options( $input ){
 	global $lblg_shortname, $lblg_default_options, $lblg_options, $lblg_defaults;
 
-	//var_dump($input);
-	//var_dump($lblg_options);
-	var_dump($lblg_defaults);
+	//print_r($input);
 	$submit = ( ! empty( $input['save']) ? true : false );
 	$reset = ( ! empty( $input['reset']) ? true : false );
 	$tabbed = ( !empty( $input['tab']) ? true : false );
 			// Admin is one screen, no tabs, so all the options are displayed at once.
 			foreach( $valid_input as $key => $value ){
 				$tmp_type = $lblg_default_options[$key]['type'];
-			
+				$tmp_options = $lblg_default_options['contents'][$key]['options'];
+
 				switch( $tmp_type ){
 					case 'text':
 					case 'textarea':
 
 					case 'select':
 					case 'radio':
+					// HERE. THIS NEEDS FIXING FOR IMGRADIO.
 					//case 'imageradio':
-					print_r($input[$key]);
-					echo $key;
 						if( isset($input[$key]) ){
-							$valid_input[$key] = ( in_array( $input[$key], $lblg_default_options[$key]['options']) ? $input[$key] : $valid_input[$key] );
+							$valid_input[$key] = ( in_array( $input[$key], $tmp_options ) ? $input[$key] : $valid_input[$key] );
 						}
 					break;
 
+					case 'imageradio':
+						$tmp_inputs = wp_list_pluck( $tmp_options, 'input' );
+						if( isset($input[$key]) ){
+							$valid_input[$key] = ( in_array( $input[$key], $tmp_inputs ) ? $input[$key] : $valid_input[$key] );
+						}
+					break;
+					
 					case 'checkbox':
 						$valid_input[$key] = (( isset($input[$key]) && ( '1' == $input[$key] ) ) ? '1' : '0' );
 					break;
 				$tab = $input['tab'];
 				foreach( $valid_input as $key => $value ){
 					$tmp_type = $lblg_default_options[$tab]['contents'][$key]['type'];
+					$tmp_options = $lblg_default_options[$tab]['contents'][$key]['options'];
 
 					switch( $tmp_type ){
 						case 'text':
 						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] );
+								$valid_input[$key] = ( in_array( $input[$key], $tmp_options ) ? $input[$key] : $valid_input[$key] );
 							}
 						break;
-
+						
+						case 'imageradio':
+							$tmp_inputs = wp_list_pluck( $tmp_options, 'input' );
+							$valid_input[$key] = ( in_array( $input[$key], $tmp_inputs ) ? $input[$key] : $valid_input[$key] );
+						break;
+						
 						case 'checkbox':
 							$valid_input[$key] = (( isset($input[$key]) && ( '1' == $input[$key] ) ) ? '1' : '0' );
 						break;