/** * Returns the contents of the log file. * * @since 3.9.6 */ function wprss_get_log() { if (!file_exists(wprss_log_file())) { wprss_clear_log(); } $contents = file_get_contents(wprss_log_file(), ''); // Trim the log file to a fixed number of chars $limit = 10000; if (strlen($contents) > $limit) { file_put_contents(wprss_log_file(), substr($contents, 0, $limit)); return wprss_get_log(); } else { return $contents; } }
/** * Creates and returns the support request email's message body. * * @since 4.7 */ function wprss_create_support_message() { // Get the WP RSS Aggregator log. $log = 'Customer did not send log'; if ($_GET['support-include-log'] === 'true') { $log = wprss_get_log(); } // Get the system information. $sys_info = 'Customer did not send system information'; if ($_GET['support-include-sys'] === 'true') { ob_start(); wprss_print_system_info(); $sys_info = ob_get_contents(); ob_end_clean(); } // Get the license keys. $keys = json_encode(get_option('wprss_settings_license_keys', array()), JSON_PRETTY_PRINT); // Get the message they entered. $message = sanitize_text_field($_GET['support-message']); // Remove any generated system data that may be present from previous form submission attempts. $idx = strpos($message, "----------------------------------------------"); if ($idx !== FALSE) { $message = substr($message, 0, $idx); } // Append the generated system data. $message .= "\n\n----------------------------------------------\n"; $message .= "\nLicense Information:\n" . $keys; $message .= "\n\n\nError Log:\n" . $log; $message .= "\n\n\nSystem Information:\n" . $sys_info . "\n"; $message = apply_filters('wprss_support_message', $message); return $message; }
/** * Renders the Clear Log button * * @since 3.9.6 */ function wprss_debug_clear_log_button() { ?> <h3><?php _e('Error Log', 'wprss'); ?> </h3> <textarea readonly="readonly" id="wprss-error-log-textarea"><?php echo wprss_get_log(); ?> </textarea> <form action="edit.php?post_type=wprss_feed&page=wprss-debugging" method="POST"> <?php wp_nonce_field('wprss-clear-error-log'); submit_button(__('Clear log', 'wprss'), 'button-primary', 'error-log', true); ?> </form> <?php }
/** * Renders the Error Log. */ function wprss_debug_render_error_log() { ?> <h3><?php _e('Error Log', WPRSS_TEXT_DOMAIN); ?> </h3> <textarea readonly="readonly" id="wprss-error-log-textarea"><?php echo wprss_get_log(); ?> </textarea> <?php }