Is there a _doing_it_wrong() equivalent for plugins?

There’s a note on the _doing_it_wrong() function that it should not be used by plugin or theme devs. This doesn’t mean it won’t work in our code, but, in keeping with best practices, I’m wondering: is there a comparable function that is acceptable to use in plugins/themes to handle incorrectly called functions? If there’s no comparable function, what would be the recommended approach to this? :thinking: Thanks for any insights!

1 Like

Not that I know of. One could certainly replicate the functionality of _doing_it_wrong (the underscore _ at the start of the function normally is used to indicate a private method, hence the note), using a custom prefix for the current plugin or theme, eg. _my_theme_prefix_doing_it_wrong or similar.

The other option that comes to mind would be using classic PHP logging, using a simple wrapper function.

cu, w0lf.

1 Like

Thanks, @fwolf… I searched high and low with no luck…then thought: hey, this is a good reason to use the forum. :slight_smile: As you noted, I’ll likely create a dedicated function. Not an ideal solution, given that the functionality preexists in the global space, but it’s not as bad as other situations I’ve run across… such as the recommendation of including a copy of the WP_List_Table class in our plugins if we want to use it. That’s a whole lot of duplicate code…but, that’s a whole other can o’ worms. Thanks again for your insight!

1 Like

This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

As @fwolf says, this message is only appearing because the function name begins with an underscore _. It’s an automated message, not specific to this function.

I find 1148 plugins that use _doing_it_wrong, and the core itself. That’s a lot, so this function is not going anywhere.

So, I’d just use _doing_it_wrong and not worry about it.

WP_List_Table is a whole other story. What a mess.

1 Like

:astonished: Yeah, that’s pretty entrenched… good point.


1 Like