PluginProbe
Adminify – White Label, Admin Menu Editor, Login Customizer / 1.0.7
Adminify – White Label, Admin Menu Editor, Login Customizer v1.0.7
4.3.2 4.3.1 4.3.0 4.2.26 4.2.25 4.2.24 4.2.23 4.2.22 4.2.21 4.2.20 4.2.19 4.2.18 4.2.17 4.2.16 4.2.15 4.2.14 4.2.13 4.2.12 4.2.11 4.2.10 4.2.9 4.2.8 4.2.7 4.2.6 4.2.5 All 165 releases
adminify / Inc / Modules / ServerInformation / ServerInfo_Error_Logs_Details.php

ServerInfo_Error_Logs_Details.php in Adminify – White Label, Admin Menu Editor, Login Customizer 1.0.7, at Inc/Modules/ServerInformation/ServerInfo_Error_Logs_Details.php

171 lines 5.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace WPAdminify\Inc\Modules\ServerInformation;
4
5 use WPAdminify\Inc\Utils;
6
7 // no direct access allowed
8 if (!defined('ABSPATH')) exit;
9
10 /**
11 * WPAdminify
12 * @package Server Information: Error Logs
13 *
14 * @author WP Adminify <support@wpadminify.com>
15 */
16
17 class ServerInfo_Error_Logs_Details
18 {
19 public function __construct()
20 {
21 $this->init();
22 }
23
24 public function init()
25 { ?>
26
27 <div class="wrap">
28 <h1>
29 <?php echo Utils::admin_page_title(esc_html__('Error Logs', WP_ADMINIFY_TD)); ?>
30 </h1>
31 <?php if ((defined('WP_DEBUG') && !WP_DEBUG) || (defined('WP_DEBUG_LOG') && !WP_DEBUG_LOG)) { ?>
32 <p style="color: #ce2754; font-weight: bold">
33 <?php echo esc_html__('You have to set and enable "WP_DEBUG" and "WP_DEBUG_LOG" in your "wp-config.php" file, to show the error log here!', WP_ADMINIFY_TD); ?>
34 </p>
35 <?php } ?>
36
37 <p>
38 <?php esc_html_e('Note that debugging (the process of finding and resolving issues in software) is disabled by default in WordPress and should not be enabled on live websites. However it can be enabled temporarily to troubleshoot issues.', WP_ADMINIFY_TD); ?>
39 <br>
40 <a href="https://wordpress.org/support/article/debugging-in-wordpress/" target="_blank" rel="noopener"><?php esc_html_e('Learn more about debugging in WordPress.', WP_ADMINIFY_TD); ?></a>
41 </p>
42 </div>
43
44 <?php
45
46 // Get the wp "debug.log" file
47 $file = self::jltwp_adminify_error_log();
48
49 // Get the wp "debug.log" file content
50 $file_content = self::jltwp_adminify_error_log_content($file);
51
52 // Check for custom "debug.log" file path
53 $custom_file_path = (defined('WP_DEBUG_LOG') && WP_DEBUG_LOG != false && WP_DEBUG_LOG != 1);
54
55 // Check for depug modes
56 $debug_modes = array();
57
58 $debug_modes['WP_DEBUG'] = '';
59 if (defined('WP_DEBUG') && WP_DEBUG) {
60 $debug_modes['WP_DEBUG'] = true;
61 }
62
63 $debug_modes['WP_DEBUG_DISPLAY'] = '';
64 if (defined('WP_DEBUG_DISPLAY') && WP_DEBUG_DISPLAY) {
65 $debug_modes['WP_DEBUG_DISPLAY'] = true;
66 }
67
68 $debug_modes['WP_DEBUG_LOG'] = '';
69 if (defined('WP_DEBUG_LOG') && WP_DEBUG_LOG) {
70 $debug_modes['WP_DEBUG_LOG'] = true;
71 }
72
73 $debug_modes['SCRIPT_DEBUG'] = '';
74 if (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) {
75 $debug_modes['SCRIPT_DEBUG'] = true;
76 }
77
78 $debug_modes['SAVEQUERIES'] = '';
79 if (defined('SAVEQUERIES') && SAVEQUERIES) {
80 $debug_modes['SAVEQUERIES'] = true;
81 } ?>
82
83 <br>
84
85 <div class="wp-adminify-error-logs block">
86 <ul>
87 <?php foreach ($debug_modes as $debug_mode => $value) {
88
89 $status = 'disable has-text-white p-1 pl-3 pr-3 is-rounded';
90 $label = esc_html__('Disabled', WP_ADMINIFY_TD);
91 if ($value) {
92 $status = 'enable has-text-white p-1 pl-3 pr-3 is-rounded';
93 $label = esc_html__('Enabled', WP_ADMINIFY_TD);
94 } ?>
95
96 <li class="is-inline-block mr-4">
97 <span>
98 <?php echo esc_html($debug_mode) . ' '; ?>
99 <span class="field-status <?php echo esc_html($status); ?>"><?php echo esc_html($label); ?></span>
100 <?php if ($debug_mode === 'WP_DEBUG_LOG' && $custom_file_path) { ?>
101 <span class="field-status"><?php echo esc_html__('Custom path', WP_ADMINIFY_TD); ?></span>
102 <?php } ?>
103 </span>
104 </li>
105 <?php } ?>
106 </ul>
107 </div>
108
109 <div class="buttons-group is-pulled-right">
110 <button id="adminify_error_log_clear" class="button clear-button">
111 <?php echo esc_html__('Clear file content', WP_ADMINIFY_TD); ?>
112 </button>
113
114 <button id="adminify_error_log_refresh" class="button button-primary ml-3">
115 <?php echo esc_html__('Refresh', WP_ADMINIFY_TD); ?>
116 </button>
117 </div>
118
119 <p class="mt-4">
120 <?php echo esc_html__('Debug log file was found at:', WP_ADMINIFY_TD) . ' <strong>' . esc_html($file) . '</strong>'; ?>
121 <br>
122 </p>
123
124 <textarea id="adminify_error_log_area" class="adminify-info-text-area" readonly><?php echo esc_html($file_content); ?></textarea>
125 <?php
126 }
127
128
129
130 public static function jltwp_adminify_error_log()
131 {
132
133 // Get the path of wp "debug.log"
134 $file = get_home_path() . 'wp-content/debug.log';
135
136 // Check for custom "debug.log" file path
137 $custom_file_path = (defined('WP_DEBUG_LOG') && WP_DEBUG_LOG != false && WP_DEBUG_LOG != 1);
138 if ($custom_file_path) {
139 $file = WP_DEBUG_LOG;
140 }
141
142 return $file;
143 }
144
145 /**
146 * * Get Error Log File Contents
147 */
148 public static function jltwp_adminify_error_log_content($file)
149 {
150
151 // Call wp file system
152 global $wp_filesystem;
153 WP_Filesystem();
154
155 // Show this notice, if no file exist
156 $content = esc_html__('debug.log file not found!', WP_ADMINIFY_TD);
157
158 // Check if "debug.log" file exist
159 if ($wp_filesystem->exists($file)) {
160 $content = $wp_filesystem->get_contents($file);
161
162 // Check if the file content is empty
163 if ($wp_filesystem->get_contents($file) == '') {
164 $content = esc_html__('File content is empty. No errors logged.', WP_ADMINIFY_TD);
165 }
166 }
167
168 return $content;
169 }
170 }
171