Plugin Directory

Changeset 606834


Ignore:
Timestamp:
10/02/2012 04:21:41 AM (13 years ago)
Author:
graphical_force
Message:

Add the ability to display the username in the widget or shortcode.

Location:
get-user-info/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • get-user-info/trunk/getUserInfo.php

    r604437 r606834  
    33Plugin Name: Get user info
    44Plugin URI: http://wordpress.org/extend/plugins/get-user-info/
    5 Choose to display any of the following for any user: First and last name, avatar, description or website. A title can be added along with a css class to allow styling if needed. Is available as a widget or shortcode. Ex. [userinfo user="User Name" class="CssClass" title="My Title" name="true" avatar="true" description="true" website="true"].
    6 Version: 1.0.9
     5Description: Choose to display any of the following for any user: User name, first and last name, avatar, description or website. A title can be added along with a css class to allow styling if needed. Is available as a widget or shortcode. Ex. [userinfo user="User Name" class="CssClass" title="My Title" username="true" name="true" avatar="true" description="true" website="true"].
     6Version: 1.1
    77Author: Jeff Freeman
    88Author URI: http://graphicalforce.com
     
    2121            'featured_widget', // Base ID
    2222            'Get User Info', // Name
    23             array( 'description' => __( 'Display the name, description, and avatar of any user. Just enter the username.', 'text_domain' ), ) // Args
     23            array( 'description' => __( 'Display any of the following: user name, first and last name, description, avatar, and website of any user. Just enter the username.', 'text_domain' ), ) // Args
    2424        );
    2525    }
     
    3838        $cssClass = apply_filters('widget_title', empty($instance['cssClass']) ? '' : $instance['cssClass'], $instance);
    3939        $user = apply_filters( 'widget_title', $instance['userName'] );
     40        $userNameDisplay = apply_filters( 'widget_title', $instance['userNameDisplay'] );
    4041        $firstLast = apply_filters( 'widget_title', $instance['firstLast'] );
    4142        $avatar = apply_filters( 'widget_title', $instance['avatar'] );
     
    5253        $user = get_userdatabylogin($user);
    5354        $user_email = $user->user_email;
     55        if ( $userNameDisplay ) {
     56            $user_name = $user->user_login;
     57        }
    5458        if ( $firstLast ) {
    5559            $user_last = $user->last_name;
     
    7377            echo $before_title . $userName . $after_title;
    7478            echo "<h3 class=\"widget-title\">{$title}</h3>";
     79            echo "<h4>{$user_name}</h4>";
    7580            echo "<h4>{$user_first} {$user_last}</h4>";
    7681            echo "{$user_avatar}";
     
    95100        $instance['title'] = strip_tags($new_instance['title']);
    96101        $instance['cssClass'] = strip_tags($new_instance['cssClass']);
     102        $instance['userNameDisplay'] = ($new_instance['userNameDisplay']);
    97103        $instance['firstLast'] = ($new_instance['firstLast']);
    98104        $instance['avatar'] = ($new_instance['avatar']);
     
    122128        if ( isset( $instance[ 'cssClass' ] ) ) {
    123129            $cssClass = strip_tags($instance['cssClass']);
     130        }
     131        if ( isset( $instance[ 'userNameDisplay' ] )) {
     132            $userNameDisplay = $instance['userNameDisplay'];
    124133        }
    125134        if ( isset( $instance[ 'firstLast' ] ) ) {
     
    153162                <tr valign="top">               
    154163                    <th scope="row">
     164                        <label for="<?php echo $this->get_field_id('userNameDisplay'); ?>"><?php _e('User name: '); ?></label>
     165                    </th>
     166                    <td>
     167                        <input id="<?php echo $this->get_field_id( 'userNameDisplay' ); ?>" name="<?php echo $this->get_field_name( 'userNameDisplay' ); ?>" type="checkbox" <?php checked($userNameDisplay, 'on' ); ?> />
     168                    </td>
     169                </tr>
     170                <tr valign="top">               
     171                    <th scope="row">
    155172                        <label for="<?php echo $this->get_field_id('firstLast'); ?>"><?php _e('User first and last name: '); ?></label>
    156173                    </th>
     
    201218            'class' => '',
    202219            'title' => '',
     220            'username' => 'false',
    203221            'name' => 'false',
    204222            'avatar' => 'false',
     
    209227        $cssClass = ($class);
    210228        $userTitle = ($title);
     229        $userNameDisplay = ($username);
    211230        $firstLast = ($name);
    212231        $avatar = ($avatar);
     
    215234        $user = get_userdatabylogin($user);
    216235        $user_email = $user->user_email;
     236        if ( $userNameDisplay === 'true' ) {
     237            $user_name = $user->user_login;
     238        }
    217239        if ( $firstLast === 'true' ) {
    218240            $user_last = $user->last_name;
     
    234256        $return_string = '<div class="' . $cssClass . '">';
    235257        $return_string .= '<h3>' . $userTitle . '</h3><br/>';
     258        $return_string .= $user_name . '<br/>';
    236259        $return_string .= $user_first . $user_last . '<br/>';
    237260        $return_string .= $user_avatar . '<br/>';
  • get-user-info/trunk/readme.txt

    r604437 r606834  
    44Requires at least: 3.0
    55Tested up to: 3.4.2
    6 Stable tag: 1.0.9
     6Stable tag: 1.1
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
    99
    10 Display the first and last name, avatar, description, or website of any user via widget or shortcode. Other options are title and/or a css class.
     10Display the user name, first and last name, avatar, description, or website of any user via widget or shortcode. Other options are title and/or a css class.
    1111
    1212== Description ==
    1313
    14 Choose to display any of the following for any user: First and last name, avatar, description or website. A title can be added along with a css class to allow styling if needed. Is available as a widget or shortcode. Use [userinfo user="User Name" class="CssClass" title="My Title" name="true" avatar="true" description="true" website="true"].
     14Choose to display any of the following for any user: user name, first and last name, avatar, description or website. A title can be added along with a css class to allow styling if needed. Is available as a widget or shortcode. Use [userinfo user="User Name" class="CssClass" title="My Title" username="true" name="true" avatar="true" description="true" website="true"].
    1515
    1616== Installation ==
     
    18181. Upload `get-user-info` file to the `/wp-content/plugins/` directory
    19192. Activate the plugin through the 'Plugins' menu in WordPress
    20 3. Add a Get User Info widget to any sidebar and add a title, cssClass if needed then add the user name of the user you want to display. Check any other information you would like to display. You can also display the user info by using the following shortcode '[userinfo user="User Name" class="CssClass" title="My Title" name="true" avatar="true" description="true" website="true"]' (replace User Name with the user name that you want to display ex. [userinfo user="Bill" class="CssClass" title="My Title" name="true" avatar="true" description="true" website="true"]). Just use false in the shortcode or don't include it if you don't want it to display.
     203. Add a Get User Info widget to any sidebar and add a title, cssClass if needed then add the user name of the user you want to display. Check any other information you would like to display. You can also display the user info by using the following shortcode '[userinfo user="User Name" class="CssClass" title="My Title" username="true" name="true" avatar="true" description="true" website="true"]' (replace User Name with the user name that you want to display ex. [userinfo user="Bill" class="CssClass" title="My Title" username="true" name="true" avatar="true" description="true" website="true"]). Just use false in the shortcode or don't include it if you don't want it to display.
    2121
    2222== Screenshots ==
     
    2626
    2727== Changelog ==
     28
     29= 1.1 =
     30* Added the ability to display the username in the widget or shortcode.
    2831
    2932= 1.0.9 =
Note: See TracChangeset for help on using the changeset viewer.