Make $current_screen->add_option() easier to use, see #18690

git-svn-id: http://svn.automattic.com/wordpress/trunk@18879 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
azaozz 2011-10-04 17:21:59 +00:00
parent 760a1f8b6c
commit d0ceca2496

View File

@ -366,13 +366,16 @@ final class WP_Screen {
* @param string $option Option ID * @param string $option Option ID
* @param mixed $args Associative array of arguments particular to the default $option or the HTML string to be printed in the Screen Options tab. * @param mixed $args Associative array of arguments particular to the default $option or the HTML string to be printed in the Screen Options tab.
*/ */
public function add_option( $option = false, $args ) { public function add_option( $option, $args = null ) {
if ( is_array($args) && !empty($option) ) if ( is_array($args) && !empty($option) )
$this->_options[ $option ] = $args; $this->_options[ $option ] = $args;
elseif ( is_string($args) ) elseif ( is_string($option) )
$this->_options['_screen_settings'] .= $args; $this->_options['_screen_settings'] .= $option;
else
return false;
$this->_show_options = true; $this->_show_options = true;
return true;
} }
/** /**
@ -413,9 +416,10 @@ final class WP_Screen {
// Ensure we have title and ID. // Ensure we have title and ID.
if ( ! $args['title'] || ! $args['id'] ) if ( ! $args['title'] || ! $args['id'] )
return; return false;
$this->_help_tabs[] = $args; $this->_help_tabs[] = $args;
return true;
} }
/** /**
@ -442,7 +446,7 @@ final class WP_Screen {
global $_wp_contextual_help; global $_wp_contextual_help;
// Intended for adding Help and Screen Options. // Intended for adding Help and Screen Options.
do_action('add_screen_help_and_options'); do_action('add_screen_help_and_options', $this);
// Call old contextual_help_list filter. // Call old contextual_help_list filter.
if ( ! isset( $_wp_contextual_help ) ) if ( ! isset( $_wp_contextual_help ) )