Skip to content

Instantly share code, notes, and snippets.

@tareiking
Created June 25, 2019 00:38
Show Gist options
  • Save tareiking/a1a03368aac2b9b564aa398947fa0ec3 to your computer and use it in GitHub Desktop.
Save tareiking/a1a03368aac2b9b564aa398947fa0ec3 to your computer and use it in GitHub Desktop.
<?php
add_action( 'cmb2_after_init', function() {
$metaboxes = \CMB2_Boxes::get_all();
$unique_field_types = [];
foreach ( $metaboxes as $cmb_id => $cmb ) {
if ( ! $cmb->meta_box['fields'] ) {
continue;
}
foreach( $cmb->meta_box['fields'] as $field ) {
$unique_field_types[] = $field['type'];
}
}
echo sc_array_to_li( array_unique( $unique_field_types ) );
exit;
}, PHP_INT_MAX );
function sc_array_to_li( $data ) {
$data = (array) $data;
$str = '<ul>';
foreach($data as $li){
if ( is_array( $li ) ) {
$li = $li[0];
}
$str .= '<li>' . esc_html($li) . '</li>';
}
$str .= '</ul>';
return $str;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment