-
Notifications
You must be signed in to change notification settings - Fork 16
Home
Welcome to the wp-custom-fields wiki! We are glad that you are considering to use WP Custom Fields in your next WordPress development project.
The wp custom fields framework is an options framework for WordPress aimed at speeding-up plug-in and theme development.
WP Custom Fields allows you to:
- Add custom option screens in the admin dashboard
- Add custom meta boxes to posts, taxonomies and users
- Add (custom) customizer fields and panels
Options are devided into sections, which are tabbed by default.
Include the src code within your theme or plugin. Load the required files using an autoloader, either manually or through composer. We also have a sample autoloader available at GitHub.
If you are not using an autoloader, you have to manually require all .php files within the src/ and src/fields/ folder.
Before you can add fields, you have to create an instance of the WP_Custom_Fields framework in the following manner:
$fields = MakeitWorkPress\WP_Custom_Fields\Framework::instance();
More information on modifying this instance can be found on the Instance Page of this wiki.
This is a basic example of adding an option screen to our admin dashboard menu using the previous instance.
$fields->add( 'options', array(
'class' => 'tabs-left',
'id' => 'wp_custom_fields_options',
'title' => __('Theme Options', 'textdomain'),
'capability' => 'manage_options',
'menu_title' => __('Theme Options', 'textdomain'),
'menu_icon' => 'dashicons-admin-generic',
'menu_position' => 99,
'location' => 'menu',
'sections' => array(
array(
'id' => 'section_one',
'title' => __('Section One', 'textdomain'),
'icon' => 'camera_enhance',
'fields' => array(
array(
'columns' => 'half',
'id' => 'checkbox',
'title' => __('Example Title', 'textdomain'),
'description' => __('Example Description', 'textdomain'),
'type' => 'checkbox',
'style' => 'switcher',
'options' => array(
array( 'id' => 'thing_one', 'label' => __('Label One', 'textdomain') ),
array( 'id' => 'thing_two', 'label' => __('Label Two', 'textdomain') )
)
)
)
)
)
);
How to add custom metaboxes, option pages or customizer settings is explained on their respective pages in the wiki.
The possible parameters for each section and field are explained in the fields page.
WP Custom Fields has been developed by Make it WorkPress