Created
December 8, 2016 19:24
-
-
Save mboynes/1b75b75ae84356e04713e0c90e838773 to your computer and use it in GitHub Desktop.
Demo of Fieldmanager_Datasource_CAP
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 | |
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