Simplify Plugin.priority function

Originally by @hitendrasingh.

Closes #1631.