$details Details. */ public static function log( string $type, string $format, int $user_id, string $title, array $details ): void { if ( $user_id <= 0 ) { return; } EventLogger::log( $type, sprintf( $format, self::login( $user_id ), $title ), 'user', $user_id, $details ); } /** * A user's login, or their id when the account cannot be read. * * @param int $user_id User id. */ public static function login( int $user_id ): string { $user = get_userdata( $user_id ); return $user ? (string) $user->user_login : '#' . $user_id; } /** * A post's title, bounded, or its id. * * @param int $post_id Post id. */ public static function post_title( int $post_id ): string { $title = $post_id > 0 ? get_the_title( $post_id ) : ''; return '' !== $title ? EventLogger::bounded( wp_strip_all_tags( $title ), self::TITLE_LENGTH ) : '#' . $post_id; } /** * An id from a value that may be an id, a numeric string or an object * with an `ID` or `id` (a WP_Post, a WP_User). * * @param mixed $value The value. */ public static function id( $value ): int { if ( is_numeric( $value ) ) { return (int) $value; } if ( is_object( $value ) ) { if ( isset( $value->ID ) && is_numeric( $value->ID ) ) { return (int) $value->ID; } if ( isset( $value->id ) && is_numeric( $value->id ) ) { return (int) $value->id; } } return 0; } }