WYSIJA_help_uninstall

The MailPoet Newsletters WYSIJA help uninstall class.

Defined (1)

The class is defined in the following location(s).

/helpers/uninstall.php  
  1. class WYSIJA_help_uninstall extends WYSIJA_object{ 
  2.  
  3. var $options_delete = array( 
  4. 'wysija_import_fields',  
  5. 'wysija',  
  6. 'installation_step',  
  7. 'wysija_polls_views',  
  8. 'wysicheck',  
  9. 'dkim_autosetup',  
  10. 'wysija_queries',  
  11. 'wysija_queries_errors',  
  12. 'wysija_msg',  
  13. 'wysija_log',  
  14. 'wysija_last_scheduled_check',  
  15. 'wysija_post_type_updated',  
  16. 'wysija_post_type_created',  
  17. 'wysija_schedules',  
  18. 'wysija_last_php_cron_call',  
  19. 'wysija_check_pn',  
  20. 'wysija_bounce_being_recorded',  
  21. 'wysijey',  
  22. 'debug_on',  
  23. 'debug_new',  
  24. 'mpoet_frequency_set' 
  25. ); 
  26.  
  27. function __construct() { 
  28. //require_once(ABSPATH . 'wp-admin'.DS.'includes'.DS.'upgrade.php'); 
  29. parent::__construct(); 
  30.  
  31. function reinstall() { 
  32.  
  33. if (current_user_can('delete_plugins') && $this->removeProcess()) { 
  34. $this->notice(__('MailPoet has been reinstalled successfully using the same version. Settings and data have been deleted.', WYSIJA)); 
  35. } else { 
  36. $this->notice(__('MailPoet cannot be reinstalled because your folder <em>wp-content/uploads/wysija</em> needs to be writable. Change your permissions and reinstall.', WYSIJA)); 
  37.  
  38.  
  39. function uninstall() { 
  40.  
  41. if(current_user_can('delete_plugins') && $this->removeProcess()) { 
  42. $this->wp_notice(__("MailPoet has been uninstalled. Your site is now cleared of MailPoet.", WYSIJA)); 
  43.  
  44.  
  45. function removeProcess() { 
  46.  
  47. // Remove the wysija folder in uploads. 
  48. $helper_file = WYSIJA::get('file', 'helper'); 
  49. $upload_dir = $helper_file->getUploadDir(); 
  50. $is_writable = is_writable($upload_dir); 
  51. if ($is_writable) { 
  52. $helper_file->rrmdir($upload_dir); 
  53. } elseif ($upload_dir!=false) { 
  54. return false; 
  55.  
  56. $file_name = WYSIJA_DIR.'sql'.DS.'uninstall.sql'; 
  57. $handle = fopen($file_name, 'r'); 
  58. $query = fread($handle, filesize($file_name)); 
  59. fclose($handle); 
  60.  
  61. $queries = str_replace('DROP TABLE `', 'DROP TABLE `[wysija]', $query); 
  62.  
  63. $queries = explode('-- QUERY ---', $queries); 
  64. $modelWysija = new WYSIJA_model(); 
  65. global $wpdb; 
  66. foreach($queries as $query) 
  67. $modelWysija->query($query); 
  68. //wysija_last_php_cron_call 
  69.  
  70. foreach($this->options_delete as $option_key) { 
  71. delete_option($option_key); 
  72.  
  73. WYSIJA::update_option('wysija_reinstall', 1); 
  74.  
  75. global $wp_roles; 
  76. foreach($wp_roles->roles as $rolek=>$roled) { 
  77. if($rolek=='administrator') continue; 
  78. $role=get_role($rolek); 
  79. //remove wysija's cap 
  80. $arr=array('wysija_newsletters', 'wysija_subscribers', 'wysija_config'); 
  81.  
  82. foreach($arr as $arrkey) $role->remove_cap( $arrkey ); 
  83.  
  84. return true; 
  85.  
  86.  
  87.