Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 17 additions & 13 deletions AdminPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public function __construct( $file = false, $options = null ) {
}

add_action( 'admin_menu', array( $this, 'page_init' ), $this->args['admin_action_priority'] );
add_filter( 'contextual_help', array( $this, '_contextual_help' ), 10, 2 );
add_filter( 'current_screen', array( $this, '_contextual_help' ), 10, 1 );

if ( $file ) {
$this->file = $file;
Expand Down Expand Up @@ -175,7 +175,7 @@ public function page_head() { }
/**
* This is where the contextual help goes.
*
* @return string
* @return array|string Array of arguments, see WP_Screen::add_help_tab( array $args ). Or the content string.
*/
protected function page_help() { }

Expand Down Expand Up @@ -534,23 +534,27 @@ private function check_args() {
/**
* Adds contextual help.
*
* @param string $help
* @param string|object $screen
*
* @return string
*/
public function _contextual_help( $help, $screen ) {
if ( is_object( $screen ) ) {
$screen = $screen->id;
}
public function _contextual_help( $screen ) {
if ( ! is_object( $screen ) )
return;

$actual_help = $this->page_help();

if ( $screen == $this->pagehook && $actual_help ) {
return $actual_help;
if ( $screen->id == $this->pagehook && $actual_help ) {
// String to array $actual_help
$actual_help = is_array( $actual_help ) ? $actual_help : array(
'content' => $actual_help,
);
$actual_help = wp_parse_args( $actual_help, array(
'id' => $this->args['page_slug'],
'title' => $this->args['menu_title'],
'content' => '',
) );
// Add help tab
$screen->add_help_tab( $actual_help );
}

return $help;
}

/**
Expand Down