Changeset 1257235
- Timestamp:
- 10/01/2015 08:45:33 AM (10 years ago)
- Location:
- profile-picture
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
profile-picture/tags/1.0/class/class_pp.php
r1250822 r1257235 98 98 return $avatar; 99 99 } 100 101 // Get the Profile Picture details 102 public function pp_picture($id_or_email, $width='', $height='', $alt=''){ 103 $user = $avatar = false; 104 105 if ( is_numeric( $id_or_email ) ) { 106 107 $id = (int) $id_or_email; 108 $user = get_user_by( 'id' , $id ); 109 110 } elseif ( is_object( $id_or_email ) ) { 111 112 if ( ! empty( $id_or_email->user_id ) ) { 113 $id = (int) $id_or_email->user_id; 114 $user = get_user_by( 'id' , $id ); 115 } 116 117 } else { 118 $user = get_user_by( 'email', $id_or_email ); 119 } 120 121 if ( $user && is_object( $user ) ) { 122 $upload_dir = wp_upload_dir(); 123 $pp_url = get_user_meta($user->ID, 'pp_url', true); 124 125 if (isset($pp_url) && !empty($pp_url)) { 126 if( !empty( $width ) && !empty( $height ) ){ 127 $imgclass = ' avatar-'.$width.'x'.$height; 128 } 129 $avatar['url'] = $upload_dir['baseurl'].$pp_url; 130 $avatar['img'] = "<img alt='{$alt}' src='{$avatar['url']}' class='avatar photo{$imgclass}' height='{$height}' width='{$width}' />"; 131 }else{ 132 if( !empty( $width ) ){ 133 $width = 150; 134 } 135 if( ProfilePicture::is_version( '4.2' ) ){ // If WP version greater than 4.2 136 $args = get_avatar_data( $curauth->ID, $args=null ); 137 $avatar['url'] = $args['url']; 138 }else{ // If WP version less than 4.2 139 preg_match("/src='(.*?)'/i", get_avatar( $curauth->ID, $width ), $matches); 140 $avatar['url'] = $matches[1]; 141 } 142 $avatar['img'] = get_avatar($user->ID); 143 } 144 $avatar['author_name'] = get_the_author(); 145 $avatar['author_url'] = get_author_posts_url( $user->ID ); 146 147 } 148 return $avatar; 149 } 150 151 # Check Version Support 152 public function is_version( $version ) { 153 global $wp_version; 154 if ( version_compare( $wp_version, $version, '>=' ) ) { 155 return true; 156 } 157 return false; 158 } 159 160 100 161 101 162 } -
profile-picture/tags/1.0/profile-picture.php
r1251703 r1257235 5 5 * Author: Arul Jayaraj 6 6 * Author URI: http://www.aruljayaraj.com 7 * Description: Upload and set user's custom profile picture in your local, and allow user permission(Subscriber, Contributor) based on your needs7 * Description: Upload and set user's custom profile picture in your local, and you may have options to allow (like Subscriber, Contributor) to upload their profile picture based on user permission 8 8 **/ 9 9 if (!defined('WP_CONTENT_URL')){ -
profile-picture/tags/1.0/readme.txt
r1251703 r1257235 1 === P lugin Name ===1 === Profile Picture === 2 2 Contributors: aruljayarajs 3 Tags: user profile , custom profile photo, profile picture, custom profile picture, profile photo3 Tags: user profile picture, custom profile picture, user photo, profile picture, profile photo, user avatar, user profile 4 4 Requires at least: 3.0 5 5 Tested up to: 4.3.1 … … 19 19 In Front End when we use `<?php do_action('edit_user_profile',$current_user); ?>` on edit profile section, it would be placed on additonal user profile fields. 20 20 21 *Future Updates: Display current user images alone, short code and bring upsocial media profile pictures.21 *Future Updates: Display current user images alone, short code and migrate withsocial media profile pictures. 22 22 23 23 == Installation == … … 25 25 1. Upload `profile-picture` folder to the `/wp-content/plugins/` directory 26 26 2. Activate the plugin through the 'Plugins' menu in WordPress 27 3. Go to Profile in admin end / Go to profile edit in front end 27 3. Go to Profile in admin end / Go to profile edit in front end 28 28 29 29 Note: If you want to add this feature to default scbscribers and contributors, Enable this action hook `<?php add_action('admin_init', array($this,'allow_uploads_permission') ); ?>` from the `ProfilePicture` class. … … 40 40 = How to show the profile image in frontend? = 41 41 42 We can show our customized profile picture in front end whereever you want with registered image sizes. 42 We can show our customized profile picture in front end whereever you want with registered image sizes. You may use wordpress <strong>get_avatar() function by default, else user our customized one it serves by your wish.</strong>. 43 43 `<?php 44 $upload_dir = wp_upload_dir(); 45 $pp_url = get_user_meta($user->ID, 'pp_url', true); 46 echo $upload_dir['baseurl'].$pp_url; 44 $ppimg = ProfilePicture::pp_picture($id_or_email, $width, $height, $alt); 47 45 ?>` 46 <strong> id_or_email </strong> 47 <strong> width </strong> (integer) (optional) Width of the image. 48 <strong> height </strong> (integer) (optional) Width of the image. 49 <strong> alt </strong> (string) (optional) alt title of image tag. 50 <strong> Return Values </strong> It would return profile picture details as array or false on failure. 48 51 49 52 == Screenshots == -
profile-picture/trunk/class/class_pp.php
r1250822 r1257235 98 98 return $avatar; 99 99 } 100 101 // Get the Profile Picture details 102 public function pp_picture($id_or_email, $width='', $height='', $alt=''){ 103 $user = $avatar = false; 104 105 if ( is_numeric( $id_or_email ) ) { 106 107 $id = (int) $id_or_email; 108 $user = get_user_by( 'id' , $id ); 109 110 } elseif ( is_object( $id_or_email ) ) { 111 112 if ( ! empty( $id_or_email->user_id ) ) { 113 $id = (int) $id_or_email->user_id; 114 $user = get_user_by( 'id' , $id ); 115 } 116 117 } else { 118 $user = get_user_by( 'email', $id_or_email ); 119 } 120 121 if ( $user && is_object( $user ) ) { 122 $upload_dir = wp_upload_dir(); 123 $pp_url = get_user_meta($user->ID, 'pp_url', true); 124 125 if (isset($pp_url) && !empty($pp_url)) { 126 if( !empty( $width ) && !empty( $height ) ){ 127 $imgclass = ' avatar-'.$width.'x'.$height; 128 } 129 $avatar['url'] = $upload_dir['baseurl'].$pp_url; 130 $avatar['img'] = "<img alt='{$alt}' src='{$avatar['url']}' class='avatar photo{$imgclass}' height='{$height}' width='{$width}' />"; 131 }else{ 132 if( !empty( $width ) ){ 133 $width = 150; 134 } 135 if( ProfilePicture::is_version( '4.2' ) ){ // If WP version greater than 4.2 136 $args = get_avatar_data( $curauth->ID, $args=null ); 137 $avatar['url'] = $args['url']; 138 }else{ // If WP version less than 4.2 139 preg_match("/src='(.*?)'/i", get_avatar( $curauth->ID, $width ), $matches); 140 $avatar['url'] = $matches[1]; 141 } 142 $avatar['img'] = get_avatar($user->ID); 143 } 144 $avatar['author_name'] = get_the_author(); 145 $avatar['author_url'] = get_author_posts_url( $user->ID ); 146 147 } 148 return $avatar; 149 } 150 151 # Check Version Support 152 public function is_version( $version ) { 153 global $wp_version; 154 if ( version_compare( $wp_version, $version, '>=' ) ) { 155 return true; 156 } 157 return false; 158 } 100 159 101 160 -
profile-picture/trunk/profile-picture.php
r1250037 r1257235 5 5 * Author: Arul Jayaraj 6 6 * Author URI: http://www.aruljayaraj.com 7 * Description: Upload and set user's custom profile picture in your local, and allow user permission(Subscriber, Contributor) based on your needs7 * Description: Upload and set user's custom profile picture in your local, and you may have options to allow (like Subscriber, Contributor) to upload their profile picture based on user permission 8 8 **/ 9 9 if (!defined('WP_CONTENT_URL')){ -
profile-picture/trunk/readme.txt
r1251703 r1257235 1 === P lugin Name ===1 === Profile Picture === 2 2 Contributors: aruljayarajs 3 Tags: user profile , custom profile photo, profile picture, custom profile picture, profile photo3 Tags: user profile picture, custom profile picture, user photo, profile picture, profile photo, user avatar, user profile 4 4 Requires at least: 3.0 5 5 Tested up to: 4.3.1 … … 19 19 In Front End when we use `<?php do_action('edit_user_profile',$current_user); ?>` on edit profile section, it would be placed on additonal user profile fields. 20 20 21 *Future Updates: Display current user images alone, short code and bring upsocial media profile pictures.21 *Future Updates: Display current user images alone, short code and migrate withsocial media profile pictures. 22 22 23 23 == Installation == … … 25 25 1. Upload `profile-picture` folder to the `/wp-content/plugins/` directory 26 26 2. Activate the plugin through the 'Plugins' menu in WordPress 27 3. Go to Profile in admin end / Go to profile edit in front end 27 3. Go to Profile in admin end / Go to profile edit in front end 28 28 29 29 Note: If you want to add this feature to default scbscribers and contributors, Enable this action hook `<?php add_action('admin_init', array($this,'allow_uploads_permission') ); ?>` from the `ProfilePicture` class. … … 40 40 = How to show the profile image in frontend? = 41 41 42 We can show our customized profile picture in front end whereever you want with registered image sizes. 42 We can show our customized profile picture in front end whereever you want with registered image sizes. You may use wordpress <strong>get_avatar() function by default, else user our customized one it serves by your wish.</strong>. 43 43 `<?php 44 $upload_dir = wp_upload_dir(); 45 $pp_url = get_user_meta($user->ID, 'pp_url', true); 46 echo $upload_dir['baseurl'].$pp_url; 44 $ppimg = ProfilePicture::pp_picture($id_or_email, $width, $height, $alt); 47 45 ?>` 46 <strong> id_or_email </strong> 47 <strong> width </strong> (integer) (optional) Width of the image. 48 <strong> height </strong> (integer) (optional) Width of the image. 49 <strong> alt </strong> (string) (optional) alt title of image tag. 50 <strong> Return Values </strong> It would return profile picture details as array or false on failure. 48 51 49 52 == Screenshots ==
Note: See TracChangeset
for help on using the changeset viewer.