NGG_Setup

The NextCellent Gallery NGG Setup class.

Defined (1)

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

/admin/class-ngg-setup.php  
  1. class NGG_Setup extends NGG_Post_Admin_Page { 
  2.  
  3. public function display() { 
  4. parent::display(); 
  5.  
  6. global $wpdb; 
  7.  
  8. ?> 
  9. <div class="wrap"> 
  10. <h2><?php _e('Reset options', 'nggallery') ;?></h2> 
  11. <form name="resetsettings" method="post"> 
  12. <?php wp_nonce_field('ngg_uninstall') ?> 
  13. <p><?php _e('Reset all options/settings to the default installation.', 'nggallery') ;?></p> 
  14. <div align="center"> 
  15. <input type="submit" class="button" id="reset-to-default" name="resetdefault" value="<?php _e('Reset settings', 'nggallery') ;?>"> 
  16. </div> 
  17. </form> 
  18. </div> 
  19. <?php if ( !is_multisite() || is_super_admin() ) : ?> 
  20. <div class="wrap"> 
  21. <h2><?php _e('Uninstall plugin tables', 'nggallery') ;?></h2> 
  22.  
  23. <form name="resetsettings" method="post"> 
  24. <div> 
  25. <?php wp_nonce_field('ngg_uninstall') ?> 
  26. <p><?php _e('You don\'t like NextCellent Gallery?', 'nggallery') ;?></p> 
  27. <p><?php _e('With this button you can clear all database tables. This should also happen if you uninstall the normal way, but it can be useful for manually uninstalling NextCellent completely.', 'nggallery') ;?> 
  28. </div> 
  29. <p style="color: red"> 
  30. <strong><?php _e('WARNING:', 'nggallery') ;?></strong> 
  31. <br> 
  32. <?php _e('Once uninstalled, this cannot be undone. You should use a Database Backup plugin of WordPress to backup all the tables first. NextCellent gallery is stored in the tables', 'nggallery') ;?> <strong><?php echo $wpdb->nggpictures; ?></strong>, <strong><?php echo $wpdb->nggalbum; ?></strong> <?php _e('and', 'nggallery') ;?> <strong><?php echo $wpdb->nggalbum; ?></strong>. 
  33. </p> 
  34. <div align="center"> 
  35. <input type="button" name="show_button" id="show-button" class="button" value="<?php _e('Show uninstall button', 'nggallery') ?>"> 
  36. <input style="display: none; color: red" id="delete-button" type="submit" name="uninstall" class="button delete" value="<?php _e('Uninstall plugin', 'nggallery') ?>"> 
  37. </div> 
  38. </form> 
  39. </div> 
  40. <?php endif; ?> 
  41.  
  42. <script type="text/javascript"> 
  43. document.getElementById('reset-to-default').addEventListener('click', function(event) { 
  44. var check = confirm( 
  45. '<?php echo esc_js( __( 'Reset all options to default settings?', 'nggallery' ) ) ?>' + 
  46. '\n\n' + 
  47. '<?php echo esc_js( __( 'Choose [Cancel] to Stop, [OK] to proceed.', 'ngallery') ) ?>' 
  48. ); 
  49. if(!check) { 
  50. event.preventDefault(); 
  51. }, false); 
  52.  
  53. document.getElementById('show-button').addEventListener('click', function() { 
  54. document.getElementById('delete-button').style.display = "block"; 
  55. }, false); 
  56.  
  57. document.getElementById('delete-button').addEventListener('click', function() { 
  58. var check = confirm( 
  59. '<?php echo esc_js( __( 'You are about to uninstall this plugin from WordPress. This action is not reversible.', 'nggallery' ) ) ?>' + 
  60. '\n\n' + 
  61. '<?php echo esc_js( __( 'Choose [Cancel] to Stop, [OK] to proceed.', 'ngallery') ) ?>' 
  62. ); 
  63. if(!check) { 
  64. event.preventDefault(); 
  65. }, false); 
  66.  
  67.  
  68.  
  69. </script> 
  70.  
  71. <?php 
  72.  
  73.  
  74.  
  75. /** 
  76. * Handle the POST updates. This functions is called by the display() function, if used properly. 
  77. */ 
  78. protected function processor() { 
  79. global $ngg; 
  80.  
  81. check_admin_referer('ngg_uninstall'); 
  82.  
  83. include_once ( dirname (__FILE__). '/class-ngg-installer.php'); 
  84.  
  85. if (isset($_POST['resetdefault'])) { 
  86.  
  87. NGG_Installer::set_default_options(); 
  88. $ngg->load_options(); 
  89.  
  90. nggGallery::show_message(__('Reset all settings to the default parameters.', 'nggallery')); 
  91.  
  92. if (isset($_POST['uninstall'])) { 
  93.  
  94. NGG_Installer::uninstall(); 
  95.  
  96. nggGallery::show_message(__('Uninstall successful! Now delete the plugin and enjoy your life!', 'nggallery'));