But they said to edit /wp-includes/plugin.php…

As some of you may know, I spend a lot of my time deep in code or hanging out in the WordPress Trac or support forum. Today, I ran a crossed a post that almost made me put down my coffee and start head banging my desk.

If you work with WordPress, then you more than likely have seen the following warning (or something along the lines of it):

PHP Warning: call_user_func_array() expects parameter 1 to be a valid callback, function ‘some_function’ not found or invalid function name in /wp-includes/plugin.php on line XXX

The above warning is very common and has nothing to do with WordPress or any file that is mentioned in the warning. So why the head banging you ask? More times than I would like to see, people are looking to the file located at /wp-includes/plugin.php for some clue and then editing the file directly.

Editing core files directly is not recommended nor advised.

So whats wrong with editing core files directly?

It boils down to how WordPress updates work. Lets say that I edited the file “/wp-includes/plugin.php” to silence an error and the following month I upgraded WordPress. The warning message will be back. WordPress is tested extensively and 99.9% of the time the error or warnings are from third party plugins and themes.

Why the warning if it is not WordPress’s fault?

WordPress has hooks called actions and filters. They are used to hook into core functionality without having to modify any core code (Remember, changes to core will be wiped on the next update). Plugin and themes tell WP where and what function to run at certain parts of the script execution.

If a plugin tells WordPress to run “some_function” but the plugin does not define “some_function” you will see an warning that looks like it is WordPress having the issue.

How do I fix the warning message?

Follow the steps of disabling all the plugins and enabling them one by one until the problem comes back is the correct way of tackling the issue. Once you find out which plugin or theme is causing the issue, contact the developer of the plugin and let them know what is going on or simply do not use that plugin/theme.