';
}
/**
* Actor label.
*
* @param array $row Event row.
* @return string
*/
public static function actor( array $row ) {
if ( ! empty( $row['user_id'] ) ) {
$name = '' !== $row['user_display'] ? $row['user_display'] : $row['user_login'];
if ( ! empty( $row['user_role'] ) ) {
$name .= ' · ' . $row['user_role'];
}
return $name;
}
$initiators = Vocabulary::initiators();
$key = isset( $row['initiator'] ) ? $row['initiator'] : 'anonymous';
return isset( $initiators[ $key ] ) ? $initiators[ $key ] : $key;
}
/**
* Local initial for the person who caused the event.
*
* Drawn in the browser. This does not call get_avatar() or any remote avatar service.
*
* @param array $row Event row.
* @param int $size Mark size in pixels. Sizes of 30 or less use the compact class.
* @return string
*/
public static function avatar( array $row, $size = 36 ) {
$size = max( 16, min( 96, (int) $size ) );
if ( ! empty( Settings::all()['use_gravatar'] ) && ! empty( $row['user_id'] ) && function_exists( 'get_avatar' ) ) {
$html = get_avatar(
(int) $row['user_id'],
$size,
'',
'',
array(
'class' => 'srah-avatar srah-avatar-gravatar',
'force_display' => true,
)
);
if ( is_string( $html ) && '' !== $html ) {
return $html;
}
}
$name = self::actor( $row );
$letter = function_exists( 'mb_substr' ) ? mb_substr( $name, 0, 1, 'UTF-8' ) : substr( $name, 0, 1 );
$letter = strtoupper( (string) $letter );
if ( '' === $letter ) {
$letter = '?';
}
$class = 'srah-avatar srah-avatar-local';
if ( $size <= 30 ) {
$class .= ' srah-avatar-sm';
}
return '' . esc_html( $letter ) . '';
}
/**
* Row IDs a selection checkbox stands for, comma separated.
*
* A collapsed group lists every stored row so deleting it removes all repeats.
*
* @param array $row Event row.
* @return string
*/
public static function selection( array $row ) {
$ids = isset( $row['group_ids'] ) && is_array( $row['group_ids'] ) ? $row['group_ids'] : array();
if ( ! $ids && ! empty( $row['id'] ) ) {
$ids = array( $row['id'] );
}
return implode( ',', array_filter( array_map( 'absint', $ids ) ) );
}
/**
* One timeline card.
*
* @param array $row Event row.
* @param array $args Display arguments.
*/
public static function card( array $row, array $args = array() ) {
$args = wp_parse_args(
$args,
array(
'checkbox' => false,
'compact' => false,
)
);
$severity = isset( $row['severity'] ) ? $row['severity'] : 'info';
$category = isset( $row['category'] ) ? $row['category'] : 'system';
$when = Time::display( isset( $row['created_gmt'] ) ? $row['created_gmt'] : '', isset( $row['created_ms'] ) ? (int) $row['created_ms'] : 0 );
$id = isset( $row['id'] ) ? (int) $row['id'] : 0;
?>
1 ) : ?>
1 ) : ?>
$lines,
'field' => isset( $change['field'] ) ? (string) $change['field'] : '',
);
continue;
}
$plain_changes[] = $change;
}
?>
$value ) : ?>