{"id":33952903,"url":"https://github.com/iniznet/acf-builder-callback","last_synced_at":"2025-12-12T19:50:52.591Z","repository":{"id":50681478,"uuid":"519802315","full_name":"iniznet/acf-builder-callback","owner":"iniznet","description":" Enhance your ACF Builder with an extension that provides a sanitization-escape callback and enables dynamic population of choice fields.","archived":false,"fork":false,"pushed_at":"2025-12-11T09:05:36.000Z","size":37,"stargazers_count":8,"open_issues_count":3,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-12T08:11:15.185Z","etag":null,"topics":["acf","acf-builder","acf-field","advanced-custom-fields","sage","sage-theme","sage10","wordpress"],"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/iniznet.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2022-07-31T14:43:01.000Z","updated_at":"2025-06-27T00:54:03.000Z","dependencies_parsed_at":"2023-01-26T00:00:14.477Z","dependency_job_id":"1d3faa2e-55b1-43a0-b3f9-c170f08289e4","html_url":"https://github.com/iniznet/acf-builder-callback","commit_stats":{"total_commits":24,"total_committers":2,"mean_commits":12.0,"dds":0.125,"last_synced_commit":"74e46cc148adb948d7c8197b8507dd4eea5409bf"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/iniznet/acf-builder-callback","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iniznet%2Facf-builder-callback","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iniznet%2Facf-builder-callback/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iniznet%2Facf-builder-callback/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iniznet%2Facf-builder-callback/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iniznet","download_url":"https://codeload.github.com/iniznet/acf-builder-callback/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iniznet%2Facf-builder-callback/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":27690102,"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","status":"online","status_checked_at":"2025-12-12T02:00:06.775Z","response_time":129,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["acf","acf-builder","acf-field","advanced-custom-fields","sage","sage-theme","sage10","wordpress"],"created_at":"2025-12-12T19:50:51.870Z","updated_at":"2025-12-12T19:50:52.582Z","avatar_url":"https://github.com/iniznet.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ACF Builder Callback\n\nA package made for [ACF Builder](https://github.com/stoutlogic/acf-builder) extension to quickly create ACF configuration with callback within builder.\n\n### Simple Example\n```php\n$banner = new StoutLogic\\AcfBuilder\\FieldsBuilder('banner');\n$banner\n    -\u003eaddText('title', [\n        'label' =\u003e 'Title',\n        'instructions' =\u003e 'Enter the title of the banner.',\n        'required' =\u003e true,\n        'maxlength' =\u003e 100,\n        'placeholder' =\u003e 'Enter title',\n        'sanitization_cb' =\u003e 'sanitize_greater_than_30',\n        'escape_cb' =\u003e 'escape_greater_than_30',\n    ])\n    -\u003eaddWysiwyg('content')\n    -\u003eaddImage('background_image')\n    -\u003esetLocation('post_type', '==', 'page')\n        -\u003eor('post_type', '==', 'post');\n\nadd_action('acf/init', function() use ($banner) {\n   acf_add_local_field_group($banner-\u003ebuild());\n});\n\n/**\n * Handle the sanitization of the title field.\n * Ensures that the title is greater than 30 characters or nothing.\n * \n * @param mixed         $value      The value of the title field.\n * @param int|string    $post_id    The post ID.\n * @param array         $field      The field settings.\n * \n * @return mixed                    The sanitized value.\n */\nfunction sanitize_greater_than_30($value, $post_id, $field) {\n    if (strlen($value) \u003e 30) {\n        return $value;\n    }\n    return '';\n}\n\n/**\n* Handle the escaping of the title field.\n* Ensures that the title is greater than 30 characters or nothing.\n* \n* @param mixed         $value      The value of the title field.\n* @param int|string    $post_id    The post ID.\n* @param array         $field      The field settings.\n* \n* @return mixed                    The escaped value.\n*/\nfunction escape_greater_than_30($value, $post_id, $field) {\n    if (strlen($value) \u003e 30) {\n        return esc_html($value);\n    }\n    return '';\n}\n\n// Call below somewhere within your application especially during initialization.\niniznet\\AcfBuilderCallback\\FieldCallback::run();\n```\n\nIf you're using the [ACF Composer](https://github.com/Log1x/acf-composer)\n```php\n\u003c?php\n\nnamespace App\\Fields;\n\nuse Log1x\\AcfComposer\\Field;\nuse StoutLogic\\AcfBuilder\\FieldsBuilder;\n\nclass Example extends Field\n{\n    /**\n     * The field group.\n     *\n     * @return array\n     */\n    public function fields()\n    {\n        $example = new FieldsBuilder('example');\n\n        $example\n            -\u003esetLocation('post_type', '==', 'post');\n\n        $example\n            -\u003eaddRepeater('items')\n                -\u003eaddText('item', [\n                    'label' =\u003e 'Item',\n                    'instructions' =\u003e 'Enter the item.',\n                    'required' =\u003e true,\n                    'maxlength' =\u003e 100,\n                    'placeholder' =\u003e 'Enter item',\n                    'sanitization_cb' =\u003e function ($value) {\n                        return strlen($value) \u003e 30 ? $value : '';\n                    },\n                    'escape_cb' =\u003e function ($value) {\n                        return strlen($value) \u003e 30 ? esc_html($value) : '';\n                    },\n                ])\n            -\u003eendRepeater();\n\n        return $example-\u003ebuild();\n    }\n}\n\n// Call below somewhere within your application especially during initialization.\niniznet\\AcfBuilderCallback\\FieldCallback::run();\n```\n\n## TODO\n- [x] Field `sanitization_cb` callback\n- [x] Field `escape_cb` callback\n- [x] Field `choices_cb` callback, expect an array of choices as return value\n- [x] Field `default_value_cb` callback\n- [x] Refactor package to standalone \u0026 doesn't extending ACF Builder as child class\n- [ ] Refactor package again but with best practices instead of the current one\n\n## Requirements\nPHP 7.4 through 8.0 Tested.\n\n## Install\nUse composer to install:\n```\ncomposer require iniznet/acf-builder-callback\n```\n\nIf your project isn't using composer, you can require the `autoload.php` file.\n\n## Tests\nThere are no tests for this package yet.\n\n## Bug Reports\nIf you discover a bug in ACF Builder Callback, please [open an issue](https://github.com/iniznet/acf-builder-callback/issues).\n\n## Contributing\nContributing whether it be through PRs, reporting an issue, or suggesting an idea is encouraged and appreciated.\n\n## License\nACF Builder Callback is provided under the [MIT License](LICENSE.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finiznet%2Facf-builder-callback","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finiznet%2Facf-builder-callback","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finiznet%2Facf-builder-callback/lists"}