Skip to content

Instantly share code, notes, and snippets.

@jdcauley
Created January 26, 2016 18:06
Show Gist options
  • Save jdcauley/b25ffd45189c580426e6 to your computer and use it in GitHub Desktop.
Save jdcauley/b25ffd45189c580426e6 to your computer and use it in GitHub Desktop.
$post_types = get_post_types(array(
'public' => true,
), 'objects');
foreach($post_types as $key => $value){
$field_name = 'binary_stars_post_type_' . $key;
print_r($field_name);
add_settings_field(
$field_name,
__( 'Load Stars on ' . $value->labels->name, 'binary_stars' ),
function(){
print_r($key);
$options = get_option( 'binary_stars_settings' );
$field_name = 'binary_stars_post_type_' . $key;
?>
<input type='checkbox' name="binary_stars_settings[<?php echo $field_name; ?>]" <?php checked( $options[$field_name], 1 ); ?> value="<?php echo $key; ?>">
<?php
},
'pluginPage',
'binary_stars_pluginPage_section'
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment