{"id":26047818,"url":"https://github.com/hasayone/acf-json-controller","last_synced_at":"2026-04-18T22:04:34.811Z","repository":{"id":279422603,"uuid":"938745485","full_name":"hasayone/ACF-JSON-Controller","owner":"hasayone","description":"Controller for WordPress site with ACF. Manages ACF JSON synchronization, provides sync notifications, and configures paths for JSON storage in the theme directory.","archived":false,"fork":false,"pushed_at":"2025-02-25T13:14:01.000Z","size":5,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-07T23:14:05.289Z","etag":null,"topics":["acf","acf-fields","wordpress"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hasayone.png","metadata":{"files":{"readme":"README.MD","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2025-02-25T12:42:17.000Z","updated_at":"2025-02-25T13:16:56.000Z","dependencies_parsed_at":"2025-03-03T18:31:12.030Z","dependency_job_id":null,"html_url":"https://github.com/hasayone/ACF-JSON-Controller","commit_stats":null,"previous_names":["hasayone/acf-json-controller"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hasayone%2FACF-JSON-Controller","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hasayone%2FACF-JSON-Controller/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hasayone%2FACF-JSON-Controller/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hasayone%2FACF-JSON-Controller/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hasayone","download_url":"https://codeload.github.com/hasayone/ACF-JSON-Controller/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242473052,"owners_count":20134021,"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":["acf","acf-fields","wordpress"],"created_at":"2025-03-07T23:14:08.575Z","updated_at":"2026-04-18T22:04:34.759Z","avatar_url":"https://github.com/hasayone.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ACF JSON Controller\n\nA lightweight PHP component for managing ACF JSON synchronization in WordPress themes.\n\n![ACF JSON Controller](https://empat.dev/img/acf_2.png)\n\n## Description\n\nACF JSON Controller is a WordPress theme component that manages ACF (Advanced Custom Fields) JSON files synchronization. It automatically configures paths for saving and loading JSON files, provides admin notifications for field updates, and enables detailed HTML escaping logging.\n\n## Features\n\n- Automatic configuration of ACF JSON save/load paths in your theme directory\n- Admin notification when field synchronization is available\n- Detailed logging of HTML escaping for debugging purposes\n- Disables automatic `\u003cp\u003e` tags in the WYSIWYG editor\n- Configures HTML escaping in ACF fields\n\n![ACF JSON Controller](https://empat.dev/img/acf_1.png)\n\n## Requirements:\n\n- PHP 8.0+\n- WordPress 6.0+\n- Advanced Custom Fields PRO 6.3.7+\n\n## Installation\n\n### 1. Create file structure\n\nPlace the `class-acf.php` file in your theme's directory:\n\n```\nyour-theme/\n├── acf-json/ # Directory for storing JSON files\n├── inc/\n│ ├── controllers/\n│ │ └── class-acf.php # Place the controller code here\n│ └── ...\n└── functions.php # Initialize the controller here\n```\n\n### 2. Include the controller in your theme\n\nAdd the following code to your theme's `functions.php`:\n\n```php\n/**\n * Initialize theme controllers\n */\nfunction theme_init_controllers() {\n    // Include ACF controller\n    require_once get_template_directory() . '/inc/controllers/class-acf.php';\n\n    // Initialize ACF controller\n    new \\YourTheme\\Controller\\ACF();\n}\nadd_action('after_setup_theme', 'theme_init_controllers');\n```\n\n### 3. Create acf-json directory\n\nEnsure the acf-json directory exists in your theme's root with write permissions.\n\n## How It Works\n\nThe controller handles several key aspects of ACF JSON synchronization:\n\n- **JSON FileManagement:** Configures paths for saving and loading ACF JSON files\n- **Sync Notifications:** Displays admin notices when field synchronization is available\n- **HTML Escaping:** Sets up HTML escaping and detailed logging\n- **WYSIWYG Cleanup:** Removes automatic paragraph tags from ACF WYSIWYG editor\n\n### Synchronization Process\n\n1. Create or edit an ACF field group\n2. Save changes (JSON file is automatically created in the **acf-json** directory)\n3. When migrating to another site, the system will detect differences between PHP and JSON field versions\n4. An admin notification will appear showing available synchronizations\n5. Click the link to apply the changes\n\n### Benefits of ACF JSON\n\n1. **Version Control:** JSON files can be tracked in version control systems (Git)\n2. **Performance:** Loading fields from JSON files is faster than from the database\n3. **Team Collaboration:** Simplifies team work on field structures\n4. **Easy Migration:** Streamlines field configuration transfer between environments\n5. **Change Tracking:** Visualization of field changes through Git diff\n\n## Customization\n\n### Changing JSON storage path\n\nTo modify the path for the **acf-json** directory, edit the **acf_json_save_callback** and **acf_json_load_callback** methods:\n\n```php\npublic function acf_json_save_callback(string $path): string {\n    // Change to your custom path\n    $path = get_stylesheet_directory() . '/custom-path/acf-json';\n\n    return $path;\n}\n\npublic function acf_json_load_callback(array $paths): array {\n    unset($paths[0]);\n    // Change to your custom path\n    $paths[] = get_stylesheet_directory() . '/custom-path/acf-json';\n\n    return $paths;\n}\n```\n\nModifying notification text\nTo change the synchronization notification text, edit the acf_sync_notice method:\n\n```php\npublic function acf_sync_notice(): void {\n    // Your code...\n    if ($sync_count \u003e 0) { ?\u003e\n        \u003cdiv class=\"notice notice-warning is-dismissible\"\u003e\n            \u003cp\u003e\n                \u003c?php printf(\n                    __('ACF Pro field synchronization available', 'your-theme-textdomain') .\n                    ' \u003ccode\u003e(%d)\u003c/code\u003e \u003ca href=\"%s\"\u003e' .\n                    __('Synchronize now', 'your-theme-textdomain') . '\u003c/a\u003e',\n                    $sync_count,\n                    admin_url('edit.php?post_type=acf-field-group\u0026post_status=sync')\n                ); ?\u003e\n            \u003c/p\u003e\n        \u003c/div\u003e\n    \u003c?php }\n}\n```\n\n### HTML Escaping Debugging\n\nThe controller includes detailed logging of any HTML content changes in ACF fields. All logs are written to the standard PHP error log with an **_ACF HTML Escaping Debug_** tag.\n\n### License\n\nThis code is released under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhasayone%2Facf-json-controller","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhasayone%2Facf-json-controller","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhasayone%2Facf-json-controller/lists"}