-
-
Save billerickson/f9f54bdf2196c5450e1295321fe926e9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Custom Fields with Carbon Fields | |
* | |
* @package CoreFunctionality | |
* @author Bill Erickson | |
* @since 1.0.0 | |
* @license GPL-2.0+ | |
**/ | |
use Carbon_Fields\Container; | |
use Carbon_Fields\Field; | |
/** | |
* Register Fields | |
* | |
*/ | |
function ea_register_custom_fields() { | |
Container::make( 'post_meta', 'Plugins' ) | |
->where( 'post_type', '=', 'page' ) | |
->where( 'post_template', '=', 'templates/plugins-carbonfields.php' ) | |
->add_fields( array( | |
Field::make( 'complex', 'be_plugins', 'Plugins' ) | |
->setup_labels( array( 'singular_name' => 'Plugin', 'plural_name' => 'Plugins' ) ) | |
->set_collapsed( true ) | |
->add_fields( array( | |
Field::make( 'text', 'name' )->set_width(33), | |
Field::make( 'text', 'url', 'URL' )->set_width(33), | |
Field::make( 'text', 'icon' )->set_width(33), | |
Field::make( 'textarea', 'summary' ), | |
Field::make( 'set', 'categories' ) | |
->set_options( 'ea_plugin_categories' ) | |
)) | |
->set_header_template( '<% if (name) { %><%- name %><% } %>' ) | |
)); | |
} | |
add_action( 'carbon_fields_register_fields', 'ea_register_custom_fields' ); | |
/** | |
* Plugin Categories | |
* | |
*/ | |
function ea_plugin_categories() { | |
return array( | |
'genesis' => 'Genesis', | |
'developer' => 'Developer', | |
'cms' => 'CMS', | |
'social' => 'Social', | |
'media' => 'Media', | |
'widget' => 'Widget', | |
'analytics' => 'Analytics' | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment