Support

Account

Home Forums Bug Reports get_fields(\'option\') no longer returns all option fields. Reply To: get_fields(\'option\') no longer returns all option fields.

  • Hi @influencebydesign

    Thanks for the bug report.

    This issue has now been fixed. Please re-download the plugin files and copy across the api/api-template.php file or make the following code change on line 267:

    
    	} else {
    		
    		$rows = $wpdb->get_results($wpdb->prepare(
    			"SELECT option_name, option_value FROM $wpdb->options WHERE option_name LIKE %s OR option_name LIKE %s",
    			$post_id . '_%' ,
    			'_' . $post_id . '_%' 
    		), ARRAY_A);
    		
    		if( !empty($rows) ) {
    			
    			foreach( $rows as $row ) {
    				
    				// vars
    				$name = $row['option_name'];
    				$prefix = $post_id . '_';
    				$_prefix = '_' . $prefix;
    				
    				
    				// remove prefix from name
    				if( strpos($name, $prefix) === 0 ) {
    					
    					$name = substr($name, strlen($prefix));
    					
    				} elseif( strpos($name, $_prefix) === 0 ) {
    					
    					$name = '_' . substr($name, strlen($_prefix));
    					
    				}
    				
    				$meta[ $name ][] = $row['option_value'];
    				
    			}
    			
    		}
    		
    	}
    

    Cheers
    E