Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question

migrated from stackoverflow.com Nov 8 '11 at 6:15

This question came from our site for professional and enthusiast programmers.

add comment

2 Answers

up vote 0 down vote accepted

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.

share|improve this answer
    
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. –  vovafeldman Jul 19 '13 at 21:53
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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