1

I have a WordPress plugin which I've built. This plugin contains a Pro version.

When user sign-up for the Pro version, he is getting a unique key.php file which he required to replace in the plugin directory.

The problem is when Pro users upgrade to newer versions, the key.php file is deleted and they need to re-upload it (every upgrade).

Is there any way to specify that this file shouldn't be deleted by WordPress installation process?

2 Answers 2

0

Two possible approaches:

File based:

Standard procedure for anything that you do not to get overwritten is to use the uploads folder. Then it will not get overwritten by any kind of update.

I have several plugins that need to save data in files for one reason or another - cached ics files, customised css snippets. I have the plugin create a subdir in the uploads folder and save the files there. Nothing gets overwritten.

Database:

Presumably your unique key.php has their 'key'. You could have them enter it in a field and save it in the database rather as an option - it will be safely hidden then - files can be found, especially if others figure out where you have them.

1
  • What I've eventually done is save the latest key.php file content in the DB. After the user upgrades the plugin, the empty key comes with empty data and thus doesn't overrides the existing DB key content. Commented Jul 19, 2013 at 21:53
1

When WordPress updates core, it doesn't overwrite the /wp-content directory. But if you're updating the plugin, you'll overwrite your plugin directory with new files.

Rather than adding a file manually to the plugins directory, I'd recommend using one of two approaches:

Host an Alternative Repository

I'll let you Google how to do this, since there are a few good tutorials on it already, and at least one outstanding book. But you can host your own separate repository for the pro version of your plugin. Push out updates directly through that and you'll control the update process 100%.

Offer a Companion Plugin

Distribute the key.php file as a separate plugin that users drop into the /wp-content directory on its own. Then they can activate the regular plugin and the "pro" plugin separately. When they update the regular plugin, nothing will happen to the "pro" files since they're separate.

Just make it so the "pro" plugin requires the standard one be activated.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.