Plugin Directory

Changeset 3259804


Ignore:
Timestamp:
03/21/2025 03:22:41 PM (12 months ago)
Author:
devsabbirahmed
Message:

WP Keyword Trademark violation fixed submitted

Location:
easy-error-log
Files:
1 added
1 deleted
7 edited

Legend:

Unmodified
Added
Removed
  • easy-error-log/trunk/assets/fe-error-style.css

    r3240222 r3259804  
    4949    font-weight: 500;
    5050    font-size: 0.95rem;
     51    border-bottom-left-radius: 12px;
    5152}
    5253
     
    109110.error-log-container.open .error-log-content {
    110111    display: block;
     112    border-bottom-left-radius: 12px;
    111113}
    112114
  • easy-error-log/trunk/easy-error-log.php

    r3245250 r3259804  
    3636
    3737
    38 if (!class_exists('EEL_Error')) {
    39     class EEL_Error {
    40         private $base;
    41        
    42         public function __construct() {
    43             $this->base = new EEL\Inc\EEL_Base();
    44         }
     38if ( ! class_exists('EEL_Error') ) {
     39    class EEL_Error {
     40        private $base;
    4541
    46         public function eel_activate() {
    47             EEL\Inc\EEL_Activate::eel_activate();
    48         }
     42        public function __construct() {
     43            $this->base = new EEL\Inc\EEL_Base();
     44        }
    4945
    50         public function eel_deactivate() {
    51             EEL\Inc\EEL_Deactivate::eel_deactivate();
    52         }
    53     }
     46        public function eel_activate() {
     47            EEL\Inc\EEL_Activate::eel_activate();
     48        }
    5449
    55     $err = new EEL_Error();
    56     register_activation_hook(__FILE__, array($err, 'eel_activate'));
    57     register_deactivation_hook(__FILE__, array($err, 'eel_deactivate'));
     50        public function eel_deactivate() {
     51            EEL\Inc\EEL_Deactivate::eel_deactivate();
     52        }
     53    }
     54
     55    $err = new EEL_Error();
     56    register_activation_hook(__FILE__, array( $err, 'eel_activate' ));
     57    register_deactivation_hook(__FILE__, array( $err, 'eel_deactivate' ));
    5858}
  • easy-error-log/trunk/inc/EEL_Ajax.php

    r3243975 r3259804  
    66class EEL_Ajax {
    77
    8     public function init() {
    9         add_action('wp_ajax_clean_debug_log', array($this, 'clean_debug_log_callback'));
    10         add_action('wp_ajax_reset_debug_constant', array($this, 'reset_debug_constant_callback'));
    11         add_action('wp_ajax_toggle_debug_mode', array($this, 'toggle_debug_mode_callback'));
    12         add_action('wp_ajax_get_debug_mode_status', array($this, 'get_debug_mode_status_callback'));
    13         add_action('wp_ajax_download_debug_log', array($this, 'download_debug_log_callback'));
    14         add_action('wp_ajax_get_error_count', array($this, 'get_error_count_callback'));
    15         add_action('wp_ajax_check_debug_constants_status', array($this, 'check_debug_constants_status_callback'));
    16         add_action('wp_ajax_toggle_widgets_mode', array($this, 'toggle_widgets_mode_callback'));
    17         add_action('wp_ajax_get_widgets_mode_status', array($this, 'get_widgets_mode_status_callback'));
    18         add_action( 'wp_ajax_display_error_log', array( $this, 'display_error_log_callback' ) );
     8    public function init() {
     9        add_action('wp_ajax_clean_debug_log', array( $this, 'clean_debug_log_callback' ));
     10        add_action('wp_ajax_reset_debug_constant', array( $this, 'reset_debug_constant_callback' ));
     11        add_action('wp_ajax_toggle_debug_mode', array( $this, 'toggle_debug_mode_callback' ));
     12        add_action('wp_ajax_get_debug_mode_status', array( $this, 'get_debug_mode_status_callback' ));
     13        add_action('wp_ajax_download_debug_log', array( $this, 'download_debug_log_callback' ));
     14        add_action('wp_ajax_get_error_count', array( $this, 'get_error_count_callback' ));
     15        add_action('wp_ajax_check_debug_constants_status', array( $this, 'check_debug_constants_status_callback' ));
     16        add_action('wp_ajax_toggle_widgets_mode', array( $this, 'toggle_widgets_mode_callback' ));
     17        add_action('wp_ajax_get_widgets_mode_status', array( $this, 'get_widgets_mode_status_callback' ));
     18        add_action( 'wp_ajax_display_error_log', array( $this, 'display_error_log_callback' ) );
    1919        add_action( 'wp_ajax_nopriv_display_error_log', array( $this, 'display_error_log_callback' ) );
    20        
    21     }
    22 
    23     /**
    24      * AJAX callback function to display error log.
    25      */
    26     public function display_error_log_callback() {
    27         $debug_log_paths = array(
    28             WP_CONTENT_DIR . '/debug.log',
    29             ABSPATH . 'debug.log',
    30         );
    31    
    32         $debug_log_path = '';
    33         foreach ($debug_log_paths as $path) {
    34             if (file_exists($path)) {
    35                 $debug_log_path = $path;
    36                 break;
    37             }
    38         }
    39    
    40         if (file_exists($debug_log_path)) {
    41             $debug_log_entries = file($debug_log_path, FILE_IGNORE_NEW_LINES);
    42             if (empty($debug_log_entries)) {
    43                 echo '<div>' . esc_html__('Debug log empty. No errors found.', 'easy-error-log') . '</div>';
    44             } else {
    45                 // Create array to store unique errors
    46                 $unique_errors = array();
    47                 $current_entry = '';
    48                 $current_timestamp = '';
    49                
    50                 // Combine multi-line entries
    51                 foreach ($debug_log_entries as $line) {
    52                     // Check if line starts with a timestamp
    53                     if (preg_match('/^\[(.*?)\](.+)$/', $line, $matches)) {
    54                         //save previous entry
    55                         if ($current_entry !== '') {
    56                             $content_key = trim($current_entry);
    57                             if (!isset($unique_errors[$content_key])) {
    58                                 $unique_errors[$content_key] = array(
    59                                     'timestamp' => $current_timestamp,
    60                                     'full_message' => "[$current_timestamp] " . $current_entry
    61                                 );
    62                             }
    63                         }
    64                         // Start new entry
    65                         $current_timestamp = $matches[1];
    66                         $current_entry = $matches[2];
    67                     } else {
    68                         // Continuation of the current entry
    69                         $current_entry .= "\n" . $line;
    70                     }
    71                 }
    72                
    73                 // Save the last entry
    74                 if ($current_entry !== '') {
    75                     $content_key = trim($current_entry);
    76                     if (!isset($unique_errors[$content_key])) {
    77                         $unique_errors[$content_key] = array(
    78                             'timestamp' => $current_timestamp,
    79                             'full_message' => "[$current_timestamp] " . $current_entry
    80                         );
    81                     }
    82                 }
    83    
    84                 // Display the unique entries
    85                 foreach ($unique_errors as $error) {
    86                     echo "<div class='debug-log-errors'>" .
    87                         nl2br(esc_html($error['full_message'])) .
    88                         "</div>";
    89                 }
    90             }
    91         } else {
    92             echo '<div>' . esc_html__('Debug log file not found.', 'easy-error-log') . '</div>';
    93         }
    94         die();
    95     }
    96 
    97 
    98     /**
    99      * AJAX callback function to clean debug log.
    100      */
    101     public function clean_debug_log_callback() {
    102         $debug_log_paths = array(
    103             WP_CONTENT_DIR . '/debug.log',
    104             ABSPATH . 'debug.log',
    105         );
    106 
    107         $debug_log_path = '';
    108         foreach ( $debug_log_paths as $path ) {
    109             if ( file_exists($path) ) {
    110                 $debug_log_path = $path;
    111                 break;
    112             }
    113         }
    114 
    115         if ( file_exists( $debug_log_path ) ) {
    116             file_put_contents( $debug_log_path, '' );
    117             echo '<p>' . esc_html__( 'Debug log cleaned successfully.', 'easy-error-log' ) . '</p>';
    118         } else {
    119             echo '<p>' . esc_html__( 'Debug log file not found.', 'easy-error-log' ) . '</p>';
    120         }
    121         die();
    122     }
    123 
    124 
    125     /**
    126      * Reset debug constant callback.
    127      */
    128     public function reset_debug_constant_callback() {
    129         update_option('easy_error_log_debug_mode_enabled', ''); // Reset the option value
    130         echo esc_html__('Debug constant reset successfully.', 'easy-error-log'); // Return success message
    131         wp_die();
    132     }
    133 
    134 
    135     /**
    136      * Callback function for toggling debug mode.
    137      */
    138     public function toggle_debug_mode_callback() {
    139         $config_path = ABSPATH . 'wp-config.php';
    140         if ( file_exists( $config_path ) ) {
    141             $config_contents = file_get_contents( $config_path );
    142 
    143             // Check if WP_DEBUG is defined.
    144             if ( preg_match( '/define\s*\(\s*\'WP_DEBUG\'\s*,\s*([^\)]+)\);/s', $config_contents, $matches ) ) {
    145                 // Toggle WP_DEBUG value.
    146                 $new_debug_value = ( 'true' === $matches[1] ) ? 'false' : 'true';
    147                 $config_contents = preg_replace( '/define\s*\(\s*\'WP_DEBUG\'\s*,\s*([^\)]+)\);/s', "define('WP_DEBUG', $new_debug_value);", $config_contents );
    148 
    149                 // Toggle WP_DEBUG_LOG value.
    150                 if ( 'false' === $new_debug_value ) {
    151                     $config_contents = preg_replace('/define\s*\(\s*\'WP_DEBUG_LOG\'\s*,\s*([^\)]+)\);/s', "define('WP_DEBUG_LOG', false);", $config_contents);
    152                 } else {
    153                     $config_contents = preg_replace('/define\s*\(\s*\'WP_DEBUG_LOG\'\s*,\s*([^\)]+)\);/s', "define('WP_DEBUG_LOG', true);", $config_contents);
    154                 }
    155 
    156                 // Update wp-config.php with the new values.
    157                 file_put_contents( $config_path, $config_contents );
    158                 $debug_status = ( 'true' === $new_debug_value ) ? 'ON' : 'OFF';
    159                 echo esc_html__( $debug_status, 'easy-error-log' );
    160 
    161             } else {
    162                 echo esc_html__( 'WP_DEBUG constant not found', 'easy-error-log' );
    163             }
    164         } else {
    165             echo esc_html__( 'wp-config not found.', 'easy-error-log' );
    166         }
    167         die();
    168     }
    169 
    170 
    171     /**
    172      * AJAX callback function to get the current debug mode status.
    173      */
    174     public function get_debug_mode_status_callback() {
    175         $debug_mode_status = ( defined( 'WP_DEBUG' ) && WP_DEBUG ) ? 'ON' : 'OFF';
    176         echo esc_html($debug_mode_status);
    177         wp_die();
    178     }
    179 
    180     /**
    181      * AJAX callback function to download debug log.
    182      */
    183     public function download_debug_log_callback() {
    184         // $debug_log_path = WP_CONTENT_DIR . '/debug.log';.
    185         $debug_log_paths = array(
    186             WP_CONTENT_DIR . '/debug.log',
    187             ABSPATH . 'debug.log',
    188         );
    189 
    190         $debug_log_path = '';
    191         foreach ( $debug_log_paths as $path ) {
    192             if ( file_exists($path) ) {
    193                 $debug_log_path = $path;
    194                 break;
    195             }
    196         }
    197 
    198         if ( file_exists( $debug_log_path ) ) {
    199             // Return the URL to the debug log file.
    200             echo esc_url( content_url( '/debug.log' ) );
    201         } else {
    202             echo esc_html__( 'Debug log file not found.', 'easy-error-log' );
    203         }
    204         wp_die();
    205     }
    206 
    207     /**
    208      * Count erros.
    209      */
    210     public function get_error_count_callback() {
    211 
    212         $debug_log_paths = array(
    213             WP_CONTENT_DIR . '/debug.log',
    214             ABSPATH . 'debug.log',
    215         );
    216 
    217         $debug_log_path = '';
    218         foreach ( $debug_log_paths as $path ) {
    219             if ( file_exists($path) ) {
    220                 $debug_log_path = $path;
    221                 break;
    222             }
    223         }
    224 
    225         $error_count = 0;
    226         if ( file_exists($debug_log_path) ) {
    227             $debug_log_entries = file( $debug_log_path, FILE_IGNORE_NEW_LINES );
    228             $error_count = count($debug_log_entries);
    229         }
    230 
    231         echo esc_html($error_count);
    232         wp_die();
    233     }
    234 
    235 
    236     /**
    237      * Show status
    238      */
    239     public function check_debug_constants_status_callback() {
    240         $status = array(
    241             'WP_DEBUG' => defined('WP_DEBUG') ? WP_DEBUG : 'Not Found',
    242             'WP_DEBUG_LOG' => defined('WP_DEBUG_LOG') ? WP_DEBUG_LOG : 'Not Found',
    243         );
    244         wp_send_json_success($status);
    245         wp_die();
    246     }
    247 
    248     public function toggle_widgets_mode_callback(){
    249         // Check the current value of the option.
    250         $widgets_mode = get_option( 'fe_widgets_mode', 'false' );
    251 
    252         // Toggle the value.
    253         if ( 'true' === $widgets_mode ) {
    254             $widgets_mode = 'false';
    255         } else {
    256             $widgets_mode = 'true';
    257         }
    258    
    259         // Update the option with the new value.
    260         update_option( 'fe_widgets_mode', $widgets_mode );
    261    
    262         // Send the new mode back as the response.
    263         wp_send_json_success( array( 'widgets_mode' => $widgets_mode ) );
    264     }
    265 
    266     public function get_widgets_mode_status_callback() {
    267         // Get the current mode value.
    268         $widgets_mode = get_option( 'fe_widgets_mode', 'false' );
    269         wp_send_json_success( array( 'widgets_mode' => $widgets_mode ) );
    270     }
    271 
    272 
    273 
    274 
    275 
    276 
     20    }
     21
     22    /**
     23     * AJAX callback function to display error log.
     24     */
     25    public function display_error_log_callback() {
     26        $debug_log_paths = array(
     27            WP_CONTENT_DIR . '/debug.log',
     28            ABSPATH . 'debug.log',
     29        );
     30
     31        $debug_log_path = '';
     32        foreach ( $debug_log_paths as $path ) {
     33            if ( file_exists($path) ) {
     34                $debug_log_path = $path;
     35                break;
     36            }
     37        }
     38
     39        if ( file_exists($debug_log_path) ) {
     40            $debug_log_entries = file($debug_log_path, FILE_IGNORE_NEW_LINES);
     41            if ( empty($debug_log_entries) ) {
     42                echo '<div>' . esc_html__('Debug log empty. No errors found.', 'easy-error-log') . '</div>';
     43            } else {
     44                // Create array to store unique errors
     45                $unique_errors = array();
     46                $current_entry = '';
     47                $current_timestamp = '';
     48
     49                // Combine multi-line entries
     50                foreach ( $debug_log_entries as $line ) {
     51                    // Check if line starts with a timestamp
     52                    if ( preg_match('/^\[(.*?)\](.+)$/', $line, $matches) ) {
     53                        // save previous entry
     54                        if ( $current_entry !== '' ) {
     55                            $content_key = trim($current_entry);
     56                            if ( ! isset($unique_errors[ $content_key ]) ) {
     57                                $unique_errors[ $content_key ] = array(
     58                                    'timestamp' => $current_timestamp,
     59                                    'full_message' => "[$current_timestamp] " . $current_entry,
     60                                );
     61                            }
     62                        }
     63                        // Start new entry
     64                        $current_timestamp = $matches[1];
     65                        $current_entry = $matches[2];
     66                    } else {
     67                        // Continuation of the current entry
     68                        $current_entry .= "\n" . $line;
     69                    }
     70                }
     71
     72                // Save the last entry
     73                if ( $current_entry !== '' ) {
     74                    $content_key = trim($current_entry);
     75                    if ( ! isset($unique_errors[ $content_key ]) ) {
     76                        $unique_errors[ $content_key ] = array(
     77                            'timestamp' => $current_timestamp,
     78                            'full_message' => "[$current_timestamp] " . $current_entry,
     79                        );
     80                    }
     81                }
     82
     83                // Display the unique entries
     84                foreach ( $unique_errors as $error ) {
     85                    echo "<div class='debug-log-errors'>"
     86                        . nl2br(esc_html($error['full_message']))
     87                        . '</div>';
     88                }
     89            }
     90        } else {
     91            echo '<div>' . esc_html__('Debug log file not found.', 'easy-error-log') . '</div>';
     92        }
     93        die();
     94    }
     95
     96
     97    /**
     98     * AJAX callback function to clean debug log.
     99     */
     100    public function clean_debug_log_callback() {
     101        $debug_log_paths = array(
     102            WP_CONTENT_DIR . '/debug.log',
     103            ABSPATH . 'debug.log',
     104        );
     105
     106        $debug_log_path = '';
     107        foreach ( $debug_log_paths as $path ) {
     108            if ( file_exists($path) ) {
     109                $debug_log_path = $path;
     110                break;
     111            }
     112        }
     113
     114        if ( file_exists( $debug_log_path ) ) {
     115            file_put_contents( $debug_log_path, '' );
     116            echo '<p>' . esc_html__( 'Debug log cleaned successfully.', 'easy-error-log' ) . '</p>';
     117        } else {
     118            echo '<p>' . esc_html__( 'Debug log file not found.', 'easy-error-log' ) . '</p>';
     119        }
     120        die();
     121    }
     122
     123
     124    /**
     125     * Reset debug constant callback.
     126     */
     127    public function reset_debug_constant_callback() {
     128        update_option('easy_error_log_debug_mode_enabled', ''); // Reset the option value
     129        echo esc_html__('Debug constant reset successfully.', 'easy-error-log'); // Return success message
     130        wp_die();
     131    }
     132
     133
     134    /**
     135     * Callback function for toggling debug mode.
     136     */
     137    public function toggle_debug_mode_callback() {
     138        $config_path = ABSPATH . 'wp-config.php';
     139        if ( file_exists( $config_path ) ) {
     140            $config_contents = file_get_contents( $config_path );
     141
     142            // Check if WP_DEBUG is defined.
     143            if ( preg_match( '/define\s*\(\s*\'WP_DEBUG\'\s*,\s*([^\)]+)\);/s', $config_contents, $matches ) ) {
     144                // Toggle WP_DEBUG value.
     145                $new_debug_value = ( 'true' === $matches[1] ) ? 'false' : 'true';
     146                $config_contents = preg_replace( '/define\s*\(\s*\'WP_DEBUG\'\s*,\s*([^\)]+)\);/s', "define('WP_DEBUG', $new_debug_value);", $config_contents );
     147
     148                // Toggle WP_DEBUG_LOG value.
     149                if ( 'false' === $new_debug_value ) {
     150                    $config_contents = preg_replace('/define\s*\(\s*\'WP_DEBUG_LOG\'\s*,\s*([^\)]+)\);/s', "define('WP_DEBUG_LOG', false);", $config_contents);
     151                } else {
     152                    $config_contents = preg_replace('/define\s*\(\s*\'WP_DEBUG_LOG\'\s*,\s*([^\)]+)\);/s', "define('WP_DEBUG_LOG', true);", $config_contents);
     153                }
     154
     155                // Update wp-config.php with the new values.
     156                file_put_contents( $config_path, $config_contents );
     157                $debug_status = ( 'true' === $new_debug_value ) ? 'ON' : 'OFF';
     158                echo esc_html__( $debug_status, 'easy-error-log' );
     159
     160            } else {
     161                echo esc_html__( 'WP_DEBUG constant not found', 'easy-error-log' );
     162            }
     163        } else {
     164            echo esc_html__( 'wp-config not found.', 'easy-error-log' );
     165        }
     166        die();
     167    }
     168
     169
     170    /**
     171     * AJAX callback function to get the current debug mode status.
     172     */
     173    public function get_debug_mode_status_callback() {
     174        $debug_mode_status = ( defined( 'WP_DEBUG' ) && WP_DEBUG ) ? 'ON' : 'OFF';
     175        echo esc_html($debug_mode_status);
     176        wp_die();
     177    }
     178
     179    /**
     180     * AJAX callback function to download debug log.
     181     */
     182    public function download_debug_log_callback() {
     183        // $debug_log_path = WP_CONTENT_DIR . '/debug.log';.
     184        $debug_log_paths = array(
     185            WP_CONTENT_DIR . '/debug.log',
     186            ABSPATH . 'debug.log',
     187        );
     188
     189        $debug_log_path = '';
     190        foreach ( $debug_log_paths as $path ) {
     191            if ( file_exists($path) ) {
     192                $debug_log_path = $path;
     193                break;
     194            }
     195        }
     196
     197        if ( file_exists( $debug_log_path ) ) {
     198            // Return the URL to the debug log file.
     199            echo esc_url( content_url( '/debug.log' ) );
     200        } else {
     201            echo esc_html__( 'Debug log file not found.', 'easy-error-log' );
     202        }
     203        wp_die();
     204    }
     205
     206    /**
     207     * Count erros.
     208     */
     209    public function get_error_count_callback() {
     210
     211        $debug_log_paths = array(
     212            WP_CONTENT_DIR . '/debug.log',
     213            ABSPATH . 'debug.log',
     214        );
     215
     216        $debug_log_path = '';
     217        foreach ( $debug_log_paths as $path ) {
     218            if ( file_exists($path) ) {
     219                $debug_log_path = $path;
     220                break;
     221            }
     222        }
     223
     224        $error_count = 0;
     225        if ( file_exists($debug_log_path) ) {
     226            $debug_log_entries = file( $debug_log_path, FILE_IGNORE_NEW_LINES );
     227            $error_count = count($debug_log_entries);
     228        }
     229
     230        echo esc_html($error_count);
     231        wp_die();
     232    }
     233
     234
     235    /**
     236     * Show status
     237     */
     238    public function check_debug_constants_status_callback() {
     239        $status = array(
     240            'WP_DEBUG' => defined('WP_DEBUG') ? WP_DEBUG : 'Not Found',
     241            'WP_DEBUG_LOG' => defined('WP_DEBUG_LOG') ? WP_DEBUG_LOG : 'Not Found',
     242        );
     243        wp_send_json_success($status);
     244        wp_die();
     245    }
     246
     247    public function toggle_widgets_mode_callback() {
     248        // Check the current value of the option.
     249        $widgets_mode = get_option( 'fe_widgets_mode', 'false' );
     250
     251        // Toggle the value.
     252        if ( 'true' === $widgets_mode ) {
     253            $widgets_mode = 'false';
     254        } else {
     255            $widgets_mode = 'true';
     256        }
     257
     258        // Update the option with the new value.
     259        update_option( 'fe_widgets_mode', $widgets_mode );
     260
     261        // Send the new mode back as the response.
     262        wp_send_json_success( array( 'widgets_mode' => $widgets_mode ) );
     263    }
     264
     265    public function get_widgets_mode_status_callback() {
     266        // Get the current mode value.
     267        $widgets_mode = get_option( 'fe_widgets_mode', 'false' );
     268        wp_send_json_success( array( 'widgets_mode' => $widgets_mode ) );
     269    }
    277270}
  • easy-error-log/trunk/inc/EEL_Base.php

    r3245250 r3259804  
    55
    66class EEL_Base {
    7    
    8         public function __construct() {
    9             $this->includes();
    10 
    11             add_action('admin_menu', array($this, 'add_error_page'));
    12             add_action('admin_enqueue_scripts', [$this, 'admin_enqueue']);
    13             add_action('wp_enqueue_scripts', [$this, 'fe_scripts']);
    14             add_action('admin_bar_menu', array($this, 'add_my_page_to_admin_bar'), 100);
    15             add_action('init', array($this, 'system_info'));
    16             add_action('wp_footer', [$this, 'display_error_floating_widget'], 99);
    17 
    18             add_action('wp_ajax_toggle_admin_widget', array($this, 'toggle_admin_widget'));
    19             add_action('admin_footer', array($this, 'display_admin_error_widget'));
    20            
    21             $this->init_ajax_handlers();
    22         }
    23 
    24         private function init_ajax_handlers() {
    25             $ajax = new EEL_Ajax();
    26             $ajax->init();
    27         }
    28 
    29         public function includes() {
    30             add_action('plugins_loaded', array($this, 'eel_load'));
    31         }
    32 
    33         public function eel_load() {
    34             load_plugin_textdomain('easy-error-log', false, __DIR__ . 'languages');
    35         }
    36 
    37         public function get_admin_widget_status() {
    38             return get_option('eel_admin_widget_enabled', 'active');
    39         }
    40        
    41         public function toggle_admin_widget() {
    42             check_ajax_referer('eel_admin_nonce', 'nonce');
    43            
    44             $current_status = $this->get_admin_widget_status();
    45             $new_status = ($current_status === 'active') ? 'inactive' : 'active';
    46            
    47             update_option('eel_admin_widget_enabled', $new_status);
    48             wp_send_json_success(array('status' => $new_status));
    49         }
     7
     8    public function __construct() {
     9        $this->includes();
     10
     11        add_action('admin_menu', array( $this, 'add_error_page' ));
     12        add_action('admin_enqueue_scripts', [ $this, 'admin_enqueue' ]);
     13        add_action('wp_enqueue_scripts', [ $this, 'fe_scripts' ]);
     14        add_action('admin_bar_menu', array( $this, 'add_my_page_to_admin_bar' ), 100);
     15        add_action('init', array( $this, 'system_info' ));
     16        add_action('wp_footer', [ $this, 'display_error_floating_widget' ], 99);
     17
     18        add_action('wp_ajax_toggle_admin_widget', array( $this, 'toggle_admin_widget' ));
     19        add_action('admin_footer', array( $this, 'display_admin_error_widget' ));
     20
     21        $this->init_ajax_handlers();
     22    }
     23
     24    private function init_ajax_handlers() {
     25        $ajax = new EEL_Ajax();
     26        $ajax->init();
     27    }
     28
     29    public function includes() {
     30        add_action('plugins_loaded', array( $this, 'eel_load' ));
     31    }
     32
     33    public function eel_load() {
     34        load_plugin_textdomain('easy-error-log', false, __DIR__ . 'languages');
     35    }
     36
     37    public function get_admin_widget_status() {
     38        return get_option('eel_admin_widget_enabled', 'active');
     39    }
     40
     41    public function toggle_admin_widget() {
     42        check_ajax_referer('eel_admin_nonce', 'nonce');
     43
     44        $current_status = $this->get_admin_widget_status();
     45        $new_status = ( $current_status === 'active' ) ? 'inactive' : 'active';
     46
     47        update_option('eel_admin_widget_enabled', $new_status);
     48        wp_send_json_success(array( 'status' => $new_status ));
     49    }
    5050
    5151        /**
    5252         * Add error page.
    5353         */
    54         public function add_error_page() {
    55             $debug_error_mode_enabled = get_option('easy_error_log_debug_mode_enabled', 0);
    56             if (empty($debug_error_mode_enabled)) {
    57                 $config_path = ABSPATH . 'wp-config.php';
    58                 if (file_exists($config_path)) {
    59                     $config_contents = file_get_contents($config_path);
    60                    
    61                     // First remove any existing duplicate constants
    62                     $config_contents = preg_replace('/define\s*\(\s*[\'"]WP_DEBUG[\'"]\s*,\s*(?:true|false)\s*\);\s*\n?/i', '', $config_contents);
    63                     $config_contents = preg_replace('/define\s*\(\s*[\'"]WP_DEBUG_LOG[\'"]\s*,\s*(?:true|false)\s*\);\s*\n?/i', '', $config_contents);
    64                    
    65                     // Add new constants
    66                     $constants_to_add = "define('WP_DEBUG', false);\ndefine('WP_DEBUG_LOG', false);\n";
    67                    
    68                     // Find position to insert
    69                     $position_to_insert = strpos($config_contents, '/* That\'s all, stop editing! Happy publishing. */');
    70                    
    71                     if (false !== $position_to_insert) {
    72                         $config_contents = substr_replace($config_contents, $constants_to_add, $position_to_insert, 0);
    73                         file_put_contents($config_path, $config_contents);
    74                         update_option('easy_error_log_debug_mode_enabled', 1);
    75                     }
     54    public function add_error_page() {
     55        $debug_error_mode_enabled = get_option('easy_error_log_debug_mode_enabled', 0);
     56        if ( empty($debug_error_mode_enabled) ) {
     57            $config_path = ABSPATH . 'wp-config.php';
     58            if ( file_exists($config_path) ) {
     59                $config_contents = file_get_contents($config_path);
     60
     61                // First remove any existing duplicate constants
     62                $config_contents = preg_replace('/define\s*\(\s*[\'"]WP_DEBUG[\'"]\s*,\s*(?:true|false)\s*\);\s*\n?/i', '', $config_contents);
     63                $config_contents = preg_replace('/define\s*\(\s*[\'"]WP_DEBUG_LOG[\'"]\s*,\s*(?:true|false)\s*\);\s*\n?/i', '', $config_contents);
     64
     65                // Add new constants
     66                $constants_to_add = "define('WP_DEBUG', false);\ndefine('WP_DEBUG_LOG', false);\n";
     67
     68                // Find position to insert
     69                $position_to_insert = strpos($config_contents, '/* That\'s all, stop editing! Happy publishing. */');
     70
     71                if ( false !== $position_to_insert ) {
     72                    $config_contents = substr_replace($config_contents, $constants_to_add, $position_to_insert, 0);
     73                    file_put_contents($config_path, $config_contents);
     74                    update_option('easy_error_log_debug_mode_enabled', 1);
    7675                }
    7776            }
    78            
    79             add_management_page('WP Errors', 'WP Errors', 'manage_options', 'errors', array($this, 'display_errors'));
    80         }
    81 
    82 
    83         /**
     77        }
     78
     79        add_management_page('WP Errors', 'WP Errors', 'manage_options', 'errors', array( $this, 'display_errors' ));
     80    }
     81
     82
     83        /**
    8484         * Enqueue plugin files.
    8585         *
    8686         * @param string $screen   use to get the current page screen.
    8787         */
    88         public function admin_enqueue( $screen ) {
    89             if ( 'tools_page_errors' === $screen ) {
    90                 remove_all_actions( 'admin_notices' );
    91                 remove_all_actions( 'all_admin_notices' );
    92 
    93                 wp_enqueue_style(
    94                     'err-admin-css',
    95                     EASY_ERROR_LOG_DIR_URL . 'assets/easy-errors.css',
    96                     '',
    97                     time(),
    98                     'all'
    99                 );
    100 
    101                 wp_enqueue_script(
    102                     'err-admin-js',
    103                     EASY_ERROR_LOG_DIR_URL . 'assets/easy-errors.js',
    104                     [ 'jquery' ],
    105                     time(),
    106                     true
    107                 );
    108 
    109                 // Localize the script with new data.
    110                 $ajax_url = admin_url( 'admin-ajax.php' );
    111                 // wp_localize_script( 'err-admin-js', 'ajax_object', array( 'ajax_url' => $ajax_url ) );
    112                 wp_localize_script('err-admin-js', 'ajax_object', array(
    113                     'ajax_url' => admin_url('admin-ajax.php'),
    114                     'admin_widget_status' => $this->get_admin_widget_status(),
    115                     'nonce' => wp_create_nonce('eel_admin_nonce')
    116                 ));
    117             }
    118             else{
    119                 wp_enqueue_script('jquery-ui-draggable');
    120                 wp_enqueue_style('dashicons');
    121 
    122                 wp_enqueue_style(
    123                     'err-admin-css',
    124                     EASY_ERROR_LOG_DIR_URL . 'assets/admin-easy-errors.css',
    125                     '',
    126                     time(),
    127                     'all'
    128                 );
    129 
    130                 wp_enqueue_script(
    131                     'err-admin-js',
    132                     EASY_ERROR_LOG_DIR_URL . 'assets/admin-easy-errors.js',
    133                     [ 'jquery' ],
    134                     time(),
    135                     true
    136                 );
    137 
    138                 // Localize the script with new data.
    139                 $ajax_url = admin_url( 'admin-ajax.php' );
    140                 wp_localize_script('err-admin-js', 'ajax_object', array(
    141                     'ajax_url' => admin_url('admin-ajax.php'),
    142                     'admin_widget_status' => $this->get_admin_widget_status(),
    143                     'nonce' => wp_create_nonce('eel_admin_nonce')
    144                 ));
    145 
    146             }
    147 
    148        
    149         }
    150    
    151         /**
     88    public function admin_enqueue( $screen ) {
     89        if ( 'tools_page_errors' === $screen ) {
     90            remove_all_actions( 'admin_notices' );
     91            remove_all_actions( 'all_admin_notices' );
     92
     93            wp_enqueue_style(
     94                'err-admin-css',
     95                EASY_ERROR_LOG_DIR_URL . 'assets/easy-errors.css',
     96                '',
     97                time(),
     98                'all'
     99            );
     100
     101            wp_enqueue_script(
     102                'err-admin-js',
     103                EASY_ERROR_LOG_DIR_URL . 'assets/easy-errors.js',
     104                [ 'jquery' ],
     105                time(),
     106                true
     107            );
     108
     109            // Localize the script with new data.
     110            $ajax_url = admin_url( 'admin-ajax.php' );
     111            // wp_localize_script( 'err-admin-js', 'ajax_object', array( 'ajax_url' => $ajax_url ) );
     112            wp_localize_script('err-admin-js', 'ajax_object', array(
     113                'ajax_url' => admin_url('admin-ajax.php'),
     114                'admin_widget_status' => $this->get_admin_widget_status(),
     115                'nonce' => wp_create_nonce('eel_admin_nonce'),
     116            ));
     117        } else {
     118            wp_enqueue_script('jquery-ui-draggable');
     119            wp_enqueue_style('dashicons');
     120
     121            wp_enqueue_style(
     122                'err-admin-css',
     123                EASY_ERROR_LOG_DIR_URL . 'assets/admin-easy-errors.css',
     124                '',
     125                time(),
     126                'all'
     127            );
     128
     129            wp_enqueue_script(
     130                'err-admin-js',
     131                EASY_ERROR_LOG_DIR_URL . 'assets/admin-easy-errors.js',
     132                [ 'jquery' ],
     133                time(),
     134                true
     135            );
     136
     137            // Localize the script with new data.
     138            $ajax_url = admin_url( 'admin-ajax.php' );
     139            wp_localize_script('err-admin-js', 'ajax_object', array(
     140                'ajax_url' => admin_url('admin-ajax.php'),
     141                'admin_widget_status' => $this->get_admin_widget_status(),
     142                'nonce' => wp_create_nonce('eel_admin_nonce'),
     143            ));
     144
     145        }
     146    }
     147
     148        /**
    152149         * Display errors files.
    153150         */
    154         public function display_errors() {
    155             $mode = '';
    156             $status = '';
    157             $widgets_mode = '';
    158             $admin_widget_status = $this->get_admin_widget_status();
    159 
    160             ?>
     151    public function display_errors() {
     152        $mode = '';
     153        $status = '';
     154        $widgets_mode = '';
     155        $admin_widget_status = $this->get_admin_widget_status();
     156
     157        ?>
    161158            <br>
    162159
     
    200197
    201198                        <form id="download-debug-log" method="post" action="">
    202                             <?php wp_nonce_field( 'download_debug_log_nonce', 'download_debug_log_nonce' ); ?>
     199                        <?php wp_nonce_field( 'download_debug_log_nonce', 'download_debug_log_nonce' ); ?>
    203200                            <input type="hidden" name="action" value="download_debug_log">
    204201                            <button type="submit" class="button"><?php echo esc_html__( 'Download', 'easy-error-log' ); ?></button>
     
    207204
    208205                        <button id="toggle-admin-widget" class="button">
    209                             <?php echo esc_html__('Admin widget:', 'easy-error-log'); ?>
     206                        <?php echo esc_html__('Admin widget:', 'easy-error-log'); ?>
    210207                            <span id="admin-widget-status" style="color: <?php echo esc_attr($admin_widget_status === 'active' ? '#ffee00' : 'red'); ?>">
    211                                 <?php echo esc_html($admin_widget_status === 'active' ? 'ON' : 'OFF'); ?>
     208                            <?php echo esc_html($admin_widget_status === 'active' ? 'ON' : 'OFF'); ?>
    212209                            </span>
    213210                        </button>
    214211                       
    215212                        <button id="toggle-fe-mode" class="button">
    216                             <?php echo esc_html__( 'FE widgets:', 'easy-error-log' ); ?>
     213                        <?php echo esc_html__( 'FE widgets:', 'easy-error-log' ); ?>
    217214                            <span id="debug-fe-status" style="color: <?php echo esc_html( 'active' === $widgets_mode ? 'red' : '#ffee00' ); ?>">
    218                                 <?php echo esc_html( $status ); ?>
     215                            <?php echo esc_html( $status ); ?>
    219216                            </span>
    220217                        </button>
     
    256253                <!-- System Info Tab -->
    257254
    258                 <?php
    259                     // Get the system information
    260                     $system_info = $this->system_info();
    261                 ?>
     255            <?php
     256                // Get the system information
     257                $system_info = $this->system_info();
     258            ?>
    262259
    263260                <div id="system-info" class="tab-pane" style="display: none;">
     
    510507                        </thead>
    511508                        <tbody>
    512                             <?php
    513                             foreach ( $system_info['plugins_info'] as $plugin ) : ?>
    514                             <tr>
    515                                 <td><?php echo $plugin['Name']; ?></td>
     509                        <?php
     510                        foreach ( $system_info['plugins_info'] as $plugin ) {
     511                            ?>
     512                            <tr>
     513                                <td><?php echo esc_html($plugin['Name'] ); ?></td>
    516514                                <td><?php echo esc_html( $plugin['Version'] ); ?></td>
    517515                                <td><?php echo esc_html( $plugin['Author'] ); ?></td>
    518516                                <td><?php echo wp_kses_post( html_entity_decode( $plugin['Description'] ) ); ?></td>
    519517                            </tr>
    520                             <?php endforeach; ?>
     518                            <?php } ?>
    521519                        </tbody>
    522520                    </table>
     
    537535                        </thead>
    538536                        <tbody>
    539                             <?php foreach ( $system_info['basic_user_info'] as $key => $value ) : ?>
     537                            <?php foreach ( $system_info['basic_user_info'] as $key => $value ) { ?>
    540538                            <tr>
    541539                                <td><?php echo esc_html( $key ); ?></td>
    542540                                <td><?php echo esc_html( $value ); ?></td>
    543541                            </tr>
    544                             <?php endforeach; ?>
     542                            <?php } ?>
    545543                        </tbody>
    546544                    </table>
    547545                </div>
    548546
    549                 <!-- About  -->
    550                 <div id="about" class="tab-pane tab-content" style="display: none;">
    551                     <div class="about-info">
    552                         <h2><?php echo esc_html__('WC Bulk Product & Order Generator', 'wc-bulk-order-generator'); ?></h2>
    553                         <p><?php echo esc_html__('Generates bulk orders/products for WooCommerce with optimized batch processing', 'wc-bulk-order-generator'); ?></p>
    554                     </div>
    555 
    556                     <div class="plugins-section-header">
    557                         <h2 class="plugins-section-title"><?php echo esc_html__('Get More Free Plugins', 'wc-bulk-order-generator'); ?></h2>
    558                     </div>
    559 
    560                     <div class="plugin-cards-container">
    561                         <?php
    562                         $plugins = [
    563                             [
    564                                 'icon' => 'forms',
    565                                 'name' => 'FormDeck',
    566                                 'description' => 'Simple Form Builder with WhatsApp Floating Forms',
    567                                 'tags' => ['Free', 'WhatsApp Integration'],
    568                                 'url' => 'https://wordpress.org/plugins/simple-form/'
    569                             ],
    570                             [
    571                                 'icon' => 'shield',
    572                                 'name' => 'Activity Guard',
    573                                 'description' => 'Real Time Notifier to Slack for System & User Activity Logs, Forum Tracker and Security',
    574                                 'tags' => ['Free', 'Pro', 'Security and Tracker'],
    575                                 'url' => 'https://wordpress.org/plugins/notifier-to-slack/'
    576                             ],
    577                             [
    578                                 'icon' => 'warning',
    579                                 'name' => 'WC Bulk Order Generator',
    580                                 'description' => 'WC Bulk Generator to create realistic WooCommerce test data quickly. Generate thousands of WooCommerce products and orders with just a few clicks.',
    581                                 'tags' => ['Free', 'Generates orders/products'],
    582                                 'url' => 'https://wordpress.org/plugins/wc-bulk-order-generator'
    583                             ]
    584                         ];
    585 
    586                         foreach ($plugins as $plugin) : ?>
    587                             <div class="plugin-card">
    588                                 <div class="plugin-content">
    589                                     <div class="plugin-header">
    590                                         <div class="plugin-icon">
    591                                             <span class="dashicons dashicons-<?php echo esc_attr($plugin['icon']); ?>"></span>
    592                                         </div>
    593                                         <h3><?php echo esc_html($plugin['name']); ?></h3>
    594                                     </div>
    595                                     <p><?php echo esc_html($plugin['description']); ?></p>
    596                                     <div class="plugin-features">
    597                                         <?php foreach ($plugin['tags'] as $tag) : ?>
    598                                             <span class="feature-tag"><?php echo esc_html($tag); ?></span>
    599                                         <?php endforeach; ?>
    600                                     </div>
    601                                     <a href="<?php echo esc_url($plugin['url']); ?>"
    602                                     class="plugin-button"
    603                                     target="_blank"
    604                                     rel="noopener noreferrer">
    605                                         <?php echo esc_html__('Learn More', 'wc-bulk-order-generator'); ?>
    606                                         <span class="dashicons dashicons-external"></span>
    607                                     </a>
    608                                 </div>
    609                             </div>
    610                         <?php endforeach; ?>
    611                     </div>
     547                <!-- About  -->
     548                <div id="about" class="tab-pane tab-content" style="display: none;">
     549                    <div class="about-info">
     550                        <h2><?php echo esc_html__('WC Bulk Product & Order Generator', 'wc-bulk-order-generator'); ?></h2>
     551                        <p><?php echo esc_html__('Generates bulk orders/products for WooCommerce with optimized batch processing', 'wc-bulk-order-generator'); ?></p>
     552                    </div>
     553
     554                    <div class="plugins-section-header">
     555                        <h2 class="plugins-section-title"><?php echo esc_html__('Get More Free Plugins', 'wc-bulk-order-generator'); ?></h2>
     556                    </div>
     557
     558                    <div class="plugin-cards-container">
     559                        <?php
     560                        $plugins = [
     561                            [
     562                                'icon' => 'forms',
     563                                'name' => 'FormDeck',
     564                                'description' => 'Simple Form Builder with WhatsApp Floating Forms',
     565                                'tags' => [ 'Free', 'WhatsApp Integration' ],
     566                                'url' => 'https://wordpress.org/plugins/simple-form/',
     567                            ],
     568                            [
     569                                'icon' => 'shield',
     570                                'name' => 'Activity Guard',
     571                                'description' => 'Real Time Notifier to Slack for System & User Activity Logs, Forum Tracker and Security',
     572                                'tags' => [ 'Free', 'Pro', 'Security and Tracker' ],
     573                                'url' => 'https://wordpress.org/plugins/notifier-to-slack/',
     574                            ],
     575                            [
     576                                'icon' => 'warning',
     577                                'name' => 'WC Bulk Order Generator',
     578                                'description' => 'WC Bulk Generator to create realistic WooCommerce test data quickly. Generate thousands of WooCommerce products and orders with just a few clicks.',
     579                                'tags' => [ 'Free', 'Generates orders/products' ],
     580                                'url' => 'https://wordpress.org/plugins/wc-bulk-order-generator',
     581                            ],
     582                        ];
     583
     584                        foreach ( $plugins as $plugin ) {
     585                            ?>
     586                            <div class="plugin-card">
     587                                <div class="plugin-content">
     588                                    <div class="plugin-header">
     589                                        <div class="plugin-icon">
     590                                            <span class="dashicons dashicons-<?php echo esc_attr($plugin['icon']); ?>"></span>
     591                                        </div>
     592                                        <h3><?php echo esc_html($plugin['name']); ?></h3>
     593                                    </div>
     594                                    <p><?php echo esc_html($plugin['description']); ?></p>
     595                                    <div class="plugin-features">
     596                                        <?php foreach ( $plugin['tags'] as $tag ) { ?>
     597                                            <span class="feature-tag"><?php echo esc_html($tag); ?></span>
     598                                        <?php } ?>
     599                                    </div>
     600                                    <a href="<?php echo esc_url($plugin['url']); ?>"
     601                                    class="plugin-button"
     602                                    target="_blank"
     603                                    rel="noopener noreferrer">
     604                                        <?php echo esc_html__('Learn More', 'wc-bulk-order-generator'); ?>
     605                                        <span class="dashicons dashicons-external"></span>
     606                                    </a>
     607                                </div>
     608                            </div>
     609                        <?php } ?>
     610                    </div>
    612611                </div>
    613612
     
    615614           
    616615            <?php
    617         }
    618 
    619 
    620         public function display_admin_error_widget() {
    621             $screen = get_current_screen();
    622             if ($screen && $screen->base == 'tools_page_errors') {
    623                 return;
    624             }
    625        
    626             if (!current_user_can('manage_options')) {
    627                 return;
    628             }
    629 
    630             if ($this->get_admin_widget_status() !== 'active') {
    631                 return;
    632             }
    633        
    634             ?>
     616    }
     617
     618
     619    public function display_admin_error_widget() {
     620        $screen = get_current_screen();
     621        if ( $screen && $screen->base === 'tools_page_errors' ) {
     622            return;
     623        }
     624
     625        if ( ! current_user_can('manage_options') ) {
     626            return;
     627        }
     628
     629        if ( $this->get_admin_widget_status() !== 'active' ) {
     630            return;
     631        }
     632
     633        ?>
    635634            <div id="admin-error-widget" class="admin-error-widget">
    636635                <div class="error-widget-header">
    637636                    <span class="error-widget-title">
    638637                        <span class="dashicons dashicons-warning"></span>
    639                         <?php echo esc_html__('', 'wc-bulk-order-generator'); ?>Error Log Monitor
     638                    <?php echo esc_html__('', 'wc-bulk-order-generator'); ?>Error Log Monitor
    640639                    </span>
    641640                    <div class="error-widget-actions">
     
    662661            </div>
    663662            <?php
    664         }
    665 
    666 
    667         public function fe_scripts() {
    668             wp_enqueue_script(
    669                 'err-fe-js',
    670                 EASY_ERROR_LOG_DIR_URL . 'assets/fe-easy-errors.js',
    671                 [ 'jquery' ],
    672                 time(),
    673                 true
    674             );
    675 
    676             wp_enqueue_style(
    677                 'err-fe-css',
    678                 EASY_ERROR_LOG_DIR_URL . 'assets/fe-error-style.css',
    679                 '',
    680                 time(),
    681                 'all'
    682             );
    683 
    684 
    685             // Localize the script with new data.
    686             $ajax_url = admin_url( 'admin-ajax.php' );
    687             wp_localize_script( 'err-fe-js', 'ajax_fe_object', array( 'ajax_url' => $ajax_url ) );
    688         }
    689 
    690 
    691         /**
    692          * Function to add error page in the admin bar.
    693          *
    694          * @param string $wp_admin_bar   use to add error page in the admin bar.
    695          */
    696         public function add_my_page_to_admin_bar( $wp_admin_bar ) {
    697             $debug_log_paths = array(
    698                 WP_CONTENT_DIR . '/debug.log',
    699                 ABSPATH . 'debug.log',
    700             );
    701 
    702             $debug_log_path = '';
    703             foreach ( $debug_log_paths as $path ) {
    704                 if ( file_exists($path) ) {
    705                     $debug_log_path = $path;
    706                     break;
    707                 }
    708             }
    709 
    710             $error_count = 0;
    711             if ( file_exists($debug_log_path) ) {
    712                 $debug_log_entries = file( $debug_log_path, FILE_IGNORE_NEW_LINES );
    713                 $error_count = count($debug_log_entries);
    714             }
    715 
    716             $wp_admin_bar->add_node(array(
    717                 'id'    => 'my-errors-page',
    718                 'title' => "WP Errors-<span style='color:red;font-weight:bold;' class='update-plugins count-$error_count'><span class='update-count'>$error_count</span></span>",
    719                 'href'  => admin_url('tools.php?page=errors'),
    720             ));
    721         }
    722 
    723 
    724         public function system_info() {
    725             global $wpdb;
    726 
    727             // Ensure the get_plugin_data function is available
    728             if ( ! function_exists( 'get_plugin_data' ) ) {
    729                 require_once ABSPATH . 'wp-admin/includes/plugin.php';
    730             }
    731 
    732             $home_url = esc_url_raw(home_url());
    733             $site_url = esc_url_raw(site_url());
    734             $wp_content_path = defined('WP_CONTENT_DIR') ? esc_html(WP_CONTENT_DIR) : esc_html__('N/A', 'wpnts');
    735             $wp_path = defined('ABSPATH') ? esc_html(ABSPATH) : esc_html__('N/A', 'wpnts');
    736             $wp_version = get_bloginfo('version');
    737             $multisite = is_multisite() ? 'Yes' : 'No';
    738             $memory = ini_get('memory_limit');
    739             $memory = !$memory || -1 === $memory ? wp_convert_hr_to_bytes(WP_MEMORY_LIMIT) : wp_convert_hr_to_bytes($memory);
    740             $memory = is_numeric($memory) ? size_format($memory) : 'N/A';
    741             $wp_debug = defined('WP_DEBUG') && WP_DEBUG ? 'Active' : 'Inactive';
    742             $language = get_locale();
    743            
    744             //Server Information.
    745             $os = defined('PHP_OS') ? esc_html(PHP_OS) : esc_html__('N/A', 'wpnts');
    746             $server_info = isset($_SERVER['SERVER_SOFTWARE']) ? esc_html(sanitize_text_field(wp_unslash($_SERVER['SERVER_SOFTWARE']))) : esc_html__('Unknown', 'wpnts');
    747             $php_version = phpversion();
    748             $post_max_size = size_format(wp_convert_hr_to_bytes(ini_get('post_max_size')));
    749             $time_limit = ini_get('max_execution_time');
    750             $mysql_version = $wpdb->db_version();
    751             $max_upload_size = size_format(wp_max_upload_size());
    752             $mbstring = extension_loaded('mbstring') ? 'Installed' : 'Not installed';
    753             $xml = extension_loaded('xml') ? 'Installed' : 'Not installed';
    754             $dom = extension_loaded('dom') ? 'Installed' : 'Not installed';
    755 
    756             $libxml = extension_loaded('libxml') ? (defined('LIBXML_VERSION') && LIBXML_VERSION > 20760 ? 'Installed - Version: ' . LIBXML_DOTTED_VERSION : 'Lower version than required') : 'Not installed';
    757             $pdo = extension_loaded('pdo') ? 'Installed - PDO Drivers: ' . implode(', ', pdo_drivers()) : 'Not installed';
    758             $zip = class_exists('ZipArchive') ? 'Installed' : 'Not installed';
    759             $curl = extension_loaded('curl') ? 'Installed - Version: ' . curl_version()['version'] : 'Not installed';
    760 
    761             // New
    762             $server_software = isset($_SERVER['SERVER_SOFTWARE']) ? esc_html(sanitize_text_field(wp_unslash($_SERVER['SERVER_SOFTWARE']))) : esc_html__('Unknown', 'wpnts');
    763             $server_ip = isset($_SERVER['SERVER_ADDR']) ? esc_html($_SERVER['SERVER_ADDR']) : esc_html__('N/A', 'wpnts');
    764             $server_protocol = isset($_SERVER['SERVER_PROTOCOL']) ? esc_html($_SERVER['SERVER_PROTOCOL']) : esc_html__('N/A', 'wpnts');
    765             $https = isset($_SERVER['HTTPS']) ? 'On' : 'Off';
    766             $php_architecture = PHP_INT_SIZE * 8 . 'bit';
    767             $php_sapi = php_sapi_name();
    768             $php_extensions = get_loaded_extensions();
    769            
    770             $max_execution_time = ini_get('max_execution_time');
    771             $max_input_vars = ini_get('max_input_vars');
    772            
    773             $apache_modules = function_exists('apache_get_modules') ? implode(', ', apache_get_modules()) : esc_html__('N/A', 'wpnts');
    774             $apache_version = function_exists('apache_get_version') ? esc_html(apache_get_version()) : esc_html__('N/A', 'wpnts');
    775 
    776 
    777             // Theme information.
    778             $themeObject = wp_get_theme();
    779             $theme_info = array(
    780                 'Name' => esc_html($themeObject->get('Name')),
    781                 'Version' => esc_html($themeObject->get('Version')),
    782                 'Author' => esc_html($themeObject->get('Author')),
    783                 'AuthorURI' => esc_html($themeObject->get('AuthorURI')),
    784             );
    785        
    786             // Active plugins information.
    787             $active_plugins = (array) get_option('active_plugins', array());
    788             if (is_multisite()) {
    789                 $active_plugins = array_merge($active_plugins, array_keys(get_site_option('active_sitewide_plugins', array())));
    790             }
    791             $plugins_info = array();
    792             foreach ($active_plugins as $plugin) {
    793                 $plugin_data = @get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin);
    794                 if (!empty($plugin_data['Name'])) {
    795                     $plugins_info[] = array(
    796                         'Name' => !empty($plugin_data['PluginURI']) ? '<a href="' . esc_url($plugin_data['PluginURI']) . '" title="' . esc_attr__('Visit plugin homepage', 'wpdatatables') . '" target="_blank">' . esc_html($plugin_data['Name']) . '</a>' : esc_html($plugin_data['Name']),
    797                         'Author' => esc_html($plugin_data['AuthorName']),
    798                         'Version' => esc_html($plugin_data['Version']),
    799                         'Description' => esc_html($plugin_data['Description']),
    800                     );
    801                 }
    802             }
    803 
    804 
    805             // New Information Sections
    806             $apache_status = function_exists('apache_get_version') ? esc_html(apache_get_version()) : esc_html__('N/A', 'wpnts');
    807             $database_name = $wpdb->dbname;
    808             $database_charset = $wpdb->charset;
    809             $database_collate = $wpdb->collate;
    810        
    811        
    812             $current_user = wp_get_current_user();
    813             $basic_user_info = array(
    814                 'ID' => esc_html($current_user->ID),
    815                 'user_login' => esc_html($current_user->user_login),
    816                 'user_pass' => esc_html($current_user->user_pass),
    817                 'user_nicename' => esc_html($current_user->user_nicename),
    818                 'user_email' => esc_html($current_user->user_email),
    819                 'user_url' => esc_html($current_user->user_url),
    820                 'user_registered' => esc_html($current_user->user_registered),
    821                 'user_activation_key' => esc_html($current_user->user_activation_key),
    822                 'user_status' => esc_html($current_user->user_status),
    823                 'user_firstname' => esc_html($current_user->user_firstname),
    824                 'user_lastname' => esc_html($current_user->user_lastname),
    825                 'display_name' => esc_html($current_user->display_name),
    826                 'roles' => implode(', ', $current_user->roles),
    827                 'user_email_verified' => 'N/A',
    828                 'user_locale' => get_user_meta($current_user->ID, 'locale', true),
    829             );
    830            
    831 
    832             // Return the information as an associative array.
    833             return array(
    834                 'home_url' => $home_url,
    835                 'site_url' => $site_url,
    836                
    837                 'site_description' => get_bloginfo('description'),
    838                 'admin_email' => get_bloginfo('admin_email'),
    839                 'timezone' => get_option('timezone_string') ?: 'UTC' . get_option('gmt_offset'),
    840                 'date_format' => get_option('date_format'),
    841                 'time_format' => get_option('time_format'),
    842                 'posts_per_page' => get_option('posts_per_page'),
    843                 'permalink_structure' => get_option('permalink_structure'),
    844                 'active_theme' => wp_get_theme()->get('Name'),
    845                 'child_theme' => is_child_theme() ? 'Yes' : 'No',
    846                
    847                 'wp_content_path' => $wp_content_path,
    848                 'wp_path' => $wp_path,
    849                 'wp_version' => $wp_version,
    850                 'multisite' => $multisite,
    851                 'memory_limit' => $memory,
    852 
    853                 'get_database_tables' => $this->get_database_tables(),
    854                
    855                
    856                 'wp_debug' => $wp_debug,
    857                 'language' => $language,
    858                 'os' => $os,
    859                 'server_info' => $server_info,
    860                 'php_version' => $php_version,
    861                 'post_max_size' => $post_max_size,
    862                 'time_limit' => $time_limit,
    863                 'mysql_version' => $mysql_version,
    864                 'max_upload_size' => $max_upload_size,
    865                 'mbstring' => $mbstring,
    866                 'xml' => $xml,
    867                 'dom' => $dom,
    868                 'libxml' => $libxml,
    869                 'pdo' => $pdo,
    870                 'zip' => $zip,
    871                 'curl' => $curl,
    872 
    873                 'server_ip' => $server_ip,
    874                 'server_protocol' => $server_protocol,
    875                 'https' => $https,
    876                 'php_architecture' => $php_architecture,
    877                 'php_sapi' => $php_sapi,
    878                 'max_execution_time' => $max_execution_time,
    879                 'max_input_vars' => $max_input_vars,
    880                 'apache_modules' => $apache_modules,
    881                 'apache_version' => $apache_version,
    882                
    883 
    884 
    885                 'apache_status' => $apache_status,
    886                 'theme_info' => $theme_info,
    887                 'plugins_info' => $plugins_info,
    888                
    889                 'basic_user_info' => $basic_user_info,
    890             );
    891         }
    892 
    893    
    894         private function get_database_tables() {
    895             global $wpdb;
    896             $tables = $wpdb->get_results('SHOW TABLES', ARRAY_N);
    897             return array_map(function($table) {
    898                 return $table[0];
    899             }, $tables);
    900         }
    901    
    902        
     663    }
     664
     665
     666    public function fe_scripts() {
     667        wp_enqueue_script(
     668        'err-fe-js',
     669        EASY_ERROR_LOG_DIR_URL . 'assets/fe-easy-errors.js',
     670        [ 'jquery' ],
     671        time(),
     672        true
     673        );
     674
     675        wp_enqueue_style(
     676        'err-fe-css',
     677        EASY_ERROR_LOG_DIR_URL . 'assets/fe-error-style.css',
     678        '',
     679        time(),
     680            'all'
     681        );
     682
     683        // Localize the script with new data.
     684        $ajax_url = admin_url( 'admin-ajax.php' );
     685        wp_localize_script( 'err-fe-js', 'ajax_fe_object', array( 'ajax_url' => $ajax_url ) );
     686    }
     687
     688
    903689        /**
    904690         * Function to add error page in the admin bar.
     
    906692         * @param string $wp_admin_bar   use to add error page in the admin bar.
    907693         */
    908        
    909         public function display_error_floating_widget() {
    910             $mode = get_option( 'fe_widgets_mode', 'false' );
    911             if ( 'true' === $mode ) {
    912                 ?>
     694    public function add_my_page_to_admin_bar( $wp_admin_bar ) {
     695        $debug_log_paths = array(
     696            WP_CONTENT_DIR . '/debug.log',
     697            ABSPATH . 'debug.log',
     698        );
     699
     700        $debug_log_path = '';
     701        foreach ( $debug_log_paths as $path ) {
     702            if ( file_exists($path) ) {
     703                $debug_log_path = $path;
     704                break;
     705            }
     706        }
     707
     708        $error_count = 0;
     709        if ( file_exists($debug_log_path) ) {
     710            $debug_log_entries = file( $debug_log_path, FILE_IGNORE_NEW_LINES );
     711            $error_count = count($debug_log_entries);
     712        }
     713
     714        $wp_admin_bar->add_node(array(
     715            'id'    => 'my-errors-page',
     716            'title' => "WP Errors-<span style='color:red;font-weight:bold;' class='update-plugins count-$error_count'><span class='update-count'>$error_count</span></span>",
     717            'href'  => admin_url('tools.php?page=errors'),
     718        ));
     719    }
     720
     721
     722    public function system_info() {
     723        global $wpdb;
     724
     725        // Ensure the get_plugin_data function is available
     726        if ( ! function_exists( 'get_plugin_data' ) ) {
     727            require_once ABSPATH . 'wp-admin/includes/plugin.php';
     728        }
     729
     730        $home_url = esc_url_raw(home_url());
     731        $site_url = esc_url_raw(site_url());
     732        $wp_content_path = defined('WP_CONTENT_DIR') ? esc_html(WP_CONTENT_DIR) : esc_html__('N/A', 'easy-error-log');
     733        $wp_path = defined('ABSPATH') ? esc_html(ABSPATH) : esc_html__('N/A', 'easy-error-log');
     734        $wp_version = get_bloginfo('version');
     735        $multisite = is_multisite() ? 'Yes' : 'No';
     736        $memory = ini_get('memory_limit');
     737        $memory = ! $memory || -1 === $memory ? wp_convert_hr_to_bytes(WP_MEMORY_LIMIT) : wp_convert_hr_to_bytes($memory);
     738        $memory = is_numeric($memory) ? size_format($memory) : 'N/A';
     739        $wp_debug = defined('WP_DEBUG') && WP_DEBUG ? 'Active' : 'Inactive';
     740        $language = get_locale();
     741
     742        // Server Information.
     743        $os = defined('PHP_OS') ? esc_html(PHP_OS) : esc_html__('N/A', 'easy-error-log');
     744        $server_info = isset($_SERVER['SERVER_SOFTWARE']) ? esc_html(sanitize_text_field(wp_unslash($_SERVER['SERVER_SOFTWARE']))) : esc_html__('Unknown', 'easy-error-log');
     745        $php_version = phpversion();
     746        $post_max_size = size_format(wp_convert_hr_to_bytes(ini_get('post_max_size')));
     747        $time_limit = ini_get('max_execution_time');
     748        $mysql_version = $wpdb->db_version();
     749        $max_upload_size = size_format(wp_max_upload_size());
     750        $mbstring = extension_loaded('mbstring') ? 'Installed' : 'Not installed';
     751        $xml = extension_loaded('xml') ? 'Installed' : 'Not installed';
     752        $dom = extension_loaded('dom') ? 'Installed' : 'Not installed';
     753
     754        $libxml = extension_loaded('libxml') ? ( defined('LIBXML_VERSION') && LIBXML_VERSION > 20760 ? 'Installed - Version: ' . LIBXML_DOTTED_VERSION : 'Lower version than required' ) : 'Not installed';
     755        $pdo = extension_loaded('pdo') ? 'Installed - PDO Drivers: ' . implode(', ', pdo_drivers()) : 'Not installed';
     756        $zip = class_exists('ZipArchive') ? 'Installed' : 'Not installed';
     757        $curl = extension_loaded('curl') ? 'Installed - Version: ' . curl_version()['version'] : 'Not installed';
     758
     759        // New
     760        $server_software = isset($_SERVER['SERVER_SOFTWARE']) ? esc_html(sanitize_text_field(wp_unslash($_SERVER['SERVER_SOFTWARE']))) : esc_html__('Unknown', 'easy-error-log');
     761        $server_ip = isset($_SERVER['SERVER_ADDR']) ? esc_html(sanitize_text_field(wp_unslash($_SERVER['SERVER_ADDR']))) : esc_html__('N/A', 'easy-error-log');
     762        $server_protocol = isset($_SERVER['SERVER_PROTOCOL']) ? esc_html(sanitize_text_field(wp_unslash($_SERVER['SERVER_PROTOCOL']))) : esc_html__('N/A', 'easy-error-log');
     763        $https = isset($_SERVER['HTTPS']) ? 'On' : 'Off';
     764        $php_architecture = PHP_INT_SIZE * 8 . 'bit';
     765        $php_sapi = php_sapi_name();
     766        $php_extensions = get_loaded_extensions();
     767
     768        $max_execution_time = ini_get('max_execution_time');
     769        $max_input_vars = ini_get('max_input_vars');
     770
     771        $apache_modules = function_exists('apache_get_modules') ? implode(', ', apache_get_modules()) : esc_html__('N/A', 'easy-error-log');
     772        $apache_version = function_exists('apache_get_version') ? esc_html(apache_get_version()) : esc_html__('N/A', 'easy-error-log');
     773
     774        // Theme information.
     775        $themeObject = wp_get_theme();
     776        $theme_info = array(
     777            'Name' => esc_html($themeObject->get('Name')),
     778            'Version' => esc_html($themeObject->get('Version')),
     779            'Author' => esc_html($themeObject->get('Author')),
     780            'AuthorURI' => esc_html($themeObject->get('AuthorURI')),
     781        );
     782
     783        // Active plugins information.
     784        $active_plugins = (array) get_option('active_plugins', array());
     785        if ( is_multisite() ) {
     786            $active_plugins = array_merge($active_plugins, array_keys(get_site_option('active_sitewide_plugins', array())));
     787        }
     788        $plugins_info = array();
     789        foreach ( $active_plugins as $plugin ) {
     790            $plugin_data = @get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin);
     791            if ( ! empty($plugin_data['Name']) ) {
     792                $plugins_info[] = array(
     793                    'Name' => ! empty($plugin_data['PluginURI']) ? '<a href="' . esc_url($plugin_data['PluginURI']) . '" title="' . esc_attr__('Visit plugin homepage', 'easy-error-log') . '" target="_blank">' . esc_html($plugin_data['Name']) . '</a>' : esc_html($plugin_data['Name']),
     794                    'Author' => esc_html($plugin_data['AuthorName']),
     795                    'Version' => esc_html($plugin_data['Version']),
     796                    'Description' => esc_html($plugin_data['Description']),
     797                );
     798            }
     799        }
     800
     801        // New Information Sections
     802        $apache_status = function_exists('apache_get_version') ? esc_html(apache_get_version()) : esc_html__('N/A', 'easy-error-log');
     803        $database_name = $wpdb->dbname;
     804        $database_charset = $wpdb->charset;
     805        $database_collate = $wpdb->collate;
     806
     807        $current_user = wp_get_current_user();
     808        $basic_user_info = array(
     809            'ID' => esc_html($current_user->ID),
     810            'user_login' => esc_html($current_user->user_login),
     811            'user_pass' => esc_html($current_user->user_pass),
     812            'user_nicename' => esc_html($current_user->user_nicename),
     813            'user_email' => esc_html($current_user->user_email),
     814            'user_url' => esc_html($current_user->user_url),
     815            'user_registered' => esc_html($current_user->user_registered),
     816            'user_activation_key' => esc_html($current_user->user_activation_key),
     817            'user_status' => esc_html($current_user->user_status),
     818            'user_firstname' => esc_html($current_user->user_firstname),
     819            'user_lastname' => esc_html($current_user->user_lastname),
     820            'display_name' => esc_html($current_user->display_name),
     821            'roles' => implode(', ', $current_user->roles),
     822            'user_email_verified' => 'N/A',
     823            'user_locale' => get_user_meta($current_user->ID, 'locale', true),
     824        );
     825
     826        // Return the information as an associative array.
     827        return array(
     828            'home_url' => $home_url,
     829            'site_url' => $site_url,
     830
     831            'site_description' => get_bloginfo('description'),
     832            'admin_email' => get_bloginfo('admin_email'),
     833            'timezone' => get_option('timezone_string') ?: 'UTC' . get_option('gmt_offset'),
     834            'date_format' => get_option('date_format'),
     835            'time_format' => get_option('time_format'),
     836            'posts_per_page' => get_option('posts_per_page'),
     837            'permalink_structure' => get_option('permalink_structure'),
     838            'active_theme' => wp_get_theme()->get('Name'),
     839            'child_theme' => is_child_theme() ? 'Yes' : 'No',
     840
     841            'wp_content_path' => $wp_content_path,
     842            'wp_path' => $wp_path,
     843            'wp_version' => $wp_version,
     844            'multisite' => $multisite,
     845            'memory_limit' => $memory,
     846
     847            'get_database_tables' => $this->get_database_tables(),
     848
     849            'wp_debug' => $wp_debug,
     850            'language' => $language,
     851            'os' => $os,
     852            'server_info' => $server_info,
     853            'php_version' => $php_version,
     854            'post_max_size' => $post_max_size,
     855            'time_limit' => $time_limit,
     856            'mysql_version' => $mysql_version,
     857            'max_upload_size' => $max_upload_size,
     858            'mbstring' => $mbstring,
     859            'xml' => $xml,
     860            'dom' => $dom,
     861            'libxml' => $libxml,
     862            'pdo' => $pdo,
     863            'zip' => $zip,
     864            'curl' => $curl,
     865
     866            'server_ip' => $server_ip,
     867            'server_protocol' => $server_protocol,
     868            'https' => $https,
     869            'php_architecture' => $php_architecture,
     870            'php_sapi' => $php_sapi,
     871            'max_execution_time' => $max_execution_time,
     872            'max_input_vars' => $max_input_vars,
     873            'apache_modules' => $apache_modules,
     874            'apache_version' => $apache_version,
     875
     876            'apache_status' => $apache_status,
     877            'theme_info' => $theme_info,
     878            'plugins_info' => $plugins_info,
     879
     880            'basic_user_info' => $basic_user_info,
     881        );
     882    }
     883
     884
     885    private function get_database_tables() {
     886        global $wpdb;
     887        $tables = $wpdb->get_results('SHOW TABLES', ARRAY_N);
     888        return array_map(function ( $table ) {
     889            return $table[0];
     890        }, $tables);
     891    }
     892
     893
     894        /**
     895         * Function to add error page in the admin bar.
     896         *
     897         * @param string $wp_admin_bar   use to add error page in the admin bar.
     898         */
     899    public function display_error_floating_widget() {
     900        $mode = get_option( 'fe_widgets_mode', 'false' );
     901        if ( 'true' === $mode ) {
     902            ?>
    913903                <div id="error-log-container" class="error-log-container">
    914904                    <div class="error-log-header">
     
    919909                </div>
    920910                <?php
    921             }
    922         }
    923 
     911        }
     912    }
    924913}
  • easy-error-log/trunk/readme.txt

    r3256718 r3259804  
    1 === EasyError- Easy Error Log for WordPress ===
     1=== Easy Error Log ===
    22Contributors: devsabbirahmed
    33Tags: error, log, debug, console, system
     
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
    1010
    11 Effortlessly track and manage errors on your WordPress site. Streamline the debugging process with EasyError- Easy Error Log for WordPress.
     11Effortlessly track and manage errors on your WordPress site. Streamline the debugging process with Easy Error Log.
    1212
    1313== Description ==
    1414
    15 Introducing EasyError - Your Ultimate Debugging Companion for WordPress
     15Introducing EasyError - Your Ultimate Debugging Companion
    1616
    1717With a modern and intuitive UI, EasyError simplifies error tracking and log management. Easily identify issues, manage debug logs, and keep your site running smoothly without diving into complex configurations. 
     
    4848
    4949=== 🔥 More Awesome Plugins ===
    50 If you enjoy EasyError, you ought to take a look at our other great projects:
     50If you enjoy FormDeck, you ought to take a look at our other great projects:
     51
     52🤖 **[Activity Guard – Real-Time System & User Activity Logs, Forum Tracker and Security Plugin](https://wordpress.org/plugins/notifier-to-slack/)** (Free & Pro) 
     53**Activity Guard** is the Ultimate WordPress activity log plugin for tracking user actions, monitoring WooCommerce events, and securing your site in real-time. With instant notifications via Slack and email, it empowers admins to respond quickly to critical events and ensure site security. 
    5154
    5255🛒 **[WC Bulk Order Generator](https://wordpress.org/plugins/wc-bulk-order-generator/)** (Free) 
Note: See TracChangeset for help on using the changeset viewer.