[wp-trac] [WordPress Trac] #24786: filter set-screen-option not triggering

WordPress Trac noreply at wordpress.org
Wed Jul 17 16:56:03 UTC 2013


#24786: filter set-screen-option not triggering
--------------------------+-----------------------------
 Reporter:  robbcaldwell  |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:  3.5.2
 Severity:  normal        |   Keywords:
--------------------------+-----------------------------
 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 (361) it saves fine.

 Shouldn't line 361 be more like:

 {{{
 $value = apply_filters('set-screen-option', $value, $other_arguments);
 }}}

--
Ticket URL: <http://core.trac.wordpress.org/ticket/24786>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list