The goal of this operation is to hide the listing of all available courses, not just the "All Courses" link. The list can be extensive and our institution wants to limit the view.
I have accomplished this in our instance by making the following modifications. The request is to have it generalized and added into the administration GUI.
In the administration:
Site Administration -> Plugins -> Blocks -> Courses
Check "Hide 'All courses' link
Site Administration -> Front page -> Front page settings
In "Front page items when logged in" have only "Enrolled Courses" selected
Hide Search Box
Remove "All Courses" Link
Under the case statement remove the all courses link from the html variable. I'm sure there is a better place/way for this, but I was not able to find it.
$mycourseshtml = str_replace('<div class="paging paging-morelink"><a href="https://my.moodle.edu/course/index.php">All courses</a></div>', '', $mycourseshtml);
Added break statement above the "No break" comment to prevent all available courses from being displayed.
// No "break" here. If there are no enrolled courses - continue to 'Available courses'.
Remove the "Courses" link from the navigation block.
$this->rootnodes['courses']->isexpandable = false;//true;