Пример #1
0
 public function wp_debug()
 {
     if (defined('WP_DEBUG') && WP_DEBUG === true && defined('WP_DEBUG_LOG') && WP_DEBUG_LOG === true) {
         $path = WP_CONTENT_DIR . '/debug.log';
         $debug = '';
         if (file_exists($path) && is_writeable($path)) {
             add_debug_header_link(Debug_This::get_current_debug_url() . '&clear-debug-log=true', __('Reset log file', 'debug-this'));
             if (isset($_GET['clear-debug-log'])) {
                 if (file_put_contents($path, '') === 0) {
                     $debug .= __('Debug log was successfully cleared.', 'debug-this');
                 } else {
                     $debug .= __('Debug log could not be reset. Please try again', 'debug-this');
                 }
             }
             $debug .= file_get_contents($path);
             if (!$debug) {
                 $debug .= __('Looking good! No notices were logged.', 'debug-this');
             }
         } elseif (touch($path)) {
             $debug = __('Looking good! No notices were logged.', 'debug-this');
         } else {
             $debug = __('Could not open debug.log. Please make sure your wp-content folder is writeable by the web server user.', 'debug-this');
         }
         return $debug;
     } else {
         $debug = __("Please add the following to wp-config.php to use this mode.\ndefine('WP_DEBUG', true);\ndefine('WP_DEBUG_LOG', true);\ndefine('WP_DEBUG_DISPLAY', false);", 'debug-this');
         return $debug;
     }
 }