Version Description
- Released 06 June 2015
- Bug fix: get_avatar override now accepts custom classes.
- Added
mpp_avatar_classes
filter to get_avatar override to allow global class overrides/additions.
Download this release
Release Info
Developer | ronalfy |
Plugin | User Profile Picture |
Version | 1.2.5 |
Comparing to | |
See all releases |
Code changes from version 1.2.3 to 1.2.5
- metronet-profile-picture.php +30 -6
- readme.txt +10 -2
metronet-profile-picture.php
CHANGED
@@ -4,7 +4,7 @@ Plugin Name: User Profile Picture
|
|
4 |
Plugin URI: http://wordpress.org/extend/plugins/metronet-profile-picture/
|
5 |
Description: Use the native WP uploader on your user profile page.
|
6 |
Author: ronalfy
|
7 |
-
Version: 1.2.
|
8 |
Requires at least: 3.5
|
9 |
Author URI: http://www.ronalfy.com
|
10 |
Contributors: ronalfy
|
@@ -59,7 +59,7 @@ class Metronet_Profile_Picture {
|
|
59 |
|
60 |
|
61 |
//User Avatar override
|
62 |
-
add_filter( 'get_avatar', array( &$this, 'avatar_override' ), 10,
|
63 |
} //end constructor
|
64 |
|
65 |
/**
|
@@ -157,7 +157,7 @@ class Metronet_Profile_Picture {
|
|
157 |
* @param string $default URL to the default image
|
158 |
* @param string $alt Alternative text
|
159 |
**/
|
160 |
-
public function avatar_override( $avatar, $id_or_email, $size, $default, $alt ) {
|
161 |
global $pagenow;
|
162 |
if ( 'options-discussion.php' == $pagenow ) return $avatar; //Stop overriding gravatars on options-discussion page
|
163 |
|
@@ -184,11 +184,28 @@ class Metronet_Profile_Picture {
|
|
184 |
$avatar_override = get_user_option( 'metronet_avatar_override', $user_id );
|
185 |
if ( !$avatar_override || $avatar_override != 'on' ) return $avatar;
|
186 |
|
187 |
-
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
188 |
|
|
|
|
|
|
|
|
|
189 |
$custom_avatar = mt_profile_img( $user_id, array(
|
190 |
'size' => array( $size, $size ),
|
191 |
-
'attr' => array( 'alt' => $alt, 'class' =>
|
192 |
'echo' => false )
|
193 |
);
|
194 |
|
@@ -505,7 +522,7 @@ function mt_profile_img( $user_id, $args = array() ) {
|
|
505 |
'echo' => true
|
506 |
);
|
507 |
$args = wp_parse_args( $args, $defaults );
|
508 |
-
extract( $args );
|
509 |
|
510 |
$post_thumbnail_id = get_post_thumbnail_id( $profile_post_id );
|
511 |
|
@@ -516,6 +533,13 @@ function mt_profile_img( $user_id, $args = array() ) {
|
|
516 |
return;
|
517 |
}
|
518 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
519 |
$post_thumbnail = wp_get_attachment_image( $post_thumbnail_id, $size, false, $attr );
|
520 |
$post_thumbnail = apply_filters( 'mpp_thumbnail_html', $post_thumbnail, $profile_post_id, $post_thumbnail_id, $user_id );
|
521 |
if ( $echo ) {
|
4 |
Plugin URI: http://wordpress.org/extend/plugins/metronet-profile-picture/
|
5 |
Description: Use the native WP uploader on your user profile page.
|
6 |
Author: ronalfy
|
7 |
+
Version: 1.2.5
|
8 |
Requires at least: 3.5
|
9 |
Author URI: http://www.ronalfy.com
|
10 |
Contributors: ronalfy
|
59 |
|
60 |
|
61 |
//User Avatar override
|
62 |
+
add_filter( 'get_avatar', array( &$this, 'avatar_override' ), 10, 6 );
|
63 |
} //end constructor
|
64 |
|
65 |
/**
|
157 |
* @param string $default URL to the default image
|
158 |
* @param string $alt Alternative text
|
159 |
**/
|
160 |
+
public function avatar_override( $avatar, $id_or_email, $size, $default, $alt, $args ) {
|
161 |
global $pagenow;
|
162 |
if ( 'options-discussion.php' == $pagenow ) return $avatar; //Stop overriding gravatars on options-discussion page
|
163 |
|
184 |
$avatar_override = get_user_option( 'metronet_avatar_override', $user_id );
|
185 |
if ( !$avatar_override || $avatar_override != 'on' ) return $avatar;
|
186 |
|
187 |
+
//Build classes array based on passed in args, else set defaults - see get_avatar in /wp-includes/pluggable.php
|
188 |
+
$classes = array(
|
189 |
+
'avatar',
|
190 |
+
sprintf( 'avatar-%s', esc_attr( $size ) ),
|
191 |
+
'photo'
|
192 |
+
);
|
193 |
+
if ( isset( $args[ 'class' ] ) ) {
|
194 |
+
if ( is_array( $args['class'] ) ) {
|
195 |
+
$classes = array_merge( $classes, $args['class'] );
|
196 |
+
} else {
|
197 |
+
$args[ 'class' ] = explode( ' ', $args[ 'class' ] );
|
198 |
+
$classes = array_merge( $classes, $args[ 'class' ] );
|
199 |
+
}
|
200 |
+
}
|
201 |
|
202 |
+
//Get custom filter classes
|
203 |
+
$classes = (array)apply_filters( 'mpp_avatar_classes', $classes );
|
204 |
+
|
205 |
+
//Determine if the user has a profile image
|
206 |
$custom_avatar = mt_profile_img( $user_id, array(
|
207 |
'size' => array( $size, $size ),
|
208 |
+
'attr' => array( 'alt' => $alt, 'class' => implode( ' ', $classes ) ),
|
209 |
'echo' => false )
|
210 |
);
|
211 |
|
522 |
'echo' => true
|
523 |
);
|
524 |
$args = wp_parse_args( $args, $defaults );
|
525 |
+
extract( $args ); //todo - get rid of evil extract
|
526 |
|
527 |
$post_thumbnail_id = get_post_thumbnail_id( $profile_post_id );
|
528 |
|
533 |
return;
|
534 |
}
|
535 |
|
536 |
+
//Implode Classes if set and array - dev note: edge case
|
537 |
+
if ( is_array( $attr ) && isset( $attr[ 'class' ] ) ) {
|
538 |
+
if ( is_array( $attr[ 'class' ] ) ) {
|
539 |
+
$attr[ 'class' ] = implode( ' ', $attr[ 'class' ] );
|
540 |
+
}
|
541 |
+
}
|
542 |
+
|
543 |
$post_thumbnail = wp_get_attachment_image( $post_thumbnail_id, $size, false, $attr );
|
544 |
$post_thumbnail = apply_filters( 'mpp_thumbnail_html', $post_thumbnail, $profile_post_id, $post_thumbnail_id, $user_id );
|
545 |
if ( $echo ) {
|
readme.txt
CHANGED
@@ -2,8 +2,8 @@
|
|
2 |
Contributors: ronalfy
|
3 |
Tags: users, user, user profile
|
4 |
Requires at least: 3.5
|
5 |
-
Tested up to: 4.2
|
6 |
-
Stable tag: 1.2.
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
@@ -105,6 +105,11 @@ Yes, but you'll have to set a new profile image per site. This is currently a l
|
|
105 |
|
106 |
== Changelog ==
|
107 |
|
|
|
|
|
|
|
|
|
|
|
108 |
= 1.2.3 =
|
109 |
* Released 20 May 2015
|
110 |
* Revised post type initialization to make sure post type is completely hidden.
|
@@ -186,6 +191,9 @@ Yes, but you'll have to set a new profile image per site. This is currently a l
|
|
186 |
|
187 |
== Upgrade Notice ==
|
188 |
|
|
|
|
|
|
|
189 |
= 1.2.3 =
|
190 |
Made MPP post type completely hidden. mt_profile_img refactored to avoid filtered output.
|
191 |
|
2 |
Contributors: ronalfy
|
3 |
Tags: users, user, user profile
|
4 |
Requires at least: 3.5
|
5 |
+
Tested up to: 4.2.2
|
6 |
+
Stable tag: 1.2.5
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
105 |
|
106 |
== Changelog ==
|
107 |
|
108 |
+
= 1.2.5 =
|
109 |
+
* Released 06 June 2015
|
110 |
+
* Bug fix: get_avatar override now accepts custom classes.
|
111 |
+
* Added `mpp_avatar_classes` filter to get_avatar override to allow global class overrides/additions.
|
112 |
+
|
113 |
= 1.2.3 =
|
114 |
* Released 20 May 2015
|
115 |
* Revised post type initialization to make sure post type is completely hidden.
|
191 |
|
192 |
== Upgrade Notice ==
|
193 |
|
194 |
+
= 1.2.5 =
|
195 |
+
Bug fix for avatar override to accept custom CSS classes.
|
196 |
+
|
197 |
= 1.2.3 =
|
198 |
Made MPP post type completely hidden. mt_profile_img refactored to avoid filtered output.
|
199 |
|