Instantly share code, notes, and snippets.

Embed
What would you like to do?
use Carbon_Fields\Container;
use Carbon_Fields\Field;
add_action( 'carbon_fields_register_fields', 'crb_attach_theme_options' );
function crb_attach_theme_options() {
Container::make( 'theme_options', __( 'Theme Options', 'crb' ) )
->add_fields( array(
Field::make('text', 'crb_text', 'Text Field' ),
Field::make('association', 'crb_association', 'Association'),
Field::make('checkbox', 'crb_checkbox', 'Checkbox')
->set_option_value('yes'),
Field::make('color', 'crb_color', 'Color'),
Field::make('date', 'crb_date', 'Date'),
Field::make('date_time', 'crb_date_time', 'Date Time'),
Field::make('file', 'crb_file', 'File'),
Field::make('footer_scripts', 'crb_footer_scripts', 'Footer Scripts'),
Field::make('gravity_form', 'crb_gravity_form', 'Gravity Form'),
Field::make('header_scripts', 'crb_header_scripts', 'Header Scripts'),
Field::make('hidden', 'crb_hidden', 'Hidden'),
Field::make('html', 'crb_html', 'HTML'),
Field::make('image', 'crb_image', 'Image'),
Field::make('map', 'crb_map', 'Map'),
Field::make('media_gallery', 'crb_media_gallery', 'Media Gallery'),
Field::make('oembed', 'crb_oembed', 'OEmbed'),
Field::make('radio', 'crb_radio', 'Radio')
->add_options(
array(
'small' => 'Small',
'medium' => 'Medium',
'large' => 'Large'
)
),
Field::make('radio_image', 'crb_radio_image', 'Radio Image')
->add_options( array(
'star-full' => 'https://wpplugincheck.com/wp-content/themes/wpplugincheck/dist/images/single/star-full.svg',
'star-empty' => 'https://wpplugincheck.com/wp-content/themes/wpplugincheck/dist/images/single/star-empty.svg'
)),
Field::make('rich_text', 'crb_rich_text', 'Rich Text'),
Field::make('select', 'crb_select', 'Select')
->add_options( array(
'left' => 'Left',
'center' => 'Center',
'right' => 'Right'
)),
Field::make('multiselect', 'crb_multiselect', 'Multiselect')
->add_options( array(
'red' => 'Red',
'green' => 'Green',
'blue' => 'Blue'
)),
Field::make('separator', 'crb_seperator', 'Seperator'), // Note the difference between seperator vs separator
Field::make( 'set', 'crb_product_features', 'Features' )
->add_options( array(
'bluetooth' => 'Bluetooth',
'gps' => 'GPS navigation',
'nfc' => 'Near field communication',
)),
Field::make('sidebar', 'crb_sidebar', 'Sidebar'),
Field::make('textarea', 'crb_textarea', 'Textarea'),
Field::make('time', 'crb_time', 'Time')
));
}
add_action( 'after_setup_theme', 'crb_load' );
function crb_load() {
require_once( 'vendor/autoload.php' );
\Carbon_Fields\Carbon_Fields::boot();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment