Support

Account

Home Forums Bug Reports ACF PRO 5.4.0 get_fields('options') BUG

Helping

ACF PRO 5.4.0 get_fields('options') BUG

  • I just updated to ACF Pro 5.4.0

    Immediately I noticed that getting all of your options doesn’t appear to work anymore.

    doing something like $options = get_fields(‘options’) will return empty whereas before the update it would return all of the fields in the options page. This breaks the way we use this plugin and had to revert to 3.9.2

  • Hi @nkals722

    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

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

You must be logged in to reply to this topic.