_EOL, $log ); $log = array_slice( $log, -$last_lines ); $log = implode( PHP_EOL, $log ); } return $log; } protected function do_reset(): void { if ( ! $this->log_file_path ) { return; } file_put_contents( $this->log_file_path, '' ); } protected function do_download(): void { if ( ! isset( $_GET['swcfpc_download_log'] ) || ! file_exists( $this->log_file_path ) || ! current_user_can( 'manage_options' ) ) { return; } if ( $_GET['swcfpc_download_log'] === 'view' ) { echo '
' . esc_html( file_get_contents( $this->log_file_path ) ) . '
'; exit; } header( 'Content-Description: File Transfer' ); header( 'Content-Type: application/octet-stream' ); header( 'Content-Disposition: attachment; filename=debug.log' ); header( 'Content-Transfer-Encoding: binary' ); header( 'Connection: Keep-Alive' ); header( 'Expires: 0' ); header( 'Cache-Control: no-cache, must-revalidate, post-check=0, pre-check=0, max-age=0, s-maxage=0' ); header( 'Pragma: public' ); header( 'Content-Length: ' . filesize( $this->log_file_path ) ); readfile( $this->log_file_path ); exit; } }