title: register_uninstall_hook not working on wordpress plugin uninstall
body: <p>Hi there i make a plugin, now i want that when a user deactivate the plugin, all the functions and posts and option values and meta values also be deleted.</p>
  
  <p>I write a hook and make a file where i delete all the values, but it did not work, i use this hook</p>
  
  <pre><code>register_uninstall_hook('foo_uninstall.php', $callback);
  </code></pre>
  
  <p>Is there any other hook to use for this purpose.</p>
  
  <p>Here is my foo_uninstall.php code</p>
  
  <pre><code>&lt;?php
  global $wpdb;
  $del_prefix = $wpdb-&gt;prefix;
  
  //if uninstall not called from WordPress exit
  if(!defined('WP_UNINSTALL_PLUGIN'))
      exit();
  
  //=========&gt; Delete foo Options
      delete_option('foo_theme_directory');
      delete_option('foo_plugin_slug');
      delete_option('foo_article_qty');
      delete_option('foo_search_setting');
      delete_option('foo_breadcrumbs_setting');
      delete_option('foo_sidebar_setting');
      delete_option('foo_comments_setting');
      delete_option('foo_bgcolor');
      delete_option('widget_foo_article_widget');
      delete_option('foo_cat_children');
  
  //=========&gt; Get and Delete Foo Page
      $foo_get_page = $wpdb-&gt;get_results("SELECT * FROM ".$del_prefix."posts WHERE post_type='page' And 
  
  post_content = '[foo_article]' And post_name = 'article'",ARRAY_A );
  
      $fooPageID = $foo_get_page['ID'];
  
      $wpdb-&gt;query("DELETE FROM ".$del_prefix."postmeta WHERE post_id = '$fooPageID'");
  
      $wpdb-&gt;query("DELETE FROM ".$del_prefix."posts WHERE post_title Like '%article%' And post_type = 
  
  'page'");
  
  //=========&gt; Delete foo Terms and Taxonomies
      $foo_Find_tax = $wpdb-&gt;get_results("SELECT term_taxonomy_id FROM ".$del_prefix."term_taxonomy WHERE 
  
  taxonomy='foo_article'",ARRAY_A );
      $fooTaxID = $foo_Find_tax[0]['term_taxonomy_id'];
  
      foreach($foo_Find_tax as $foo_find_tax){
      $fooTaxID = $foo_find_tax['term_taxonomy_id'];
  
      $delete_foo_relations = $wpdb-&gt;query("DELETE FROM ".$del_prefix."term_relationships WHERE 
  
  term_taxonomy_id='$fooTaxID'");
      $delete_foo_tax = $wpdb-&gt;query("DELETE FROM ".$del_prefix."term_taxonomy WHERE 
  
  term_taxonomy_id='$fooTaxID'");
      $delete_foo_terms = $wpdb-&gt;query("DELETE FROM ".$del_prefix."terms WHERE term_id='$fooTaxID'");
      }
  
  //=========&gt; Delete terms_order From wp_terms
      $wpdb-&gt;query("ALTER TABLE ".$del_prefix."terms DROP `terms_order`");
  
  //=========&gt; Delete comments of articles
      $foo_comments = $wpdb-&gt;get_results("SELECT ID FROM ".$del_prefix."posts WHERE post_type = 
  
  'foo_article'");
  
      $foo_comment_id = $foo_comments-&gt;ID;
  
      foreach($foo_comments as $foo_comment){
          $foo_comment_id = $foo_comment-&gt;ID;
          $wpdb-&gt;query("DELETE FROM ".$del_prefix."comments WHERE comment_post_ID='$foo_comment_id'");
      }
  
  //=========&gt; Delete All Articles and Attachments
      $foo_all_articles = new WP_Query('post_type=foo_article&amp;posts_per_page=-1');
  
      if($foo_all_articles){
          while($foo_all_articles-&gt;have_posts()) :
              $foo_all_articles-&gt;the_post();
              $fooID = get_the_id();
  
              $foo_del_args = array('post_parent' =&gt; $fooID);
              $foo_attachments = get_children($foo_del_args);
  
              if($foo_attachments){
                  foreach($foo_attachments as $foo_attachment){
                      wp_delete_attachment($foo_attachment-&gt;ID, true);
                  }
              }
              wp_delete_post($fooID, true);
          endwhile;
      }
  
  //=========&gt; Remove all files and images
      unlink(get_template_directory()."/foo_articles.php");
      unlink(get_template_directory()."/foo_style.css");
      unlink(get_template_directory()."/single-foo_articles.php");
      unlink(get_template_directory()."/taxonomy-foo_cat.php");
      unlink(get_template_directory()."/foo_search.php");
  
  ?&gt;
  </code></pre>