Support

Account

Home Forums ACF PRO Updates & ACF PRO distribution

Solved

Updates & ACF PRO distribution

  • What is the right way to distribute ACF PRO within a custom theme regarding to the licence and updates ?
    I’ve included ACF PRO in a custom theme by including files and everything works and my client doesn’t see ACF plugin (That’s what I wanted).
    But what about updates ? Can I include my licence key in the files, and especially is it knowledgeable ?

    Thanks

  • Is this a premium theme that you are selling? It sounds more like it’s a one off theme for a specific client.

    There rules are:

    1) You cannot include ACF Pro on a free theme (in a repository like WordPress)
    2) You can include ACF Pro in a premium theme
    3) You can include ACF Pro in one off themes build for clients

    In the case of 2, a premium theme, you cannot include your license key. You must update ACF Pro and then supply and updated version of your theme…. if updates is something that you provide.

    In the case of 3, a one of theme. You would activate your license and allow the client to update ACF Pro.

  • Sorry for my bad explanations :
    It’s a unique website made for a unique client. I included ACF as files and activate it with a must use plugin because I don’t want that my client see that I use ACF plugin.
    So, how can I make it updatable, but not by the client ?

  • You can’t since WP doesn’t know it’s installed. All I create is unique custom themes form clients and I install ACF the standard way. 99% of the time I am the one maintaining the site and doing the updates.

    I am a firm believer in not marrying clients and I want them free to move on if they choose to do so, so I don’t hide anything from them.

    My suggestion would be to move it into the plugins folder if you’re not going to be maintaining the site. There is nothing wrong with using ACF to create a custom theme.

  • Ok. Thanks for the answer.
    I’m not sure about what I’m gonna do with this client : I will be the one maintaining the website so I thought at first that I could manually update files each time there’s an update. But what you say makes me think…

  • Just last one : It would be a lot of work for me for this project because, first of all, it’s the end of the development, and most of all, because I use polylang for languages and I loop on every language by declaring my fields exported in PHP in functions. If I remove php fields declarations from my mu-plugin and install ACF PRO as a normal plugin, I don’t know how I will loop on languages to declare them.

  • Since you’ll be maintaining the site, at least for now, I’d leave it where it is and do the updates manually as part of whatever maintenance you plan on doing.

    Putting the field declarations in the MU plugin folder is a bit of a problem because that means you must have ACF there as well. MU plugins are loaded before those in the plugins folder, actually before some anything else. In order to move it take a significant amount of work, more than likely since you’d also need to put all your code into another plugin and alter it to use the correct hooks for setting up your fields, which I’m guessing you didn’t do since you could guarantee that ACF was loaded before creating your field groups.

    Having ACF in the MU folder basically means that updating manually is the only choice that there will ever be, so if you ever need this to not be the case then it will mean a bit of a rebuild.

  • Ok. I think I’ve understood everything especially that I need to change my way of using ACF in future projects. There are many tutos about how to do something or another with acf but there is not a lot of about how to use it properly.

    Thanks a lot πŸ™‚

  • I’ve found that with anything WP it’s a matter of understanding the order that things happen and when specific files are loaded that’s most important.

    For example, registering a field group in a plugin. The documentation for ACF says to put something like this in your functions.php file:

    
    if (function_exists('acf_add_local_field_group')) {
      // register your field group here
    }
    

    This works for 95% of users because for the average user they are going to be doing the work as part of a theme, and the documentation is aimed at what most people are going to do.

    But if you build a plugin and want to add fields groups in code the chances are good that the field groups will not get registered because ACF isn’t loaded when your plugin code is loaded. So you need to use an action hook that will not trigger until after all the plugins are loaded. There are several WP hooks that can be used. This could be done no the plugins_loaded hook or the init hook.

    
    add_action('init', 'register_my_field_groups');
    function register_my_field_groups() {
      if (function_exists('acf_add_local_field_group')) {
        // register your field group here
      }
    }
    

    or you can eliminate the need to check if the function exists by using an acf hook that will only be called if acf is actually active. (I actually don’t think this is documented anywhere, but I’ve spend a lot of hours looking at what ACF does and how it does it.)

    
    add_action('acf/include_fields', 'register_my_field_groups');
    function register_my_field_groups() {
      // register your field groups
    }
    

    It’s always hard to say what the best or most proper way to do anything is. I’ve been working with WordPress and ACF for a very long time and I still learn something new every time I build a site.

    The best thing to do is ask here and someone that’s been working with ACF for a while will probably pop in and try to help.

  • Didn’t know acf hook… I’m doing it on plugins_loaded
    And because I use Polylang, I get back Ids of translated pages in an array, then begin my declaration like this :

        $contact_args = array (
            'key' => 'group_573366ed5685a',
    

    and end it like that :

       foreach($idLangs[1718] as $idLang){
            $contact_args['location'][] = array (
                array (
                    'param' => 'page',
                    'operator' => '==',
                    'value' => $idLang,
                ),
            );
        }
        acf_add_local_field_group($contact_args);
    

    I don’t like it because I don’t like to have to set an id page directly in code but I didn’t find anything else to make it work with polylang.

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

You must be logged in to reply to this topic.