Support

Account

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

Solving

get_fields(\'option\') no longer returns all option fields.

  • When a lot of options fields need to be pulled I typically use:

    $fields = get_fields(‘option’);

    This has always worked in the past, but as of 5.4.0 nothing is returned.

  • 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

  • @elliot

    Thanks,

    Could you push a release for this? I’m concerned about clients who may have updated their plugin and are now experiencing issues.

    With the number of sites we do it’s not feasible to manually track down and update all the sites affected.

  • Hi all …

    this is a major issue. It took me quiet a while to nail down what the problem was. I came here to file a bug report, too.

    I think this is worth an immediate bug fix release. I was close to push update on the life web site out of good faith … everything would now be broken …

  • Hi guys

    Thanks for the replies.

    I’ll release a version later today

    Cheers
    E

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.