Skip to content

Commit

Permalink
Merge pull request #5 from WordPoints/develop
Browse files Browse the repository at this point in the history
1.1.0
  • Loading branch information
JDGrimes authored Jun 6, 2017
2 parents f0831e1 + 9e26455 commit efc30c2
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 3 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,23 @@ This project adheres to [Semantic Versioning](http://semver.org/) and [Keep a CH

Nothing documented right now.

## [1.1.0] - 2017-06-06

### Added

- Points logs are now displayed on the user profile.
- The usernames in the top users and points logs tables now link to the user profile.

### Fixed

- The points displayed on the profile header are now visible against any background.

## [1.0.0] - 2017-06-05

### Added

- Function to display points on the user's profile and on user cards.

[unreleased]: https://github.com/WordPoints/userpro/compare/master...HEAD
[1.1.0]: https://github.com/WordPoints/userpro/compare/1.0.0...1.1.0
[1.0.0]: https://github.com/WordPoints/userpro/compare/...1.0.0
10 changes: 10 additions & 0 deletions src/assets/css/profile.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
div.wordpoints-userpro-user-points {
margin-top: 10px;
}

.userpro-profile-img-after .wordpoints-userpro-user-points span {
color: #fff;
background-color: #75737380;
padding: 3px;
border-radius: 3px;
}
7 changes: 7 additions & 0 deletions src/includes/actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,15 @@
*/

if ( wordpoints_component_is_active( 'points' ) ) {

add_action( 'init', 'wordpoints_userpro_register_scripts' );

add_action( 'userpro_after_name_user_list', 'wordpoints_userpro_display_points' );
add_action( 'userpro_after_profile_img', 'wordpoints_userpro_display_points' );
add_action( 'userpro_after_fields', 'wordpoints_userpro_display_points_logs' );

add_filter( 'wordpoints_points_top_users_username', 'wordpoints_userpro_profile_link_filter', 10, 2 );
add_filter( 'wordpoints_points_logs_table_username', 'wordpoints_userpro_profile_link_filter', 10, 2 );
}

// EOF
77 changes: 76 additions & 1 deletion src/includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,19 @@
* @since 1.0.0
*/

/**
* Registers the module's scripts and styles.
*
* @since 1.1.0
*/
function wordpoints_userpro_register_scripts() {

wp_register_style(
'wordpoints-userpro-profile'
, wordpoints_modules_url( '/assets/css/profile.css', dirname( __FILE__ ) )
);
}

/**
* Displays a user's points of each type.
*
Expand All @@ -19,18 +32,80 @@
*/
function wordpoints_userpro_display_points( $user_id ) {

echo '<div class="wordpoints-userpro-user-points" style="margin-top: 10px;">';
wp_enqueue_style( 'wordpoints-userpro-profile' );

echo '<div class="wordpoints-userpro-user-points">';

foreach ( wordpoints_get_points_types() as $points_type => $data ) {

echo '<span>';

echo esc_html( $data['name'] . ': ' );

wordpoints_display_points( $user_id, $points_type, 'userpro_profile' );

echo '</span>';

echo ' ';
}

echo '</div>';
}

/**
* Filters a username to wrap it in a link to the user's profile.
*
* @since 1.1.0
*
* @param string $username The username.
* @param int|WP_User $user_id The user's ID or user object.
*
* @return string The filtered username.
*/
function wordpoints_userpro_profile_link_filter( $username, $user_id ) {

global $userpro;

if ( $user_id instanceof WP_User ) {
$user_id = $user_id->ID;
}

return '<a href="'. esc_url( $userpro->permalink( $user_id ) ) . '">' . $username . '</a>';
}

/**
* Displays a user's points logs of each type.
*
* @since 1.1.0
*
* @WordPress\action userpro_after_fields
*
* @param array $args Hook args.
*/
function wordpoints_userpro_display_points_logs( $args ) {

if ( empty( $args['user_id'] ) ) {
return;
}

$user_id = $args['user_id'];

echo '<div class="wordpoints-userpro-user-points-logs">';

foreach ( wordpoints_get_points_types() as $points_type => $data ) {

echo '<div class="userpro-section userpro-column userpro-collapsible-0 userpro-collapsed-0">';
echo esc_html( $data['name'] );
echo '</div>';

$query = new WordPoints_Points_Logs_Query(
array( 'user_id' => $user_id, 'points_type' => $points_type )
);

wordpoints_show_points_logs( $query, array( 'show_users' => false ) );
}

echo '</div>';
}

// EOF
4 changes: 2 additions & 2 deletions src/userpro.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* ---------------------------------------------------------------------------------|
*
* @package WordPoints_UserPro
* @version 1.0.0
* @version 1.1.0
* @author J.D. Grimes <[email protected]>
* @license GPLv2+
*/
Expand All @@ -32,7 +32,7 @@
Author: J.D. Grimes
Author URI: https://wordpoints.org/
Module URI: https://wordpoints.org/modules/userpro/
Version: 1.0.0
Version: 1.1.0
License: GPLv2+
Description: Integrates with the UserPro plugin.
Text Domain: wordpoints-userpro
Expand Down

0 comments on commit efc30c2

Please sign in to comment.