Why does WordPress have private functions?

It is quite normal practice for code to not be a part of public API.

But much of WP code is ancient and procedural. There are no technical ways to make a private function.

These are semantically private, that is WP doesn’t want you to use them, but it cannot actually forbid you to. There is a long history of “private” WP APIs being actively used in practice by extensions.

The reasons for declaring something private vary from case to case. In this specific case you raised the reason seems to be that “public” version is pluggable, so moving implementation to a “private” version allows original to be replaced more easily / with less issues.

Leave a Comment