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 read on the codex that the best way to implement a clean uninstallation functionality to a plugin is by adding a uninstall.php file inside your plugin directory.

I'm wondering: can i use my plugin's Class instance data inside the uninstall.php file?

This is the code sitting in my uninstall.php file:

if(!defined('WP_UNINSTALL_PLUGIN')) exit;
delete_option('my_plugin_options');
$table_name = $wpdb->prefix . $this->dbName;
$wpdb->query("DROP TABLE `$table_name`");

I'm wondering if the table_name variable will be properly retrieved, or if i should hardcode it.

As per my tests, the table remains after deletion, so i guess i'l fallback to using a hook inside my plugin's file, unless i'm missing something?

share|improve this question

1 Answer 1

up vote 0 down vote accepted

I'm not in my desktop, but I suspect it won't be retrieved.

But:

  • have you tested it? Does the table gets droped?
  • I'd say you need to declare global $wpdb;, isn't it?
  • if you don't have any, a tool like FirePHP is really handy when developing
  • anyway, this seems a case where is pretty harmless to hardcode the table name
share|improve this answer

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.