Support

Account

Home Forums Bug Reports Radio Buttons don't retain choices on export/import Reply To: Radio Buttons don't retain choices on export/import

  • No I don’t, but if you want to fix it sooner

    in advanced-custom-fields-pro/api/api-helpers.php

    Look for the function acf_decode_choices and replace it with the following code.

    
    function acf_decode_choices( $string = '' ) {
    	
    	// bail early if already array
    	if( is_array($string) ) {
    		
    		return $string;
    	
    	// allow numeric values (same as string)
    	} elseif( is_numeric($string) ) {
    		
    		// do nothing
    	
    	// bail early if not a string
    	} elseif( !is_string($string) ) {
    		
    		return array();
    	
    	// bail early if is empty string 
    	} elseif( $string === '' ) {
    		
    		return array();
    		
    	}
    	
    	
    	// vars
    	$array = array();
    	
    	
    	// explode
    	$lines = explode("\n", $string);
    	
    	
    	// key => value
    	foreach( $lines as $line ) {
    		
    		// vars
    		$k = trim($line);
    		$v = trim($line);
    		
    		
    		// look for ' : '
    		if( acf_str_exists(' : ', $line) ) {
    		
    			$line = explode(' : ', $line);
    			
    			$k = trim($line[0]);
    			$v = trim($line[1]);
    			
    		}
    		
    		
    		// append
    		$array[ $k ] = $v;
    		
    	}
    	
    	
    	// return
    	return $array;
    	
    }