mirror of
https://github.com/moodle/moodle.git
synced 2025-01-29 11:46:19 +01:00
MDL-33592 navigation: Added support for local_ prefix on navigation callback
This commit is contained in:
parent
f8dfdb524b
commit
5c1f0d1ff6
@ -1423,14 +1423,15 @@ class global_navigation extends navigation_node {
|
||||
}
|
||||
|
||||
// Give the local plugins a chance to include some navigation if they want.
|
||||
foreach (get_list_of_plugins('local') as $plugin) {
|
||||
if (!file_exists($CFG->dirroot.'/local/'.$plugin.'/lib.php')) {
|
||||
continue;
|
||||
}
|
||||
require_once($CFG->dirroot.'/local/'.$plugin.'/lib.php');
|
||||
$function = $plugin.'_extends_navigation';
|
||||
foreach (get_plugin_list_with_file('local', 'lib.php', true) as $plugin => $file) {
|
||||
$function = "local_{$plugin}_extends_navigation";
|
||||
$oldfunction = "{$plugin}_extends_navigation";
|
||||
if (function_exists($function)) {
|
||||
// This is the preferred function name as there is less chance of conflicts
|
||||
$function($this);
|
||||
} else if (function_exists($oldfunction)) {
|
||||
// We continue to support the old function name to ensure backwards compatability
|
||||
$oldfunction($this);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -213,10 +213,11 @@ These two functions both need to be defined within /local/nicehack/lib.php.
|
||||
|
||||
sample code
|
||||
<?php
|
||||
function nicehack_extends_navigation(global_navigation $nav) {
|
||||
function local_nicehack_extends_navigation(global_navigation $nav) {
|
||||
// $nav is the global navigation instance.
|
||||
// Here you can add to and manipulate the navigation structure as you like.
|
||||
// This callback was introduced in 2.0
|
||||
// This callback was introduced in 2.0 as nicehack_extends_navigation(global_navigation $nav)
|
||||
// In 2.3 support was added for the now preferred local_nicehack_extends_navigation(global_navigation $nav).
|
||||
}
|
||||
function local_nicehack_extends_settings_navigation(settings_navigation $nav, context $context) {
|
||||
// $nav is the settings navigation instance.
|
||||
|
Loading…
x
Reference in New Issue
Block a user