PluginProbe
Adminify – White Label, Admin Menu Editor, Login Customizer / 4.1.3
Adminify – White Label, Admin Menu Editor, Login Customizer v4.1.3
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 4.1.17 All 164 releases
adminify / Inc / Modules / ServerInformation / ServerInfo_Error_Logs_Details.php

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

171 lines 4.9 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' ) ) {
9 exit;
10 }
11
12 /**
13 * WPAdminify
14 *
15 * @package Server Information: Error Logs
16 *
17 * @author WP Adminify <support@wpadminify.com>
18 */
19
20 class ServerInfo_Error_Logs_Details {
21
22 public function __construct() {
23 $this->init();
24 }
25
26 public function init() { ?>
27
28 <div class="wrap">
29 <h1> <?php echo Utils::admin_page_title( esc_html__( 'Error Logs', 'adminify' ) ); ?> </h1>
30
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!', 'adminify' ); ?>
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.', 'adminify' ); ?>
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.', 'adminify' ); ?></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 = [];
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
84 <br>
85
86 <div class="wp-adminify-error-logs block">
87 <ul>
88 <?php
89 foreach ( $debug_modes as $debug_mode => $value ) {
90 $status = 'disable has-text-white p-1 pl-3 pr-3 is-rounded';
91 $label = esc_html__( 'Disabled', 'adminify' );
92 if ( $value ) {
93 $status = 'enable has-text-white p-1 pl-3 pr-3 is-rounded';
94 $label = esc_html__( 'Enabled', 'adminify' );
95 }
96 ?>
97
98 <li class="is-inline-block mr-4">
99 <span>
100 <?php echo esc_html( $debug_mode ) . ' '; ?>
101 <span class="field-status <?php echo esc_html( $status ); ?>"><?php echo esc_html( $label ); ?></span>
102 <?php if ( $debug_mode === 'WP_DEBUG_LOG' && $custom_file_path ) { ?>
103 <span class="field-status"><?php echo esc_html__( 'Custom path', 'adminify' ); ?></span>
104 <?php } ?>
105 </span>
106 </li>
107 <?php } ?>
108 </ul>
109 </div>
110
111 <div class="buttons-group is-pulled-right">
112 <button id="adminify_error_log_clear" class="adminify-btn adminify-btn-outline-primary clear-button">
113 <?php echo esc_html__( 'Clear file content', 'adminify' ); ?>
114 </button>
115
116 <button id="adminify_error_log_refresh" class="adminify-btn adminify-btn-primary ml-3">
117 <?php echo esc_html__( 'Refresh', 'adminify' ); ?>
118 </button>
119 </div>
120
121 <p class="mt-4">
122 <?php echo esc_html__( 'Debug log file was found at:', 'adminify' ) . ' <strong>' . esc_html( $file ) . '</strong>'; ?>
123 <br>
124 </p>
125
126 <textarea id="adminify_error_log_area" class="adminify-info-text-area" readonly><?php echo esc_html( $file_content ); ?></textarea>
127 <?php
128 }
129
130
131
132 public static function jltwp_adminify_error_log() {
133
134 // Get the path of wp "debug.log"
135 $file = get_home_path() . 'wp-content/debug.log';
136
137 // Check for custom "debug.log" file path
138 $custom_file_path = ( defined( 'WP_DEBUG_LOG' ) && WP_DEBUG_LOG != false && WP_DEBUG_LOG != 1 );
139 if ( $custom_file_path ) {
140 $file = WP_DEBUG_LOG;
141 }
142
143 return $file;
144 }
145
146 /**
147 * * Get Error Log File Contents
148 */
149 public static function jltwp_adminify_error_log_content( $file ) {
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!', 'adminify' );
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.', 'adminify' );
165 }
166 }
167
168 return $content;
169 }
170 }
171