Skip to content
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

Merged
merged 9 commits into from Mar 20, 2014
Merged

Add new tooltip to users #340

merged 9 commits into from Mar 20, 2014

Conversation

jonathanbardo
Copy link
Contributor

This should close #338

@fjarrett Can you review this?

sprintf(
'%s%5$s%s%5$s%s%5$s%s',
__( 'ID:', 'stream' ) . ' ' . $user->ID,
__( 'User:', 'stream' ) . ' ' . $user->user_nicename,
Copy link
Contributor

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.

@fjarrett
Copy link
Contributor

@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 ),
Copy link
Contributor

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() ),
Copy link
Contributor

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 😉

screen shot 2014-03-15 at 5 08 32 pm

Copy link
Contributor

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
)

Copy link
Contributor Author

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.

Copy link
Contributor

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?

Copy link
Contributor Author

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/

Copy link
Contributor

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.

@jonathanbardo
Copy link
Contributor Author

@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' ),
Copy link
Contributor

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.

@fjarrett
Copy link
Contributor

@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.

@jonathanbardo
Copy link
Contributor Author

@fjarrett I saw your comment on Stream Record but isn't that a separate plugin? You think we have to enable this here?

@fjarrett
Copy link
Contributor

@jonathanbardo Not sure what you mean, Stream Records is the main screen 😸 It was part of the original requirement described in #338

screen shot 2014-03-18 at 11 38 43 am

@jonathanbardo
Copy link
Contributor Author

Oh my bad... I really thought this was something else. Will take a look for this one as well.

@fjarrett
Copy link
Contributor

@jonathanbardo Thanks!

@jonathanbardo
Copy link
Contributor Author

@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?

@fjarrett
Copy link
Contributor

@jonathanbardo there's not much here to duplicate, I'm OK with adding this separately to the list table.

@jonathanbardo
Copy link
Contributor Author

I've added the tooltip to the record page.

@fjarrett
Copy link
Contributor

@jonathanbardo Sorry but I am not seeing the title= attribute anywhere in the Stream Records screen Authors dropdown results. Maybe I'm missing something?

screen shot 2014-03-20 at 12 11 57 pm

@fjarrett
Copy link
Contributor

@jonathanbardo Sorry, I'm dumb and forgot to git pull #facepalm

fjarrett added a commit that referenced this pull request Mar 20, 2014
@fjarrett fjarrett merged commit 34cfd8f into develop Mar 20, 2014
@fjarrett fjarrett deleted the issue-338 branch March 20, 2014 23:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Store additional user meta in title attribute of Author results
3 participants