Created
June 25, 2019 00:38
-
-
Save tareiking/a1a03368aac2b9b564aa398947fa0ec3 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 | |
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