Advertisement
SergeyBiryukov

Custom wp_die() handler for comments

Oct 19th, 2011
473
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.48 KB | None | 0 0
  1. function comment_post_wp_die_handler( $message, $title = '', $args = array() ) {
  2.     if ( !headers_sent() ) {
  3.         nocache_headers();
  4.         header( 'Content-Type: text/html; charset=utf-8' );
  5.     }
  6. ?>
  7. <!DOCTYPE html>
  8. <html xmlns="http://www.w3.org/1999/xhtml">
  9. <head>
  10.     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  11.     <title><?php _e('WordPress &rsaquo; Error'); ?></title>
  12.     <style type="text/css">
  13.         html {
  14.             background: #f9f9f9;
  15.         }
  16.         body {
  17.             background: #fff;
  18.             color: #333;
  19.             font-family: "Lucida Grande", Verdana, Arial, "Bitstream Vera Sans", sans-serif;
  20.             margin: 2em auto;
  21.             width: 700px;
  22.             padding: 1em 2em;
  23.             -moz-border-radius: 11px;
  24.             -khtml-border-radius: 11px;
  25.             -webkit-border-radius: 11px;
  26.             border-radius: 11px;
  27.             border: 1px solid #dfdfdf;
  28.         }
  29.         #error-page {
  30.             margin-top: 50px;
  31.         }
  32.         #error-page p {
  33.             font-size: 12px;
  34.             line-height: 18px;
  35.             margin: 25px 0 20px;
  36.         }
  37.         #error-page code {
  38.             font-family: Consolas, Monaco, monospace;
  39.         }
  40.     </style>
  41. </head>
  42. <body id="error-page">
  43.     <p><?php if ( is_string( $message ) ) echo $message; ?></p>
  44.     <p><a href='javascript:history.back()'><?php _e('&laquo; Back'); ?></a></p>
  45. </body>
  46. </html>
  47. <?php
  48.     die();
  49. }
  50.  
  51. function add_comment_post_wp_die_handler() {
  52.     if ( false !== strpos( $_SERVER['REQUEST_URI'], 'wp-comments-post.php' ) )
  53.         return 'comment_post_wp_die_handler';
  54.     else
  55.         return '_default_wp_die_handler';
  56. }
  57. add_filter('wp_die_handler', 'add_comment_post_wp_die_handler');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement