Changeset 3093644
- Timestamp:
- 05/28/2024 05:56:15 AM (2 months ago)
- Location:
- easy-error-log
- Files:
-
- 25 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
easy-error-log/trunk/assets/easy-errors.js
r3070183 r3093644 28 28 }, 29 29 success: function(response) { 30 30 31 // console.log(response); 31 32 $('#error-log-container').append(response); … … 125 126 }); 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 127 148 128 149 // Function to fetch and update error count … … 166 187 // Set intervals to update error count and error log periodically 167 188 var errorCountInterval = setInterval(updateErrorCount, 5000); // Update every 5 seconds 168 var errorLogInterval = setInterval(updateErrorLog, 5000); // To Update every 10 seconds 10000189 var errorLogInterval = setInterval(updateErrorLog, 5000); // To Update every 10 seconds 10000 169 190 170 191 // Clean up intervals when the page is unloaded 171 192 $(window).on('unload', function() { 172 193 clearInterval(errorCountInterval); 173 clearInterval(errorLogInterval); 174 }); 175 176 177 178 194 // clearInterval(errorLogInterval); 195 }); 196 179 197 180 198 // Initial load of error log -
easy-error-log/trunk/easy-error-log.php
r3070183 r3093644 11 11 * Plugin URI: https://github.com/sabbirsam/wp-error-log 12 12 * Description: Experience hassle-free debugging by conveniently defining error modes and debug log constants within the config file. No need to delve into core files – simply toggle the settings. Logs PHP errors and access all errors in a single, user-friendly dashboard page, making it effortless to identify and rectify issues. 13 * Version: 1. 1.113 * Version: 1. 14 14 * Requires at least: 5.9 or higher 15 15 * Requires PHP: 5.4 or higher … … 31 31 use EEL\Inc\EEL_Deactivate; //phpcs:ignore 32 32 33 define( 'EASY_ERROR_LOG_VERSION', '1. 1.0' );33 define( 'EASY_ERROR_LOG_VERSION', '1..0' ); 34 34 define( 'EASY_ERROR_LOG_FILE', __FILE__ ); 35 35 define( 'EASY_ERROR_LOG_DIR_URL', plugin_dir_url( __FILE__ ) ); … … 54 54 add_action( 'wp_ajax_display_error_log', array( $this, 'display_error_log_callback' ) ); 55 55 add_action( 'wp_ajax_clean_debug_log', array( $this, 'clean_debug_log_callback' ) ); 56 56 add_action('wp_ajax_reset_debug_constant', array($this, 'reset_debug_constant_callback')); 57 57 add_action( 'wp_ajax_toggle_debug_mode', array( $this, 'toggle_debug_mode_callback' ) ); 58 58 add_action( 'wp_ajax_get_debug_mode_status', array( $this, 'get_debug_mode_status_callback' ) ); … … 128 128 */ 129 129 public function add_error_page() { 130 // Check if wp-config.php exists and add Easy Error Log and debug if not found.130 // Check if . 131 131 $debug_error_mode_enabled = get_option('easy_error_log_debug_mode_enabled', 0); 132 if ( 0 === $debug_error_mode_enabled) {132 if ( ) { 133 133 $config_path = ABSPATH . 'wp-config.php'; 134 134 if ( file_exists($config_path) ) { 135 135 $config_contents = file_get_contents($config_path); 136 136 137 137 // Check if both WP_DEBUG and WP_DEBUG_LOG are defined, if not, add them. 138 138 if ( ! preg_match('/define\s*\(\s*\'WP_DEBUG\'\s*,\s*([^\)]+)\);/s', $config_contents) || 139 139 ! preg_match('/define\s*\(\s*\'WP_DEBUG_LOG\'\s*,\s*([^\)]+)\);/s', $config_contents) ) { 140 141 // If WP_DEBUG is not defined, add it along with WP_DEBUG_LOG. 142 $replacement = "define('WP_DEBUG', false); define('WP_DEBUG_LOG', false);"; 143 144 // Adjust the regular expression to match the existing WP_DEBUG line. 145 $pattern = '/define\s*\(\s*\'WP_DEBUG\'\s*,\s*([^;]+)\);\s*$/m'; 146 147 if ( preg_match($pattern, $config_contents, $matches) ) { 148 // If WP_DEBUG mode found/active, replace it with both definitions. 149 $config_contents = str_replace($matches[0], $replacement, $config_contents); 140 141 // Define constants. 142 $constants_to_add = "define('WP_DEBUG', false);\n" . 143 "define('WP_DEBUG_LOG', false);\n"; 144 145 // Find the position to insert constants. 146 $position_to_insert = strpos($config_contents, '/* That\'s all, stop editing! Happy publishing. */'); 147 148 if ($position_to_insert !== false) { 149 // Insert constants above the line. 150 $config_contents = substr_replace($config_contents, $constants_to_add . "\n", $position_to_insert, 0); 151 152 // Write the updated content back to wp-config.php. 153 file_put_contents($config_path, $config_contents); 154 155 // Update the option value. 156 update_option('easy_error_log_debug_mode_enabled', 1); 150 157 } 151 158 } 152 153 // Write the updated content back to wp-config.php. 154 file_put_contents($config_path, $config_contents); 155 156 update_option('easy_error_log_debug_mode_enabled', 1); 157 } 158 } 159 160 /** 161 * Add WP Error Dashboard in Tools. 162 */ 159 } 160 } 161 162 // Add WP Error Dashboard in Tools. 163 163 add_management_page( 'WP Errors', 'WP Errors', 'manage_options', 'errors', array( $this, 'display_errors' ) ); 164 164 } … … 189 189 <button type="submit" class="button"><?php echo esc_html__( 'Download Debug Log', 'easy-error-log' ); ?></button> 190 190 </form> 191 191 192 192 193 </div> … … 214 215 </table> 215 216 216 217 <!-- JS coe added here befor -->218 <!-- <script>219 jQuery(document).ready(function($) {220 });221 </script> -->222 217 <?php 223 218 } … … 271 266 if ( file_exists( $config_path ) ) { 272 267 $config_contents = file_get_contents( $config_path ); 273 268 274 269 // Check if WP_DEBUG is defined. 275 270 if ( preg_match( '/define\s*\(\s*\'WP_DEBUG\'\s*,\s*([^\)]+)\);/s', $config_contents, $matches ) ) { … … 277 272 $new_debug_value = ( 'true' === $matches[1] ) ? 'false' : 'true'; 278 273 $config_contents = preg_replace( '/define\s*\(\s*\'WP_DEBUG\'\s*,\s*([^\)]+)\);/s', "define('WP_DEBUG', $new_debug_value);", $config_contents ); 279 280 // Update wp-config.php with the new debug value. 274 275 // Toggle WP_DEBUG_LOG value. 276 if ($new_debug_value === 'false') { 277 $config_contents = preg_replace('/define\s*\(\s*\'WP_DEBUG_LOG\'\s*,\s*([^\)]+)\);/s', "define('WP_DEBUG_LOG', false);", $config_contents); 278 } else { 279 $config_contents = preg_replace('/define\s*\(\s*\'WP_DEBUG_LOG\'\s*,\s*([^\)]+)\);/s', "define('WP_DEBUG_LOG', true);", $config_contents); 280 } 281 282 // Update wp-config.php with the new values. 281 283 file_put_contents( $config_path, $config_contents ); 282 283 // Return the new debug status.284 284 $debug_status = ( 'true' === $new_debug_value ) ? 'ON' : 'OFF'; 285 285 echo esc_html__( $debug_status, 'easy-error-log' ); 286 286 287 } else { 287 288 echo esc_html__( 'WP_DEBUG constant not found', 'easy-error-log' ); … … 321 322 322 323 /** 324 325 326 327 328 329 330 331 332 333 323 334 * AJAX callback function to download debug log. 324 335 */ -
easy-error-log/trunk/readme.txt
r3070183 r3093644 1 1 === EasyError- Easy Error Log for WordPress === 2 Contributors: wpxpertise,devsabbirahmed2 Contributors: devsabbirahmed 3 3 Tags: error, log, debug, site error 4 4 Requires at least: 5.9 5 5 Tested up to: 6.5 6 6 Requires PHP: 5.6 7 Stable Tag: 1. 1.17 Stable Tag: 1. 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 36 36 37 37 == Changelog == 38 39 40 41 42 43 38 44 = 1.1.1 -14 April 2024 = 39 45 - PHPCS and WPCS followed in code
Note: See TracChangeset
for help on using the changeset viewer.