Support

Account

Home Forums ACF PRO Technical differences between free and Pro versions of ACF?

Solved

Technical differences between free and Pro versions of ACF?

  • Hi, I develop plugins for WordPress. After I added the support for the free ACF plugin in one of my plugins a user reported that would not work on his site. The reason was that he used the ACF Pro version.

    I compared the codes of both ACF versions and found significant differences. One difference is that ACF free stores field objects in the postmeta table, while ACF Pro stores them in the post table.

    I want to add support for the Pro version and want to get a safe way to check which of the two versions of ACF is running on the server. Which check can you recommend?

  • 
    $acf_version = acf_get_setting('version');
    

    returns the ACF verion

  • It raises an error if the free ACF plugin is installed.

  • 
    if (!function_exists('')) {
      // assume ACF Version 4
    } else {
      $acf_version = acf_get_setting('version');
    }
    

    I think that there is a similar function in ACF4, but I don’t know what it is.

  • Do you mean function_exists( 'acf_get_setting' )?

    Since I do not need the version number but the information whether the installed ACF plugin is the free version or the PRO version I built that code:

    $is_acf_free = $is_acf_pro = false;
    if ( class_exists( 'acf' ) {
    	if ( defined( 'ACF_PRO' ) ) {
    		$is_acf_pro = true;
    	} else {
    		$is_acf_free = true;
    	}
    }
  • There will soon, or there is supposed to be, a free version of ACF5 on WP. This free version of the plugin will include this function. So at that point, the existence of this function won’t really tell you if it’s the free or pro version that’s installed.

    Exactly what functionality do you need to change depending on if it’s the free or pro version? If you give me more info on that maybe I can suggest a better way to do the detection.

  • I want to get the stored fields, post-independent. There is no function like get_all_registered_fields() so I wrote something like that. And there the differences between the free and the PRO versions matter. See my first post. There I described the reason.

  • Actually, in ACF 5 there is a function to get all of the field groups and then using each field group you can get all of the fields for each group. The functions are not documented but they are acf_get_field_groups() and acf_get_fields(). If you search the ACF code you can find them.

    In ACF 4 this could be done with filters apply_filters('acf/get_field_groups', array()) and apply_filters('acf/field_group/get_fields', array(), $group_id). These were never documented either, but if you search the code you will find them.

    Yes, at one time the fields in a group were stored as post meta for each of the field groups. This was changed because it caused an issue when nesting repeaters.

    In ACF 4 the version can be gotten using a filter as well apply_filters('acf/get_info', 'version').

    I think the version number will be important to you, like I said, there is supposed to be a free version of ACF 5 released and knowing the version will be far more important since you’ll need to base what you do on that and not necessarily on if it is the free or pro version.

  • I would not rely on the version number so I wrote that

    if ( class_exists( 'acf' ) ) {
    	$all_fields = array();
    	if ( defined( 'ACF_PRO' ) ) {
    		$field_groups = acf_get_field_groups();
    		foreach ( $field_groups as $f_group ) {
    			$group_fields = acf_get_fields( $f_group );
    			foreach ( $group_fields as $f ) {
    				$all_fields[] = $f;
    			}
    		}
    	} else {
    		$field_groups = apply_filters( 'acf/get_field_groups', array() );
    		foreach ( $field_groups as $f_group ) {
    			$group_fields = apply_filters( 'acf/field_group/get_fields', array(), $f_group[ 'id' ] );
    			foreach ( $group_fields as $f ) {
    				$all_fields[] = $f;
    			}
    		}
    	}
    	var_dump( $all_fields );
    }
Viewing 9 posts - 1 through 9 (of 9 total)

The topic ‘Technical differences between free and Pro versions of ACF?’ is closed to new replies.