/CFDBDie.php

  1. <?php 
  2. /** 
  3. "Contact Form to Database" Copyright (C) 2011-2012 Michael Simpson (email : michael.d.simpson@gmail.com) 
  4.   
  5. This file is part of Contact Form to Database. 
  6.   
  7. Contact Form to Database is free software: you can redistribute it and/or modify 
  8. it under the terms of the GNU General Public License as published by 
  9. the Free Software Foundation, either version 3 of the License, or 
  10. (at your option) any later version. 
  11.   
  12. Contact Form to Database is distributed in the hope that it will be useful,  
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of 
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
  15. GNU General Public License for more details. 
  16.   
  17. You should have received a copy of the GNU General Public License 
  18. along with Contact Form to Database. 
  19. If not, see <http://www.gnu.org/licenses/>. 
  20. */ 
  21.  
  22. class CFDBDie { 
  23.  
  24. /** 
  25. * Why this function? It is meant to do what wp_die() does. But in 
  26. * Ajax mode, wp_die just does die(-1). But in this plugin we are leveraging 
  27. * Ajax mode to put in URL hooks to do exports. So it is not really making a in-page 
  28. * call to the url, the full page is navigating to it, then it downloads a CSV file for 
  29. * example. So if there are errors we want the wp_die() error page. So this 
  30. * function is a copy of wp_die without the Ajax mode check. 
  31. * @static 
  32. * @param string $message HTML 
  33. * @param string $title HTML Title 
  34. * @param array $args see wp_die 
  35. * @return void 
  36. */ 
  37. static function wp_die($message, $title = '', $args = array()) { 
  38. // Code copied from wp_die without it stopping due to AJAX 
  39. if ( function_exists( 'apply_filters' ) ) { 
  40. $function = apply_filters( 'wp_die_handler', '_default_wp_die_handler'); 
  41. } else { 
  42. $function = '_default_wp_die_handler'; 
  43. call_user_func( $function, $message, $title, $args ); 
.