-
Notifications
You must be signed in to change notification settings - Fork 119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add new tooltip to users #340
Conversation
sprintf( | ||
'%s%5$s%s%5$s%s%5$s%s', | ||
__( 'ID:', 'stream' ) . ' ' . $user->ID, | ||
__( 'User:', 'stream' ) . ' ' . $user->user_nicename, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jonathanbardo This should be $user->user_login
instead.
@jonathanbardo This should also work in the Stream Records screen too. |
__( 'ID:', 'stream' ) . ' ' . $user->ID, | ||
__( 'User:', 'stream' ) . ' ' . $user->user_login, | ||
__( 'Email:', 'stream' ) . ' ' . $user->user_email, | ||
__( 'Role:', 'stream' ) . ' ' . implode( ',', $user->roles ), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jonathanbardo Would be great if we could use the role label rather than slugs here. They are available in self::get_roles()
.
__( 'ID:', 'stream' ) . ' ' . $user->ID, | ||
__( 'User:', 'stream' ) . ' ' . $user->user_login, | ||
__( 'Email:', 'stream' ) . ' ' . $user->user_email, | ||
__( 'Role:', 'stream' ) . ' ' . implode( ',', self::get_roles() ), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jonathanbardo This is getting all the role labels, not the labels for this user only 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jonathanbardo Also, the string concatenation here is bugging me. What do you think about something like this?
sprintf(
__( "ID: %d\nUser: %s\nEmail: %s\nRole: %s", 'stream' ),
$user->ID, // xss ok
$user->user_login, // xss ok
$user->user_email, // xss ok
implode( ', ', $user->roles ), // xss ok
PHP_EOL
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that's good. I'll just change \n to PHP_EOL so it works across multiple system.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think PHP_EOL
will make much difference here, since it would only matter (even slightly) for server-side processing of the textual data. But this is getting output straight to the client. So the question is, in JS do browsers like \n
or \r\n
more?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's wrong with PHP_EOL? By using it we don't have to worry about asking
ourselves what we need to use.
On Saturday, March 15, 2014, Weston Ruter notifications@github.com wrote:
In includes/settings.php:
@@ -124,8 +121,19 @@ public static function get_users(){
}$args = array(
'id' => $user->ID,
'text' => $user->display_name,
'id' => $user->ID,
'text' => $user->display_name,
);
$args['tooltip'] = esc_attr(
sprintf(
'%s%5$s%s%5$s%s%5$s%s',
__( 'ID:', 'stream' ) . ' ' . $user->ID,
__( 'User:', 'stream' ) . ' ' . $user->user_login,
__( 'Email:', 'stream' ) . ' ' . $user->user_email,
__( 'Role:', 'stream' ) . ' ' . implode( ',', self::get_roles() ),
I don't think PHP_EOL will make much difference here, since it would only
matter (even slightly) for server-side processing of the textual data. But
this is getting output straight to the client. So the question is, in JS do
browsers like \n or \r\n more?Reply to this email directly or view it on GitHubhttps://github.com//pull/340/files#r10638244
.
Jonathan Bardo
Web Developer
[image: X-Team] http://x-team.com/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because we don't actually care about PHP's native EOL marker. We care about JS_EOL
😄 If on a Windows machine, PHP_EOL
is \r\n
then this will get sent to the browser in the code above. Whereas on a Unix machine, if PHP_EOL
is \n
then that will get sent to the browser. The browser doesn't care what EOL marker is native to the server. I'm just curious what differences (if any) between browsers when rendering \r\n
vs \n
in tooltips.
@fjarrett This should be good to go. |
$user_roles = array_map( 'ucwords', $user->roles ); | ||
$args['tooltip'] = esc_attr( | ||
sprintf( | ||
__( 'ID: %d\nUser: %s\nEmail: %s\nRole: %s', 'stream' ), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jonathanbardo \n
requires double quote style.
@jonathanbardo You may have missed my comment above that this should also apply to the Stream Records list table screen as well, not just the Settings. |
@fjarrett I saw your comment on Stream Record but isn't that a separate plugin? You think we have to enable this here? |
@jonathanbardo Not sure what you mean, Stream Records is the main screen 😸 It was part of the original requirement described in #338 |
Oh my bad... I really thought this was something else. Will take a look for this one as well. |
@jonathanbardo Thanks! |
@fjarrett Right now the record page doesn't use the same mechanism as the settings page to get all user. Do you think I can change that to be only loaded by ajax and use the same method for both functions? |
@jonathanbardo there's not much here to duplicate, I'm OK with adding this separately to the list table. |
I've added the tooltip to the record page. |
@jonathanbardo Sorry but I am not seeing the |
@jonathanbardo Sorry, I'm dumb and forgot to |
This should close #338
@fjarrett Can you review this?