Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    I investigated this a bit. Checking WP_UNINSTALL_PLUGIN from even a procedural hook defined on the plugin main file yields an undefined error, it’s not just due to your class method. So I dug deeper.

    Take a look at the source code for uninstall_plugin() in wp-admin/includes/plugin.php. The only place where the constant is defined in the entire WP installation is on line 916. Notice this line executes ONLY when the uninstall.php technique is used. It is NOT defined for the hook technique!

    Even though it is not clear, the Codex article is correct. The Stack Exchange answer is clearly wrong, but it is over 2 years old and a few versions later, so apparently things have changed. I will attempt to make the Codex article more clear.

    So as it stands, only check for the constant when using the uninstall.php technique, not the hook technique.

    Thread Starter djeyewater

    (@djeyewater)

    Thanks very much for the answer!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Confused about WP_UNINSTALL_PLUGIN and uninstall hook’ is closed to new replies.