WP CLI Call to undefined function apply_filters()

Doing a BackupBuddy backup from the commandline using WP CLI on a GoDaddy server the other day I ran into a fatal error. A WP CLI Call to undefined function apply_filters() error to be precise. It did not allow me to backup from the command line at all. The site was running fine.

Anyways, the error I got running the command:

wp backupbuddy backup 2

was the following one:

Fatal error: Call to undefined function apply_filters() in /home/user/public_html/wordpress/wp-includes/load.php on line 317


Googling the issue I found out that many websites were displaying similar issues. And no solutions really but to remove the core files and replace them with a fresh set or turning off all plugins and checking if that helps. The basics. But then I stumbled upon this SO thread. There the suggestion was to see if wp cli could be updated. And then I remembered wp cli having some issues with Trellis and WordPress 4.6. And I thought, yeah, that could be it!

Updating WP CLI to 0.24.1

So I ran the updater using the following command:

wp cli update

and it worked updating it all:

 wp cli update

You have version 0.22.0. Would you like to update to 0.24.1? [y/n] y

Downloading from https://github.com/wp-cli/wp-cli/releases/download/v0.24.1/wp-cli-0.24.1.phar...

New version works. Proceeding to replace.

Success: Updated WP-CLI to 0.24.1

WP CLI BackupBuddy Re-Run

After that I ran the command to backup the site again:

wp backupbuddy backup 2

It did not spit out the same error again, but it did take its sweet time showing some feedback. After like 2 minutes it mentioned zip functionality it could not find as usual and then proceeded to do the backup.

Happy ending!

NB Reasons for using wp cli for BB backups on GoDaddy and installation instructions are mentioned here if you need them.

BackupBuddy Wordfence Conflict

Had a BackupBuddy Wordfence conflict the other day. I noticed in the BackupBuddy logs that BackupBuddy failed to make a backup as it tried to backup the Wordfence tmp file while that was being used by Wordfence. And therefore it failed.

Calling BackupBuddy..

I contacted BackBuddy support. They responded quite quickly as they always do. Love that and love BackupBuddy for making complete backups and taking care of migrations. Just like I love Wordfence for taking care of my sites’ security.

Site to Site Solution

To deal with this you need to excluded the directory for all file and complete backups:


in BackupBuddy under general settings > Default excluded files & directories (relative to WordPress root):

BackupBuddy File and Directory Defaults


That way that directory will always be ignored / excluded. Did use directory exclusion on BackupBuddy before the exclude certain error logs, backup directories. I also excluded some tables like Slimstat tables as they can get really big if you intend on keeping data for a year or more.

Database Defaults Settings BackupBuddy:

BackupBuddy Database Defaults

This was the first time I bumped into a specific BackupBuddy Wordfence conflict though.

TMP in Plugin Directory?

In my correspondence with BackupBuddy they stated that:

Plugins really should not create temporary directories/data under their own plugin installation directory but Wordfence tends to play by its own rules 🙂

Whether a plugin author should place a tmp folder in the plugin directory or in the webroot is a discussion I would love to have. I think it is OK to have it in the plugin root. I love to keep the webroot clean and avoid conflicts with other plugins. Would love to hear what other people think about this.

Permanent Solution

You would think that BackupBuddy – commercial WordPress plugin for backups – would make sure it would work well with the most populair Freemium Security plugin out there. Even though iThemes have their own commercial Security plugin they should still play nice with others out there, shouldn’t they? Especially if the other party is populair and has a free version.

But that is my opinion. I will not leave either plugin any time soon. Would however love to have this conflict out of the way and not being forced to add this exclusion to every WordPress site I work on.

What do you think?

If you have an opinion on the location of the tmp directory for plugins or have questions on the blog post do let me know. Would love to hear about it all!


Update Feedback BackupBuddy

Quite happy to discuss tmp file locations, but under a plugin installation directory is not a location to use as you cannot rely on write access. Here is the code from WF related to this:

private static function getCacheFile(){
    return WORDFENCE_PATH . 'tmp/configCache.php';

and this simply will not yield a usable file if there is no write access. WordPress provides a specific function to yield a (base) temporary directory location which also allows the user to set their own temporary directory and a plugin might then create their own subdirectory for their own use – this allows the user to control where theywant temporary files to go and makes it simpler for all such temporary data to be excluded from a backup by simply excluding that directory. Of course a user can define this to be outside the installation directory provided PHP has access to it (it doesn’t need to be externally accessible).

Would be nice though if BB would play nice with Wordfence – very populair security plugin – without using this directory
exclusion solution.

Yes, it certainly would be good if the Wordfence developers gave a little more thought to their design decisions and the impact they are going to have on their users. WordPress is a largely “uncontrolled” ecosystem and it relies upon developers thinking in a wider context than just their product and sadly with Wordfence this is not an isolated case.

WordFence’s Take

I have had no feedback from WordFence yet. Must say that I do feel that BackupBuddy seems to be having a point here..

  1.  BackupBuddy is an awesome WordPress backup plugin
  2. Wordfence is the best freemium security WordPress plugin out there

WP CLI Error Running BackupBuddy Backup

Updating a site using BackupBuddy from the command line using WP CLI I ran into the following error related to the LayerSlider 5.6.2 plugin on WordPress 4.4.1.

WP CLI Error Running BackupBuddy Backup

The WP CLI Error running BackupBuddy Backup on a GoDaddy Ultimate Linux hosted site was:

Fatal error: Class 'WP_Widget' not found in /home/user/public_html/wordpress/wp-content/plugins/LayerSlider/wp/widgets.php on line 6

Code Scan

When you check that line inside the LayerSlider widgets.php file you will see

class LayerSlider_Widget extends WP_Widget {

Here the plugin builds upon the WP_Widget. That is pretty common when you want to create your own custom widget. See the Codex article on the WP_Widget here. But looking through the code all seemed to be loaded well and there were no issues with including classes.

WP CLI Upgrade

On contacting the author of the plugin I was told it was an issue with the WP CLI version I was using. So following the instructions in my own post I upgraded WP CLI to 0.22.0 and then I was able to backup all again properly.

BackupBuddy and GoDaddy

BackupBuddy and GoDaddy have never really been buddies really. Been hard to run BackupBuddy on GoDaddy to say the least, but I am here to tell you there are options to make it work on GoDaddy as running backups from the Dashboard fail most if not all the time. The option is running backups from the shell. This  you can of course only do if can access the site from shell and know how to use shell commands and or follow this short tutorial.


First of all you need to install WP CLI, the wonderful WordPress command line that is completely open source. GoDaddy explains how this can be done here. FYI this guide can be followed to upgrade WP CLI as well.

You first access GoDaddy using shell like so:

 ssh user@domain.com

Then you use curl to download WP CLI:

 curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar

Shell - Download WP CLI
Then you make sure the file can be executed

 chmod +x wp-cli.phar

And to check the functionality of WP CLI you can run the following command:

 php wp-cli.phar --info

Then you create an alias so you can use wp instead of the entire path to the file. Mind you that you make sure you have the PHP phar file in your home directory or else move it there.


NB If you were following this guide for updating WP CLI you should be done now.

 alias wp='~/wp-cli.phar'

Once the alias is created add it to .bashrc:

 echo "alias wp='~/wp-cli.phar'" >> .bashrc

and make sure it is taken up in the current Bash session:

 source .bashrc

Once that is done the wp cli command line tool should be working and we can move on to running BackupBuddy from the commandline.

Backup with BackupBuddy from the Command Line

Now from the command line you can do the following command to do a full backup:

 wp backupbuddy backup 2

Number two is related to a FULL backup of the site. Once that command is given a full backup will be run without I/O or RAM issues and you will see that it can be done!

Extra Tip

You could also add a crontab job from GoDaddy (see document at GD here) to run the script automatically on certain times, but that is for another tutorial.