Support

Account

Home Forums Bug Reports filter acf/settings/save_json/name= seems to not work

Solving

filter acf/settings/save_json/name= seems to not work

  • Dear Colleagues,

    My ACF version is 6.2. My wp version is 6.3. PHP is 8.1

    What i’m trying to achieve is setting a separate save dir to a field group connected to gutenberg block. My code is:

    
    add_filter( 'acf/settings/save_json/name=block_hero', function () {
    	return THEME_DIR . '/blocks/hero';
    } );
    add_filter( 'acf/settings/save_json/key=group_64d215c488698', function () {
    	return THEME_DIR . '/blocks/hero';
    } );
    

    But the filters seems to not work. The problem might be here:
    /var/www/domain11.com/public_html/wp-content/plugins/advanced-custom-fields-pro/includes/local-json.php
    line 413

    
    foreach ( $paths as $path ) {
    				if ( ! is_writable( $path ) ) {
    					continue;
    				}
    				if ( false === $first_writable ) {
    					$first_writable = $path;
    				}
    				$file_to_check = trailingslashit( $path ) . $filename;
    				if ( is_file( $file_to_check ) ) {
    					$file = $file_to_check;
    				}
    			}
    

    it is supposed to take the first path available from $paths but it takes the last

  • Someone else just reported a similar issue. I have not tested this but it appears this new feature may have bugs. You should contact the developers.

  • There should be “break;” after “$file = $file_to_check;”.

  • As far as I can see, this issue should only occur if you’ve got the same ACF group JSON in multiple places, in which case we’ll use the last one.

    If you’ve only got it in one folder, this issue won’t occur.

    We’ll dig in the code here to see if we should still add that break for efficiency, but having the same ACF JSON file in multiple places read or written from ACF is not supported and unexpected things may happen!

  • I do not have the same ACF JSON file in multiple places read or written.

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

You must be logged in to reply to this topic.