codesoup / acf-options
Manage ACF options using custom post types with instance key support for WordPress
Installs: 22
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
pkg:composer/codesoup/acf-options
Requires
- php: >=8.1.0
Requires (Dev)
Suggests
- advanced-custom-fields/advanced-custom-fields-pro: Required for ACF location rules and field management
This package is auto-updated.
Last update: 2025-12-13 10:40:26 UTC
README
Composer package for managing WordPress options pages using ACF and custom post type. Data is stored and retrieved from post_content field and does not use the wp_options table. Supports multiple instances and capability-based access control.
This approach leverages native WordPress post locking to prevent concurrent edits and provides optionial revision history for all option changes.
In case you use custom capabilities make sure you create and assign capability to Administrator role otherwise options page will not be visible/accessible. You can use plugin like User Role Editor to manage custom capabilites and roles.
Requirements
- PHP >= 8.1
- WordPress >= 6.0
- Advanced Custom Fields
Installation
Via Composer
composer require codesoup/acf-options
As WordPress Plugin from GitHub
-
Download the plugin as a ZIP file from GitHub
-
Extract the ZIP file to your WordPress plugins directory
-
Activate the plugin
-
Add required create/register_page code to your functions.php
Usage
Example 1: Create and retrieve in same file
use CodeSoup\ACFOptions\Manager; $manager = Manager::create( 'my_instance_key' ); $manager->register_page( array( 'id' => 'general', 'title' => 'General Settings', 'capability' => 'manage_options', ) ); $manager->init(); // Retrieve options $options = $manager->get_options( 'general' );
Example 2: Retrieve existing instance from different file
// In functions.php or plugin init $manager = \CodeSoup\ACFOptions\Manager::create( 'my_instance_key' ); $manager->register_page( array( 'id' => 'general', 'title' => 'General Settings', 'capability' => 'manage_footer_options', // Custom wp_capability ) ); $manager->init(); // In template file eg: header.php $manager = \CodeSoup\ACFOptions\Manager::get( 'my_instance_key' ); $options = $manager->get_options( 'general' );
Configuration
Available options with defaults:
$manager = Manager::create( 'my_instance_key', array( 'post_type' => 'codesoup_options', // {my_instance_key}_options 'prefix' => 'codesoup-', // {my_instance_key}-options- 'menu_position' => 50, // 99 'menu_icon' => 'dashicons-admin-settings', // dashicons-admin-generic 'menu_label' => 'Site Options', // ACF Options ) );
ACF Field Groups
Assign field groups using the ACF Options location rule.
API
Static Methods
create( string $instance_key, array $config = [] ): Managerget( string $instance_key ): ?Managerget_all(): arraydestroy( string $instance_key ): bool
Instance Methods
register_page( array $args ): voidinit(): voidget_options( string $page_id ): array