WordPress.org

Making WordPress.org


Ignore:
Timestamp:
10/10/2016 07:46:37 PM (3 years ago)
Author:
coffee2code
Message:

Forums Theme: Show Slack username and/or WordPress.org username (linked to profiles.wordpress.org) in user profiles.

Also adds missing translator comments for all the placeholders in the same block.

Props SergeyBiryukov.
Fixes #2068.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-forums/functions.php

    r4163 r4206  
    174174
    175175/**
     176 * Get user's WordPress.org profile link.
     177 *
     178 * @param int $user_id
     179 * @return string
     180 */
     181function wporg_support_get_wporg_profile_link( $user_id = 0 ) {
     182    $user_nicename = bbp_get_user_nicename( $user_id );
     183
     184    return sprintf( '<a href="%s">@%s</a>',
     185        esc_url( 'https://profiles.wordpress.org/' . $user_nicename ),
     186        $user_nicename
     187    );
     188}
     189
     190/**
     191 * Get user's Slack username.
     192 *
     193 * @param int $user_id
     194 * @return string The user's Slack username (without '@') if user has one.
     195 */
     196function wporg_support_get_slack_username( $user_id = 0 ) {
     197    global $wpdb;
     198
     199    $user_id = bbp_get_user_id( $user_id );
     200    $slack_username = '';
     201
     202    $data = $wpdb->get_var( $wpdb->prepare( "SELECT profiledata FROM slack_users WHERE user_id = %d", $user_id ) );
     203    if ( $data && ( $data = json_decode( $data, true ) ) ) {
     204        $slack_username = $data['name'];
     205    }
     206
     207    return $slack_username;
     208}
     209
     210/**
    176211 * Get user's registration date.
     212 *
     213 * @param int $user_id
     214 * @return string
    177215 */
    178216function wporg_support_get_user_registered_date( $user_id = 0 ) {
Note: See TracChangeset for help on using the changeset viewer.