Skip to content

A composer install helper for Advanced Custom Fields PRO

License

Notifications You must be signed in to change notification settings

wpvillain/acf-pro-installer

 
 

Repository files navigation

ACF PRO Installer

Packagist Packagist Travis Coveralls

A composer plugin that makes installing ACF PRO with composer easier.

It reads your 🔑 ACF PRO key from the environment or a .env file.

Usage

1. Add the package repository to the repositories field in composer.json (based on this gist):

{
  "type": "package",
  "package": {
    "name": "advanced-custom-fields/advanced-custom-fields-pro",
    "version": "*.*.*(.*)",
    "type": "wordpress-plugin",
    "dist": {
      "type": "zip",
      "url": "https://connect.advancedcustomfields.com/index.php?p=pro&a=download"
    },
    "require": {
      "philippbaschke/acf-pro-installer": "^1.0",
      "composer/installers": "^1.0"
    }
  }
}

Replace "version": "*.*.*(.*)" with your desired version.

Replace "type": "wordpress-plugin" with "type": "library" if you would like to have ACF PRO installed in the ./vendor directory instead of ./wp-content/plugins. This may be desireable if for example, you are including ACF PRO in a WordPress theme.

2. Make your ACF PRO key available

Set the environment variable ACF_PRO_KEY to your ACF PRO key.

Alternatively you can add an entry to your .env file:

# .env (same directory as composer.json)
ACF_PRO_KEY=Your-Key-Here

3. Require ACF PRO

composer require advanced-custom-fields/advanced-custom-fields-pro:*

You can specify an exact version (that matches your desired version).

If you use *, composer will install the version from the package repository (see 1). This has the benefit that you only need to change the version in the package repository when you want to update.

Be aware that composer update will only work if you change the version in the package repository. Decreasing the version only works if you require an exact version.

4. Load ACF in Theme

With thanks to janman22 at https://discourse.roots.io/t/include-advanced-custom-fields-in-sage-9/10267/5?u=jasperfrumau

/**
 * Customize ACF dir
 */
add_filter('acf/settings/dir', function ( $dir ) {

    $dir = get_stylesheet_directory_uri() . '/../vendor/advanced-custom-fields/advanced-custom-fields-pro/';

    return $dir;

});

/**
 * Hide ACF field group menu item
 */
// add_filter('acf/settings/show_admin', '__return_false');

/**
 * include ACF
 */
include_once( get_stylesheet_directory() . '/../vendor/advanced-custom-fields/advanced-custom-fields-pro/acf.php' );

About

A composer install helper for Advanced Custom Fields PRO

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%