Pages Navigation Menu

Embed “Advanced Custom Fields PRO” (ACF PRO) plugin in your own WordPress plugin

If you want to distribute you own paid WorPress plugin with “Advanced Custom Fields PRO” embedded:

  1. Create in your plugin folder “acf”
  2. Upload there ACF PRO files
  3. Use below code in your plugin to change path, dir and include ACF PRO:
    // 1. customize ACF path
    add_filter('acf/settings/path', 'my_acf_settings_path');
     
    function my_acf_settings_path( $path )
    {
    	// update path
    	$path = plugin_dir_path( __FILE__ ) . 'acf/';
    
    	// return
    	return $path;
    }
     
    
    // 2. customize ACF dir
    add_filter('acf/settings/dir', 'my_acf_settings_dir');
    
    function my_acf_settings_dir( $dir )
    {
    	// update path
    	$dir = plugin_dir_url( __FILE__ ) . 'acf/';
    
    	// return
    	return $dir;
    }
     
    // 3. Hide ACF field group menu item
    add_filter('acf/settings/show_admin', '__return_false');
    
    
    // 4. Include ACF
    include_once( plugin_dir_path( __FILE__ ) . 'acf/acf.php' );
    

Leave a Reply