Skip to content

Instantly share code, notes, and snippets.

@mboynes
Created December 8, 2016 19:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mboynes/1b75b75ae84356e04713e0c90e838773 to your computer and use it in GitHub Desktop.
Save mboynes/1b75b75ae84356e04713e0c90e838773 to your computer and use it in GitHub Desktop.
Demo of Fieldmanager_Datasource_CAP
<?php
require_once( __DIR__ . '/inc/class-fieldmanager-datasource-cap.php' );
add_action( 'fm_post_post', function() {
$fm = new \Fieldmanager_Group( [
'name' => 'byline',
'limit' => 0,
'label' => __( 'Author', 'cap-sandbox' ),
'sortable' => true,
'add_more_label' => __( 'Add a coauthor', 'cap-sandbox' ),
'children' => [
'author' => new \Fieldmanager_Autocomplete( [
'label' => __( 'Author Name', 'cap-sandbox' ),
'datasource' => new \Fieldmanager_Datasource_CAP,
] ),
'type' => new \Fieldmanager_TextField( __( 'Author Type', 'cap-sandbox' ) ),
],
] );
$fm->add_meta_box( 'Authors', 'post' );
} );
/**
* Remove CAP meta box for post types where we replaced it.
*/
add_action( 'add_meta_boxes', function() {
global $coauthors_plus;
if ( $coauthors_plus ) {
remove_meta_box( $coauthors_plus->coauthors_meta_box_name, 'post', apply_filters( 'coauthors_meta_box_context', 'normal' ) );
}
}, 20 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment