filter set-screen-option not triggering
-
Displaying my own table of records, I want to have a “Per Page” option in the Screen Options pull down. So I setup my option:
function add_options() { $option = 'per_page'; $args = array( 'label' => 'Properties', 'default' => 20, 'option' => 'my_custom_per_page' ); add_screen_option( $option, $args ); add_filter('set-screen-option', 'my_custom_set_option', 10, 3); } function my_custom_set_option($status, $option, $value) { return $value; }
This works fine, the option is created and displayed in the Screen Options pull down. However, my_custom_set_option is NEVER called and when you change the value of my_custom_per_page in the Screen Options, it will revert back to its original value and never save.
Furthermore, looking at the core code, wp-admin/includes/misc.php, line 361, version 3.5.2
$value = apply_filters('set-screen-option', false, $option, $value);
$value is always returned as false.
Looking up the apply_filters function, wp-includes/plugin.php, line 137
function apply_filters($tag, $value)
The second parameter of apply_filters is $value, but passed ‘false’
If I comment out this line it saves fine.
So is this a bug?
- The topic ‘filter set-screen-option not triggering’ is closed to new replies.