{"id":21189035,"url":"https://github.com/sackrin/fusion","last_synced_at":"2025-08-24T22:31:25.077Z","repository":{"id":62539110,"uuid":"121744063","full_name":"sackrin/fusion","owner":"sackrin","description":"This project aims to provide a standard programming interface with the popular WordPress advanced custom fields plugin. Field groups are created and managed programmatically without the use of the graphical frontend or acf json files.","archived":false,"fork":false,"pushed_at":"2018-02-16T12:22:47.000Z","size":16,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-14T20:45:58.158Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sackrin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-02-16T11:36:07.000Z","updated_at":"2020-10-16T01:08:18.000Z","dependencies_parsed_at":"2022-11-02T15:17:25.203Z","dependency_job_id":null,"html_url":"https://github.com/sackrin/fusion","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/sackrin/fusion","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sackrin%2Ffusion","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sackrin%2Ffusion/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sackrin%2Ffusion/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sackrin%2Ffusion/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sackrin","download_url":"https://codeload.github.com/sackrin/fusion/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sackrin%2Ffusion/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261255901,"owners_count":23131479,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-20T18:49:36.509Z","updated_at":"2025-06-22T07:38:08.268Z","avatar_url":"https://github.com/sackrin.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Fusion\n\nThis project aims to provide a standard programming interface with the popular WordPress advanced custom fields plugin. Field groups are created and managed programmatically without the use of the graphical front end or acf-json files.\n\nPlease note this library will only work correctly with field groups built using the fusion builder. In theory there shouldn't be any problem working with ACF field groups however the output of native field groups is unpredictable. It is advised to build all field groups using the fusion builder.\n\n### Installing Fusion\n\n```\ncomposer require sackrin/fusion\n``` \n\n### Registering field groups\n\n```php\nuse Fusion\\Builder;\nuse Fusion\\FieldGroup;\nuse Fusion\\Field\\Tab;\nuse Fusion\\Field\\Group;\nuse Fusion\\Field\\Text;\nuse Fusion\\Field\\Select;\nuse Fusion\\Field\\Repeater;\nuse Fusion\\Field\\DatePicker;\n\nfunction fusion_register() {\n    // Create a new builder instance and populate with field group fields\n    // It may be a good idea to either store this instance somewhere or create a function to access\n    // your builder instance later. You will need it to access and persist field values\n    $builder = (new Builder())\n        -\u003eaddFieldGroup((new FieldGroup('example_settings', 'Settings'))\n            // Add that we want these fields to appear on the page post type\n            -\u003eaddLocation('post_type', 'page')\n            // Add various fields, tabs etc\n            -\u003eaddField((new Tab('profile', 'PROFILE DETAILS')))\n            -\u003eaddField((new Select('profile_title', 'Title'))\n                -\u003esetChoices([\n                    'mr' =\u003e 'Mr',\n                    'mrs' =\u003e 'Mrs',\n                    'ms' =\u003e 'Ms'\n                ])\n                -\u003esetDefault('mr')\n                -\u003esetWrapper(20)\n            )\n            -\u003eaddField((new Text('profile_first_name', 'First Name'))\n                -\u003esetPlaceholder('Johnny')\n                -\u003esetWrapper(40)\n            )\n            -\u003eaddField((new Text('profile_surname', 'Surname'))\n                -\u003esetPlaceholder('Acfseed')\n                -\u003esetWrapper(40)\n            )\n            -\u003eaddField((new Group('foroffice', 'Office Use Only'))\n                // Repeaters and groups allow for fields to be added directly against them\n                -\u003eaddField((new DatePicker('signedup_on', 'Signed Up Date'))\n                    -\u003esetWrapper(50))\n                -\u003eaddField((new Text('officer_name', 'Officer Name'))\n                    -\u003esetDefault('')\n                    -\u003esetWrapper(50))\n            )\n            -\u003eaddField((new Repeater('profile_emails', 'Email Addresses'))\n                -\u003eaddField((new Text('address', 'Email Address'))\n                    -\u003esetPlaceholder('')\n                    -\u003esetWrapper(50)\n                )\n                -\u003eaddField((new Text('label', 'Email Label'))\n                    -\u003esetPlaceholder('')\n                    -\u003esetWrapper(50)\n                )\n            )\n        );\n    // Call the acf function to register the field group\n    acf_add_local_field_group($builder-\u003etoArray());\n}\n\nadd_action('init', 'fusion_register');\n\n```\n\n### Creating a field group manager\n\n```php\nuse Fusion\\Manager;\n\n// The manager is used to interact with the builder\n// It gets and sets fields for post objects etc\n$manager = (new Manager($post_id, $builder))-\u003eload();\n\n```\n\n### Getting a field from a field group\n\nFor non nested fields \n\n```php\n$value = $manager-\u003egetField('profile_first_name', 'Some Default Value');\n```\n\nFor nested fields you use dot notation\n\n```php\n$value = $manager-\u003egetField('foroffice.signedup_on', 'Some Default Value');\n```\n\nFor fields within repeaters you use dot notation with index values\n\n```php\n$value = $manager-\u003egetField('profile_emails.0.address', 'Some Default Value');\n```\n\n### Retrieving all current values of a field group\n\nRetrieves all values using the field names\n\n```php\n$values = $manager-\u003edumpNames();\n```\n\nRetrieves all values using the field keys\n\n```php\n$values = $manager-\u003edumpKeys();\n```\n\n### Setting a field field groups\n\nSetting fields follows the same path rules as getting including dot notation\n\n```php\n$manager-\u003esetField('profile_first_name', 'A new name');\n```\n\nPLEASE NOTE: Setting a field does not update the database. You can set and interact with fields without persisting to the DB. This is very useful if you want to inject values into a post to make calculations etc. \n\n### Saving field group values\n\n```php\n$manager-\u003esave();\n```\n\n### Available Fields\n\n```\n// Standard fields\nnew Fusion\\Field\\ButtonGroup();\nnew Fusion\\Field\\Checkbox();\nnew Fusion\\Field\\ColorPicker();\nnew Fusion\\Field\\DatePicker();\nnew Fusion\\Field\\DateTimePicker();\nnew Fusion\\Field\\Email();\nnew Fusion\\Field\\File();\nnew Fusion\\Field\\Gallery();\nnew Fusion\\Field\\GoogleMap();\nnew Fusion\\Field\\Image();\nnew Fusion\\Field\\Message();\nnew Fusion\\Field\\Number();\nnew Fusion\\Field\\oEmbed();\nnew Fusion\\Field\\PageLink();\nnew Fusion\\Field\\Password();\nnew Fusion\\Field\\PostObject();\nnew Fusion\\Field\\Radio();\nnew Fusion\\Field\\Range();\nnew Fusion\\Field\\Relationship();\nnew Fusion\\Field\\Select();\nnew Fusion\\Field\\Tab();\nnew Fusion\\Field\\Taxonomy();\nnew Fusion\\Field\\Text();\nnew Fusion\\Field\\Textarea();\nnew Fusion\\Field\\TimePicker();\nnew Fusion\\Field\\User();\nnew Fusion\\Field\\Wysiwyg();\n\n// Fields with subfields\nnew Fusion\\Field\\Repeater();\nnew Fusion\\Field\\Group();\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsackrin%2Ffusion","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsackrin%2Ffusion","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsackrin%2Ffusion/lists"}