From 9e1cbaf47d148f4e43f7014ce37d6f32ad611433 Mon Sep 17 00:00:00 2001 From: JDGrimes Date: Tue, 6 Jun 2017 11:25:28 -0400 Subject: [PATCH 1/5] Ensure points are visible on all profile backgrounds Fixes #4 --- src/assets/css/profile.css | 10 ++++++++++ src/includes/actions.php | 1 + src/includes/functions.php | 21 ++++++++++++++++++++- 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 src/assets/css/profile.css diff --git a/src/assets/css/profile.css b/src/assets/css/profile.css new file mode 100644 index 0000000..257b4a9 --- /dev/null +++ b/src/assets/css/profile.css @@ -0,0 +1,10 @@ +.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; +} diff --git a/src/includes/actions.php b/src/includes/actions.php index eff857e..3b8f66e 100644 --- a/src/includes/actions.php +++ b/src/includes/actions.php @@ -8,6 +8,7 @@ */ 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' ); } diff --git a/src/includes/functions.php b/src/includes/functions.php index df03a85..3851b22 100644 --- a/src/includes/functions.php +++ b/src/includes/functions.php @@ -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. * @@ -19,14 +32,20 @@ */ function wordpoints_userpro_display_points( $user_id ) { - echo '
'; + wp_enqueue_style( 'wordpoints-userpro-profile' ); + + echo '
'; foreach ( wordpoints_get_points_types() as $points_type => $data ) { + echo ''; + echo esc_html( $data['name'] . ': ' ); wordpoints_display_points( $user_id, $points_type, 'userpro_profile' ); + echo ''; + echo ' '; } From 9df5a0db7cd80bd8d7647d30e43985f03af18695 Mon Sep 17 00:00:00 2001 From: JDGrimes Date: Tue, 6 Jun 2017 11:43:06 -0400 Subject: [PATCH 2/5] Link to user profiles in top users and points logs tables Fixes #2 --- src/includes/actions.php | 2 ++ src/includes/functions.php | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/src/includes/actions.php b/src/includes/actions.php index 3b8f66e..40869e4 100644 --- a/src/includes/actions.php +++ b/src/includes/actions.php @@ -11,6 +11,8 @@ 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_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 diff --git a/src/includes/functions.php b/src/includes/functions.php index 3851b22..5b09321 100644 --- a/src/includes/functions.php +++ b/src/includes/functions.php @@ -52,4 +52,25 @@ function wordpoints_userpro_display_points( $user_id ) { echo '
'; } +/** + * 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 '' . $username . ''; +} + // EOF From 9cdf4fd8a7c59ded418ba6093fe09f8008b40bd9 Mon Sep 17 00:00:00 2001 From: JDGrimes Date: Tue, 6 Jun 2017 12:10:07 -0400 Subject: [PATCH 3/5] Display points logs on user profile Fixes #3 --- src/includes/actions.php | 4 ++++ src/includes/functions.php | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/src/includes/actions.php b/src/includes/actions.php index 40869e4..b6a6bb7 100644 --- a/src/includes/actions.php +++ b/src/includes/actions.php @@ -8,9 +8,13 @@ */ 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 ); } diff --git a/src/includes/functions.php b/src/includes/functions.php index 5b09321..b8d9bfb 100644 --- a/src/includes/functions.php +++ b/src/includes/functions.php @@ -73,4 +73,39 @@ function wordpoints_userpro_profile_link_filter( $username, $user_id ) { return '' . $username . ''; } +/** + * 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 '
'; + + foreach ( wordpoints_get_points_types() as $points_type => $data ) { + + echo '
'; + echo esc_html( $data['name'] ); + echo '
'; + + $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 '
'; +} + // EOF From 3de4b593df2fb2c0e6d08bad949fb890e8452334 Mon Sep 17 00:00:00 2001 From: JDGrimes Date: Tue, 6 Jun 2017 12:10:55 -0400 Subject: [PATCH 4/5] Use a more specific selector Needed because of styles in the UserPro plugin. See #4 --- src/assets/css/profile.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/assets/css/profile.css b/src/assets/css/profile.css index 257b4a9..43f9e26 100644 --- a/src/assets/css/profile.css +++ b/src/assets/css/profile.css @@ -1,4 +1,4 @@ -.wordpoints-userpro-user-points { +div.wordpoints-userpro-user-points { margin-top: 10px; } From 9e26455e4ace3cba587c0bb8c235ae350e6cd68d Mon Sep 17 00:00:00 2001 From: JDGrimes Date: Tue, 6 Jun 2017 15:29:22 -0400 Subject: [PATCH 5/5] 1.1.0 --- CHANGELOG.md | 12 ++++++++++++ src/userpro.php | 4 ++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4bc013a..8db7e84 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,17 @@ 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 @@ -15,4 +26,5 @@ Nothing documented right now. - 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 diff --git a/src/userpro.php b/src/userpro.php index 62481dd..05dd81c 100644 --- a/src/userpro.php +++ b/src/userpro.php @@ -21,7 +21,7 @@ * ---------------------------------------------------------------------------------| * * @package WordPoints_UserPro - * @version 1.0.0 + * @version 1.1.0 * @author J.D. Grimes * @license GPLv2+ */ @@ -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