Reputation:
For my plugin I added a screen option with number input field. I want to add checkbox fields. Could not found out anything here. See the code:
//defined $my_admin here
add_action( 'load-' . $my_admin, "my_add_screen_options" );
//add screen options
function my_add_screen_options() {
$screen = get_current_screen();
//some checks
$args = array(
'label' => __('description', 'my'),
'default' => 20,
'option' => 'my_per_page'
);
add_screen_option( 'per_page', $args );
}
//Save the data from screen options
add_filter( 'set-screen-option', 'my_set_screen_option', 10, 3 );
function my_set_screen_option( $status, $option, $value ) {
if ( 'my_per_page' == $option ) return $value;
}
It works for number input. I thought changing $args
will make it display checkboxes or any other field. But could not find anything significant by google too.
Can anybody help?
Upvotes: 0
Views: 1839
Reputation: 531
Using filter hook create one option in screen option.
For example i create Thumbnail option in post list. following code add in theme function.php
add_filter('manage_posts_columns', 'posts_columns', 5);
function posts_columns($defaults){
$defaults['my_post_thumbs'] = __('Thumbnail');
return $defaults;
}
Upvotes: 1