'Wordpress plugin options need to delete after deactivate & uninstall

I have developed a WordPress plugin and I need to delete the options I am creating when uninstalling. What I did is I created a file called uninstall.php and included the following code:

<?php

function WCM_Setup_Demo_on_uninstall()
{
  //if uninstall not called from WordPress exit
  if (!defined('WP_UNINSTALL_PLUGIN'))
    exit();

  $video - thumbnail1 = 'video-thumbnail1';


  // For Single site
  if (!is_multisite()) {
    delete_option($video - thumbnail1);
  }
}

?>

And included this in my main plugin file:

register_uninstall_hook('uninstall.php', 'WCM_Setup_Demo_on_uninstall');

This is how i'm registering the option in my main plugin file:

register_setting( 'baw-settings-group', 'video-thumbnail1' );

When I deactivated and deleted the plugin from the dashboard, the plugin gets deactivated but not deleted. When one press delete a blank white page comes up.



Solution 1:[1]

With activate/deactivate hooks:

http://codex.wordpress.org/Function_Reference/register_activation_hook http://codex.wordpress.org/Function_Reference/register_uninstall_hook http://codex.wordpress.org/Function_Reference/register_deactivation_hook

I don't post a example, you found it on the WordPress-Codex.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Adrian Preuss