Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: The 'contextual_help' hook is deprecated - use add_help_tab() instead #31

Open
wants to merge 1 commit into
base: v2.x
Choose a base branch
from
Open
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
17 changes: 11 additions & 6 deletions scormcloud/admin/scormcloudadminui.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public static function admin_menu_actions()
'show_settings',
]);

add_action('contextual_help', [__CLASS__, 'contextual_help'], 10, 3);
add_action('in_admin_header', [__CLASS__, 'contextual_help']);
}

/**
Expand All @@ -72,7 +72,7 @@ public static function network_admin_menu_actions()
'show_network_settings',
]);

add_action('contextual_help', [__CLASS__, 'contextual_help'], 10, 3);
add_action('in_admin_header', [__CLASS__, 'contextual_help']);
}

/**
Expand Down Expand Up @@ -140,10 +140,12 @@ public static function set_js_vars()
/**
* Build contextual help stubs.
*/
public static function contextual_help($text, $screen_id, $screen)
public static function contextual_help()
{
$plugin_hooks = ScormCloudPlugin::$hooks;

$screen = get_current_screen();
$screen_id = $screen->id;
if (substr($screen_id, -8) == '-network') {
$screen_id = substr_replace($screen_id, '', -8);
}
Expand Down Expand Up @@ -248,9 +250,12 @@ public static function contextual_help($text, $screen_id, $screen)

$help_html .= "</div>";

return $help_html;
} else {
return $text;
// Add the contextual help tab
$screen->add_help_tab(array(
'title' => 'Overview',
'id' => 'scormcloud-help',
'content' => $help_html,
));
}
}
}