so I’m using WordPress, which loads the theme and possibly many plugins which can have functions with the same names as the ones in the theme.
How can I avoid function name conflicts between the theme and plugins, without having to rename them to something like “theme_function()”?
You can’t really. You need to rename your functions in a way they don’t collide with any other function. Prefixing functions with your theme’s name sounds pretty clean and optimal.
Possible other workarounds that come to mind are
Using a static class
Themeand adding any functions to that (Theme::function();)- not much different from adding atheme_prefix to normal function names, thoughOnce PHP 5.3 is widely spread in a few years, you can use namespaces – it’s too early at the moment, though, if you want to build redistributable themes or plugins.