1. Go to this page and download the library: Download sackrin/fusion library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
sackrin / fusion example snippets
use Fusion\Builder;
use Fusion\FieldGroup;
use Fusion\Field\Tab;
use Fusion\Field\Group;
use Fusion\Field\Text;
use Fusion\Field\Select;
use Fusion\Field\Repeater;
use Fusion\Field\DatePicker;
function fusion_register() {
// Create a new builder instance and populate with field group fields
// It may be a good idea to either store this instance somewhere or create a function to access
// your builder instance later. You will need it to access and persist field values
$builder = (new Builder())
->addFieldGroup((new FieldGroup('example_settings', 'Settings'))
// Add that we want these fields to appear on the page post type
->addLocation('post_type', 'page')
// Add various fields, tabs etc
->addField((new Tab('profile', 'PROFILE DETAILS')))
->addField((new Select('profile_title', 'Title'))
->setChoices([
'mr' => 'Mr',
'mrs' => 'Mrs',
'ms' => 'Ms'
])
->setDefault('mr')
->setWrapper(20)
)
->addField((new Text('profile_first_name', 'First Name'))
->setPlaceholder('Johnny')
->setWrapper(40)
)
->addField((new Text('profile_surname', 'Surname'))
->setPlaceholder('Acfseed')
->setWrapper(40)
)
->addField((new Group('foroffice', 'Office Use Only'))
// Repeaters and groups allow for fields to be added directly against them
->addField((new DatePicker('signedup_on', 'Signed Up Date'))
->setWrapper(50))
->addField((new Text('officer_name', 'Officer Name'))
->setDefault('')
->setWrapper(50))
)
->addField((new Repeater('profile_emails', 'Email Addresses'))
->addField((new Text('address', 'Email Address'))
->setPlaceholder('')
->setWrapper(50)
)
->addField((new Text('label', 'Email Label'))
->setPlaceholder('')
->setWrapper(50)
)
)
);
// Call the acf function to register the field group
acf_add_local_field_group($builder->toArray());
}
add_action('init', 'fusion_register');
use Fusion\Manager;
// The manager is used to interact with the builder
// It gets and sets fields for post objects etc
$manager = (new Manager($post_id, $builder))->load();