Use $plugin instead of $module for 2.7 compatibility

Also works with 2.5 and 2.6.

See https://tracker.moodle.org/browse/MDL-43896 and https://tracker.moodle.org/browse/MDL-43040