$alert ) {
$date = ( isset( $alert['created_on'] ) ) ? $alert['created_on'] : '';
$r = '
';
$processed_row_data = array();
foreach ( self::$columns_header as $key => $label ) {
$value = array_key_exists( $key, $alert ) ? $alert[ $key ] : '';
if ( 'timestamp' === $key ) {
$value = $date;
}
$processed_row_data[ $key ] = $value;
}
foreach ( $processed_row_data as $key => $label ) {
$cell_styling = 'padding: 16px 7px;';
if ( 'alert_id' === $key ) {
$cell_styling .= ' text-align: center; font-weight: 700;';
} elseif ( 'severity' === $key ) {
$cell_styling = '" class="tooltip" title="' . $label;
$label = '';
} elseif ( 'user_displayname' === $key ) {
$cell_styling .= ' min-width: 100px;';
} elseif ( 'message' === $key ) {
$cell_styling .= ' min-width: 400px; word-break: break-all; line-height: 1.5;';
}
$r .= '| ' . $label . ' | ';
}
$r .= '
';
fwrite( $output, $r );
}
}
fclose( $output );
}
/**
* Sets the writer file name.
*
* @param string $file - The name of the writer file to be used.
*
* @return void
*
* @since 5.0.0
*/
public static function set_file( string $file ) {
self::$file_name = $file;
}
/**
* Returns the writer file name.
*
* @return string
*
* @since 5.0.0
*/
public static function get_file(): string {
return (string) self::$file_name;
}
/**
* Sets the header_columns property to be used in HTML generation
*
* @param array $columns - The column names.
*
* @return void
*
* @since 5.0.0
*/
public static function set_header_columns( array $columns ) {
self::$columns_header = $columns;
}
/**
* Set the file footer - closes the HTML output.
*
* @return void
*
* @since 5.0.0
*/
public static function set_footer() {
$output = fopen( self::get_file(), 'a+' );
fwrite( $output, ' WP Activity Log is supported and developed by Melapress.